Breakthrough / DVR-Scan

:vhs: Tool for extracting scenes with motion from videos (e.g. security camera or DVR footage). Written in Python, uses OpenCV.
http://www.dvr-scan.com/
Other
362 stars 47 forks source link

ROI / region of interest not working #136

Closed celmi closed 1 year ago

celmi commented 1 year ago

Bug/Issue Description: I have run three DVR-Scans: test 1: without declaring a region of interest (roi) test 2: roi large test 3: roi small

The results are surpising: test 1 detected 40 events, test 2 detected 42 events, test 3 detected 50 events (even though it had the smallest roi of all). I would have expected the opposite.

Also, i had the impression that the extracted clips in test 2 and test 3 contained many events that were outside the roi.

Log-Output of Test 2 and Test 3

C:\Users\CEL>dvr-scan -i "C:\c_tmp_downloads\tmp_dvr\1_Zeit 21.56-22.07.mp4" -d "C:\c_tmp_downloads\tmp_dvr\dvr_cuts" -tc -t 0.05 -roi
[DVR-Scan] DVR-Scan v1.5.1
[DVR-Scan] Initializing scan context...
[DVR-Scan] Opened video 1_Zeit 21.56-22.07.mp4 (1024 x 768 at 24.905 FPS).
[DVR-Scan] Selecting area of interest:
Select a ROI and then press SPACE or ENTER button!
Cancel the selection process by pressing c button!
[DVR-Scan] ROI set: (x,y)/(w,h) = (1,1)/(1023,407)
[DVR-Scan] Scanning input video for motion events...
Detected: 42 | Progress: 100%|████████████████████████████████████████████▉| 16822/16843 [01:19<00:00, 211.33 frames/s]
[DVR-Scan] Processed 16822 frames read in 93.9 secs (avg 179.2 FPS).
[DVR-Scan] Detected 42 motion events in input.
[DVR-Scan] List of motion events:
-------------------------------------------------------------
|   Event #    |  Start Time  |   Duration   |   End Time   |
-------------------------------------------------------------
|  Event    1  |  00:00:00.0  |  00:00:05.1  |  00:00:05.2  |
|  Event    2  |  00:00:05.2  |  00:00:03.4  |  00:00:08.6  |
|  Event    3  |  00:00:09.6  |  00:00:09.5  |  00:00:19.1  |
|  Event    4  |  00:00:19.1  |  00:00:07.9  |  00:00:27.0  |
|  Event    5  |  00:00:36.7  |  00:00:09.4  |  00:00:46.1  |
|  Event    6  |  00:00:46.5  |  00:00:17.6  |  00:01:04.1  |
|  Event    7  |  00:01:22.1  |  00:00:04.6  |  00:01:26.7  |
|  Event    8  |  00:01:43.4  |  00:00:12.5  |  00:01:55.9  |
|  Event    9  |  00:02:00.9  |  00:00:18.3  |  00:02:19.2  |
|  Event   10  |  00:02:19.3  |  00:00:07.1  |  00:02:26.4  |
|  Event   11  |  00:02:26.4  |  00:00:03.2  |  00:02:29.6  |
|  Event   12  |  00:02:46.2  |  00:00:06.1  |  00:02:52.3  |
|  Event   13  |  00:03:05.1  |  00:00:06.5  |  00:03:11.6  |
|  Event   14  |  00:03:24.7  |  00:00:08.6  |  00:03:33.3  |
|  Event   15  |  00:03:33.3  |  00:00:03.5  |  00:03:36.8  |
|  Event   16  |  00:03:39.4  |  00:00:04.8  |  00:03:44.1  |
|  Event   17  |  00:03:50.0  |  00:00:09.4  |  00:03:59.4  |
|  Event   18  |  00:03:59.4  |  00:00:02.5  |  00:04:01.9  |
|  Event   19  |  00:04:03.9  |  00:00:03.8  |  00:04:07.7  |
|  Event   20  |  00:04:15.5  |  00:00:05.4  |  00:04:20.9  |
|  Event   21  |  00:04:21.0  |  00:00:04.1  |  00:04:25.0  |
|  Event   22  |  00:04:37.7  |  00:00:19.4  |  00:04:57.1  |
|  Event   23  |  00:04:58.2  |  00:00:10.8  |  00:05:09.0  |
|  Event   24  |  00:05:09.0  |  00:00:07.8  |  00:05:16.8  |
|  Event   25  |  00:05:16.9  |  00:00:07.2  |  00:05:24.1  |
|  Event   26  |  00:05:26.9  |  00:00:03.6  |  00:05:30.5  |
|  Event   27  |  00:05:39.5  |  00:00:03.6  |  00:05:43.1  |
|  Event   28  |  00:06:02.9  |  00:00:06.3  |  00:06:09.2  |
|  Event   29  |  00:06:16.7  |  00:00:05.1  |  00:06:21.7  |
|  Event   30  |  00:06:58.1  |  00:00:05.5  |  00:07:03.6  |
|  Event   31  |  00:07:03.6  |  00:00:02.7  |  00:07:06.3  |
|  Event   32  |  00:07:06.3  |  00:00:02.5  |  00:07:08.9  |
|  Event   33  |  00:07:40.6  |  00:00:19.2  |  00:07:59.7  |
|  Event   34  |  00:08:05.7  |  00:00:03.6  |  00:08:09.3  |
|  Event   35  |  00:08:43.4  |  00:00:05.2  |  00:08:48.6  |
|  Event   36  |  00:09:00.4  |  00:00:06.4  |  00:09:06.8  |
|  Event   37  |  00:09:09.6  |  00:00:06.4  |  00:09:16.0  |
|  Event   38  |  00:09:26.4  |  00:00:20.0  |  00:09:46.4  |
|  Event   39  |  00:09:50.8  |  00:00:08.3  |  00:09:59.2  |
|  Event   40  |  00:10:21.1  |  00:00:03.6  |  00:10:24.7  |
|  Event   41  |  00:10:27.5  |  00:00:04.6  |  00:10:32.2  |
|  Event   42  |  00:11:11.6  |  00:00:03.9  |  00:11:15.5  |
-------------------------------------------------------------
[DVR-Scan] Comma-separated timecode values:
00:00:00.040,00:00:05.180,00:00:05.220,00:00:08.593,00:00:09.556,00:00:19.072,00:00:19.113,00:00:27.023,00:00:36.659,00:00:46.095,00:00:46.497,00:01:04.124,00:01:22.072,00:01:26.689,00:01:43.353,00:01:55.880,00:02:00.899,00:02:19.249,00:02:19.289,00:02:26.356,00:02:26.396,00:02:29.568,00:02:46.231,00:02:52.335,00:03:05.103,00:03:11.608,00:03:24.698,00:03:33.290,00:03:33.330,00:03:36.824,00:03:39.353,00:03:44.131,00:03:50.034,00:03:59.389,00:03:59.429,00:04:01.919,00:04:03.927,00:04:07.741,00:04:15.531,00:04:20.911,00:04:20.951,00:04:25.007,00:04:37.695,00:04:57.129,00:04:58.213,00:05:08.974,00:05:09.014,00:05:16.843,00:05:16.884,00:05:24.071,00:05:26.922,00:05:30.536,00:05:39.530,00:05:43.143,00:06:02.858,00:06:09.202,00:06:16.671,00:06:21.730,00:06:58.148,00:07:03.609,00:07:03.649,00:07:06.299,00:07:06.339,00:07:08.869,00:07:40.589,00:07:59.742,00:08:05.685,00:08:09.258,00:08:43.428,00:08:48.608,00:09:00.413,00:09:06.837,00:09:09.608,00:09:15.992,00:09:26.432,00:09:46.427,00:09:50.844,00:09:59.156,00:10:21.119,00:10:24.733,00:10:27.544,00:10:32.161,00:11:11.591,00:11:15.486
[DVR-Scan] Motion events written to disk.

