1.Which seller did you purchase the product(s) from?
UCTRONICS
2.The Model number of the product(s) you have purchased?
B0290
3.Which Platform are you using the product(s) on?
Jetson Xavier NX
4.Which instruction are you following?
5.Has your product ever worked properly?
Yes
6.What problems are you experiencing?
Hello,
I try to set a fixed focus and exposure time to my camera (16MP, USB-UVC, Autofocus).
The problem is when I run the script the first time, the image is OK. But if I run it again (and again), I get a blurry image. The only way to get back a good image with the correct focus is to change a little the focus value (for example 350->351) before running again the script.
How can I avoid that?
What am I doing wrong?
Here the script:
import numpy as np
import cv2
import time
import os
from datetime import datetime
cap = cv2.VideoCapture(0, cv2.CAP_V4L2)
Set MJPG Mode
fourcc = cv2.VideoWriter.fourcc(*“MJPG”)
cap.set(cv2.CAP_PROP_FOURCC, fourcc)
Set resolution
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 3264)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 2448)
Set exposure time
#cap.set(cv2.CAP_PROP_AUTO_EXPOSURE, 1)
cap.set(cv2.CAP_PROP_EXPOSURE, 30)
Set focus
#cap.set(cv2.CAP_PROP_AUTOFOCUS, 0)
cap.set(cv2.CAP_PROP_FOCUS, 350) # need to change before each run of the script
time.sleep(1)
Capture frame
ret, frame = cap.read()
filename = datetime.now().strftime("%Y_%m_%d-%I_%M_%S_%p")
cv2.imwrite(filename+’.jpg’, frame)
cap.release()
Thanks in advance!
Daniel
7.What attempts at troubleshooting have you already made?
8.How would you like us to help you?