mabl / PyPylon

An experimental python wrapper around the Basler Pylon 5 library
BSD 3-Clause "New" or "Revised" License
53 stars 34 forks source link

Cannot read image from generator #9

Open rragundez opened 8 years ago

rragundez commented 8 years ago
>>> 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

mabl commented 8 years ago

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?

rragundez commented 8 years ago

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

mabl commented 8 years ago

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

rragundez commented 8 years ago

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

mabl commented 8 years ago

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.

rragundez commented 8 years ago

great, thanks a lot

rragundez commented 8 years ago

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

mabl commented 8 years ago

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

rragundez commented 8 years ago

@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?

mabl commented 8 years ago

Have you changed the Camera property to Color?

rragundez commented 8 years ago

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

mabl commented 8 years ago

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.

rragundez commented 8 years ago

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

mabl commented 8 years ago

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

rragundez commented 8 years ago

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

mabl commented 8 years ago

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

rragundez commented 8 years ago

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

ghost commented 8 years ago

@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

SubinGeorge commented 6 years ago

@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
vascotenner commented 6 years ago

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