Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

per_xxx_function accept bool value to indicate abort #330 #342

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 17 additions & 11 deletions imageai/Detection/Custom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1095,10 +1095,12 @@ def detectObjectsFromVideo(self, input_file_path="", camera_input=None, output_f
if (counting == 1 or check_frame_interval == 0):
if (per_frame_function != None):
if (return_detected_frame == True):
per_frame_function(counting, output_objects_array, output_objects_count,
detected_frame)
if(per_frame_function(counting, output_objects_array, output_objects_count,
detected_frame)):
break
elif (return_detected_frame == False):
per_frame_function(counting, output_objects_array, output_objects_count)
if(per_frame_function(counting, output_objects_array, output_objects_count)):
break

if (per_second_function != None):
if (counting != 1 and (counting % frames_per_second) == 0):
Expand All @@ -1125,14 +1127,16 @@ def detectObjectsFromVideo(self, input_file_path="", camera_input=None, output_f
eachCountingItem] / frames_per_second

if (return_detected_frame == True):
per_second_function(int(counting / frames_per_second),
if(per_second_function(int(counting / frames_per_second),
this_second_output_object_array, this_second_counting_array,
this_second_counting, detected_frame)
this_second_counting, detected_frame)):
break

elif (return_detected_frame == False):
per_second_function(int(counting / frames_per_second),
if(per_second_function(int(counting / frames_per_second),
this_second_output_object_array, this_second_counting_array,
this_second_counting)
this_second_counting)):
break

if (per_minute_function != None):

Expand Down Expand Up @@ -1161,14 +1165,16 @@ def detectObjectsFromVideo(self, input_file_path="", camera_input=None, output_f
frames_per_second * 60)

if (return_detected_frame == True):
per_minute_function(int(counting / (frames_per_second * 60)),
if(per_minute_function(int(counting / (frames_per_second * 60)),
this_minute_output_object_array, this_minute_counting_array,
this_minute_counting, detected_frame)
this_minute_counting, detected_frame)):
break

elif (return_detected_frame == False):
per_minute_function(int(counting / (frames_per_second * 60)),
if(per_minute_function(int(counting / (frames_per_second * 60)),
this_minute_output_object_array, this_minute_counting_array,
this_minute_counting)
this_minute_counting)):
break


else:
Expand Down
56 changes: 34 additions & 22 deletions imageai/Detection/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1227,10 +1227,12 @@ def detectObjectsFromVideo(self, input_file_path="", camera_input=None, output_f
if (counting == 1 or check_frame_interval == 0):
if (per_frame_function != None):
if (return_detected_frame == True):
per_frame_function(counting, output_objects_array, output_objects_count,
detected_copy)
if(per_frame_function(counting, output_objects_array, output_objects_count,
detected_copy)):
break
elif (return_detected_frame == False):
per_frame_function(counting, output_objects_array, output_objects_count)
if(per_frame_function(counting, output_objects_array, output_objects_count)):
break

if (per_second_function != None):
if (counting != 1 and (counting % frames_per_second) == 0):
Expand All @@ -1257,14 +1259,16 @@ def detectObjectsFromVideo(self, input_file_path="", camera_input=None, output_f
eachCountingItem] / frames_per_second

if (return_detected_frame == True):
per_second_function(int(counting / frames_per_second),
if(per_second_function(int(counting / frames_per_second),
this_second_output_object_array, this_second_counting_array,
this_second_counting, detected_copy)
this_second_counting, detected_copy)):
break

elif (return_detected_frame == False):
per_second_function(int(counting / frames_per_second),
if(per_second_function(int(counting / frames_per_second),
this_second_output_object_array, this_second_counting_array,
this_second_counting)
this_second_counting)):
break

if (per_minute_function != None):

Expand Down Expand Up @@ -1293,14 +1297,16 @@ def detectObjectsFromVideo(self, input_file_path="", camera_input=None, output_f
frames_per_second * 60)

if (return_detected_frame == True):
per_minute_function(int(counting / (frames_per_second * 60)),
if(per_minute_function(int(counting / (frames_per_second * 60)),
this_minute_output_object_array, this_minute_counting_array,
this_minute_counting, detected_copy)
this_minute_counting, detected_copy)):
break

elif (return_detected_frame == False):
per_minute_function(int(counting / (frames_per_second * 60)),
if(per_minute_function(int(counting / (frames_per_second * 60)),
this_minute_output_object_array, this_minute_counting_array,
this_minute_counting)
this_minute_counting)):
break


else:
Expand Down Expand Up @@ -1610,10 +1616,12 @@ def detectCustomObjectsFromVideo(self, custom_objects=None, input_file_path="",
if (counting == 1 or check_frame_interval == 0):
if (per_frame_function != None):
if (return_detected_frame == True):
per_frame_function(counting, output_objects_array, output_objects_count,
detected_copy)
if(per_frame_function(counting, output_objects_array, output_objects_count,
detected_copy)):
break
elif (return_detected_frame == False):
per_frame_function(counting, output_objects_array, output_objects_count)
if(per_frame_function(counting, output_objects_array, output_objects_count)):
break

if (per_second_function != None):
if (counting != 1 and (counting % frames_per_second) == 0):
Expand All @@ -1640,14 +1648,16 @@ def detectCustomObjectsFromVideo(self, custom_objects=None, input_file_path="",
eachCountingItem] / frames_per_second

if (return_detected_frame == True):
per_second_function(int(counting / frames_per_second),
if(per_second_function(int(counting / frames_per_second),
this_second_output_object_array, this_second_counting_array,
this_second_counting, detected_copy)
this_second_counting, detected_copy)):
break

elif (return_detected_frame == False):
per_second_function(int(counting / frames_per_second),
if(per_second_function(int(counting / frames_per_second),
this_second_output_object_array, this_second_counting_array,
this_second_counting)
this_second_counting)):
break

if (per_minute_function != None):

Expand Down Expand Up @@ -1676,14 +1686,16 @@ def detectCustomObjectsFromVideo(self, custom_objects=None, input_file_path="",
frames_per_second * 60)

if (return_detected_frame == True):
per_minute_function(int(counting / (frames_per_second * 60)),
if(per_minute_function(int(counting / (frames_per_second * 60)),
this_minute_output_object_array, this_minute_counting_array,
this_minute_counting, detected_copy)
this_minute_counting, detected_copy)):
break

elif (return_detected_frame == False):
per_minute_function(int(counting / (frames_per_second * 60)),
if(per_minute_function(int(counting / (frames_per_second * 60)),
this_minute_output_object_array, this_minute_counting_array,
this_minute_counting)
this_minute_counting)):
break


else:
Expand Down