Skip to content

Commit

Permalink
utilityimageformatconverter addapted to handel color images
Browse files Browse the repository at this point in the history
  • Loading branch information
SMA2016a committed Apr 4, 2022
1 parent 2bd0a62 commit 0b432f6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions samples/utilityimageformatconverter.py
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 0b432f6

Please sign in to comment.