Hi.
I was trying to use the Jetson TX2 board to test the MIPI CSI-2 signal.
First, I checked the video output with the Jetson TX2 onboard camera.
The relevant source code is shown below.
#!/usr/bin/env python
import sys
import argparse
import cv2
import numpy as np
def parse_cli_args():
parser = argparse.ArgumentParser()
parser.add_argument("--video_device", dest="video_device",
help="Video device # of USB webcam (/dev/video?) [0]",
default=0, type=int)
arguments = parser.parse_args()
return arguments
# On versions of L4T previous to L4T 28.1, flip-method=2
# Use the Jetson onboard camera
def open_onboard_camera():
#return cv2.VideoCapture("nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)1280, height=(int)720, format=(string)I420, framerate=(fraction)30/1 ! nvvidconv ! video/x-raw, format=(string)I420 ! videoconvert ! video/x-raw, format=(string)BGR ! appsink")
return cv2.VideoCapture("nvcamerasrc ! "
"video/x-raw(memory:NVMM), width=(int)640, height=(int)480,"
"format=(string)I420, framerate=(fraction)30/1 ! "
"nvvidconv ! video/x-raw, format=(string)I420 ! "
"videoconvert ! video/x-raw, format=(string)BGR ! appsink")
# Open an external usb camera /dev/videoX
def open_camera_device(device_number):
return cv2.VideoCapture(device_number)
def read_cam(video_capture):
if video_capture.isOpened():
windowName = "JetsononboardDemo"
cv2.namedWindow(windowName, cv2.WINDOW_NORMAL)
cv2.resizeWindow(windowName,1280,720)
cv2.moveWindow(windowName,0,0)
cv2.setWindowTitle(windowName,"Jetson onboard Demo")
showWindow=1 # Show all stages
while True:
if cv2.getWindowProperty(windowName, 0) < 0: # Check to see if the user closed the window
# This will fail if the user closed the window; Nasties get printed to the console
break;
ret_val, frame = video_capture.read();
hsv=cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
if showWindow==1: # Show Camera Frame
displayBuf = frame
elif showWindow == 2: # Show Gray Frame
displayBuf = hsv
cv2.imshow(windowName,displayBuf)
key=cv2.waitKey(10)
if key == 27: # Check for ESC key
cv2.destroyAllWindows()
break ;
elif key==49: # 1 key, show frame
showWindow=1
elif key==50: # 2 key, show Gray
showWindow=2
else:
print ("camera open failed")
if __name__ == '__main__':
arguments = parse_cli_args()
print("Called with args:")
print(arguments)
print("OpenCV version: {}".format(cv2.__version__))
print("Device Number:",arguments.video_device)
if arguments.video_device==0:
video_capture=open_onboard_camera()
else:
video_capture=open_camera_device(arguments.video_device)
read_cam(video_capture)
video_capture.release()
cv2.destroyAllWindows()
I refer to the circuit diagram of the Jetson TX2 Camera module board. And I connected the Jetson TX2 board to the Lattice FPGA board.
I created a 1280 x 720 resolution, RGB888 format image with a Lattice FPGA. And I sent that video to Jetson TX2.
Then I get the following error.
Called with args:
Namespace(video_device=0)
OpenCV version: 3.4.1-dev
('Device Number:', 0)
VIDEOIO ERROR: V4L: device nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)640, height=(int)480, format=(string)I420, framerate=(fraction)30/1 ! nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink: Unable to query number of channels
Socket read error. Camera Daemon stopped functioning.....
gst_nvcamera_open() failed ret=0
OpenCV(3.4.1-dev) Error: Unspecified error (GStreamer: unable to start pipeline
) in cvCaptureFromCAM_GStreamer, file /home/nvidia/opencv/modules/videoio/src/cap_gstreamer.cpp, line 890
VIDEOIO(cvCreateCapture_GStreamer (CV_CAP_GSTREAMER_FILE, filename)): raised OpenCV exception:
OpenCV(3.4.1-dev) /home/nvidia/opencv/modules/videoio/src/cap_gstreamer.cpp:890: error: (-2) GStreamer: unable to start pipeline
in function cvCaptureFromCAM_GStreamer
I think I need to fix the opencv videocapture part to fix this error.
But I do not know what to do.
I’ll wait for your help.