karstenBehrendt / raspi_security_camera

Real-time, full HD, 25fps, motion detection, network security camera.
9 stars 2 forks source link

Brightness control oversteering on video start #20

Open karstenBehrendt opened 10 years ago

karstenBehrendt commented 10 years ago

The way this camera works is, that it starts a new video every 30 seconds. During some lighting conditions (in the observed case with reflecting surfaces in more than 60% of the view) the brightness controls oversteer shortly, causing motion (the tool) to signal detected motion.

This may be fixed by:

1) Setting a fixed brightness (not a fan)

2) Ignoring changes within the first 3-4 seconds, if not other change is recorded. (May be okay, since most motion <3 seconds is not too interesting anyways? I'd rather not do this. )

3) For this specific case, only look at the interesting part of the image and check if problem still exists.

lwd8cmd commented 10 years ago

Hi! I found this project from raspberry forums and because I have similar project I took a brief look of a project. Unfortunately camera don't know the lighting conditions so it tries to record with default shutter speed and change it according to frame lightness (first frame might be dark, following frames are a little lighter until optimal shutter settings have been found).

I'm not sure how raspimjpeg works and can you modify the source code, but at least raspivid command have parameters that allow splitting h264 stream (-sg and -wr params http://elinux.org/Rpi_Camera_Module). It's possible to save first 30s to 0.h264, then to 1.h264, again to 0.h264 and so on without restarting the camera.

You could also look picamera library: http://picamera.readthedocs.org/en/release-1.5/recipes1.html It allows recording to circular stream and capture images at the same time. Motion software can detect when motion started and ended from these images and pass these values to python and save that part from circularIO to the USB drive. This method also avoids restarting the camera, because video is recorded continuously to circular buffer.

I also spent same time configuring the motion software until picamera allowed motion vectors extraction, where motion estimation is done on a GPU. CPU usage is around 20% with 30fps@1080p stream, motion tool allowed only 2fps@720p with 100% CPU usage. Video quality is also considerably better when camera records using 5MP resolution and converts it to desired resolution before h264 encoding.