Open gmiller-whus opened 7 years ago
Any update on this one? Did you get it working? Thanks
Yes, I did get it working. I am now able to capture an image from a color camera using the “RGB8” format. I need more testing before I branch/merge the code.
Gasry
From: Vineet Gundecha [mailto:notifications@github.com] Sent: Wednesday, November 30, 2016 9:14 AM To: mabl/PyPylon Cc: Gary Miller; Author Subject: Re: [mabl/PyPylon] Color camera support (#24)
Any update on this one? Did you get it working? Thanks
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/mabl/PyPylon/issues/24#issuecomment-263934023, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AWa4HhRwO7cTsV9rOlhxQncqTBHRRcWKks5rDa7pgaJpZM4K0bSs.
Confidentiality: The contents of this e-mail and any attachments transmitted with it are intended to be confidential to the intended recipient; and may be privileged or otherwise protected from disclosure. If you are not an intended recipient of this e-mail, do not duplicate or redistribute it by any means. Please delete it and any attachments and notify the sender that you have received it in error. This e-mail is sent by a William Hill PLC group company. The William Hill group companies include, among others, William Hill PLC (registered number 4212563), William Hill Organization Limited (registered number 278208), William Hill US HoldCo Inc, William Hill Australia Holdings Pty Limited (registered number ACN 161 652 955) and WHG (International) Limited (registered number 99191). Each of William Hill PLC, William Hill Organization Limited is registered in England and Wales and has its registered office at Greenside House, 50 Station Road, Wood Green, London N22 7TP. William Hill U.S. HoldCo, Inc. is 160 Greentree Drive, Suite 101, Dover 19904, Kent, Delaware, United States of America. William Hill Australia Holdings Pty Limited is registered in Australia and has its registered office at Level 30, 2 Park Street, Sydney, NSW 2000, Australia. WHG (International) Limited is registered in Gibraltar and has its registered office at 6/1 Waterport Place, Gibraltar. Unless specifically indicated otherwise, the contents of this e-mail are subject to contract; and are not an official statement, and do not necessarily represent the views, of William Hill PLC, its subsidiaries or affiliated companies. Please note that neither William Hill PLC, nor its subsidiaries and affiliated companies can accept any responsibility for any viruses contained within this e-mail and it is your responsibility to scan any emails and their attachments. William Hill PLC, its subsidiaries and affiliated companies may monitor e-mail traffic data and also the content of e-mails for effective operation of the e-mail system, or for security, purposes.
Hi! have you tried your solution? Do you plan to commit your code?
Thx
Hi,
Yes, I have tries my solution and it works great with a color camera. I do not have a B&W camera to confirm that it still works properly that way.
I do intent to commit my code in the next few days.
Thx.
From: akhila [mailto:notifications@github.com] Sent: Monday, March 20, 2017 5:17 AM To: mabl/PyPylon PyPylon@noreply.github.com Cc: Gary Miller GMiller@williamhill.us; Author author@noreply.github.com Subject: Re: [mabl/PyPylon] Color camera support (#24)
Hi! have you tried your solution? Do you plan to commit your code?
Thx
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/mabl/PyPylon/issues/24#issuecomment-287743021, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AWa4HrvUMH8c97PpqzlrMbQw5q5ODbiaks5rnm4kgaJpZM4K0bSs.
Confidentiality: The contents of this e-mail and any attachments transmitted with it are intended to be confidential to the intended recipient; and may be privileged or otherwise protected from disclosure. If you are not an intended recipient of this e-mail, do not duplicate or redistribute it by any means. Please delete it and any attachments and notify the sender that you have received it in error. This e-mail is sent by a William Hill PLC group company. The William Hill group companies include, among others, William Hill PLC (registered number 4212563), William Hill Organization Limited (registered number 278208), William Hill US HoldCo Inc, William Hill Australia Holdings Pty Limited (registered number ACN 161 652 955) and WHG (International) Limited (registered number 99191). Each of William Hill PLC, William Hill Organization Limited is registered in England and Wales and has its registered office at Greenside House, 50 Station Road, Wood Green, London N22 7TP. William Hill U.S. HoldCo, Inc. is 160 Greentree Drive, Suite 101, Dover 19904, Kent, Delaware, United States of America. William Hill Australia Holdings Pty Limited is registered in Australia and has its registered office at Level 30, 2 Park Street, Sydney, NSW 2000, Australia. WHG (International) Limited is registered in Gibraltar and has its registered office at 6/1 Waterport Place, Gibraltar. Unless specifically indicated otherwise, the contents of this e-mail are subject to contract; and are not an official statement, and do not necessarily represent the views, of William Hill PLC, its subsidiaries or affiliated companies. Please note that neither William Hill PLC, nor its subsidiaries and affiliated companies can accept any responsibility for any viruses contained within this e-mail and it is your responsibility to scan any emails and their attachments. William Hill PLC, its subsidiaries and affiliated companies may monitor e-mail traffic data and also the content of e-mails for effective operation of the e-mail system, or for security, purposes.
For those who run into this issue while the support for color cameras is not there yet, here's a quick fix:
Comment lines 224 and 225 on PyPylon/cython/factory.pyx
Change line 251 to: img_data = np.frombuffer((<char*>img.GetBuffer())[:img.GetImageSize()], dtype='uint8')#+bits_per_pixel_prop[3:])
install pypylon with python setup.py install
This results in the different color channels being repeated in a single one channel image. The snippet below takes the picture and returns the image in BGR colors which can be directly worked on with OpenCV.
cam = pypylon.factory.create_device(devices[0])
cam.open()
cam.properties['PixelFormat'] = 'RGB8'
images = cam.grab_images(1)
img = [o for o in images][0]
out = np.zeros((img.shape[0], img.shape[1] / 3, 3), dtype=np.uint8)
for j in range(img.shape[1]):
c = int(j / 3)
out[:, c, 2 - (j % 3)] = img[:, j]
@Wing0
I have an issue with your solution. the code return an error
out = np.zeros((img.shape[0], img.shape[1] / 3, 3), dtype=np.uint8) TypeError: 'float' object cannot be interpreted as an integer
seems like I have to cast "img.shape[1] / 3" to int. otherwise Python stores it as a float and now it's working
As @Wing0 says in the next comment, I'm using python 3.6
@Terrapon Thanks for pointing this out! You're probably using python 3.x whereas I have python 2.7.13 and division always returns an integer. Other than that, I hope it's working out for you.
Any info on when or if support for color cameras will be available? Any info on why it is disabled at this time? Thanks.