|
19 | 19 |
|
20 | 20 | height, width, _ = frame.shape
|
21 | 21 |
|
22 |
| - |
23 |
| - blob = cv2.dnn.blobFromImage(frame, 0.00392, (416, 416), (0, 0, 0), True, crop=False) |
| 22 | + blob = cv2.dnn.blobFromImage( |
| 23 | + frame, 0.00392, (416, 416), (0, 0, 0), True, crop=False) |
24 | 24 | yolo_net.setInput(blob)
|
25 | 25 |
|
26 | 26 | layer_names = yolo_net.getUnconnectedOutLayersNames()
|
|
32 | 32 |
|
33 | 33 | class_id = np.argmax(scores)
|
34 | 34 | confidence = scores[class_id]
|
35 |
| - if confidence > 0.5 and class_id == 2: |
| 35 | + if confidence > 0.5 and class_id == 2: |
36 | 36 | center_x = int(detection[0] * width)
|
37 | 37 |
|
38 | 38 | center_y = int(detection[1] * height)
|
|
42 | 42 |
|
43 | 43 | x = int(center_x - bbox_width / 2)
|
44 | 44 | y = int(center_y - bbox_height / 2)
|
45 |
| - cv2.rectangle(frame, (x, y), (x + bbox_width, y + bbox_height), (0, 255, 0), 2) |
| 45 | + cv2.rectangle(frame, (x, y), (x + bbox_width, |
| 46 | + y + bbox_height), (0, 255, 0), 2) |
46 | 47 |
|
47 |
| - |
48 | 48 | resized_frame = cv2.resize(frame, (720, 480))
|
49 | 49 |
|
50 | 50 | cv2.imshow('Car Tracking', frame)
|
|
0 commit comments