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

Try to use web worker for motion detection #29

Open
szimek opened this issue Nov 10, 2016 · 2 comments
Open

Try to use web worker for motion detection #29

szimek opened this issue Nov 10, 2016 · 2 comments

Comments

@szimek
Copy link
Collaborator

szimek commented Nov 10, 2016

The motion detection works pretty slow and causes video to pause quite often. We could try out using web worker, send an image to it and perform the detection there.

@grechut
Copy link
Owner

grechut commented Nov 15, 2016

I ran a bit of poor man's profiling..

So the current compare in motion detector took ~130s.
~75% of time was spent on comparison of images.
~25% of time was spent on taking a screenshot.
Current solution works on hidden canvas of size 400x300

screen shot 2016-11-15 at 1 37 06 am

After reducing size of hidden canvas to 100x100 (which still seems to detect motion quite well), I got ~10 times faster performance.

screen shot 2016-11-15 at 1 38 07 am

So maybe https://github.com/grechut/watchdog/pull/31/files is good enough, short-term fix.
Right now we're not saving any screenshots.
Once we return to the development of screenshots saving, we can move the work of motion detector to a web worker.
We can also work on its performance. Maybe there are better, faster motion detection algorithms.

@grechut
Copy link
Owner

grechut commented Jan 16, 2017

Saw this nice snippet today: https://gist.github.com/SunboX/5849664
Might be helpful :)

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

No branches or pull requests

2 participants