C:\Users\CEL>dvr-scan -i "C:\c_tmp_downloads\tmp_dvr\1_Zeit 21.56-22.07.mp4" -d "C:\c_tmp_downloads\tmp_dvr\dvr_cuts" -tc -t 0.05 -roi
[DVR-Scan] DVR-Scan v1.5.1
[DVR-Scan] Initializing scan context...
[DVR-Scan] Opened video 1_Zeit 21.56-22.07.mp4 (1024 x 768 at 24.905 FPS).
[DVR-Scan] Selecting area of interest:
Select a ROI and then press SPACE or ENTER button!
Cancel the selection process by pressing c button!
[DVR-Scan] ROI set: (x,y)/(w,h) = (1,2)/(1023,165)
[DVR-Scan] Scanning input video for motion events...
Detected: 50 | Progress: 100%|████████████████████████████████████████████▉| 16822/16843 [01:01<00:00, 271.75 frames/s]
[DVR-Scan] Processed 16822 frames read in 81.1 secs (avg 207.4 FPS).
[DVR-Scan] Detected 50 motion events in input.
[DVR-Scan] List of motion events:
-------------------------------------------------------------
|   Event #    |  Start Time  |   Duration   |   End Time   |
-------------------------------------------------------------
|  Event    1  |  00:00:00.0  |  00:00:05.3  |  00:00:05.3  |
|  Event    2  |  00:00:05.3  |  00:00:14.1  |  00:00:19.5  |
|  Event    3  |  00:00:19.5  |  00:00:07.5  |  00:00:27.1  |
|  Event    4  |  00:00:36.4  |  00:00:09.8  |  00:00:46.2  |
|  Event    5  |  00:00:46.5  |  00:00:17.7  |  00:01:04.2  |
|  Event    6  |  00:01:22.1  |  00:00:04.7  |  00:01:26.8  |
|  Event    7  |  00:01:32.5  |  00:00:04.3  |  00:01:36.8  |
|  Event    8  |  00:01:43.4  |  00:00:14.3  |  00:01:57.7  |
|  Event    9  |  00:02:01.0  |  00:00:09.6  |  00:02:10.6  |
|  Event   10  |  00:02:10.7  |  00:00:03.1  |  00:02:13.8  |
|  Event   11  |  00:02:13.8  |  00:00:03.5  |  00:02:17.3  |
|  Event   12  |  00:02:19.5  |  00:00:06.3  |  00:02:25.8  |
|  Event   13  |  00:02:33.9  |  00:00:03.6  |  00:02:37.5  |
|  Event   14  |  00:02:46.2  |  00:00:06.1  |  00:02:52.3  |
|  Event   15  |  00:02:53.8  |  00:00:03.6  |  00:02:57.4  |
|  Event   16  |  00:03:05.1  |  00:00:06.5  |  00:03:11.6  |
|  Event   17  |  00:03:24.0  |  00:00:09.3  |  00:03:33.3  |
|  Event   18  |  00:03:33.3  |  00:00:03.5  |  00:03:36.8  |
|  Event   19  |  00:03:39.4  |  00:00:04.8  |  00:03:44.1  |
|  Event   20  |  00:03:50.1  |  00:00:09.3  |  00:03:59.4  |
|  Event   21  |  00:03:59.4  |  00:00:02.6  |  00:04:02.0  |
|  Event   22  |  00:04:03.9  |  00:00:03.6  |  00:04:07.5  |
|  Event   23  |  00:04:15.5  |  00:00:13.9  |  00:04:29.4  |
|  Event   24  |  00:04:50.1  |  00:00:08.0  |  00:04:58.1  |
|  Event   25  |  00:04:58.2  |  00:00:03.9  |  00:05:02.1  |
|  Event   26  |  00:05:12.5  |  00:00:03.6  |  00:05:16.1  |
|  Event   27  |  00:05:16.1  |  00:00:07.7  |  00:05:23.9  |
|  Event   28  |  00:05:25.7  |  00:00:03.7  |  00:05:29.4  |
|  Event   29  |  00:05:39.5  |  00:00:03.6  |  00:05:43.1  |
|  Event   30  |  00:06:02.9  |  00:00:06.3  |  00:06:09.2  |
|  Event   31  |  00:06:16.1  |  00:00:08.0  |  00:06:24.1  |
|  Event   32  |  00:06:28.8  |  00:00:03.6  |  00:06:32.4  |
|  Event   33  |  00:06:58.1  |  00:00:11.0  |  00:07:09.1  |
|  Event   34  |  00:07:40.3  |  00:00:19.4  |  00:07:59.7  |
|  Event   35  |  00:08:05.4  |  00:00:04.2  |  00:08:09.7  |
|  Event   36  |  00:08:12.4  |  00:00:04.5  |  00:08:16.9  |
|  Event   37  |  00:08:20.9  |  00:00:04.1  |  00:08:24.9  |
|  Event   38  |  00:08:42.8  |  00:00:06.7  |  00:08:49.5  |
|  Event   39  |  00:08:57.1  |  00:00:11.4  |  00:09:08.5  |
|  Event   40  |  00:09:08.7  |  00:00:07.3  |  00:09:16.0  |
|  Event   41  |  00:09:16.1  |  00:00:02.6  |  00:09:18.7  |
|  Event   42  |  00:09:21.1  |  00:00:04.5  |  00:09:25.6  |
|  Event   43  |  00:09:25.6  |  00:00:20.6  |  00:09:46.2  |
|  Event   44  |  00:09:50.8  |  00:00:08.3  |  00:09:59.1  |
|  Event   45  |  00:10:17.6  |  00:00:03.9  |  00:10:21.5  |
|  Event   46  |  00:10:21.5  |  00:00:03.4  |  00:10:24.9  |
|  Event   47  |  00:10:24.9  |  00:00:02.6  |  00:10:27.5  |
|  Event   48  |  00:10:27.6  |  00:00:04.5  |  00:10:32.1  |
|  Event   49  |  00:10:36.1  |  00:00:03.8  |  00:10:39.9  |
|  Event   50  |  00:11:11.6  |  00:00:03.9  |  00:11:15.5  |
-------------------------------------------------------------
[DVR-Scan] Comma-separated timecode values:
00:00:00.040,00:00:05.300,00:00:05.340,00:00:19.474,00:00:19.514,00:00:27.063,00:00:36.378,00:00:46.175,00:00:46.497,00:01:04.244,00:01:22.072,00:01:26.810,00:01:32.511,00:01:36.808,00:01:43.433,00:01:57.687,00:02:00.980,00:02:10.616,00:02:10.656,00:02:13.788,00:02:13.828,00:02:17.322,00:02:19.530,00:02:25.794,00:02:33.905,00:02:37.478,00:02:46.231,00:02:52.335,00:02:53.820,00:02:57.394,00:03:05.103,00:03:11.608,00:03:24.015,00:03:33.290,00:03:33.330,00:03:36.824,00:03:39.353,00:03:44.131,00:03:50.074,00:03:59.389,00:03:59.429,00:04:02.039,00:04:03.927,00:04:07.500,00:04:15.450,00:04:29.383,00:04:50.142,00:04:58.132,00:04:58.213,00:05:02.108,00:05:12.467,00:05:16.081,00:05:16.121,00:05:23.870,00:05:25.677,00:05:29.371,00:05:39.530,00:05:43.143,00:06:02.858,00:06:09.162,00:06:16.149,00:06:24.099,00:06:28.797,00:06:32.411,00:06:58.108,00:07:09.110,00:07:40.268,00:07:59.702,00:08:05.444,00:08:09.660,00:08:12.390,00:08:16.887,00:08:20.862,00:08:24.918,00:08:42.786,00:08:49.491,00:08:57.080,00:09:08.483,00:09:08.724,00:09:16.032,00:09:16.072,00:09:18.682,00:09:21.131,00:09:25.588,00:09:25.628,00:09:46.227,00:09:50.844,00:09:59.116,00:10:17.626,00:10:21.481,00:10:21.521,00:10:24.894,00:10:24.934,00:10:27.544,00:10:27.584,00:10:32.121,00:10:36.096,00:10:39.870,00:11:11.591,00:11:15.486
[DVR-Scan] Motion events written to disk.

C:\Users\CEL>

Computing Environment:

celmi commented 1 year ago

AHA! I just detected issue https://github.com/Breakthrough/DVR-Scan/issues/100

If I understand right, by making the roi smaller this will increase sensitivity in the remaining roi if other parameters are kept constant?

That would explain, why the number of cuts is increasing. But not why some cuts contain motion events outside the roi. But then again, there might be motion going on I cannot detect with my eye... I suppose I need first go thouroghly through your explanations with issue100 before I file an issue myself.