Help setting up Basler Camera on YOLOv8 Python Script

I am attempting to use a real time image detection script based on YOLOv8 which has already worked using a Logitech webcam on Jetson Orin NX however my new Basler ace 2 a2A4200-40ucPRO camera seems to be working differently.

I used OpenCV functions which rely on the camera being given a video index as I understand.

import cv2
import pandas as pd
from ultralytics import YOLO
from tracker import*
import paho.mqtt.client as mqtt
import json
cap = cv2.VideoCapture(0)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)

lsusb reads:

Bus 002 Device 011: ID 2676:ba05 Basler AG USB3.1 Hub

but tools like v412-utils or ls -l /dev/video
do not show anything related to Basler or the camera.
cheese also does not recognize any camera.
PylonViewer has no issues aswell.

Is there a smart way to circumvent completely overhauling the script by making the Basler camera recogniseable by the computer?

Platform: Jetson Orin NX J40 Custom board with Jetpack 5.1
Camera: a2A4200-40ucPRO

Please check dmesg to see if the device is enumerated successfully, And it is enumerated as highspeed(USB2) or superspeed(USB3).

If it is enumerated successfully, you should be able to run the command and see information of the camera:

$ v4l2-ctl --list-formats-ext -d /dev/videoX

Sorry for the late reply.

Bash outputs the following aswell as executed with sudo.

cannot open device /dev/videoX, exiting

I suspect Basler Cameras are treated differently as devices and can only be accessed by Pylon…

videoX means video0, video1, etc. It depends on index of the device. Please confirm what the node is and run like $ v4l2-ctl --list-formats-ext -d /dev/video0

The camera itself is not listed as a video device if I am understanding this correctly.

$ v4l2-ctl --list-devices
NVIDIA Tegra Video Input Device (platform:tegra-camrtc-ca):

Cannot open device /dev/video0, exiting.

$ v4l2-ctl --list-formats-ext -d /dev/video(0-6)

did not yield any results. video0 is the same as list devices.

$ lsusb
Bus 002 Device 003: ID 2676:ba05 Basler AG Vision Camera

its definetly recognized but is not listed as a camera?

Your camera is an USB3Vision device.
The default linux drivers will work only for a webcam ( USB Video Class device ).

In python you have two options:

a) use pypylon to control the camera and capture frames. The frames are compatible to numpy and opencv
GitHub - basler/pypylon: The official python wrapper for the pylon Camera Software Suite

b) use the pylon gstreamer source as input for opencv’s VideoCapture
GitHub - basler/gst-plugin-pylon: The official GStreamer plug-in for Basler cameras

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.