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

Test on the color image #41

Open felixi1986 opened 6 years ago

felixi1986 commented 6 years ago

Hallo, I have test this cod with my acA2040-90uc Basler.

It works well.

what I have done is:

  1. set assert image_format.startswith('Mono'), 'Only mono images allowed at this point' in factory.pyx as comment.
  2. install with python
  3. change the plot method in the Simple usage example from : import matplotlib.pyplot as plt for image in cam.grab_images(1): plt.imshow(image) plt.show()

    to import cv2 while True: for image in cam.grab_images(1): image = cv2.cvtColor(image, cv2.COLOR_BAYER_BG2RGB) cv2.imshow('Image', image) if cv2.waitKey(300) & 0xFF == 27: break

I have only tried it in Ubuntu 14.04. PixelFormat of the camera is BayerBG8 .

I think, if I want to use BayerBG12, I must change the code by the buffer reading: img_data = np.frombuffer((<char*>img.GetBuffer())[:img.GetImageSize()], dtype='uint'+bits_per_pixel_prop[3:]) in the factory.pyx

BR