basler / pypylon

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

Low Frame Rate #284

Open evangstav opened 4 years ago

evangstav commented 4 years ago

I am using model acA2040-55um, with the pypylon SDK and I can't grab images with more than 1 FPS. Ideally I want to wait for an event and then grab an image, do some processing on it. If I set the timeout lower than 2000 miliseconds I get this timeout: TimeoutException thrown (file 'instantcameraimpl.h', line 1389) Is it possible to grab images faster??

    camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice())
    camera.Open()
    camera.MaxNumBuffer = 10
    numberOfImagesToGrab = 1000
    count = 0
    while True:

        result = camera.GrabOne(2000)

    camera.Close()
thiesmoeller commented 4 years ago

Of course you can grab faster ;-) GrabOne is the slowest way to grab images because you are setting up the full grab engine everytime. The projects readme shows the normal/faster way to grab.

But from what you describe your issue is somewhere else

As a first question where in your code is the 'wait for event'? Or do you refer with 'event' to a hardware trigger?

evangstav commented 4 years ago

Thanks for the answer :) Using the normal way to grab from the readme I could grab on average 1.2 frames per second.
I am planning to run this on a jetson nano. What I want to do is wait for a signal on the gpIO and the grab some frames. What would a better approach ?


import time

camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice())
camera.Open()

# demonstrate some feature access
new_width = camera.Width.GetValue() - camera.Width.GetInc()
if new_width >= camera.Width.GetMin():
    camera.Width.SetValue(new_width)

camera.StartGrabbing()

while camera.IsGrabbing():
    tic = time.time()
    grabResult = camera.RetrieveResult(3000, pylon.TimeoutHandling_ThrowException)

    if grabResult.GrabSucceeded():
        # Access the image data.
        print(1 / (time.time() - tic))
        print("SizeX: ", grabResult.Width)
        print("SizeY: ", grabResult.Height)
        # img = grabResult.Array
        # print("Gray value of first pixel: ", img[0, 0])

    grabResult.Release()
camera.Close() ```
sgn87 commented 4 years ago

I had problem with low FPS which I was able to resolve it. Attaching the issue reference for sample code. Hope this helps

287