basler / pypylon

The official python wrapper for the pylon Camera Software Suite
http://www.baslerweb.com
BSD 3-Clause "New" or "Revised" License
567 stars 207 forks source link

Bandwidth errors on Raspberry Pi #49

Closed jveitchmichaelis closed 5 years ago

jveitchmichaelis commented 6 years ago

I'm running PyPylon on a Pi 3B+. I can capture images using the basic grab.py example, however if I plug another camera in and acquire, I'm no longer able to capture images. For example if I run this script:

import cv2
import time

cap = cv2.VideoCapture(0 + cv2.CAP_V4L2)

_, _ = cap.read()
time.sleep(10)

Even after the other camera has finished capturing (i.e. I wait for the delay), I get:

pi@raspberrypi:~/pypylon/samples $ python3 grab.py
Using device  daA1600-60uc
Error:  3791651083 The image stream is out of sync.
Error:  3791651083 The image stream is out of sync.
Error:  3791651083 The image stream is out of sync.
Error:  3791651083 The image stream is out of sync.
Error:  3791651083 The image stream is out of sync.
Error:  3791651083 The image stream is out of sync.
Error:  3791651083 The image stream is out of sync.
Error:  3791651083 The image stream is out of sync.
Error:  3791651083 The image stream is out of sync.
Error:  3791651083 The image stream is out of sync.

I've also seen payload discarded errors. It's definitely not the same camera, because the Dart doesn't enumerate as a V4L device. Is there some configuration I can change? Could this be due to an undervoltage condition on the Pi or something to that effect?

The script works perfectly well when run on its own.

thiesmoeller commented 6 years ago

Assuming the other camera is an UVC camera, which is using ISO transmission on USB.

ISO has prio on BULK used by the usb3vision protocol.

The errors you see are the final effect of a camera not being able to deliver the video data to the Raspberry Pi

Steps: A) Reduce the ISO bandwidth of the other camera. B) Adust Devicelinkthroughputlimit to the remaining bandwidth ( 480Mbit - ISO bandwidth )

jveitchmichaelis commented 6 years ago

Hi Thies,

Yep it's a UVC camera. I assume that opencv must be reading in a stream continuously, even if you don't call "read". Though it's only a 16-bit VGA camera so it shouldn't be saturating the bandwidth. I don't think there's an obvious way of bandwidth limiting in opencv. It's using the V4L backend so perhaps there's a better capture library to use.

Depending on the latency involved with releasing the uvc camera, I could probably alternate capture between the two.

Thanks!

On Tue, 16 Oct 2018, 18:27 Thies Möller, notifications@github.com wrote:

Assuming the other camera is an UVC camera, which is using ISO transmission on USB.

ISO has prio on BULK used by the usb3vision protocol.

The errors you see are the final effect of a camera not being able to deliver the video data to the Raspberry Pi

Steps: A) Reduce the ISO bandwidth of the other camera. B) Adust Devicelinkthroughputlimit to the remaining bandwidth ( 480Mbit - ISO bandwidth )

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/basler/pypylon/issues/49#issuecomment-430325308, or mute the thread https://github.com/notifications/unsubscribe-auth/ADA2J3EXR01v3_R9fL1VhwEstNrTFaQqks5ulhcCgaJpZM4Xeae2 .

thiesmoeller commented 6 years ago

Hi Josh,

Bandwidth allocation for UVC cameras is done per resolution x pixelformat x framerate.

As long a the device is openened, the bandwidth is allocated. Even without images transmitted. This is how the ISO mode in USB works.

You could try to reduce the framerate of the UVC camera.

Thies

Josh Veitch-Michaelis notifications@github.com schrieb am Di., 16. Okt. 2018, 19:57:

Hi Thies,

Yep it's a UVC camera. I assume that opencv must be reading in a stream continuously, even if you don't call "read". Though it's only a 16-bit VGA camera so it shouldn't be saturating the bandwidth. I don't think there's an obvious way of bandwidth limiting in opencv. It's using the V4L backend so perhaps there's a better capture library to use.

Depending on the latency involved with releasing the uvc camera, I could probably alternate capture between the two.

Thanks!

On Tue, 16 Oct 2018, 18:27 Thies Möller, notifications@github.com wrote:

Assuming the other camera is an UVC camera, which is using ISO transmission on USB.

ISO has prio on BULK used by the usb3vision protocol.

The errors you see are the final effect of a camera not being able to deliver the video data to the Raspberry Pi

Steps: A) Reduce the ISO bandwidth of the other camera. B) Adust Devicelinkthroughputlimit to the remaining bandwidth ( 480Mbit - ISO bandwidth )

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/basler/pypylon/issues/49#issuecomment-430325308, or mute the thread < https://github.com/notifications/unsubscribe-auth/ADA2J3EXR01v3_R9fL1VhwEstNrTFaQqks5ulhcCgaJpZM4Xeae2

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/basler/pypylon/issues/49#issuecomment-430334905, or mute the thread https://github.com/notifications/unsubscribe-auth/AFQsJSweerP0o0NLsT5S_OAGcKg7zxKTks5ulh3tgaJpZM4Xeae2 .

jveitchmichaelis commented 6 years ago

Thanks - that makes a bit more sense. The UVC camera is pulling 60fps, which is around 320mbps. I'll see if I can halve that and run the Dart with what's left over.

Thyagutamizhan commented 5 years ago

hi bro, lemme know how did you install the pypylon package in raspberry pi 3b+?

jveitchmichaelis commented 5 years ago

@Thyagutamizhan just use the arm 32 bit hard float package from here (either the deb file or the tarball).

https://www.baslerweb.com/en/sales-support/downloads/software-downloads/#type=pylonsoftware;version=all;os=linuxarm

The deb installer is easiest sudo dpkg -I pylon*.deb

Then clone this repository and build. You will likely need to build swig from source because the version in apt is out of date.

From my docker file

RUN git clone https://github.com/swig/swig
RUN apt-get install automake bison flex
RUN cd swig && ./autogen.sh && ./configure && make && make install

# Install Basler stuff 
COPY ./pylon_5*armhf.deb ./
RUN dpkg -i pylon_5*armhf.deb
RUN git clone https://github.com/basler/pypylon.git 
RuN cd pypylon && python3 setup.py install && python setup.py install
charlie-plenty commented 5 years ago

@Thyagutamizhan Did you manage to get everything up and running okay from within a Docker container?

jveitchmichaelis commented 5 years ago

@charlie-plenty Late reply, but yes I did in the end. It works quite well, I just limited the Dart bandwidth to 10MB/s which let me capture at full speed from the other camera and also save to an external USB stick.