Sign inSign up

chameleoncloud/jetson-camera

By chameleoncloud

•Updated about 5 years ago

Image for Chameleon Jetson Nano with Raspberry Pi Camera.

Image
0

55

chameleoncloud/jetson-camera repository overview

OpenStack command to launch a container with the image:

openstack appcontainer create --name <container name> --security-group <security group (allow http/https and open port 8888)> --hint reservation=<reservation id> --net network=<containernet1> --device-profile jetson_csi_camera --runtime nvidia --interactive zhenz/nano-camera:r32.5.0-py3
JupyterLab url: http://<floating ip>:8888

JupyterLab password: nvidia

Sample Python code to read from the camera:

import cv2

MAX_FRAMES = 10

def 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)
    frame_cnt = 0
    while cap.isOpened() and frame_cnt < MAX_FRAMES:
        ret, frame = cap.read()
        if ret:
          print("frame captured!")
          frame_cnt = frame_cnt + 1
          if cv2.waitKey(1) & 0xFF == ord('q'):
            break
        else:
          break
    # Release everything if job is finished
    cap.release()

show_camera()

Tag summary

Content type

Image

Digest

Size

1.4 GB

Last updated

about 5 years ago

docker pull chameleoncloud/jetson-camera:r32.5.0-py3