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

check motion in just one area of screen #3

Open
pete111 opened this issue Feb 3, 2019 · 6 comments
Open

check motion in just one area of screen #3

pete111 opened this issue Feb 3, 2019 · 6 comments

Comments

@pete111
Copy link

pete111 commented Feb 3, 2019

Hello, in fact this is not issue, it is just question :) I would like to be able to define just rectangle area where motion detection is enabled. E.g. by what I mean is on this picture http://answers.opencv.org/upfiles/1360702661403047.jpg. What is the easiest way to achieve this please? (it can be hard coded in picamera-motion.py, for now I am just experimenting with your great library) Many thanks!

@pageauc
Copy link
Owner

pageauc commented Feb 3, 2019

Currently program does not have this feature since it was made to be a simple demo. Scanning for motion in a specific zone (crop area) can be added to function scan_motion
Detection range is 0 to streamHeight
and 0 to streamWidth

This could be altered to create scan a crop area withing the full image Eg
crop area to monitor for motion crop_x, crop_y, crop_L, crop_W within existing image area
You may have to check bounds to ensure area is inside full size image otherwise an error will get raised.
For full scan of image set crop_x=0, crop_y=0 and crop_W=streamWidth, crop_H = streamHeight.

crop_x = 20  
crop_y = 10
crop_W = 60
crop_H = 50

modify scan_motion function per code below

for y in range(crop_y, crop_y + crop_H):
    for x in range(crop_x,  crop_x + crop_W):

The crop settings could also be passed to the scan_motion function. and the crop variables added to settings.py

If I get a change I will look at adding this feature. Let me know if you implement this

Regards
Claude ...

@pete111
Copy link
Author

pete111 commented Feb 3, 2019

Hi Claude, perfect, this seems to be a nice little workaround for testing purposes :) I will try to play with it. Thanks again for great advice.

@pageauc
Copy link
Owner

pageauc commented Feb 3, 2019 via email

@pete111
Copy link
Author

pete111 commented Feb 4, 2019

Yes, I am a bit familiar with python but unfortunately not familiar with github :)

@pageauc
Copy link
Owner

pageauc commented Feb 5, 2019

Please note I have updated the code so it will work correctly.
For full scan of stream area set variables per below

crop_x, crop_y = 0, 0
crop_W, crop_H = streamWidth, streamHeight

Please note that the streamWidth and streamHeight are already smaller than the full size image and will be in the middle area of the full image width and height so this cropping may not give you what you want. Eg the default full size image taken is 1280x720 while the motion detection stream size default is 128x80. Therefore the motion detection stream is already a small subset area of the final full size image.
the motion stream image will be in the center area of the full image that is saved to disk.

I recommend you position the camera so the center of the final full mage is pointed at the motion area of interest where the default 128x80 pixel stream image size is located

Regards Claude ....

@pete111
Copy link
Author

pete111 commented Feb 5, 2019

Hi Claude,
awesome! I just read python code till now and was not able to check it live yet. I saw that 128x80 thing in settings so I though it works as you wrote - thank you for mentioning it.

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