picamera-motion icon indicating copy to clipboard operation
picamera-motion copied to clipboard

check motion in just one area of screen

Open pete111 opened this issue 5 years ago • 6 comments

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!

pete111 avatar Feb 03 '19 12:02 pete111

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 ...

pageauc avatar Feb 03 '19 16:02 pageauc

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.

pete111 avatar Feb 03 '19 16:02 pete111

Sounds like you are familiar with python. I would implement your changes if you send me a github push Claude ..

On Sun, Feb 3, 2019 at 10:48 AM pete111 [email protected] wrote:

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.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/pageauc/picamera-motion/issues/3#issuecomment-460067705, or mute the thread https://github.com/notifications/unsubscribe-auth/AFr1ZJldI_gGHaCEAB5__heX2P_CypuJks5vJxLpgaJpZM4agFEg .

-- See my YouTube Channel at http://www.youtube.com/user/pageaucp

pageauc avatar Feb 03 '19 21:02 pageauc

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

pete111 avatar Feb 04 '19 06:02 pete111

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 ....

pageauc avatar Feb 05 '19 09:02 pageauc

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.

pete111 avatar Feb 05 '19 11:02 pete111