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

Request: produce image file (thumb) of the frame with the highest amount of motion per output video #159

Closed
goatzillax opened this issue Apr 21, 2024 · 3 comments
Labels
Milestone

Comments

@goatzillax
Copy link
Contributor

Description of Problem & Solution

Mark-I Eyeball scanning of output might be really sped up with intelligent thumbnail production.

For each output video produced, it might be nice to track which frame had the highest amount of motion and then just pop out that still frame as an image to go along with the video.

If they're all going into one file, well, you get one image. Multi-output mode will produce one image per video output.

Media Examples:

Probably not applicable.

Proposed Implementation:

So since "--thumbs" does not appear to be a switch, this might be it.

I took a peek in scanner.py and it seems like frame_score would be the metric to look at. If it's within bounds, check if it's the highest scoring frame. If so, save the score and the frame.

Whenever an output file is closed, dump out that frame and reset.

That's my guess from a cursory look at the code.

Alternative Solutions:

uhhhh... hrm....

@goatzillax
Copy link
Contributor Author

Curiosity got the better of me and I hacked up a test of this feature. I didn't handle the comp_file thing and I wasn't sure about some of the frame copying, but basically I added a _highscore and a _highframe and when a motion event is closed up I dump the frame with cv2.imwrite.

It seems to work really well for my test cases. Mark-I Eyeball efficiency went up like 500%.

Other possibly useful things:

  • printing the high score per event seems kind of helpful for tuning thresholds
  • another vote for get_output_path

@Breakthrough
Copy link
Owner

Breakthrough commented Apr 27, 2024

This is a great idea!

Curiosity got the better of me and I hacked up a test of this feature. I didn't handle the comp_file thing and I wasn't sure about some of the frame copying, but basically I added a _highscore and a _highframe and when a motion event is closed up I dump the frame with cv2.imwrite.

That sounds like a reasonable approach to me. Feel free to push a PR to the develop branch if you would like. In the meantime will keep this open since this sounds like a great feature to have for a CLI tool like this.

@Breakthrough Breakthrough added this to the v1.6.1 milestone Apr 28, 2024
@goatzillax
Copy link
Contributor Author

When looking at the feature I kinda realized it gets a little more complicated, particularly with the awkward combination of options available. i.e. bounding box doesn't make sense with ffmpeg as the output… unless you want bounding boxes in the thumbnails for your ffmpeg produced output.

At the risk of becoming too ffmpeg-like in complexity, it seems like some sort of output chain would serve implementing stuff like this. Like every time a motion event is closed up, it's just packaged up with its frame list and scores and sent down a chain of processors. One processor in the chain could be the video encoder output, and another might be a thumbnail producer.

I'm also sure someone will want some other variant of a thumbnail other than just the high scorer.

(And my end goal is actually to also feed a motion group to AI straight within python.)

Just something I thought about. If I make a reasonably crude-but-unobtrusive version of the thumb feature I'll send a PR.

Thanks!

@Breakthrough Breakthrough modified the milestones: v1.6.1, v1.7 May 12, 2024
goatzillax added a commit to goatzillax/DVR-Scan that referenced this issue Jul 9, 2024
…vent.

This is a very basic cut of this functionality and doesn't comprehend certain
options like comp_file.  But it can still be quite useful as is.

fixes Breakthrough#159
Breakthrough pushed a commit that referenced this issue Jul 15, 2024
* Add basic thumbnail generation based on highest scoring frame in an event.

This is a very basic cut of this functionality and doesn't comprehend certain
options like comp_file.  But it can still be quite useful as is.

fixes #159

* Default thumbnail option to None (disabled)

* Thumbnail code formatting cleanups

---------

Co-authored-by: goatzilla <[email protected]>
@Breakthrough Breakthrough modified the milestones: v1.7, v1.6.2 Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants