Skip to content

Commit

Permalink
Merge pull request #487 from SMA2016a/samplecode
Browse files Browse the repository at this point in the history
 utilityimageformatconverter adapted to handle color images
  • Loading branch information
thiesmoeller authored and Stefan Klug committed Nov 24, 2022
2 parents e235871 + b3a71d5 commit 2a02097
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions samples/utilityimageformatconverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def show_image(image, message):
try:
# Create the converter and set parameters.
converter = pylon.ImageFormatConverter()
converter.OutputPixelFormat = pylon.PixelType_Mono8
converter.OutputPixelFormat = pylon.PixelType_RGB8packed
converter.OutputBitAlignment = pylon.OutputBitAlignment_MsbAligned

# Try to get a grab result for demonstration purposes.
print("Waiting for an image to be grabbed.")
Expand All @@ -47,8 +48,10 @@ def show_image(image, message):
else:
# Conversion is needed.
show_image(grabResult, "Grabbed image.")

targetImage=converter.Convert(grabResult)
show_image(targetImage, "Converted image.")
filename = "saved_pypylon_converted.png"
targetImage.Save(pylon.ImageFileFormat_Png, filename)

except genicam.GenericException as e:
print("Could not grab an image: ", e.GetDescription())
Expand Down

0 comments on commit 2a02097

Please sign in to comment.