CSI-Camera icon indicating copy to clipboard operation
CSI-Camera copied to clipboard

Can't use it twice if it crashes

Open xrstokes opened this issue 3 years ago • 1 comments

Hi, I'm trying to use the code with some other features. When my code crashes though. I have to reboot my nano before i can use the camera again. Here is what i'm using. Thanks in advance.

def gstreamer_pipeline(
    capture_width=1920,
    capture_height=1080,
    display_width=960,
    display_height=540,
    framerate=30,
    flip_method=0,
    ):
    return (
        "nvarguscamerasrc exposurecompensation=-2 ! "
        "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,
        )
    )

cap = cv2.VideoCapture(gstreamer_pipeline(flip_method=0), cv2.CAP_GSTREAMER)

while True:
    ret_val, img = cap.read()
    print(ret_val)
    if ret_val:
        send_img(img)
        break
    else:
        break
        
cap.release()

xrstokes avatar May 20 '21 05:05 xrstokes

me too

CodeColdCook avatar Nov 25 '21 07:11 CodeColdCook