PiCapture › Interface PiCapture SD1 with Nvidia Jetson Nano
- This topic has 9 replies, 2 voices, and was last updated 9 months, 1 week ago by
bjtomasic.
-
AuthorPosts
-
April 8, 2020 at 5:16 pm #28632
bjtomasic
ParticipantTrying to input analog component video to Jetson Nano using the CSI port. Was successfully able to get Raspberry Pi camera V2 to work. When trying to use PiCaptue SD 1 Camera shown as unavailable when running CSI-Camera “simple_camera.py”.
April 8, 2020 at 5:25 pm #28633bjtomasic
Participant`# MIT License
# Copyright (c) 2019 JetsonHacks
# See license
# Using a CSI camera (such as the Raspberry Pi Version 2) connected to a
# NVIDIA Jetson Nano Developer Kit using OpenCV
# Drivers for the camera and OpenCV are included in the base imageimport cv2
# gstreamer_pipeline returns a GStreamer pipeline for capturing from the CSI camera
# Defaults to 1280×720 @ 60fps
# Flip the image by setting the flip_method (most common values: 0 and 2)
# display_width and display_height determine the size of the window on the screendef gstreamer_pipeline(
capture_width=1280,
capture_height=720,
display_width=1280,
display_height=720,
framerate=60,
flip_method=0,
):
return (
“nvarguscamerasrc ! ”
“video/x-raw(memory:NVMM), ”
“width=(int)%d, height=(int)%d, ”
“format=(string)NV12, framerate=(fraction)%d/1 ! ”
“nvvidconv flip-method=%d ! ”
“video/x-raw, width=(int)%d, height=(int)%d, format=(string)BGRx ! ”
“videoconvert ! ”
“video/x-raw, format=(string)BGR ! appsink”
% (
capture_width,
capture_height,
framerate,
flip_method,
display_width,
display_height,
)
)def show_camera():
# To flip the image, modify the flip_method parameter (0 and 2 are the most common)
print(gstreamer_pipeline(flip_method=0))
cap = cv2.VideoCapture(gstreamer_pipeline(flip_method=0), cv2.CAP_GSTREAMER)
if cap.isOpened():
window_handle = cv2.namedWindow(“CSI Camera”, cv2.WINDOW_AUTOSIZE)
# Window
while cv2.getWindowProperty(“CSI Camera”, 0) >= 0:
ret_val, img = cap.read()
cv2.imshow(“CSI Camera”, img)
# This also acts as
keyCode = cv2.waitKey(30) & 0xFF
# Stop the program on the ESC key
if keyCode == 27:
break
cap.release()
cv2.destroyAllWindows()
else:
print(“Unable to open camera”)if __name__ == “__main__”:
show_camera()April 8, 2020 at 5:29 pm #28635bjtomasic
ParticipantApril 8, 2020 at 5:30 pm #28636bjtomasic
ParticipantApril 9, 2020 at 9:14 am #28637mwlinder
KeymasterThank you for posting your experience with Jetson. That is a configuration we have not tried. Unfortunately, your post with the error message can’t be seen – if you could post the message we can take a look and see if there is anything we can think of to resolve the issue.
April 9, 2020 at 2:44 pm #28638bjtomasic
ParticipantApril 9, 2020 at 2:46 pm #28639bjtomasic
ParticipantApril 9, 2020 at 3:19 pm #28640mwlinder
KeymasterThanks for the additional detail. The SD1 outputs 640×480 (4:3) video, and I see that you have specified 1280×720 (16:9) as the resolution (which seems to be the default). It is important to make sure that the system is expecting the same resolution and format, and I would start there to resolve the error.
April 22, 2020 at 11:40 am #28642bjtomasic
Participant# MIT License
# Copyright (c) 2019 JetsonHacks
# See license
# Using a CSI camera (such as the Raspberry Pi Version 2) connected to a
# NVIDIA Jetson Nano Developer Kit using OpenCV
# Drivers for the camera and OpenCV are included in the base imageimport cv2
# gstreamer_pipeline returns a GStreamer pipeline for capturing from the CSI camera
# Defaults to 1280×720 @ 60fps
# Flip the image by setting the flip_method (most common values: 0 and 2)
# display_width and display_height determine the size of the window on the screendef gstreamer_pipeline(
#capture_width=1280,
capture_width=640,
#capture_height=720,
capture_height=480,
#display_width=1280,
display_height=640,
#display_height=720,
display_width=480,
framerate=60,
flip_method=0,
):
return (
“nvarguscamerasrc ! ”
“video/x-raw(memory:NVMM), ”
“width=(int)%d, height=(int)%d, ”
“format=(string)NV12, framerate=(fraction)%d/1 ! ”
“nvvidconv flip-method=%d ! ”
“video/x-raw, width=(int)%d, height=(int)%d, format=(string)BGRx ! ”
“videoconvert ! ”
“video/x-raw, format=(string)BGR ! appsink”
% (
capture_width,
capture_height,
framerate,
flip_method,
display_width,
display_height,
)
)def show_camera():
# To flip the image, modify the flip_method parameter (0 and 2 are the most common)
print(gstreamer_pipeline(flip_method=0))
cap = cv2.VideoCapture(gstreamer_pipeline(flip_method=0), cv2.CAP_GSTREAMER)
if cap.isOpened():
window_handle = cv2.namedWindow(“CSI Camera”, cv2.WINDOW_AUTOSIZE)
# Window
while cv2.getWindowProperty(“CSI Camera”, 0) >= 0:
ret_val, img = cap.read()
cv2.imshow(“CSI Camera”, img)
# This also acts as
keyCode = cv2.waitKey(30) & 0xFF
# Stop the program on the ESC key
if keyCode == 27:
break
cap.release()
cv2.destroyAllWindows()
else:
print(“Unable to open camera”)if __name__ == “__main__”:
show_camera()April 22, 2020 at 11:44 am #28643bjtomasic
Participant -
AuthorPosts
- You must be logged in to reply to this topic.