Petro O. Bochan
Member
Hello, we are using WCS to transfer frame data to OpenCV, process it there and then return the resulting frame to WCS in order to change pixels colours. The pixels we return are in either BGR or RGB pixel sequence. The generic formula we use is this:
byte by = (byte) (r * .299000 + g * .587000 + b * .114000);
byte bu = (byte) (r * -.168736 + g * -.331264 + b * .500000 + 128);
byte bv = (byte) (r * .500000 + g * -.418688 + b * -.081312 + 128);
frame.writePixel(x, y, new byte[] { by, bu, bv });
This formula works fine for solid colours (e.g. RGB(126, 126, 126)) but generally fails with regular frames coming from a stream. We wonder, if that's the problem of the formula or the way WCS treats some pixel numbers.
Attached is the original image being streamed and also what we get as the result of a BGR pixel sequence when used with the writePixel method.
Thanks,
P
byte by = (byte) (r * .299000 + g * .587000 + b * .114000);
byte bu = (byte) (r * -.168736 + g * -.331264 + b * .500000 + 128);
byte bv = (byte) (r * .500000 + g * -.418688 + b * -.081312 + 128);
frame.writePixel(x, y, new byte[] { by, bu, bv });
This formula works fine for solid colours (e.g. RGB(126, 126, 126)) but generally fails with regular frames coming from a stream. We wonder, if that's the problem of the formula or the way WCS treats some pixel numbers.
Attached is the original image being streamed and also what we get as the result of a BGR pixel sequence when used with the writePixel method.
Thanks,
P
Attachments
-
408.9 KB Views: 105
-
958.6 KB Views: 96