Skip to content

Instantly share code, notes, and snippets.

@hugs
Last active June 15, 2023 02:59
Show Gist options
  • Save hugs/fe253cd1d2f242a3ac1b5f5d89c34de9 to your computer and use it in GitHub Desktop.
Save hugs/fe253cd1d2f242a3ac1b5f5d89c34de9 to your computer and use it in GitHub Desktop.
Test for disabling autofocus on an Arducam 16MP camera.
import cv2
cap = cv2.VideoCapture(0)
# You *must* grab at least frame before focus settings take effect.
# Try commenting and uncommenting the following line to test it
grabbed, frame = cap.read()
cap.set(cv2.CAP_PROP_AUTOFOCUS, 0)
cap.set(cv2.CAP_PROP_FOCUS, 460)
while True:
grabbed, frame = cap.read()
cv2.imshow('frame', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment