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 cv2import time# -- Camera Parameters --# Camera IndexCAM_IDX = 0# resolutionWIDTH = 1600HEIGHT = 1200# Hardware supported framerate of the camera. Highest for best results.FRAMERATE = 60# used to set the pixel format to MJPEG/MJPG mode.MJPG = cv2.VideoWriter_fourcc(*'MJPG')# -- DEVICE SETUP --stellarHD = 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 firststellarHD.set(cv2.CAP_PROP_FOURCC, MJPG)stellarHD.set(cv2.CAP_PROP_FRAME_WIDTH, WIDTH)stellarHD.set(cv2.CAP_PROP_FRAME_HEIGHT, HEIGHT)# Set frameratestellarHD.set(cv2.CAP_PROP_FPS, FRAMERATE)# (Optional) Disable auto exposurestellarHD.set(cv2.CAP_PROP_AUTO_EXPOSURE, 1)stellarHD.set(cv2.CAP_PROP_EXPOSURE, 90)# Error Checkif ((stellarHD == None) or (not stellarHD.isOpened())): print('\nError - could not open video device.\n') exit(0)while(True): success, frame = stellarHD.read() if (success): cv2.imshow('stellarHD', frame) # required for frames to buffer and show properly. k = cv2.waitKey(1) # press 'q' to quit if k == ord('q'): breakstellarHD.release()cv2.destroyAllWindows()