pypylon icon indicating copy to clipboard operation
pypylon copied to clipboard

_genicam.InvalidArgumentException: Cannot convert image.

Open varagantis opened this issue 3 years ago • 1 comments

Hello,

I am facing a weird problem where an error mentioning the following, is occurring occasionally: buff = converter.Convert(res) File "/usr/local/lib/python3.10/site-packages/pypylon/pylon.py", line 6866, in Convert return _pylon.ImageFormatConverter_Convert(self, *args) _genicam.InvalidArgumentException: Cannot convert image. The passed source image is invalid. : InvalidArgumentException thrown

I am trying to convert my cameras output (Mono) into BGR format using the following code: def capture(): tlf = py.TlFactory.GetInstance() camera = py.InstantCamera(tlf.CreateFirstDevice()) camera.Open() res = camera.GrabOne(1000) converter = py.ImageFormatConverter() converter.OutputPixelFormat = py.PixelType_BGR8packed converter.OutputBitAlignment = py.OutputBitAlignment_MsbAligned buff = converter.Convert(res) image = buff.GetArray()
camera.Close()
return image

The error mentioned above is not popping up every time I run my program, rather its occurring occasionally for which I am not able to ascertain the reason. Does anyone have any suggestions or know how can I rectify this error.

Thanks in Advance, Srikar

varagantis avatar Aug 16 '22 22:08 varagantis

may be the image buffer is not valid for some reason. Check if the grab result is valid before pass it to image converter

   if result.GrabSucceeded():
       buff = converter.Convert(res)

SMA2016a avatar Aug 17 '22 01:08 SMA2016a