Open qbonnard opened 10 years ago
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.
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.