I want to use MIPI CSI Camera on TX 2

Hello. I have a Tx2 board.
These are the versions of the programs I installed.

  1. Tensorflow 2.3.1
  2. cv2 4.5.3

openCV install reference
: Install OpenCV 4.5 on Jetson Nano - Q-engineering

I am currently working on a jupyter notebook.
I am trying to start with something simple,
but the MIPI CSI camera is not recognized in the code I wrote below.

import cv2 
cap = cv2.VideoCapture(0) # 

if cap.isOpened():
       print('width : ' , cap.get(cv2.CAP_PROP_FRAME_WIDTH))
       print('height : ' , cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
       print('fps : ' , cap.get(cv2.CAP_PROP_FPS))

while cap.isOpened():
     ret, img = cap.read()

     if ret :

          cv2.imshow('Video Capture',img)

          key = cv2.waitKey(1) &0xFF
          if key ==27: #ESC
               break

cap.release()
cv2.destroyAllWindows()

Is there anything I need to install in advance through sudo to use the onboard camera? I haven’t installed anything except something about tensorflow and OpenCV and jupyter notebook.

This would use V4L API for getting frames from sensor at /dev/video0. One problem is that opencv cannot get bayer10 frames. Better use ISP/Argus through gstreamer plugin nvarguscamerasrc that will provide NV12 frames into NVMM memory:

cap = cv2.VideoCapture("nvarguscamerasrc ! video/x-raw(memory:NVMM),width=640,height=480,framerate=30/1,format=NV12 ! nvvidconv ! video/x-raw,format=BGRx ! videoconvert ! video/x-raw,format=BGR ! appsink drop=1", cv2.CAP_GSTREAMER)

Also note that imshow is not very fast for high pixel rates. You may use a gstreamer VideoWriter to a display sink (you may find various examples searching this forum).

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.