Yayın Tarihi: 2 Haziran 2025
🚗 HIZLI BAŞLANGIÇ: Plaka tanıma sistemi (ALPR - Automatic License Plate Recognition), kameralar aracılığıyla araç plakalarını otomatik olarak okuyup tanıyan yapay zeka destekli bir teknolojidir. 2025 yılında Türkiye''de 15.000+ aktif ALPR kamerası bulunuyor!
Modern plaka tanıma sistemleri 4 temel aşamada çalışır:
"Plaka tanıma teknolojisi artık %99.7 doğruluk oranına ulaştı - bu insandan bile daha hassas!" - Ayberk Irmak
Son nesil ALPR sistemleri sadece plaka okumakla kalmıyor:
Özellik | 2020 | 2025 |
---|---|---|
Doğruluk Oranı | %92 | %99.7 |
İşleme Hızı | 2 saniye | 0.3 saniye |
Gece Görüş | Sınırlı | Tam destek |
Hava Koşulları | %70 başarı | %95 başarı |
Akıllı Kavşaklar: İstanbul''da pilot uygulama olarak başlayan sistem, trafik yoğunluğunu %35 azalttı.
// Gerçek zamanlı trafik analizi class TrafficAnalyzer: def analyze_flow(self, plate_data): # Son 1 saatteki geçiş sayısı hourly_count = self.count_vehicles_last_hour() # Yoğunluk analizi if hourly_count > 500: self.trigger_smart_lights("extend_green") # Acil durum tespiti if self.detect_emergency_vehicle(plate_data): self.priority_green_corridor()
Akıllı Otopark Sistemi Özellikleri:
class SmartParkingSystem: def __init__(self): self.camera = ALPRCamera() self.database = ParkingDB() def vehicle_entry(self, plate_number): # Plaka tanıma vehicle_info = self.camera.read_plate() # Ödeme durumu kontrolü if self.check_payment_status(plate_number): self.open_barrier() self.log_entry(plate_number, datetime.now()) else: self.send_payment_notification(plate_number) def automatic_billing(self, plate_number, exit_time): entry_time = self.database.get_entry_time(plate_number) duration = exit_time - entry_time cost = self.calculate_cost(duration) # Otomatik ödeme self.process_payment(plate_number, cost)
Kendi plaka tanıma sisteminizi oluşturmak için temel kod:
import cv2 import numpy as np import pytesseract import re class LicensePlateRecognizer: def __init__(self): # Tesseract yapılandırması pytesseract.pytesseract.tesseract_cmd = r''C:\Program Files\Tesseract-OCR\tesseract.exe'' # Plaka boyutu oranları (Türk plakaları için) self.plate_ratio_min = 3.0 self.plate_ratio_max = 6.0 def preprocess_image(self, image): """Görüntü ön işleme""" # Gri tonlamaya çevir gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # Gaussian blur blurred = cv2.GaussianBlur(gray, (5, 5), 0) # Kenar tespiti edges = cv2.Canny(blurred, 50, 150) return edges def find_plate_contours(self, edges): """Plaka konturlarını bul""" contours, _ = cv2.findContours(edges, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) potential_plates = [] for contour in contours: # Alan kontrolü area = cv2.contourArea(contour) if area < 1000: continue # Dikdörtgen kontrolü rect = cv2.minAreaRect(contour) width, height = rect[1] if width == 0 or height == 0: continue ratio = max(width, height) / min(width, height) # Plaka oranı kontrolü if self.plate_ratio_min <= ratio <= self.plate_ratio_max: potential_plates.append(contour) return potential_plates def extract_text(self, image, contour): """Plakadan metin çıkarma""" # Konturun sınırlayıcı dikdörtgenini al x, y, w, h = cv2.boundingRect(contour) plate_region = image[y:y+h, x:x+w] # Görüntüyü büyüt plate_region = cv2.resize(plate_region, None, fx=3, fy=3, interpolation=cv2.INTER_CUBIC) # Gri tonlama gray_plate = cv2.cvtColor(plate_region, cv2.COLOR_BGR2GRAY) # Threshold uygula _, thresh = cv2.threshold(gray_plate, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU) # OCR ile metin tanıma config = r''--oem 3 --psm 8 -c tessedit_char_whitelist=ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'' text = pytesseract.image_to_string(thresh, config=config) return text.strip() def validate_turkish_plate(self, text): """Türk plaka formatını doğrula""" # Türk plaka formatı: 34 ABC 123 veya 34 AB 1234 patterns = [ r'^\d{2}\s?[A-Z]{2,3}\s?\d{2,4}$', # Standart format r'^\d{2}\s?[A-Z]{1,2}\s?\d{3,4}$' # Alternatif format ] cleaned_text = re.sub(r'[^A-Z0-9]', '', text) for pattern in patterns: if re.match(pattern, text): return True, cleaned_text return False, cleaned_text def recognize_plate(self, image_path): """Ana plaka tanıma fonksiyonu""" # Görüntüyü yükle image = cv2.imread(image_path) if image is None: return None, "Görüntü yüklenemedi" # Ön işleme edges = self.preprocess_image(image) # Plaka konturlarını bul contours = self.find_plate_contours(edges) if not contours: return None, "Plaka bulunamadı" # En büyük konturu seç (muhtemelen plaka) largest_contour = max(contours, key=cv2.contourArea) # Metni çıkar text = self.extract_text(image, largest_contour) # Türk plaka formatını doğrula is_valid, cleaned_text = self.validate_turkish_plate(text) if is_valid: return cleaned_text, "Başarılı" else: return text, "Geçersiz plaka formatı" # Kullanım örneği recognizer = LicensePlateRecognizer() plate_number, status = recognizer.recognize_plate("arac_resmi.jpg") if plate_number: print(f"Tespit edilen plaka: {plate_number}") print(f"Durum: {status}") else: print(f"Hata: {status}")
Aktif ALPR Kamerası
Günlük Plaka Okuma
Doğruluk Oranı
Ortalama İşleme Süresi
Modern plaka tanıma sistemleri derin öğrenme kullanıyor:
import tensorflow as tf from tensorflow import keras import numpy as np class DeepLearningALPR: def __init__(self): self.plate_detector = self.load_plate_detection_model() self.char_recognizer = self.load_character_recognition_model() def load_plate_detection_model(self): """YOLO tabanlı plaka tespit modeli""" model = keras.models.load_model(''yolo_plate_detector.h5'') return model def load_character_recognition_model(self): """CNN tabanlı karakter tanıma modeli""" model = keras.models.load_model(''char_recognition_cnn.h5'') return model def detect_plate_regions(self, image): """Görüntüde plaka bölgelerini tespit et""" # Görüntüyü modele uygun hale getir input_image = cv2.resize(image, (416, 416)) input_image = np.expand_dims(input_image, axis=0) / 255.0 # YOLO ile tespit predictions = self.plate_detector.predict(input_image) # NMS (Non-Maximum Suppression) uygula boxes = self.apply_nms(predictions) return boxes def segment_characters(self, plate_image): """Plaka görüntüsünden karakterleri ayır""" gray = cv2.cvtColor(plate_image, cv2.COLOR_BGR2GRAY) # Otsu threshold _, binary = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU) # Kontur bulma contours, _ = cv2.findContours(binary, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) # Karakterleri sırala (soldan sağa) char_contours = sorted(contours, key=lambda x: cv2.boundingRect(x)[0]) characters = [] for contour in char_contours: x, y, w, h = cv2.boundingRect(contour) # Karakter boyut kontrolü if w > 10 and h > 20: char_image = binary[y:y+h, x:x+w] char_image = cv2.resize(char_image, (28, 28)) characters.append(char_image) return characters def recognize_characters(self, character_images): """Karakterleri tanı""" if not character_images: return "" # Batch halinde işle batch = np.array(character_images).reshape(-1, 28, 28, 1) / 255.0 # Tahmin yap predictions = self.char_recognizer.predict(batch) # Karakterleri çözümle chars = "" char_map = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" for pred in predictions: char_index = np.argmax(pred) confidence = pred[char_index] if confidence > 0.8: # Güven eşiği chars += char_map[char_index] return chars def process_image(self, image_path): """Tam pipeline işlemi""" image = cv2.imread(image_path) # Plaka bölgelerini tespit et plate_boxes = self.detect_plate_regions(image) results = [] for box in plate_boxes: x, y, w, h = box plate_region = image[y:y+h, x:x+w] # Karakterleri ayır characters = self.segment_characters(plate_region) # Karakterleri tanı plate_text = self.recognize_characters(characters) if len(plate_text) >= 6: # Minimum plaka uzunluğu results.append({ ''plate_number'': plate_text, ''confidence'': self.calculate_confidence(characters), ''bbox'': box }) return results # Kullanım alpr = DeepLearningALPR() results = alpr.process_image("trafik_goruntusu.jpg") for result in results: print(f"Plaka: {result[''plate_number'']}") print(f"Güven: {result[''confidence'']:.2f}")
Canlı video akışından plaka tanıma:
import cv2 import threading from queue import Queue class RealTimeALPR: def __init__(self, video_source=0): self.video_source = video_source self.alpr_engine = DeepLearningALPR() self.frame_queue = Queue(maxsize=10) self.result_queue = Queue() self.running = False def capture_frames(self): """Video çerçevelerini yakala""" cap = cv2.VideoCapture(self.video_source) while self.running: ret, frame = cap.read() if ret: if not self.frame_queue.full(): self.frame_queue.put(frame) else: break cap.release() def process_frames(self): """Çerçeveleri işle""" while self.running: if not self.frame_queue.empty(): frame = self.frame_queue.get() # Plaka tanıma results = self.alpr_engine.process_frame(frame) if results: self.result_queue.put({ ''timestamp'': time.time(), ''results'': results, ''frame'': frame }) def start_processing(self): """İşlemi başlat""" self.running = True # Thread''ları başlat capture_thread = threading.Thread(target=self.capture_frames) process_thread = threading.Thread(target=self.process_frames) capture_thread.start() process_thread.start() return capture_thread, process_thread def get_latest_results(self): """En son sonuçları al""" results = [] while not self.result_queue.empty(): results.append(self.result_queue.get()) return results # Kullanım örneği real_time_alpr = RealTimeALPR(video_source=''rtsp://camera_ip:554/stream'') capture_thread, process_thread = real_time_alpr.start_processing() # Ana döngü try: while True: results = real_time_alpr.get_latest_results() for result in results: timestamp = result[''timestamp''] plates = result[''results''] for plate in plates: print(f"[{timestamp}] Tespit: {plate[''plate_number'']}") # Veritabanına kaydet save_to_database(plate[''plate_number''], timestamp) time.sleep(0.1) # CPU kullanımını azalt except KeyboardInterrupt: real_time_alpr.running = False print("İşlem durduruldu")
Zorluk | Geleneksel Çözüm | AI Destekli Çözüm |
---|---|---|
Kötü hava koşulları | %60 başarı | %95 başarı |
Gece görüş | Ek aydınlatma | IR kameralar + AI |
Hızlı hareket | Motion blur | Özel algoritma |
Kirli/hasarlı plaka | Manuel müdahale | Derin öğrenme |
class AdvancedALPR: def handle_challenging_conditions(self, image): """Zor koşulları işle""" # Hava koşulu tespiti weather_condition = self.detect_weather(image) if weather_condition == ''rain'': # Yağmur için özel işleme enhanced = self.rain_enhancement(image) elif weather_condition == ''fog'': # Sis için contrast artırma enhanced = self.fog_removal(image) elif weather_condition == ''night'': # Gece için IR iyileştirme enhanced = self.night_vision_enhancement(image) else: enhanced = image return enhanced def motion_compensation(self, video_frames): """Hareket kompensasyonu""" stable_frames = [] for i in range(1, len(video_frames)): # Optik akış hesapla flow = cv2.calcOpticalFlowPyrLK( video_frames[i-1], video_frames[i], None, None ) # Stabilizasyon matrix''i hesapla transform = self.estimate_transform(flow) # Frame''i stabilize et stable_frame = cv2.warpAffine( video_frames[i], transform, (video_frames[i].shape[1], video_frames[i].shape[0]) ) stable_frames.append(stable_frame) return stable_frames
class EthicalALPR: def __init__(self): self.privacy_settings = { ''data_retention_days'': 30, ''anonymous_processing'': True, ''consent_required'': True, ''audit_logging'': True } def process_with_privacy(self, plate_data): """Gizlilik korumalı işleme""" # Anonimleştirme if self.privacy_settings[''anonymous_processing'']: anonymized_data = self.anonymize_plate(plate_data) # Consent kontrolü if self.privacy_settings[''consent_required'']: if not self.check_consent(plate_data[''vehicle_id'']): return None # Audit log if self.privacy_settings[''audit_logging'']: self.log_processing_activity(plate_data) return self.process_data(anonymized_data) def auto_delete_expired_data(self): """Süresi dolan verileri otomatik sil""" retention_period = self.privacy_settings[''data_retention_days''] cutoff_date = datetime.now() - timedelta(days=retention_period) # Eski kayıtları sil deleted_count = self.database.delete_records_before(cutoff_date) self.log_audit(f"Auto-deleted {deleted_count} expired records")
Sistem Tipi | CPU | GPU | RAM | Depolama |
---|---|---|---|---|
Temel ALPR | Intel i5 | - | 8 GB | 1 TB HDD |
Gelişmiş AI | Intel i7 | GTX 1060 | 16 GB | 500 GB SSD |
Enterprise | Xeon | RTX 3080 | 64 GB | 2 TB NVMe |
class PerformanceOptimizer: def __init__(self): self.gpu_available = tf.config.list_physical_devices(''GPU'') self.cpu_count = multiprocessing.cpu_count() def optimize_inference(self, model): """Model çıkarım optimizasyonu""" # Model quantization converter = tf.lite.TFLiteConverter.from_keras_model(model) converter.optimizations = [tf.lite.Optimize.DEFAULT] # INT8 quantization converter.representative_dataset = self.representative_dataset converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8] tflite_model = converter.convert() return tflite_model def parallel_processing(self, image_batch): """Paralel işleme""" # CPU core sayısına göre batch ayır batch_size = len(image_batch) // self.cpu_count batches = [image_batch[i:i+batch_size] for i in range(0, len(image_batch), batch_size)] # Paralel işle with multiprocessing.Pool(self.cpu_count) as pool: results = pool.map(self.process_batch, batches) # Sonuçları birleştir combined_results = [] for result in results: combined_results.extend(result) return combined_results def memory_management(self): """Bellek yönetimi""" # GPU bellek artışını sınırla if self.gpu_available: gpus = tf.config.experimental.list_physical_devices(''GPU'') for gpu in gpus: tf.config.experimental.set_memory_growth(gpu, True) # Cache temizliği tf.keras.backend.clear_session() # Garbage collection import gc gc.collect()
Plaka tanıma sistemi 2025 yılında artık sadece güvenlik amaçlı değil, akıllı şehir ekosisteminin temel bileşeni haline geldi. İstatistikler gösteriyor ki:
Unutmayın: Teknoloji her zaman insanlara hizmet etmeli, onları kontrol etmemeli. Plaka tanıma sistemleri de bu prensipler doğrultusunda geliştirilmeli ve kullanılmalıdır.
Bu makale, plaka tanıma teknolojisinin mevcut durumu ve gelecek potansiyeli hakkında kapsamlı bilgi vermek amacıyla hazırlanmıştır. Tüm kod örnekleri eğitim amaçlıdır ve yasal düzenlemelere uygun olarak kullanılmalıdır.
Teknoloji her zaman insanlara hizmet etmeli, onları kontrol etmemeli.
Akıllı Sistemler UzmanıCopyright © 2024 Betay Bilişim
Yorum Yap
E-posta adresiniz yorumunuzda yayınlanmayacaktır.