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

Allow to specify the pixel format #52

Open
qbonnard opened this issue Jul 24, 2014 · 1 comment
Open

Allow to specify the pixel format #52

qbonnard opened this issue Jul 24, 2014 · 1 comment

Comments

@qbonnard
Copy link
Member

When we don't use opencv's framegrabber (e.g. on android or Qt), we're not very likely to have BGR24 as a pixel format.

Chilitags converts the image to grayscale anyway, and OpenCV allows for more conversions than just the BGR2Gray we're using.

If we can specify the input pixel format, we don't have to convert the image to BGR24 before giving it to Chilitags for a second conversion.

@ayberkozgur
Copy link
Member

I think replacing https://github.com/chili-epfl/chilitags/blob/master/src/EnsureGreyscale.cpp#L29 with

if numchannels == 3
    convert BGR24 to gray
else if numbytes == width*height*3/2
    convert YUV to gray
else
    shallow copy

would cover 99% of cases on desktop and Android, since YUV formats all have Y channel in the first width*height bytes and can be treated equally when converting to grayscale.

If the user really wants to use some obscure color format, then they should convert it to grayscale themselves beforehand, since OpenCV doesn't cover conversion from all formats to all formats and to my knowledge there's no way to know which conversion constant to use given an initial format and a final format without writing a huge switch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants