Skip to content

Instantly share code, notes, and snippets.

@qaz10102030
Created January 25, 2022 05:51
Show Gist options
  • Save qaz10102030/b90f61f481a5a4cce99d8fbbcbaadf5d to your computer and use it in GitHub Desktop.
Save qaz10102030/b90f61f481a5a4cce99d8fbbcbaadf5d to your computer and use it in GitHub Desktop.
import cv2
cam = cv2.VideoCapture(0 + cv2.CAP_DSHOW)
cam.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
cam.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)
cam.set(cv2.CAP_PROP_CONVERT_RGB, 0)
try:
print("Starting video. Press CTRL+C to exit.")
while True:
ret_val, im = cam.read()
bRGGB = cv2.convertScaleAbs(im, 0.249023)
BGRim = cv2.cvtColor(bRGGB, cv2.COLOR_BayerRG2BGR)
cv2.imshow("example", BGRim)
cv2.waitKey(1)
except KeyboardInterrupt:
cv2.destroyAllWindows()
# release camera
cam = cam.release()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment