Hi all, I’m stuck on a framerate issue with a B0321 module and hoping someone here has seen it.
At 640x480 I’m only getting around 13 fps, but with the same code I should be getting 30 fps. I tested the exact same code on B0292 and B0196 modules and those both hit ~30 fps. So I don’t think it’s the sensor — it looks more like the timing system on the B0321 chip. For reference, I understand the B0321 is basically the same as the B0292 apart from the extension cable.
Environment:
- OpenCV (cv2) with the CAP_V4L2 backend
- Modules: B0321 (problem), B0292 and B0196 (both fine)
- Sensor: IMX219 8MP autofocus USB2.0 module
- Resolution of interest: 640x480
Here’s the reproduction code I’m using:
import cv2
import time
# open video0
# cap = cv2.VideoCapture(2,cv2.CAP_GSTREAMER)
# cap = cv2.VideoCapture(2,cv2.CAP_FFMPEG)
cap = cv2.VideoCapture(2, cv2.CAP_V4L2)
# The control range can be viewed through v4l2-ctl -L
# print(cap.set(cv2.CAP_PROP_BRIGHTNESS, 64))
# print(cap.set(cv2.CAP_PROP_CONTRAST, 0))
cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc('M', 'J', 'P', 'G'))
# cap.set(cv2.CV_CAP_PROP_FOURCC, cv2.CV_FOURCC('M', 'J', 'P', 'G'))
codec_code = cap.get(cv2.CAP_PROP_FOURCC)
print(codec_code)
print(cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640))
print(cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480))
# time.sleep(2)
print(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
print(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
print(cap.set(cv2.CAP_PROP_FPS, 30))
print(cap.set(cv2.CAP_PROP_AUTOFOCUS, 1))
# time.sleep(2)
print(cap.set(cv2.CAP_PROP_AUTOFOCUS, 0))
# time.sleep(2)
print(cap.get(cv2.CAP_PROP_AUTOFOCUS))
# print(cap.set(cv2.CAP_PROP_AUTO_EXPOSURE, 3))
# time.sleep(2)
print(cap.set(cv2.CAP_PROP_AUTO_EXPOSURE, 1))
# It depends on the capture api you are using. If you are using CAP_V4L2, then automatic exposure is set to 'on' with value 3 and 'off' with value 1.
print(cap.set(cv2.CAP_PROP_EXPOSURE, 157))
print(cap.get(cv2.CAP_PROP_AUTO_EXPOSURE))
print(cap.get(cv2.CAP_PROP_EXPOSURE))
time.sleep(2)
print(cap.set(cv2.CAP_PROP_AUTO_WB , 0))
# time.sleep(2)
print(cap.get(cv2.CAP_PROP_AUTO_WB ))
# used to record the time when we processed last frame
prev_frame_time = 0
# used to record the time at which we processed current frame
new_frame_time = 0
while (True):
ret, frame = cap.read()
font = cv2.FONT_HERSHEY_SIMPLEX
new_frame_time = time.time()
fps = 1/(new_frame_time-prev_frame_time)
prev_frame_time = new_frame_time
fps = int(fps)
fps = str(fps)
cv2.putText(frame, fps, (7, 70), font, 3, (100, 255, 0), 3, cv2.LINE_AA)
cv2.imshow('frame', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
Is this fixable on my end (firmware/settings), or is it something specific to this module? Any ideas would be appreciated.