Get OpenCV to recognize Basler camera

cvfresh report abuse

I have OpenCV and PyPylon successfully installed, but I can't seem to figure out how to get OpenCV to access the camera (Basler USB Pulse) as it would a regular camera (i.e. with cv2.VideoCapture(0)). Is there a simple way to do this?

Thank you!

Comments

Answers

WeepingAngel report abuse

Hi cvfresh,

There is a complete project on this site with a long example of this:

https://imaginghub.com/projects/97-face-detection-on-raspberry-pi/documentation

the essence is though:

import pypylon.pylon as py
icam = py.InstantCamera(py.TlFactory.GetInstance().CreateFirstDevice())

icam.Open()
icam.PixelFormat = "RGB8"

img = icam.GrabOne(4000)

img = img.Array

now you should have a openCV compatible image which can be used (for example)

cv2.cvtColor(img, cv2.COLOR_RGB2BGR)

Ciao!

Comments
Add Answer