--csi2webcam option is not working for IMX219 Camera

Continuing the discussion from Nanoowl Container doesnt open camera:

Hello NVIDIA Team,

I know that NanoOWL is not supporting CSI Camera but can you support to figure out where is my issue as some engineers make it work ex: @kikoyah .
I’m still getting no camera from the browser …
i Have been used the bellow commands to run NanoOWL :
0-sudo apt update && sudo apt install v4l2loopback-dkms v4l-utils
1-jetson-containers run --csi2webcam --workdir /opt/nanoowl $(autotag nanoowl)
2- pip install --index-url jp6/cu126 index aiohttp
3-python3 tree_demo.py --camera 1 --resolution 640x480 ../../data/owl_image_encoder_patch32.engine

Hi,

The sample read camera with OpenCV cv2.VideoCapture() API.

You will need to update the command for the CSI camera.
Thanks.

1 Like

Hi @AastaLLL ,

** I know you can reject this request due to NVIDIA not support CSI camera for this Project , But you can have look and share your advices
As per chatGpt below is the updated code for tree_demo.py could you please verify below code ..
this code should be run for both CSI or USB WEB camera ..**And if we updated the CSI Camera will work directly from container ? as also face issue during from inside/outside container , Recognition issues .
**

import asyncio
import argparse
from aiohttp import web, WSCloseCode
import logging
import weakref
import cv2
import time
import PIL.Image
import matplotlib.pyplot as plt
from typing import List
from nanoowl.tree import Tree
from nanoowl.tree_predictor import TreePredictor
from nanoowl.tree_drawing import draw_tree_output
from nanoowl.owl_predictor import OwlPredictor

# -------- GStreamer Pipeline for CSI Camera (Jetson) -------- #
def gstreamer_pipeline(sensor_id=0, width=640, height=480, framerate=30, flip_method=0):
    """
    Builds a GStreamer pipeline string to access a CSI camera (e.g. IMX219) on NVIDIA Jetson devices.
    """
    return (
        f"nvarguscamerasrc sensor_id={sensor_id} ! "
        f"video/x-raw(memory:NVMM), width={width}, height={height}, "
        f"format=NV12, framerate={framerate}/1 ! nvvidconv flip-method={flip_method} ! "
        f"video/x-raw, width={width}, height={height}, format=BGRx ! "
        f"videoconvert ! video/x-raw, format=BGR ! appsink"
    )

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("image_encode_engine", type=str)
    parser.add_argument("--image_quality", type=int, default=50)
    parser.add_argument("--port", type=int, default=7860)
    parser.add_argument("--host", type=str, default="0.0.0.0")

    # ✅ Camera type selection: USB or CSI
    parser.add_argument("--camera_type", type=str, default="usb", choices=["usb", "csi"],
                        help="Select camera type: 'usb' uses /dev/video*, 'csi' uses Jetson CSI camera.")
    parser.add_argument("--camera", type=int, default=0,
                        help="Camera index: For USB it is /dev/videoX, for CSI it is sensor_id value.")
    parser.add_argument("--resolution", type=str, default="640x480", help="Resolution in WIDTHxHEIGHT format")
    parser.add_argument("--framerate", type=int, default=30, help="FPS for CSI camera")

    args = parser.parse_args()
    width, height = map(int, args.resolution.split("x"))

    # Initialize the predictor
    predictor = TreePredictor(
        owl_predictor=OwlPredictor(
            image_encoder_engine=args.image_encode_engine
        )
    )

    # Global prompt data (text to detect)
    prompt_data = None

    # Initialize camera depending on selected type
    if args.camera_type == "csi":
        cam_str = gstreamer_pipeline(sensor_id=args.camera, width=width, height=height, framerate=args.framerate)
        camera = cv2.VideoCapture(cam_str, cv2.CCAP_GSTREAMER)
        logging.info(f"Using CSI Camera (sensor_id={args.camera})")
    else:
        camera = cv2.VideoCapture(args.camera)
        camera.set(cv2.CAP_PROP_FRAME_WIDTH, width)
        camera.set(cv2.CAP_PROP_FRAME_HEIGHT, height)
        logging.info(f"Using USB Camera (/dev/video{args.camera})")

✔ How to Run It

🔹 USB Camera (default /dev/video0):

python3 app.py vit_base_patch16_224 --camera_type usb --camera 0 --resolution 1280x720

🔹 CSI Camera (Jetson IMX219):

python3 app.py vit_base_patch16_224 --camera_type csi --camera 0 --resolution 1280x720 --framerate 30

Hi @AastaLLL ,

I purchased USB webcam in order to see if the NanoOWL for my jeston orin nano super dev the image is frezzing do you know why ?

Hi,

Are you able to read frames with OpenCV cv2.VideoCapture() API?
If so, the same pipeline should also work in the nanoowl example.

Thanks.

1 Like

Hi @AastaLLL ,

Thank you for reply, the project working successfully and I’m happy finally that i did it but it’s take a lots of time and dedications however the issue has been fixed in the next day i come to office and tried again and result is fine.
But I’m wondering why when run the project the temperature of device increased and receiving pop up messages notifications about throttling… . what i did is to disable notification ..

please share with me how can run the project without to reach high temp(61 cellecius degree)
also i want to start to doing reverse engineer in order to understand the source code and Deep Learning Algorithms which has been used in Nano OWL can you please guiding me ?

Hi,

You can set the device to lower power mode.

$ sudo nvpmode -m 1

Or you can turn off the throttling message directly:

Thanks.