Is there a script that auto focus the camera or can I incorporate it within the script I already have:
import cv2
import depthai
# Create a pipeline
pipeline = depthai.Pipeline()
# Create a node to capture the video stream from the mono camera
mono_cam = pipeline.createMonoCamera()
mono_cam.setBoardSocket(depthai.CameraBoardSocket.LEFT)
mono_cam.setResolution(depthai.MonoCameraProperties.SensorResolution.THE_800_P)
# Create an output node to receive the video
streamxout = pipeline.createXLinkOut()xout.setStreamName("video")
# Link the nodes
mono_cam.out.link(xout.input)
# Connect to the device
with depthai.Device(pipeline) as device:
# Get the output stream
q = device.getOutputQueue(name="video", maxSize=4, blocking=False)
while True:
# Get the next frame from the output stream
in_data = q.get()
if in_data is not None:
# Get the frame data
frame = in_data.getCvFrame()
# Display the frame
cv2.imshow("Viewer for Material and Part from OAK-D SR",frame)
# cv2.imshow('DepthAI Mono Camera', frame)
k = cv2.waitKey(1) & 0xFF
#PRESS esc to close window of Material
if k%256 == 27:
print('Window for Material Viewer is closing!')
# cv2.imwrite('captured_image2.png', frame)
# print('Image captured!')
break
#PRESS c to capture image
elif k%256 == 99:
# Save the captured image
cv2.imwrite('captured_image2.png', frame)
print('Image captured!')
# Release the camera
cv2.destroyAllWindows()