Skip to content

Commit

Permalink
Added configuration for realtime object detection
Browse files Browse the repository at this point in the history
  • Loading branch information
connervieira committed Oct 22, 2023
1 parent c917f16 commit a55e265
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ These are the features actively planned for Predator and are likely to be added
- [X] Test updated license plate validation in pre-recorded mode.
- [X] Test updated license plate validation in real-time mode.
- [X] Add Phantom alert handling to updated ALPR stream.
- [ ] Display prominent alerts of the ALPR process fails.
- [ ] Complete OpenCV dashcam recording.
- [X] Improve the efficiency of GPS location requests when many requests are made in quick succession.
- [ ] Test that improved GPS location querying behaves as expected.
Expand Down
6 changes: 5 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"debugging_output": false
},
"object_recognition": {
"enabled": false
"enabled": true
},
"modes": {
"auto_start": "",
Expand Down Expand Up @@ -75,6 +75,10 @@
"clearing": true
}
},
"object_recognition": {
"enabled": true,
"video_still_path": "/dev/shm/phantom-webcam.jpg"
},
"gps": {
"enabled": false,
"alpr_location_tagging": true
Expand Down
25 changes: 13 additions & 12 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1318,18 +1318,19 @@
if (config["realtime"]["interface"]["display"]["output_level"] >= 3): # Only display this status message if the output level indicates to do so.
print("Running object recognition...")

image = cv2.imread(config["realtime"]["object_recognition"]["enabled"]) # Load the frame.
object_recognition_bounding_box, object_recognition_labels, object_recognition_confidence = cv.detect_common_objects(image) # Anaylze the image.
objects_identified = str(object_recognition_labels) # Convert the list of objects identified into a plain string.
if (objects_identified != "[]"): # Check to see that there were actually identified objects.
if (config["realtime"]["interface"]["display"]["output_level"] >= 2): # Only display this status message if the output level indicates to do so.
print("Objects identified: " + objects_identified)
export_data = str(round(time.time()*10)/10) + "," + objects_identified + "\n" # Add the timestamp to the export data, followed by the object's detected, followed by a line break to prepare for the next entry to be added later.
if (save_real_time_object_recognition == True): # Check to make sure the user has configured Predator to save recognized objects to disk.
add_to_file(root + "/real_time_object_detection.csv", export_data, silence_file_saving) # Add the export data to the end of the file and write it to disk.

if (config["realtime"]["interface"]["display"]["output_level"] >= 3): # Only display this status message if the output level indicates to do so.
print("Done\n----------")
if (os.path.exists(video_still_path) == True):
image = cv2.imread(config["realtime"]["object_recognition"]["video_still_path"]) # Load the frame.
object_recognition_bounding_box, object_recognition_labels, object_recognition_confidence = cv.detect_common_objects(image) # Anaylze the image.
objects_identified = str(object_recognition_labels) # Convert the list of objects identified into a plain string.
if (objects_identified != "[]"): # Check to see that there were actually identified objects.
if (config["realtime"]["interface"]["display"]["output_level"] >= 2): # Only display this status message if the output level indicates to do so.
print("Objects identified: " + objects_identified)
export_data = str(round(time.time()*10)/10) + "," + objects_identified + "\n" # Add the timestamp to the export data, followed by the object's detected, followed by a line break to prepare for the next entry to be added later.
if (save_real_time_object_recognition == True): # Check to make sure the user has configured Predator to save recognized objects to disk.
add_to_file(root + "/real_time_object_detection.csv", export_data, silence_file_saving) # Add the export data to the end of the file and write it to disk.

if (config["realtime"]["interface"]["display"]["output_level"] >= 3): # Only display this status message if the output level indicates to do so.
print("Done\n----------")



Expand Down

0 comments on commit a55e265

Please sign in to comment.