How to use the pypylon.genicam.GenericException function in pypylon

To help you get started, we’ve selected a few pypylon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github basler / pypylon / samples / grab.py View on Github external
# Wait for an image and then retrieve it. A timeout of 5000 ms is used.
        grabResult = camera.RetrieveResult(5000, pylon.TimeoutHandling_ThrowException)

        # Image grabbed successfully?
        if grabResult.GrabSucceeded():
            # Access the image data.
            print("SizeX: ", grabResult.Width)
            print("SizeY: ", grabResult.Height)
            img = grabResult.Array
            print("Gray value of first pixel: ", img[0, 0])
        else:
            print("Error: ", grabResult.ErrorCode, grabResult.ErrorDescription)
        grabResult.Release()
    camera.Close()

except genicam.GenericException as e:
    # Error handling.
    print("An exception occurred.")
    print(e.GetDescription())
    exitCode = 1

sys.exit(exitCode)
github basler / pypylon / samples / utilityimageformatconverter.py View on Github external
print(converter.IsSupportedOutputFormat(pylon.PixelType_Mono8))
        # Now we can check if conversion is required.
        if converter.ImageHasDestinationFormat(grabResult):
            # No conversion is needed. It can be skipped for saving processing
            # time.
            show_image(grabResult, "Grabbed image.")

        else:
            # Conversion is needed.
            show_image(grabResult, "Grabbed image.")

            show_image(targetImage, "Converted image.")

    except genicam.GenericException as e:
        print("Could not grab an image: ", e.GetDescription())
except genicam.GenericException as e:
    print("An exception occurred. ", e.GetDescription())
github basler / pypylon / samples / utilityimageformatconverter1.py View on Github external
def grab_image():
    try:
        camera = pylon.InstantCamera(
            pylon.TlFactory.GetInstance().CreateFirstDevice())

        camera.Open()
        result = camera.GrabOne(100)
        camera.Close()
        return result
    except genicam.GenericException as e:
        print("Could not grab an image: ", e.GetDescription())