Accessing external Basler Camera in Visual Studio

49 views Asked by At

I am currently trying to access a Basler camera, that is connected to my computer via Ethernet, from Visual Studio. The camera is not displayed in the device manager, but I can ping it in the command prompt so I guess it is connected. The general idea is to scan a surface and get a live picture.

This is the code snippet:

import cv2
import numpy as np

cap = cv2.VideoCapture('http://172.20.1.40:80/?stream')

But as soon as I execute the program, I get the error that it is unable to open the camera. If i do "cv2.VideoCapture(0) or (1), it also does not work.

Does anyone have an idea what the problem might be?

Many thanks and regards

1

There are 1 answers

0
Marcin Kowalski On

I presume that you use an industrial series of Basler camera (ace / ace 2 etc.). These models are not IP cameras and do not produce RSTP stream. They rely on GigE Vision protocol.

In order to connect them to your python app:

  1. download and install pylon SDK,
  2. make sure that camera is running smoothly in Basler pylon Viewer
  3. in your python project, install pypylon,
pip3 install pypylon
  1. use pypython/samples/opencv.py as your starting sample project.

For full picture of your situation, please paste a model of camera.

Hope it helps.