Hi, I’m looking for some example python code that works for the IMX477 with the UVC adapter board. I would like to be able to change exposure. The examples I’ve found online don’t seem to work for changing exposure. I recently purchased the camera so I believe it’s the UC433 rev C or D board.
Additionally, can you please put clear instructions on setting up my Ubuntu raspberry pi to use the code? The instructions on the GitHub are a little confusing and I would like to make sure that I use clear instructions.
import cv2
# Set the camera index (0 by default, or use 1, 2, etc. for multiple cameras)
camera_index = 0
# Open the camera capture
cap = cv2.VideoCapture(camera_index, cv2.CAP_V4L2)
# Check if the camera was opened successfully
if not cap.isOpened():
print("Failed to open camera")
exit()
# Set the camera properties (exposure, in this case)
cap.set(cv2.CAP_PROP_AUTO_EXPOSURE, 0.25) # Disable auto exposure
cap.set(cv2.CAP_PROP_EXPOSURE, 0.1) # Set exposure value (0.1 seconds in this case)
# Read and display frames from the camera
while True:
# Capture frame-by-frame
ret, frame = cap.read()
# Check if the frame was captured successfully
if not ret:
print("Failed to capture frame")
break
# Display the resulting frame
cv2.imshow('Frame', frame)
# Check for key press to exit
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# Release the capture and close all windows
cap.release()
cv2.destroyAllWindows()
Thanks Dion! This is really helpful. It is similar to what I have running now, but had some key helpful changes!
Could you please direct me to all the other settings and range of values that I can set for them please?
what’s the range and units of exposure setting and the gain?
Also is there a way to specify for the image to be monochrome and use a larger data representation like long integers or floats?
Also what is the longest exposure possible? I am using the camera to take images of stars and I would like to have exposures of 1 second or longer without doing image stacking.
Is there a way to take a single exposure at the specifies exposure time instead of looping to get fps?
Im using Ubuntu Linux. I remember reading that the arguments for some of the cv2 functions change if you’re in a windows machine. I want to confirm that all the arguments you’re giving me are for Linux?
how do I reenable auto exposure after disabling it?