We are using ctrl.setManualFocus()
as shown in the attached script. We call it at the start of our application and expect the OAK-D to maintain a constant focus position while capturing images. However, we've noticed that the camera lens occasionally moves (trying to AF ?), causing some images to become blurry. Is there any way to verify that the manual focus remains active at all times?
Hardware: OAK-D Pro AF
OAK-D firmware version: 3.9.9.
Depthai version: 2.22.0.0
PC environment: Ubuntu 18.04, ROS1 Melodic
Target object distance (WD): ~40 cm
def focus_callback(msg):
global startX, startY, width, height
startX = int(msg.pose.pose.orientation.x)
startY = int(msg.pose.pose.orientation.y)
width = int(msg.pose.pose.orientation.z)
height = int(msg.pose.pose.orientation.w)
ctrl = dai.CameraControl()
# time.sleep(1) # Wait for camera switching
exposureTimeUs = msg.pose.pose.position.x
lensDistance = msg.pose.pose.position.y
iso = msg.pose.pose.position.z
ctrl.setAutoFocusMode(dai.RawCameraControl.AutoFocusMode.OFF)
if lensDistance != 0:
ctrl.setManualFocus(int(lensDistance))
elif lensDistance == 0:
ctrl.setAutoFocusMode(dai.RawCameraControl.AutoFocusMode.AUTO)
if exposureTimeUs != 0:
if iso == 0:
iso = 100
ctrl.setManualExposure(int(exposureTimeUs), int(iso)) #ISO 100..1600
elif exposureTimeUs == 0:
ctrl.setAutoExposureEnable()
# qControl.send(ctrl.setAutoFocusRegion(startX,startY,width,height))
# time.sleep(3) #Wait for focus on the barcode
rospy.logwarn('focus_callback service call is finished BUT focus may take 3 more seconds')
return(True)