How to use the pypylon.pylon.PylonImage.Create 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 / utilityimageformatconverter.py View on Github external
print("Bytes of the image: \n")
    print(pBytes)


try:
    # Create the converter and set parameters.
    converter = pylon.ImageFormatConverter()
    converter.OutputPixelFormat = pylon.PixelType_Mono8

    # Try to get a grab result for demonstration purposes.
    print("Waiting for an image to be grabbed.")
    try:
        camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice())
        grabResult = camera.GrabOne(1000)
        show_image(grabResult, "Grabbed image.")
        targetImage = pylon.PylonImage.Create(pylon.PixelType_Mono8, grabResult.GetWidth(), grabResult.GetHeight());
        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: