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

MOG2_CUDA detects entire file as a motion event, MOG2 detects 9 short events #176

Open
TMAdams opened this issue Nov 23, 2024 · 1 comment

Comments

@TMAdams
Copy link

TMAdams commented Nov 23, 2024

Bug/Issue Description:
Difference in results between MOG2_CUDA and MOG2.
When running on the same file, leaving -b at default identifies 9 different motion events (8 of these are legitimate motion, one I believe may be an artefact on the file). Setting -b MOG2_CUDA causes the entire file to be identified as a motion event. These use the same opencv build.

Required Information:

with CUDA:

dvr-scan -i 10_03_R_112024060000.avi -b MOG2_CUDA --verbosity debug
INFO: controller.parse_settings(): DVR-Scan 1.6.1
DEBUG: controller.parse_settings(): User config file not found.
DEBUG: controller.parse_settings(): Program arguments:
Namespace(scan_only=False, debug=False, input=['10_03_R_112024060000.avi'], bg_subtractor='mog2_cuda', verbosity='debug')
INFO: controller.run_dvr_scan(): Initializing scan context...
INFO: video_joiner._load_input_videos(): Opened video 10_03_R_112024060000.avi (1280 x 720 at 22.000 FPS).
DEBUG: scanner._handle_regions(): No regions selected.
INFO: scanner.scan(): Using subtractor MOG2_CUDA with kernel_size = 5 (auto) and learning_rate = auto
INFO: scanner.scan(): Scanning input video for motion events...
DEBUG: video_joiner.read(): No more input to process.
Detected: 1 | Progress: 100%|███████████████████████████████████████████████| 79200/79200 [07:25<00:00, 177.64 frames/s]
INFO: controller.run_dvr_scan(): Processed 79200 frames read in 446.3 secs (avg 177.5 FPS).
INFO: controller.run_dvr_scan(): Detected 1 motion events in input.
INFO: controller.run_dvr_scan(): List of motion events:
-------------------------------------------------------------
|   Event #    |  Start Time  |   Duration   |   End Time   |
-------------------------------------------------------------
|  Event    1  |  00:00:50.5  |  00:59:09.5  |  01:00:00.0  |
-------------------------------------------------------------
INFO: controller.run_dvr_scan(): Comma-separated timecode values:
00:00:50.500,01:00:00.000
INFO: controller.run_dvr_scan(): Motion events written to disk.

without CUDA:

dvr-scan -i 10_03_R_112024060000.avi --verbosity debug
INFO: controller.parse_settings(): DVR-Scan 1.6.1
DEBUG: controller.parse_settings(): User config file not found.
DEBUG: controller.parse_settings(): Program arguments:
Namespace(scan_only=False, debug=False, input=['10_03_R_112024060000.avi'], verbosity='debug')
INFO: controller.run_dvr_scan(): Initializing scan context...
INFO: video_joiner._load_input_videos(): Opened video 10_03_R_112024060000.avi (1280 x 720 at 22.000 FPS).
DEBUG: scanner._handle_regions(): No regions selected.
INFO: scanner.scan(): Using subtractor MOG2 with kernel_size = 5 (auto) and learning_rate = auto
INFO: scanner.scan(): Scanning input video for motion events...
DEBUG: video_joiner.read(): No more input to process.
Detected: 9 | Progress: 100%|███████████████████████████████████████████████| 79200/79200 [09:58<00:00, 132.23 frames/s]
INFO: controller.run_dvr_scan(): Processed 79200 frames read in 599.0 secs (avg 132.2 FPS).
INFO: controller.run_dvr_scan(): Detected 9 motion events in input.
INFO: controller.run_dvr_scan(): List of motion events:
-------------------------------------------------------------
|   Event #    |  Start Time  |   Duration   |   End Time   |
-------------------------------------------------------------
|  Event    1  |  00:13:15.7  |  00:00:14.1  |  00:13:29.8  |
|  Event    2  |  00:13:47.6  |  00:00:06.0  |  00:13:53.6  |
|  Event    3  |  00:15:06.0  |  00:00:19.4  |  00:15:25.5  |
|  Event    4  |  00:16:11.2  |  00:00:19.7  |  00:16:30.9  |
|  Event    5  |  00:17:30.1  |  00:00:03.9  |  00:17:34.0  |
|  Event    6  |  00:17:38.9  |  00:00:15.4  |  00:17:54.3  |
|  Event    7  |  00:23:22.8  |  00:00:06.0  |  00:23:28.8  |
|  Event    8  |  00:30:06.0  |  00:00:08.5  |  00:30:14.5  |
|  Event    9  |  00:30:34.6  |  00:00:06.0  |  00:30:40.7  |
-------------------------------------------------------------
INFO: controller.run_dvr_scan(): Comma-separated timecode values:
00:13:15.682,00:13:29.773,00:13:47.591,00:13:53.591,00:15:06.045,00:15:25.455,00:16:11.227,00:16:30.909,00:17:30.136,00:17:34.000,00:17:38.864,00:17:54.273,00:23:22.773,00:23:28.773,00:30:06.000,00:30:14.545,00:30:34.636,00:30:40.682
INFO: controller.run_dvr_scan(): Motion events written to disk.

Expected Behavior:
Expected similar results with improved performance when running with CUDA. Runtime is improved with CUDA, but results differ.

Computing Environment:

  • OS: Ubuntu 24.04.1 LTS (GNU/Linux 5.15.167.4-microsoft-standard-WSL2 x86_64) - virtualised on Windows 11 23H2 build 22631.4460
  • Python Version: 3.12
  • OpenCV Version: 4.10.0-dev - compiled from source with CUDA support

Additional Information:
GPU used is NVIDIA GeForce RTX 3060 Ti, have confirmed CUDA is running on it and monitored activity on the device

Please let me know if you need any more information or if I can provide any more specifications.

@Breakthrough
Copy link
Owner

Breakthrough commented Nov 23, 2024

What do you see if you generate a mask with the --mask-output flag? I've noticed small differences in the results running on GPU versus CPU. You might need to tweak the threshold a bit to make the results closer.

You can also have the mask file include frame scores if you set frame-metrics = yes in a config file. It can be helpful to compare a few similar areas in both the CPU and GPU version of MOG to see where the differences are. Let me know what you see!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants