Skip to content

Commit

Permalink
Bugfix #11
Browse files Browse the repository at this point in the history
  • Loading branch information
heming-h committed May 27, 2024
1 parent e54657e commit 140fe2a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 38 deletions.
8 changes: 6 additions & 2 deletions vision-ai-service/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ def main() -> None:
analytics_start = EventsAdapter().get_global_setting_bool(
"VIDEO_ANALYTICS_START"
)
stop_tracking = EventsAdapter().get_global_setting_bool("VIDEO_ANALYTICS_STOP")
draw_trigger_line = EventsAdapter().get_global_setting_bool("DRAW_TRIGGER_LINE")
stop_tracking = EventsAdapter().get_global_setting_bool(
"VIDEO_ANALYTICS_STOP"
)
draw_trigger_line = EventsAdapter().get_global_setting_bool(
"DRAW_TRIGGER_LINE"
)

if stop_tracking:
EventsAdapter().update_global_setting("VIDEO_ANALYTICS_STOP", "false")
Expand Down
26 changes: 1 addition & 25 deletions vision-ai-service/config/global_settings.json
Original file line number Diff line number Diff line change
@@ -1,25 +1 @@
{
"TIME_ZONE_OFFSET_G_PHOTOS": 2,
"CONFIDENCE_LIMIT": "0.7",
"PHOTOS_FILE_PATH": ".",
"PHOTOS_URL_PATH": "../files",
"PHOTO_THUMB_SIZE": "240",
"PHOTO_THUMB_WIDTH": "240",
"PHOTO_THUMB_HEIGTH": "160",
"PHOTO_OUTPUT_MAXSIZE": "4000",
"PHOTO_WATERMARK_TEXT": "Ragdesprinten",
"AZURE_THUMB_SERVICE": "True",
"AZURE_VISION_TEXT_SERVICE": "False",
"GOOGLE_PHOTO_SERVER": "https://photoslibrary.googleapis.com/v1",
"GOOGLE_PHOTO_SCOPE": "https://www.googleapis.com/auth/photoslibrary",
"TRIGGER_LINE_XYXYN": "0:0.75:1:0.75",
"VIDEO_URL": "20240113_105758_KJ.mp4",
"CAMERA_LOCATION": "Finish",
"VIDEO_ANALYTICS_START": "False",
"VIDEO_ANALYTICS_RUNNING": "true",
"VIDEO_ANALYTICS_STOP": "False",
"DRAW_TRIGGER_LINE": "False",
"SHOW_VIDEO": "False",
"DETECTION_BOX_MINIMUM_SIZE": "0.08",
"DETECTION_BOX_MAXIMUM_SIZE": "0.9"
}
{"TIME_ZONE_OFFSET_G_PHOTOS": 2, "CONFIDENCE_LIMIT": "0.7", "PHOTOS_FILE_PATH": ".", "PHOTOS_URL_PATH": "../files", "PHOTO_THUMB_SIZE": "240", "PHOTO_THUMB_WIDTH": "240", "PHOTO_THUMB_HEIGTH": "160", "PHOTO_OUTPUT_MAXSIZE": "4000", "PHOTO_WATERMARK_TEXT": "Ragdesprinten", "AZURE_THUMB_SERVICE": "True", "AZURE_VISION_TEXT_SERVICE": "False", "GOOGLE_PHOTO_SERVER": "https://photoslibrary.googleapis.com/v1", "GOOGLE_PHOTO_SCOPE": "https://www.googleapis.com/auth/photoslibrary", "TRIGGER_LINE_XYXYN": "0:0.75:1:0.75", "VIDEO_URL": "20240113_105758_KJ.mp4", "CAMERA_LOCATION": "Finish", "VIDEO_ANALYTICS_START": "False", "VIDEO_ANALYTICS_RUNNING": "False", "VIDEO_ANALYTICS_STOP": "False", "DRAW_TRIGGER_LINE": "False", "SHOW_VIDEO": "False", "DETECTION_BOX_MINIMUM_SIZE": "0.08", "DETECTION_BOX_MAXIMUM_SIZE": "0.9"}
8 changes: 1 addition & 7 deletions vision-ai-service/config/video_status.json
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
[
"15:35:52 Trigger line photo created",
"15:35:49 Starter AI video detection.",
"15:35:29 Vision AI is ready.",
"15:28:56 Trigger line photo created",
"15:28:21 Starter AI video detection.",

["15:59:49 Vision AI is ready.", "15:35:52 Trigger line photo created", "15:35:49 Starter AI video detection.", "15:35:29 Vision AI is ready.", "15:28:56 Trigger line photo created", "15:28:21 Starter AI video detection."]
8 changes: 6 additions & 2 deletions vision-ai-service/events_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ def get_video_service_status_messages(self) -> list:
with open(config_file, "r") as json_file:
video_status = json.load(json_file)
except Exception as e:
err_info = f"Error getting video status message. File path {config_file} - {e}"
err_info = (
f"Error getting video status message. File path {config_file} - {e}"
)
logging.error(err_info)
raise Exception(err_info) from e
return video_status
Expand Down Expand Up @@ -105,7 +107,9 @@ def add_video_service_message(self, message: str) -> None:
json.dump(video_status, json_file)

except Exception as e:
err_info = f"Error adding video service message. File path {config_file} - {e}"
err_info = (
f"Error adding video service message. File path {config_file} - {e}"
)
logging.error(err_info)
raise Exception(err_info) from e

Expand Down
5 changes: 3 additions & 2 deletions vision-ai-service/vision_ai_service_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@ def detect_crossings_with_ultraltyics(
firstDetection = True
camera_location = EventsAdapter().get_global_setting("CAMERA_LOCATION")
show_video = EventsAdapter().get_global_setting_bool("SHOW_VIDEO")

informasjon = ""

# Load an official or custom model
model = YOLO("yolov8n.pt") # Load an official Detect model

# Perform tracking with the model
results = model.track(source=photos_file_path, show=show_video, stream=True, persist=True)
results = model.track(
source=photos_file_path, show=show_video, stream=True, persist=True
)
# open new stream to capture higher quality image
cap = cv2.VideoCapture(photos_file_path)
EventsAdapter().update_global_setting("VIDEO_ANALYTICS_RUNNING", "true")
Expand Down

0 comments on commit 140fe2a

Please sign in to comment.