You can use the following main.py script to connect to the camera and view the video feed. A critical step when configuring the camera is that the MJPG pixel format must be set before setting the resolution.
import cv2# -- Camera Parameters --# Camera IndexCAM_IDX = 0# resolutionWIDTH = 1920HEIGHT = 1080# used to set the pixel format to MJPEG/MJPG mode.MJPG = cv2.VideoWriter_fourcc(*'MJPG')# -- DEVICE SETUP --exploreHD = cv2.VideoCapture(CAM_IDX)# set to MJPEG mode, by default idx 0 is YUYV# MJPG needs to be set, before resolution. Pixel format is always selected firstexploreHD.set(cv2.CAP_PROP_FOURCC, MJPG)exploreHD.set(cv2.CAP_PROP_FRAME_WIDTH, WIDTH)exploreHD.set(cv2.CAP_PROP_FRAME_HEIGHT, HEIGHT)# (Optional) Disable auto exposureexploreHD.set(cv2.CAP_PROP_AUTO_EXPOSURE, 1)exploreHD.set(cv2.CAP_PROP_EXPOSURE, 90)# Error Checkif ((exploreHD == None) or (not exploreHD.isOpened())): print('\nError - could not open video device.\n') exit(0)while(True): success, frame = exploreHD.read() if (success): cv2.imshow('exploreHD', frame) # required for frames to buffer and show properly. k = cv2.waitKey(1) # press 'q' to quit if k == ord('q'): breakexploreHD.release()cv2.destroyAllWindows()