Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color camera support #24

Open
gmiller-whus opened this issue Nov 16, 2016 · 7 comments
Open

Color camera support #24

gmiller-whus opened this issue Nov 16, 2016 · 7 comments

Comments

@gmiller-whus
Copy link

Any info on when or if support for color cameras will be available? Any info on why it is disabled at this time? Thanks.

@vgundecha
Copy link

Any update on this one? Did you get it working?
Thanks

@gmiller-whus
Copy link
Author

gmiller-whus commented Dec 1, 2016 via email

@AkhilAKrasH
Copy link

Hi!
have you tried your solution? Do you plan to commit your code?

Thx

@gmiller-whus
Copy link
Author

gmiller-whus commented Mar 20, 2017 via email

@Wing0
Copy link

Wing0 commented May 17, 2017

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]

@Terrapon
Copy link

Terrapon commented Jun 12, 2017

@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

@Wing0
Copy link

Wing0 commented Jun 12, 2017

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

Qbicz added a commit to Qbicz/PyPylon that referenced this issue Nov 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants