basler / pypylon

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

Grab timed out. The acquisition is not started. #393

Open rdrandom opened 3 years ago

rdrandom commented 3 years ago

Hello everyone, first of all, sorry for my English. I have a problem when I run this script that I have trouble understanding because I start: (I specify that I am working on a Pylon container and that a nas synology)

from pypylon import pylon
import platform

num_img_to_save = 5
img = pylon.PylonImage()

ip_address = '.....'
factory = pylon.TlFactory.GetInstance()
ptl = factory.CreateTl('BaslerGigE')
empty_camera_info = ptl.CreateDeviceInfo()
empty_camera_info.SetPropertyValue('IpAddress', ip_address)
camera_device = factory.CreateDevice(empty_camera_info)
cam = pylon.InstantCamera(camera_device)

cam.Open()
cam.AcquisitionMode.SetValue('Continuous')
cam.StartGrabbing()
for i in range(num_img_to_save):
    with cam.RetrieveResult(2000) as result:
        img.AttachGrabResultBuffer(result)

        if platform.system() == 'Windows':
            ipo = pylon.ImagePersistenceOptions()
            quality = 90 - i * 10
            ipo.SetQuality(quality)

            filename = "saved_pypylon_img_%d.jpeg" % quality
            img.Save(pylon.ImageFileFormat_Jpeg, filename, ipo)
        else:
            filename = "saved_pypylon_img_%d.png" % i
            img.Save(pylon.ImageFileFormat_Png, filename)
        img.Release()
cam.StopGrabbing()
cam.Close()

I am getting this error:

Traceback (most recent call last): File "./test_sauvegarde.py", line 28, in with cam.RetrieveResult(2000) as result: File "/usr/local/lib/python3.8/dist-packages/pypylon/pylon.py", line 3474, in RetrieveResult return _pylon.InstantCamera_RetrieveResult(self, *args) _genicam.TimeoutException: Grab timed out. The acquisition is not started. : TimeoutException thrown (file 'InstantCameraImpl.h', line 1056)

Thank you in advance for any help you can give me!

sorry for editing my post, but the issue has totally changed / evolved

SMA2016a commented 3 years ago

you may try ip_address = '192.168.0.123' without port number

rdrandom commented 3 years ago

thanks but I tried and nothing has changed, still the same error ...

SMA2016a commented 3 years ago

is camera working fine in pylonviewer or simple grab sample code?

rdrandom commented 3 years ago

hey ! I use pylonviewer and i can have an image yes

SMA2016a commented 3 years ago

try this.

empty_camera_info = pylon.DeviceInfo()

rdrandom commented 3 years ago

if i use this :

ip_address = '*****'
factory = pylon.TlFactory.GetInstance()
ptl = factory.CreateTl('BaslerGigE')
empty_camera_info = pylon.DeviceInfo()
empty_camera_info.SetPropertyValue('IpAddress', ip_address)
camera_device = factory.CreateDevice(empty_camera_info)
cam = pylon.InstantCamera(camera_device)

cam.Open()

cam.StartGrabbing(pylon.GrabStrategy_OneByOne)

i have this error :

Traceback (most recent call last): File "./sauvegarde_image.py", line 24, in camera_device = factory.CreateDevice(empty_camera_info) File "/usr/local/lib/python3.8/dist-packages/pypylon/pylon.py", line 1594, in CreateDevice return _pylon.TlFactory_CreateDevice(self, *args) _genicam.RuntimeException: No device is available or no device contains the provided device info properties. : RuntimeException thrown (file 'TlFactory.cpp', line 694)

thank you very much for taking the time to help me

rdrandom commented 3 years ago

Good morning ! I discovered something! When I run my script on PyCharm on the computer, 0 problem and everything is done correctly if I am connected by wire and not by wifi! If it's wifi: same problem as on the container!

So I tested ... I can connect to the camera with Pylon Viewer but not take pictures or have any image stream if I am in wifi! Only the wired that works.

Is this normal? Are there ways to change this?

SMA2016a commented 3 years ago

now you have 2 cases in one thread. This makes supporting you a bit more complicated.If you discover new issue create a new question.

1) it seems that you are not setting up the proper IP address in the info object.

ip_address = '*****' factory = pylon.TlFactory.GetInstance() ptl = factory.CreateTl('BaslerGigE') empty_camera_info = pylon.DeviceInfo() empty_camera_info.SetPropertyValue('IpAddress', ip_address) camera_device = factory.CreateDevice(empty_camera_info) cam = pylon.InstantCamera(camera_device)

cam.Open()

cam.StartGrabbing(pylon.GrabStrategy_OneByOne)

2) Most properly you waln componant does not perform well.

 Set the packet size in transport layer to 1500 and increase the inter packet delay in small steps.
rdrandom commented 3 years ago

excuse me if it seems to you to be two different problems because I just wanted to explain my progress and I thought that might enlighten you on the problem. (in itself I'm not trying to make it work on pylon viewer!)

1- in fact, i don't understand why there would be a problem with the ip address since, when i'm wired, it doesn't pose a problem and i can recover photos. also, i have this error if i try :

_genicam.RuntimeException: No device is available or no device contains the provided device info properties. : RuntimeException thrown (file 'TlFactory.cpp', line 694)

2- I'm trying to do it more slowly, I'll keep you posted

thank you for helping me and sorry for any questions!