depthai icon indicating copy to clipboard operation
depthai copied to clipboard

[BUG] Focus issues with two OAK-D-PoE

Open redur opened this issue 4 years ago • 1 comments
trafficstars

Hi all,

We are experiencing some strange behavior with focus of the OAK-D-PoE.

Setup Description Our setup consists of 2 OAK-D-PoE, connected via Ethernet to a Raspberry-PI (Raspbian OS).

We're using depthai==2.10.0.0.dev+0d80161d1c68e79bf345ce3e5b2cbf4fc8000910

The two cameras are installed in a large hall, roughly 50mx20mx25m (lenght, widht, height). One camera is on the top left corner and the other camera is on the top right corner of the hall. The objects under considerations are on the ground and both cameras have roughly the same distance to the objects. We apply identical settings to both cameras (i.e. loop through the same code).

Bug Description Now what is strange: One camera (lets call it camera 1) continuously manages to autofocus properly and the returned images are super crisp. The other (camera 2) one only returns blurred images (no, there's nothing on the lense).

Since objects of interest are at the same distance for both cameras, we tried setting the focus manually. However, the focus doesnt seem to be the same for the two cameras. We experienced that changing the focus manually did impact the pictures of both cameras. But it never happened that both cameras would deliver decent images. In fact, it was almost impossible to get camera 2 crisp.

We also tried to set the focus area for autofocus. Most of the image is far away (30+m) for both camera, and it should be easy to find a focus area that can be applied for both cameras. But again, camera 1 was focused most of the times. Focus of camera 2 was affected, and we could improve it a lot. But it never reached the quality of camera 1.

Expected behavior: We would expect both cameras to behave the same way. I.e. to be in focus together given that the objects are at the same distance. Especially when setting the focus explicitly we would expect identical behavior.

Do you happen to know that issue? Or could it be that other settings are initialized differently on the cameras?

Find the code example here for manual focus:

get_pipeline() # defining a pipeline
	pipeline = dai.Pipeline()
	
	# initialize camera
	cam_rgb = pipeline.createColorCamera()
	cam_rgb.setBoardSocket(dai.CameraBoardSocket.RGB)
	
	# Set camera settings
	res = dai.ColorCameraProperties.SensorResolution.THE_12_MP
	cam_rgb.setResolution(res)
	cam_rgb.initialControl.setManualFocus(200) # value from 0 - 255
	cam_rgb.initialControl.setAutoFocusMode(dai.RawCameraControl.AutoFocusMode.OFF)

	# Add a script node
	script = pipeline.create(dai.node.Script)
	script.setScript(
		"""
		import time
		ctrl = CameraControl()
		ctrl.setCaptureStill(True)
		while True:
		    time.sleep({})
		    node.io['out'].send(ctrl)

		""".format(
		    1 / fps
		)
	)

	# Create output
	xout_rgb = pipeline.createXLinkOut()
	xout_rgb.setStreamName("rgb")
	script.outputs["out"].link(cam_rgb.inputControl)
	cam_rgb.still.link(xout_rgb.input)
	
	return pipeline

And here is the code that calls the pipeline for both devices.

load_output_queues(stack: contextlib.ExitStack): 
	q_rgb_list = []  # List of all rgb queues.
	device_infos = dai.Device.getAllAvailableDevices()

	for device_info in device_infos:
		openvino_version = dai.OpenVINO.Version.VERSION_2021_4
		usb2_mode = False
		device = stack.enter_context(
		    dai.Device(openvino_version, device_info, usb2_mode)
		)

		mxid = device.getMxId()
		cameras = device.getConnectedCameras()
		pipeline = get_Pipeline()

		device.startPipeline(pipeline)

		q_rgb = device.getOutputQueue(name="rgb", maxSize=4, blocking=False)
		stream_name = "rgb-" + mxid + "-" + device_type
		q_rgb_list.append((q_rgb, stream_name))

	return q_rgb_list

Here is the code example for autofocus:

cam_rgb = pipeline.createColorCamera()
cam_rgb.initialControl.setAutoFocusMode(dai.RawCameraControl.AutoFocusMode.CONTINUOUS_PICTURE)
cam_rgb.initialControl.setAutoFocusRegion(startX=2000, startY=1500, width=500, height=500)

We'd be happy to get any input on how to get both cameras to focus properly.

Thanks a lot!

PS: I'd love to attach sample pictures. Unfortunately, I can't due to data privacy issues.

redur avatar Nov 02 '21 10:11 redur

Sorry about the trouble here. We'll send you a replacement OAK-D-PoE for the one that is acting up. We haven't seen this before so we don't know what is wrong. Our best guess is that some portion of the foam seal internal the camera is interfering with the autofocus mechanism.

So if possible, we'd love to get the unit back that is acting up.

Could you please email [email protected] to facilitate the shipment of a new OAK-D-PoE to you? We'll also get a prepaid label to you for the return shipment.

Thanks - and sorry again about the trouble, Brandon

Luxonis-Brandon avatar Nov 02 '21 19:11 Luxonis-Brandon