How to change camera resolution of camera onboard the Jetson TX2

Hi, I am new to the Jetson TX2 and I am currently trying to use python and openCV2 to do open the Jetson TX2 camera.

I am able to turn on the camera using:

cap = cv2.VideoCapture(“nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)1280, height=(int)720, format=(string)I420, framerate=(fraction)30/1 !
nvvidconv flip-method=4 ! video/x-raw, format=(string)I420 !
videoconvert ! video/x-raw, format=(string)BGR !
appsink”)

However, I get a message when the camera turns on that says:

VIDEOIO ERROR: V4L: device nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)1280, height=(int)720, format=(string)I420, framerate=(fraction)30/1 ! nvvidconv flip-method=4 ! video/x-raw, format=(string)I420 ! videoconvert ! video/x-raw, format=(string)BGR ! appsink: Unable to query number of channels

Available Sensor modes :
2592 x 1944 FR=30.000000 CF=0x1109208a10 SensorModeType=4 CSIPixelBitDepth=10 DynPixelBitDepth=10
2592 x 1458 FR=30.000000 CF=0x1109208a10 SensorModeType=4 CSIPixelBitDepth=10 DynPixelBitDepth=10
1280 x 720 FR=120.000000 CF=0x1109208a10 SensorModeType=4 CSIPixelBitDepth=10 DynPixelBitDepth=10

NvCameraSrc: Trying To Set Default Camera Resolution. Selected sensorModeIndex = 1 WxH = 2592x1458 FrameRate = 30.000000 …

How can I change the sensorModeIndex to 3 where the resolution is 1280x720 and framerate is 120 and dont get this message everytime I turn on the camera?

For using 1280x720@120fps, you would just specify this into gstreamer caps:

cap = cv2.VideoCapture("nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)1280, height=(int)720, format=(string)I420, <b>framerate=(fraction)120/1 </b>! \
nvvidconv ! video/x-raw, format=(string)<b>BGRx</b> ! \
videoconvert ! video/x-raw, format=(string)BGR ! \
appsink")

These sensor modes messages are usual, if you really don’t want to see these, you may filter your application’s output with grep -v.

@Honey_Patouceul: I used your code, however, I got only 60FPS, not 120FPS. why?