basler / pypylon

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

grabResult.GrabSucceeded()==True rarely #311

Open MCilento93 opened 3 years ago

MCilento93 commented 3 years ago

Type of Issues

Enhancement/Error

Operating System

Windows 64

Python version

3.7.9

pypylon version

1.5.4

Basler camera

acA1300-30g

Description of Problem / Question / Details

My target is to grab a single photo when a button is pressed in a GUI. The method triggered now is the one reported below:

import numpy as np
NULL_ARRAY=np.ndarray(shape=(0,0))

def grab_basler_photo():
    array=NULL_ARRAY
    try:
        from pypylon import pylon
        camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice())
        camera.Open()
        numberOfImagesToGrab = 100
        camera.StartGrabbingMax(numberOfImagesToGrab)
        while camera.IsGrabbing():
            grabResult = camera.RetrieveResult(5000, pylon.TimeoutHandling_ThrowException)
            if grabResult.GrabSucceeded():
                array = grabResult.Array
                camera.Close()
                return array
            else:
                pass
            grabResult.Release()
        camera.Close()
    except Exception as Err:
        array=NULL_ARRAY
        logger.error('errors with pypylon\n'+Err)
    return array

As you can see, I simply want to retreive the numpy array from camera as soon as the capture is successfull (no pixels above bit depth and capture without errors/common black stripes). I want implement the fastest way to do this simple one-shot grab.

Actually it happens that often numberOfImagesToGrab = 100 is not sufficient i.e. grabResult.GrabSucceeded() is False for the most of the times... Increase the buffer rises too much computational times. On Pylon software suite the snapping process by button is quite perfect, I see promptly and always a good photo.

Thank you for everybody willing to help, and have nice Xmas holidays.

thiesmoeller commented 3 years ago

Hi @MCilento93 , grabbing must succeed every time with correct settings!

What you describe ( black stripes ) results from wrong bandwidth configuration. Please read the chapter on network parameters: https://docs.baslerweb.com/network-related-parameters-(gige-cameras) You can verify correct settings in the pylon viewer with the bandwidth manager: https://docs.baslerweb.com/bandwidth-manager#optimizing-bandwidth-consumption

Bandwidth manager will show you most issues, that might exists in your setup.

MCilento93 commented 3 years ago

Hi @MCilento93 , grabbing must succeed every time with correct settings!

What you describe ( black stripes ) results from wrong bandwidth configuration. Please read the chapter on network parameters: https://docs.baslerweb.com/network-related-parameters-(gige-cameras) You can verify correct settings in the pylon viewer with the bandwidth manager: https://docs.baslerweb.com/bandwidth-manager#optimizing-bandwidth-consumption

Bandwidth manager will show you most issues, that might exists in your setup.

Thank you for the answer, I will give a look as soon as I can.

On pylon viewer I did not checked the bandwitch tool, even though in there for single shots and continuous capture didn't give any errors.

nchauhan5 commented 3 years ago

@thiesmoeller - I have the correct settings as checked from the bandwidth manager. I have the Basler aca4600-7gc Ace GigE Camera. I have the same problem. The statement - if grabResult.GrabSucceeded() is false more often than not. Like 95% of the time. This Camera at my current settings is giving out 2 frames per second as seen in the pylon viewer, but I am getting like 1 frame every 10 seconds or something.

MCilento93 commented 3 years ago

@thiesmoeller - I have the correct settings as checked from the bandwidth manager. I have the Basler aca4600-7gc Ace GigE Camera. I have the same problem. The statement - if grabResult.GrabSucceeded() is false more often than not. Like 95% of the time. This Camera at my current settings is giving out 2 frames per second as seen in the pylon viewer, but I am getting like 1 frame every 10 seconds or something.

Are you trying my code above? I had at the time many troubles with ethernet ports and cables... With right settings if worked

nchauhan5 commented 3 years ago

@MCilento93 - I got this to work just now. Make sure you add the statement "camera.Open()" before calling "camera.StartGrabbing". I was able to get more frames then before at the frame rate that my camera supports at the settings that I have. Try it now. Seems you are still actively looking for an answer on this @MCilento93