blackjack/webcam

UYVY format support

youssefoumate opened this issue · 1 comments

Hello,
I want to modify the http_mjpeg_streamer so it can support also the UYVY format.
How can I change the following code to do that:

switch format {
case V4L2_PIX_FMT_YUYV:
	yuyv := image.NewYCbCr(image.Rect(0, 0, int(w), int(h)), image.YCbCrSubsampleRatio422)
	for i := range yuyv.Cb {
		ii := i * 4
		yuyv.Y[i*2] = frame[ii]
		yuyv.Y[i*2+1] = frame[ii+2]
		yuyv.Cb[i] = frame[ii+1]
		yuyv.Cr[i] = frame[ii+3]
	}
	img = yuyv

Thank you,

I added V4L2_PIX_FMT_UYVY (0x59565955) case and it works:

switch format {
case V4L2_PIX_FMT_UYVY:
	uyvy := image.NewYCbCr(image.Rect(0, 0, int(w), int(h)), image.YCbCrSubsampleRatio422)
	for i := range uyvy.Cb {
		ii := i * 4
		uyvy.Y[i*2] = frame[ii+1]
		uyvy.Y[i*2+1] = frame[ii+3]
		uyvy.Cb[i] = frame[ii]
		uyvy.Cr[i] = frame[ii+2]
	}
	img = uyvy