Exposure for Quad-Camera (OV9782) does not work properly

  1. Where did you get the camera module(s)?
    uctronics
  2. Model number of the product(s)?
    Arducam 1MP*4 Quadrascopic Camera Bundle Kit for Raspberry Pi, Nvidia Jetson Nano/Xavier NX, Four OV9782 Global Shutter Color Camera Modules and Camarray Camera HAT
  3. What hardware/platform were you working on?
    Raspberry Pi 4
  4. Instructions you have followed. (link/manual/etc.)
    OpenCV: Capture Frames from V4L2-Compliant Camera on Raspberry Pi (Python) - Arducam
  5. Problems you were having?
    -I use python script for frame capturing and use subprocess.call([‘v4l2-ctl -d /dev/video0 -c exposure=50’],shell=True) to set exposure.
    a) Exposure settings applied only if before and right after subprocess.call script makes frame capturing
    ret, frame1 = cap1.read()
    subprocess.call([‘v4l2-ctl -d /dev/video0 -c exposure=50’],shell=True)
    ret, frame1 = cap1.read()
    b) If the same script will run once again exposure setting does not work and picture looks like default exposure value (681) was used. Despite this ‘v4l2-ctl -d /dev/video0 -all’ shows exposure=50.
    please see pic exposure-50 — ImgBB - with exposure 50
    please see at second attempt to run exposure-like-681 — ImgBB

The only workaround I found is reboot, then script can be run one time with customized exposure.
c) Сolor distortion os observed. Red objects looks blue on the picture
see example here Test-outside-exposure-50 — ImgBB
6. The dmesg log from your hardware?

  1. Troubleshooting attempts you’ve made?
    frame capturing before and after exposure set, reboot.
  2. What help do you need?
    For the issue described in point a) - any other elegant solution can be applied?
    For the issue described in point b) - what workaround/solution can be applied to do not make reboot. E.g. some re-init/reset by v4l2-ctl
    For the issue described in point c) is there any filter whic can be switched off/removed?
    Most critical points are b and c
    Thanks
    Python script
    import numpy as np
    import cv2
    import subprocess
    import time

def camera_capture(frames_to_skip, max_frames):
#Initialisation
cap1 = cv2.VideoCapture(0) #, cv2.CAP_V4L)
if not cap1.isOpened():
print(‘Error open camera array. Exiting’) #Write to log and exit
#Set resolution for camera array
cap1.set(3,5120)
cap1.set(4,800)
#subprocess.call([‘v4l2-ctl -d /dev/video0 -c exposure=50’],shell=True) #it does not make any effect if set exposure here
ContinueFlag=True
i=0
#Set exposure required immediate capturing of frame to take in to effect
ret, frame1 = cap1.read()
subprocess.call([‘v4l2-ctl -d /dev/video0 -c exposure=50’],shell=True)
ret, frame1 = cap1.read()
#Cycle to capture frames given in frames_to_skip parameter to skip frames which still use “old” exposure settings
while(i < frames_to_skip):
ret, frame1 = cap1.read()
if not ret:
print (‘Unable to read frame from camera array’) #Write to log and exit
i+=1
i=0
while(i < max_frames):
ret, frame1 = cap1.read()
ret1, frame1 = cap1.read()
cv2.imwrite(f’C1{str(i)}c100{time.strftime("%Y%m%d-%H%M%S")}.jpg’, frame1, [int(cv2.IMWRITE_JPEG_QUALITY), 100])
i+=1
cap1.release()
cv2.destroyAllWindows()
#End of camera_capture

#Main routine
camera_capture(3, 5)
Printout before second attempt to run script
pi@raspberrypi:~ $ uname -a
Linux raspberrypi 5.4.79-v7l+ #4 SMP Thu Dec 10 10:08:29 CST 2020 armv7l GNU/Linux
pi@raspberrypi:~ $ v4l2-ctl -d /dev/video0 --all
Driver Info:
Driver name : unicam
Card type : unicam
Bus info : platform:fe801000.csi
Driver version : 5.4.79
Capabilities : 0x85a00001
Video Capture
Metadata Capture
Read/Write
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x05200001
Video Capture
Read/Write
Streaming
Extended Pix Format
Media Driver Info:
Driver name : unicam
Model : unicam
Serial :
Bus info : platform:fe801000.csi
Media version : 5.4.79
Hardware revision: 0x00000000 (0)
Driver version : 5.4.79
Interface Info:
ID : 0x03000005
Type : V4L Video
Entity Info:
ID : 0x00000003 (3)
Name : unicam-image
Function : V4L2 I/O
Flags : default
Pad 0x01000004 : 0: Sink
Link 0x02000007: from remote pad 0x1000002 of entity ‘arducam 10-000c’: Data, Enabled, Immutable
Priority: 2
Video input : 0 (Camera 0: ok)
Format Video Capture:
Width/Height : 5120/800
Pixel Format : ‘BA81’ (8-bit Bayer BGBG/GRGR)
Field : None
Bytes per Line : 5120
Size Image : 4096000
Colorspace : sRGB
Transfer Function : Default (maps to sRGB)
YCbCr/HSV Encoding: Default (maps to ITU-R 601)
Quantization : Default (maps to Full Range)
Flags :

User Controls

                   exposure 0x00980911 (int)    : min=1 max=65535 step=1 default=681 value=50
                       gain 0x00980913 (int)    : min=0 max=15 step=1 default=1 value=1
               trigger_mode 0x00981901 (bool)   : default=0 value=0
                 frame_rate 0x00981906 (int)    : min=5 max=46 step=1 default=30 value=30