SOLVED Taking images with different shutter settings i2c
-
Hi there,
I am trying to use the Starvis 327 RPI Mipi Camera with an RPI4B to take images with different illumination settings. For our use case, I need to change the shutter settings to adjust for different levels of light.
I tried to enable the "capture mode" in order to change the shutter settings but always get a kernel error when trying to do so.
Here is the script:
from time import sleep from signal import pause import datetime import time import RPi.GPIO as GPIO import D_mipicamera as Dcam import os status = os.system('sh ./veye_mipi_i2c.sh -w -f videoformat -p1 PAL -b 10') status = os.system('sh ./veye_mipi_i2c.sh -w -f cameramode -p1 0x1 -b 10') print status camera = Dcam.mipi_camera() camera.init_camera() #Folder CREATION #os.makedirs("/home/pi/testmipi") directory="/home/pi/testmipi/" directory sleep(2) date = datetime.datetime.now().strftime("%m_%d_%Y_%H_%M_%S") frame = camera.capture(encoding = 'jpeg') frame.as_array.tofile((directory)+"nm385"+ date + ".jpg") camera.release_buffer(frame) del frame time.sleep(1) print("Close camera...") camera.close_camera() GPIO.cleanup(Alled)
The error I get is:
An error ocurred while starting the kernel mmal: mmal_component_enable w 1920 h 1080
It works in stream mode, but node in capture mode...
But in stream mode it seams like i cannot change the shutter speed.
-
@veye_xumm OK, so accordin to your suggestion,
I now switched back to stream mode and discard one frame taken with the capture command before taking another one and saving it:import D_mipicamera as Dcam camera = Dcam.mipi_camera() camera.init_camera() import os status = os.system('sh ./veye_mipi_i2c.sh -w -f cameramode -p1 0x0 -b 10') print status status = os.system('sh ./veye_mipi_i2c.sh -w -f daynightmode -p1 0xFC -p1 0x00 -b 10') #print status ##turn off automatic exposure status = os.system('sh ./veye_mipi_i2c.sh -w -f agc -p1 0 -b 10') print status ##turn off white balance status = os.system('sh ./veye_mipi_i2c.sh -w -f wbmode -p1 0x1b -b 10') print status status = os.system('sh ./veye_mipi_i2c.sh -w -f lowlight -p1 0x09 -b 10') print status directory="/home/pi/testmipi/" date = datetime.datetime.now().strftime("%m_%d_%Y_%H_%M_%S") frame = camera.capture(encoding = 'jpeg') camera.release_buffer(frame) del frame time.sleep(1) frame = camera.capture(encoding = 'jpeg') frame.as_array.tofile((directory)+"nm590"+ date + ".jpg") camera.release_buffer(frame) del frame
Now it is taking repeatedly and reliably the same images. That is good.
However, I feel like I am not in control of the shutter/ frame rate. I tried different framerate settings with *lowlight -p1 XX but nothing changed.
How can I change the exposure time now?
-
These are the 2c settings:
I2C Settings Devid: 0x6 Hdver: 0x3 Wdrmode: 0x0 Videomode: frame rate reg 1, NTSC (60Hz) Mirrormode: 0x0 Denoise: 0x5 AGC: 0x c Lowlight: 0x 0 Daynightmode: 0xfc Mshutter: 0x41 Cameramode: 0x0 Nodf: 0x0 CAPTURE ???? Csienable 0x1 Brightness: NTSC60 brightness is 0x20 Agcspeed: agcspeed is 0x a shutter speed is 0x50 Contrast: 0x80 Saturation: 0x28 Sharpen : enable is 0x1 cal is 0x3 Wdrtargetbr: 0x30 Boardmodel: no information I2cwen: no information I2cauxenable: no information
-
- about capture mode:
- http://wiki.veye.cc/index.php/VEYE-MIPI-290/327_i2c/#cameramode
Caputre mode: output the next frame each capture cmd.
You have to run the cmd below to get one picture.
./veye_mipi_i2c.sh -w -f capture -b 10
- camera.capture(encoding = 'jpeg')
This function do CAPTURE one frame from the MIPI csi-2 port.
- So I suggest add this cmd before capture a frame.
./veye_mipi_i2c.sh -w -f capture -b 10
-
@veye_xumm and then change the shutter with mshutter or with lowlight command?
-
@seka Sometimes I have the impression that the frame I get in the images is an old one. Can there be a problem with having "old" frames in the images?
-
@seka
mshutter is manual exposure time. -
@seka said in Taking images with different shutter settings i2c:
an there be a problem with having "old" frames in the images?
Could you add a little sleep between mshutter cmd and capture cmd?
-
@veye_xumm OK, so accordin to your suggestion,
I now switched back to stream mode and discard one frame taken with the capture command before taking another one and saving it:import D_mipicamera as Dcam camera = Dcam.mipi_camera() camera.init_camera() import os status = os.system('sh ./veye_mipi_i2c.sh -w -f cameramode -p1 0x0 -b 10') print status status = os.system('sh ./veye_mipi_i2c.sh -w -f daynightmode -p1 0xFC -p1 0x00 -b 10') #print status ##turn off automatic exposure status = os.system('sh ./veye_mipi_i2c.sh -w -f agc -p1 0 -b 10') print status ##turn off white balance status = os.system('sh ./veye_mipi_i2c.sh -w -f wbmode -p1 0x1b -b 10') print status status = os.system('sh ./veye_mipi_i2c.sh -w -f lowlight -p1 0x09 -b 10') print status directory="/home/pi/testmipi/" date = datetime.datetime.now().strftime("%m_%d_%Y_%H_%M_%S") frame = camera.capture(encoding = 'jpeg') camera.release_buffer(frame) del frame time.sleep(1) frame = camera.capture(encoding = 'jpeg') frame.as_array.tofile((directory)+"nm590"+ date + ".jpg") camera.release_buffer(frame) del frame
Now it is taking repeatedly and reliably the same images. That is good.
However, I feel like I am not in control of the shutter/ frame rate. I tried different framerate settings with *lowlight -p1 XX but nothing changed.
How can I change the exposure time now?
-
@seka Sorry, my bad, I can change the exposure now with the mshutter command.
THANK YOU for your help!
-
@seka
It's really nice to know this. You are welcome.