PyPylon icon indicating copy to clipboard operation
PyPylon copied to clipboard

Cannot read image from generator

Open rragundez opened this issue 9 years ago • 20 comments

>>> import pypylon
>>> pypylon.pylon_version.version
'5.0.1.build_6388'
>>> available_cameras = pypylon.factory.find_devices()
GetDeviceDiscoveryInfo: bFunctionClass = 14, bFunctionSubClass = 3, bFunctionProtocol = 0. Device is not an U3V device.
>>> available_cameras
[<DeviceInfo Basler acA1920-25gc (21815208)>]
>>> cam = pypylon.factory.create_device(available_cameras[0])
>>> cam.opened
False
>>> cam.open()
>>> import matplotlib.pyplot as plt
>>> for image in cam.grab_images(1):
...     print type(image)
... 
terminate called after throwing an instance of 'GenICam_3_0_Basler_pylon_v5_0::TimeoutException'
Aborted (core dumped)

I'm using Python2, also all the Key mentioned in the README file return a KeyError

rragundez avatar Apr 20 '16 10:04 rragundez

Hi @ragundez,

I see you are using an Ethernet camera. I've never tested the code myself against it, though I have a report where someone told me it works. Can you connect to the camera via Pylon viewer? If no, is the camera on the same network and pingable?

mabl avatar Apr 20 '16 19:04 mabl

I don't have the camera now, but it is pingable and I can use the Pylon software and see the video/images.

rragundez avatar Apr 20 '16 19:04 rragundez

While it should not matter, you are under Linux, right?

mabl avatar Apr 21 '16 05:04 mabl

yes, is there a terminal output that it would be helpful to see?

rragundez avatar Apr 21 '16 05:04 rragundez

No, at the moment I'm not even sure on how to approach this problem. I'll probably add some debug outputs and ask you to run it.

mabl avatar Apr 21 '16 06:04 mabl

great, thanks a lot

rragundez avatar Apr 21 '16 07:04 rragundez

Hi @mabl I fixed it, I actually cannot point out how. But know I can only read mono images, any idea why?

rragundez avatar May 01 '16 13:05 rragundez

Because I have not implemented colour cameras yet, I have only one mono camera. Give me one one and I'll implement it :-)

If you are okay having a basic buffer without structure returned, I could to that, too. But somehow I'd love to return proper numpy arrays.

If you like, you can also try your hand implementing a proper scheme here: https://github.com/mabl/PyPylon/blob/master/cython/factory.pyx#L242

mabl avatar May 01 '16 13:05 mabl

@mabl Sound like it should be easy but the GetBuffer just return one channel. There is no difference between img.GetBuffer()[:img.GetImageSize()] and img.GetBuffer() i think the initial change should be elsewhere. What do you think?

rragundez avatar May 01 '16 14:05 rragundez

Have you changed the Camera property to Color?

mabl avatar May 01 '16 15:05 mabl

no, where do i do this and what do I have to put? I think you mean intest of Mono12 in PixelFormat or not? thanks

rragundez avatar May 01 '16 15:05 rragundez

Since I do not own a color Camera I cannot help you much. Have a look at the available entries in cam.properties and into the camera documentation. It should be somewhere.

mabl avatar May 01 '16 15:05 mabl

I tried, I set the PixelFormat to YUV422Packed and other options but no success.

rragundez avatar May 01 '16 17:05 rragundez

Packed is probably tricky to get right. What does no success mean?

mabl avatar May 01 '16 19:05 mabl

still returns mono, one channel. Of course I had to remove the assert

rragundez avatar May 01 '16 19:05 rragundez

Then I'm out of my depths.... Sorry...

mabl avatar May 01 '16 19:05 mabl

no problem, thanks a lot for your time. If I figure it later I will let you know.

rragundez avatar May 01 '16 19:05 rragundez

@mabl at the end I made my own wrapper, but just for capturing the image. You can find it in my other repository if you are interested https://github.com/rragundez/pybasler.git

ghost avatar May 05 '16 14:05 ghost

@mabl, I am using acA 1920-48gc gigE color camera and i am getting following error on sample code. please help me to sort out.

for image in cam.grab_images(1): print type(image)


AssertionError Traceback (most recent call last) in () ----> 1 for image in cam.grab_images(1): 2 print type(image) 3

D:\my_experiments\basler\PyPylon-master\cython\factory.pyx in grab_images() 222 cdef str bits_per_pixel_prop = str(self.properties['PixelSize']) 223 assert bits_per_pixel_prop.startswith('Bpp'), 'PixelSize property should start with "Bpp"' --> 224 assert image_format.startswith('Mono'), 'Only mono images allowed at this point' 225 assert not image_format.endswith('p'), 'Packed data not supported at this point' 226

AssertionError: Only mono images allowed at this point

SubinGeorge avatar Jan 13 '18 19:01 SubinGeorge

@SubinGeorge: The current implementation only supports monochromatic cameras. Please be welcome to contribute code to get color cameras also supported.

vascotenner avatar Jan 15 '18 12:01 vascotenner