CaptureDevice icon indicating copy to clipboard operation
CaptureDevice copied to clipboard

how come there's no grayscale data type?

Open makc opened this issue 12 years ago • 6 comments

I mean, byte array with YYYYY.... that would save both some memory and cpu time

makc avatar Nov 23 '12 12:11 makc

well it actually available for android since it is native output. on ios it is not native output of camera stream so it is not available. see sources carefully ;)

inspirit avatar Nov 23 '12 13:11 inspirit

I think the source said it's YCbCr for android, I am asking about all Y-s. Which would be 3x or 4x less memory and probably faster than averaging RGB-s on AS3 side.

makc avatar Nov 23 '12 13:11 makc

besides in C++ you could probably do something like

byte y = (r >> 2) + (g >> 1) + (b >> 2);

and it would be actually faster than multiplication

makc avatar Nov 23 '12 13:11 makc

i don't get what the problem here? YCbCr - just use first WidthxHeight bytes to get grayscale data only for further processing. u still need RGB for rendering to screen. when u converting to grayscale us should care about about actual coefficients since some algorithms like HAAR for example very dependent on grayscale data. real life example: i was using averaged coefficients to grayscale like

y = (77*r + 155*g + 22*b) >> 8;

it results in 30% more search iterations in haar classifiers. when changed it to high precision conversion:

y = r * 4899+ g * 9617+ b * 1868+ 8192) >> 14

i get 30% faster haar with better results!

inspirit avatar Nov 23 '12 13:11 inspirit

YCbCr - just use first WidthxHeight bytes to get grayscale data

you mean there are 3 separate blocks, not triplets?

as for "the problem" - you have one if you want to operate on more than single frame.

faster haar with better results

well sure it is expected since you were training cascades using different formula.

makc avatar Nov 23 '12 14:11 makc

YCbCr means that first width*height bytes is luma values only.

inspirit avatar Nov 23 '12 14:11 inspirit