silvanmelchior / RPi_Cam_Web_Interface

A web interface for the RPi Cam
MIT License
1.53k stars 489 forks source link

Motion Mask Image #401

Open smallzZz8 opened 6 years ago

smallzZz8 commented 6 years ago

So I am currently trying to only record on motion when and only when a certain part of the frame is triggered. I understand that I have to create a mask image file but I am confused on how to. I read the wiki instructions but they were a bit confusing. So I would like to ask if anyone has done this and could explain it better. From my knowledge I need to take a still image picture with raspistill and get the resolution and aspect ratio. Once done I paint paint all the areas that I want the camera to detect white and the areas I want ignored black, Now do I just save that image with the same resolution as the still picture as a .pgm? The wiki said something about down scaling it which confuses me. Once done where do I save it to?

roberttidey commented 6 years ago

These assume using the recommended internal motion detection. If using external the process is similar but the mask file has different dimension (the same as a preview image)

1) First check in schedule log to find out the required mask image size. This will appear in a line like Set up internal detect width=82 height=61 This is logged after camera starts up or motion detected is started. If you don't see one then start and stop motion detection. The size is approximately 1/16 of video resolution.

2) Grab a still image using the web interface. Make sure still image resolution is same as the video resolution. Download image to a PC.

3) Open Image in an image editor that can support pgm bit map format. I use an old free PaintShopPro.

4) Use Image Resize to set the image to the pixel dimensions found in step 1

5) Use image edit tools to make the wanted areas to white and the unwanted to black.

6) Set image to be Grayscale (e.g. 8bits per pixel monochrome).

7) Save as image type pgm (portable greymap) Give it some name like motionmask.pgm

8) Copy the mask image file to same place as where the web software was installed e.g. /var/www/html

9) Change motion settings to motion image to have the name of the mask file including path and extension. e.g. /var/www/html/motionmask.pgm