Skip to content

Commit 26f4e15

Browse files
committed
clean up the codes
1 parent ad921b3 commit 26f4e15

File tree

7 files changed

+26
-2
lines changed

7 files changed

+26
-2
lines changed

detected_objects/object1.png

15.8 KB
Loading

detected_objects/object2.png

17.2 KB
Loading

detected_objects/object3.png

31.5 KB
Loading

detected_objects/object4.png

19.6 KB
Loading
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from utils.image_utils import image_saver
2+
3+
is_object_detected = [0]
4+
bottom_position_of_detected_object = [0]
5+
6+
def count_objects(top, bottom, right, left, crop_img, roi_position, y_min, y_max, deviation):
7+
direction = "n.a." # means not available, it is just initialization
8+
isInROI = True # is the object that is inside Region Of Interest
9+
update_csv = False
10+
11+
if (abs(((bottom+top)/2)-roi_position) < deviation):
12+
is_object_detected.insert(0,1)
13+
update_csv = True
14+
image_saver.save_image(crop_img) # save detected object image
15+
16+
if(bottom > bottom_position_of_detected_object[0]):
17+
direction = "down"
18+
else:
19+
direction = "up"
20+
21+
bottom_position_of_detected_object.insert(0,(bottom))
22+
23+
return direction, is_object_detected, update_csv
24+

utils/visualization_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from utils.image_utils import image_saver
3434

3535
# predicted_speed predicted_color module - import
36-
from utils.object_counting_module import object_counter
36+
from utils.object_counting_module import object_counter_y_axis
3737
# predicted_speed predicted_color module - import
3838
from utils.object_counting_module import object_counter_x_axis
3939

@@ -234,7 +234,7 @@ def draw_bounding_box_on_image(current_frame_number,image,
234234
if(x_axis[0] == 1):
235235
predicted_direction, is_object_detected, update_csv = object_counter_x_axis.count_objects_x_axis(top, bottom, right, left, detected_object_image, ROI_POSITION[0], ROI_POSITION[0]+DEVIATION[0], ROI_POSITION[0]+(DEVIATION[0]*2), DEVIATION[0])
236236
elif(y_axis[0] == 1):
237-
predicted_direction, is_object_detected, update_csv = object_counter.count_objects(top, bottom, right, left, detected_object_image, ROI_POSITION[0], ROI_POSITION[0]+DEVIATION[0], ROI_POSITION[0]+(DEVIATION[0]*2), DEVIATION[0])
237+
predicted_direction, is_object_detected, update_csv = object_counter_y_axis.count_objects(top, bottom, right, left, detected_object_image, ROI_POSITION[0], ROI_POSITION[0]+DEVIATION[0], ROI_POSITION[0]+(DEVIATION[0]*2), DEVIATION[0])
238238
elif(standalone_image[0] == 1):
239239
image_saver.save_image(detected_object_image) # save detected object image
240240

0 commit comments

Comments
 (0)