motioneye-project / motioneye

A web frontend for the motion daemon.
GNU General Public License v3.0
3.97k stars 651 forks source link

No auto exposure with OV5647 at high resolutions #2560

Open jrhansen opened 2 years ago

jrhansen commented 2 years ago

Hi

MotionEye and Pi camera newbie here :)

I bought a bunch of OV5647 cameras and Raspberry Pi Zero 2 W's, and it seems that the auto exposure function stops working (the exposure doesn't change according to overall light level) when I set the resolution to anything over 1280x720 (BTW: I am not using the "Automatic Brightness" function in MotionEye). Is this a known "feature" with the particular camera or MotionEye?

In general, I don't understand the camera settings that is shown in MotionEye (Auto Exposure, Auto Exposure Bias, etc.), because they don't seem to do anything. Also, when using the v4l2-clt command the settings are not synchronized to the ones in MotionEye. Can anyone explain the relationsship between the camera settings in MotionEye and the ones listed by the v4l2-clt command?

Finally, the camera is connected to the CSI connector of the Raspberry Pi, but I can only add it to MotionEye as a "Local V4L2 Camera" and not "MMAL". Is that ok, or is this related to some of my problems?

Thanks in advance Hansen :)

harakka commented 2 years ago

AFAIK the MMAL driver isn't available any more in newer distros like Bullseye, it's been replaced by a new V4L2 driver/software stack and the brightness problem seems to relate to this new driver. I've seen the problem talked about elsewhere but haven't come across any real solutions. The same module works fine with MotioneyeOS that still uses the old MMAL driver.

MichaIng commented 2 years ago

AFAIK the MMAL driver isn't available any more in newer distros like Bullseye

It is, but legacy display drivers need to be enabled, e.g. via raspi-config or by removing the vc4-(f)kms-v3d overlay from /boot/config.txt.

Basically it is all discussed here: #2425

mattlazarowitz commented 2 months ago

I'm having the same issue and I've been trying to find a solution for weeks. I've tried both the local V4L2 camera->mmal service 16.1 and Local MMAL Camera->VideoCore Camera In the check I just ran, it's underexposed when set up as a Local MMAL camera at 1080p. At 720p the exposure might be a little high, but the image quality is still good enough to use. When running as a V4L2 camera, the image at 1080p is completely overexposed. At 720p things work and I think the image quality is a little better than wuen set up as a local MMAL camera. The additional video controls I get with the V4L2 system also make this system preferable.

I did try to follow the libcamera threads to try using that but it sounds like I need to compile motion from scratch with a specific patch and possibly MotionEye as well. I'd be willing to give that a try with clear instructions and some confidence that the patches aren't totally stale.

mrneutron42 commented 1 month ago

I am also seeing this overly bright exposure when using Auto Exposure with a RaspberryPi Zero 2 W, Raspberry Pi HQ camera at 1280x1024, using V4L2 camera setting, Raspberry Pi OS Bullseye July 2024, motionEye Version 0.43.1b2, Motion Version 4.7.0.

This behavior was not present when using the MMAL Camera setting in the 2020 version of MotioneyeOS. The Auto Exposure appears stay at whatever exposure that is arrived at when the Motioneye software starts, and then goes into a dormant mode? If you manually change any camera setting and click Apply, the Auto Exposure becomes active for a few seconds, resets the exposure to a reasonable level, and then goes dormant again.

I've had the Auto Exposure mode set to 0, which is auto. I found the code that defines what the 4 auto exposure modes are.

#define V4L2_CID_EXPOSURE_AUTO          (V4L2_CID_CAMERA_CLASS_BASE+1)
enum  v4l2_exposure_auto_type {
    V4L2_EXPOSURE_AUTO = 0,
    V4L2_EXPOSURE_MANUAL = 1,
    V4L2_EXPOSURE_SHUTTER_PRIORITY = 2,
    V4L2_EXPOSURE_APERTURE_PRIORITY = 3

in https://github.com/gjasny/v4l-utils/blob/201ccf743cde99748f955482920be27c883fdf3a/include/linux/v4l2-controls.h#L977