Skip to content

Commit 97c6563

Browse files
committed
accuracy improvement for counting
1 parent b089432 commit 97c6563

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

api/object_counting_api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def cumulative_object_counting_x_axis(input_video, detection_graph, category_ind
119119
cap.release()
120120
cv2.destroyAllWindows()
121121

122-
def cumulative_object_counting_y_axis(input_video, detection_graph, category_index, is_color_recognition_enabled, roi, deviation, custom_object_name):
122+
def cumulative_object_counting_y_axis(input_video, detection_graph, category_index, is_color_recognition_enabled, roi, deviation, custom_object_name, targeted_objects=None):
123123
total_passed_objects = 0
124124

125125
# input video
@@ -178,6 +178,7 @@ def cumulative_object_counting_y_axis(input_video, detection_graph, category_ind
178178
np.squeeze(classes).astype(np.int32),
179179
np.squeeze(scores),
180180
category_index,
181+
targeted_objects = targeted_objects,
181182
y_reference = roi,
182183
deviation = deviation,
183184
use_normalized_coordinates=True,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
212,255,127
1+
0,0,0

utils/visualization_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,10 +919,10 @@ def visualize_boxes_and_labels_on_image_array_y_axis(current_frame_number,
919919
if(targeted_objects == None):
920920
counting_mode = counting_mode + str(display_str_list)
921921

922-
elif(targeted_objects in display_str_list[0]):
922+
elif(display_str_list[0].split(":")[0] in targeted_objects):
923923
counting_mode = counting_mode + str(display_str_list)
924924

925-
if ((targeted_objects != None) and (targeted_objects in display_str_list[0])):
925+
if ((targeted_objects != None) and (display_str_list[0].split(":")[0] in targeted_objects)):
926926
if instance_masks is not None:
927927
draw_mask_on_image_array(image, box_to_instance_masks_map[box], color=color)
928928

vehicle_counting.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
detection_graph, category_index = backbone.set_model('ssd_mobilenet_v1_coco_2018_01_28', 'mscoco_label_map.pbtxt')
1818

1919
is_color_recognition_enabled = 1 # set it to 1 for enabling the color prediction for the detected objects
20-
roi = 185 # roi line position
21-
deviation = 2 # the constant that represents the object counting area
20+
roi = 237 # roi line position
21+
deviation = 4.5 # the constant that represents the object counting area
2222
custom_object_name = 'Vehicle' # set it to your custom object name
23+
targeted_objects_name = "car, truck"
2324

24-
object_counting_api.cumulative_object_counting_y_axis(input_video, detection_graph, category_index, is_color_recognition_enabled, roi, deviation, custom_object_name) # counting all the objects
25+
object_counting_api.cumulative_object_counting_y_axis(input_video, detection_graph, category_index, is_color_recognition_enabled, roi, deviation, custom_object_name, targeted_objects_name) # counting all the objects

0 commit comments

Comments
 (0)