Take full resolution pictures CSI camera nvidia Jetson nano 4gb

Hello,

I have troubles to use my raspberry pi v2 CSI camera with a Nvidia Jetson Nano 4gb.

I manage to take 1280*720 pictures with :
nvgstcapture-1.0 --image-res=4
but when I try to get higher resolution, there is an error :

Error on bus: by /GstPipeline:capture_native_pipeline/GstBin:cap_bin/GstNvArgusCameraSrc:nvarguscamerasrc0 : CANCELLED

I have the same kind or error on Python with CV2 and nanocamera libraries

Does anyone knows how to take pictures with the camera with full resolution (3280 x 2464) ?

Thank you very much,

Benjamin

Hello again ,

I have founded a solution in Python but it is pretty slow :

import cv2
from datetime import datetime
import time

def gstreamer_pipeline(
    capture_width=3280,
    capture_height=2464,
    display_width=3280,
    display_height=2464,
    framerate=21,
    flip_method=2,):
    
    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 gstreamer_pipeline2(
    capture_width=3280,
    capture_height=2464,
    display_width=720,
    display_height=480,
    framerate=21,
    flip_method=2,):
    
    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 Take_Picture():
    
    cap2 = cv2.VideoCapture(gstreamer_pipeline2(), cv2.CAP_GSTREAMER)
    if cap2.isOpened():
        cv2.namedWindow("Picture", cv2.WINDOW_AUTOSIZE)
        while cv2.getWindowProperty("Picture", 0) >= 0:
            
            ret2, img2 = cap2.read()

            now = datetime.now()

            cv2.imshow("Picture", img2)
            keyCode = cv2.waitKey(30) & 0xFF
            
            if keyCode == 32:
                cap2.release()
                cap = cv2.VideoCapture(gstreamer_pipeline(), cv2.CAP_GSTREAMER)
                for k in range(0,30):
                    ret, img = cap.read()
                    k=k+1
                
                cv2.imwrite(str(now)+".jpg", img)
                print("image captured")
                cap.release()
                cap2 = cv2.VideoCapture(gstreamer_pipeline2(), cv2.CAP_GSTREAMER)

            if keyCode == 27:
                break

        cap.release()
        cap2.release()
        cv2.destroyAllWindows()
    else:
        print("Unable to open camera")


if __name__ == "__main__":
    Take_Picture()

I open a pipeline to get the preview of the camera and when I want to take a picture :

  • I close the preview pipeline
  • open a new one with a better resolution
  • wait 1 sec for the camera initialise and adjust brightness
  • take picture
  • close the high resolution pipeline
  • open the preview pipeline again.

Does anyone know if there is a better way to do it ?

Thank you very much

Below is Pi V2 camera support resolution. Looks like don’t support the resolution what you want.

nvidia@nvidia-desktop:~$ v4l2-ctl --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
        Index       : 0
        Type        : Video Capture
        Pixel Format: 'RG10'
        Name        : 10-bit Bayer RGRG/GBGB
                Size: Discrete 3264x2464
                        Interval: Discrete 0.048s (21.000 fps)
                Size: Discrete 3264x1848
                        Interval: Discrete 0.036s (28.000 fps)
                Size: Discrete 1920x1080
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 1640x1232
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 1280x720
                        Interval: Discrete 0.017s (60.000 fps)