1.Which seller did you purchase the product(s) from?
Amazon
2.The Model number of the product(s) you have purchased?
13MP AR1335 OBISP MIPI Camera Module
3.Which Platform are you using the product(s) on?
Pi 4
4.Which instruction are you following?
https://www.arducam.com/docs/arducam-obisp-mipi-camera-module/3-use-on-raspberry-pi/3-9-test-samples/
5.Has your product ever worked properly?
To be decided
6.What problems are you experiencing?
I am having issues with my python program taking consistent pictures and setting camera properties for optimal photographs with opencv using the same method as the documentation linked above.
I am able to successfully see the picture of the camera change according to settings when I use the shell programpi@raspberrypi:~ $ v4l2-ctl -d /dev/video0 -c exposure=50000
pi@raspberrypi:~ $ v4l2-ctl -d /dev/video0 -c white_balance_automatic=1
pi@raspberrypi:~ $ v4l2-ctl -d /dev/video0 -c zoom=2
I can observe these changes when streaming with gstreamer over netcat (arducamstill -t 0 -e h264 -o stdout | nc -l -p 5000) or using arducamstill. I can get the picture to look the way I want this way.
When I use OpenCV within python I do not see that these changes. First I tried setting them like in the example linked above.
subprocess.call([‘v4l2-ctl -d /dev/video0 -c ircut=1’],shell=True)
I noticed that opencv may have its own way to set attributes. So I tried this:
cap = cv2.VideoCapture(0)
cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter.fourcc(*“UYVY”))
cap.set(cv2.CAP_PROP_FRAME_WIDTH,4160) #set width
cap.set(cv2.CAP_PROP_FRAME_HEIGHT,3120) #set height
cap.set(cv2.CAP_PROP_AUTO_EXPOSURE, 0)
cap.set(cv2.CAP_PROP_GAMMA, 4000)
cap.set(cv2.CAP_PROP_AUTO_WB, 0)
Other than setting the correct resolution I am not able to see any changes in the picture I have taken. They look very unusual and over-exposed without changing these settings. I used code to attempt to find supported settings:
supported = list()
for attr in dir(cv2):
if attr.startswith(‘CAP_PROP’):
if cap.get(getattr(cv2, attr)) != -1:
print(attr)
And I receive the following:
CAP_PROP_AUTO_EXPOSURE
CAP_PROP_AUTO_WB
CAP_PROP_BACKEND
CAP_PROP_BUFFERSIZE
CAP_PROP_CONTRAST
CAP_PROP_CONVERT_RGB
CAP_PROP_FORMAT
CAP_PROP_FOURCC
CAP_PROP_FRAME_HEIGHT
CAP_PROP_FRAME_WIDTH
CAP_PROP_GAIN
CAP_PROP_GAMMA
CAP_PROP_MODE
CAP_PROP_POS_MSEC
CAP_PROP_SATURATION
CAP_PROP_SHARPNESS
CAP_PROP_TEMPERATURE
CAP_PROP_WB_TEMPERATURE
CAP_PROP_ZOOM
It seems like these should be supported but I am not seeing the properties do anything (aside from resolution)
Here is a photo with arducamstill
Here is a similar photo with opencv
The opencv looks very odd because I cannot adjust the properties
7.What attempts at troubleshooting have you already made?
Described in post
8.How would you like us to help you?
Please help me figure out how to adjust exposure, brightness, gamma etc that affect OpenCV photos in python