(Cross posted to libjpeg-turbo-users list.)
(Cross发送到libjpeg-turbo-users列表。)
I'm having a problem with libjpeg-turbo.
我对libjpeg-turbo有问题。
The tjCompress2 function requires an RGB or Greyscale image to compress.
tjCompress2函数需要一个RGB或灰度图像进行压缩。
http://libjpeg-turbo.sourceforge.net/ljtdoc.branches_1.3.x/turbojpeg-c/group___turbo_j_p_e_g.html#gaba62b7a98f960839b588579898495cf2
(Sorry, you'll have to paste that link as it breaks markdown.)
(对不起,当链接出现故障时,您必须将其粘贴。)
My webcam (a PS3 EyeToy) has the following characteristics:
我的网络摄像头(PS3 EyeToy)有以下特点:
chris@raspberrypi ~ $ v4l2-ctl --get-fmt-video
Format Video Capture:
Width/Height : 320/240
Pixel Format : 'YUYV'
Field : None
Bytes per Line: 640
Size Image : 153600
Colorspace : SRGB
From http://en.wikipedia.org/wiki/JPEG#Color_space_transformation it looks like YUYV is equivalent to the YCbCr that JPEG needs (though it has half the Cb and Cr data, compared with luminance). Have I understood correctly?
从http://en.wikipedia.org/wiki/JPEG#Color_space_transformation可以看出YUYV与JPEG需要的YCbCr相当(尽管与亮度相比,它有一半的Cb和Cr数据)。我的理解正确吗?
I know how to turn YUYV into RGB, using a matrix, but it seems a waste of scarce CPU cycles and colour accuracy, to perform two colour space changes when none are needed.
我知道如何使用矩阵将YUYV转换为RGB,但在不需要时执行两个颜色空间更改,这似乎是浪费宝贵的CPU周期和颜色精度。
Is there a function which can directly compress a YUYV image into a JPEG?
是否有一个函数可以直接将YUYV图像压缩到JPEG中?
1 个解决方案
#1
2
Since the time the question was asked, a tjCompressFromYUV
function has been implemented in the TurboJPEG API. It takes an image in the YCbCr
or YUV
format and transforms it into a JPEG image.
自从提出问题以来,在TurboJPEG API中实现了tjCompressFromYUV函数。它采用YCbCr或YUV格式的图像并将其转换为JPEG图像。
However, to compress a YUYV
image using the TurboJPEG API you'd still need to transform the YUYV
into a Y-Cb-Cr
pixel format.
然而,要使用TurboJPEG API压缩YUYV图像,您仍然需要将YUYV转换为Y-Cb-Crpixel格式。
There might also be a little chance to use the YUYV
image as YUV
image with a subsampling of 4:2:2
, as this would result in two Y
components per UV
components, but if this source is exact, there are four different possible ways to place the YUVY
components. But to be positive, there is a chance of 1/4 for this to work.
也有可能使用YUYV图像作为YUV图像,子采样率为4:2:2,因为这将导致每个UV组件有两个Y分量,但是如果这个源是准确的,有四种可能的方式放置YUVY组件。但要保持乐观,就有1/4的可能性。
Otherwise you might also transform the image using PNGU or something similar before you transform it to JPEG, as this library is able to "save YCbYCr images in png RGB8 format."
否则,您也可以使用PNGU或类似的方法对图像进行转换,然后将其转换为JPEG,因为这个库能够“以png RGB8格式保存YCbYCr图像”。
#1
2
Since the time the question was asked, a tjCompressFromYUV
function has been implemented in the TurboJPEG API. It takes an image in the YCbCr
or YUV
format and transforms it into a JPEG image.
自从提出问题以来,在TurboJPEG API中实现了tjCompressFromYUV函数。它采用YCbCr或YUV格式的图像并将其转换为JPEG图像。
However, to compress a YUYV
image using the TurboJPEG API you'd still need to transform the YUYV
into a Y-Cb-Cr
pixel format.
然而,要使用TurboJPEG API压缩YUYV图像,您仍然需要将YUYV转换为Y-Cb-Crpixel格式。
There might also be a little chance to use the YUYV
image as YUV
image with a subsampling of 4:2:2
, as this would result in two Y
components per UV
components, but if this source is exact, there are four different possible ways to place the YUVY
components. But to be positive, there is a chance of 1/4 for this to work.
也有可能使用YUYV图像作为YUV图像,子采样率为4:2:2,因为这将导致每个UV组件有两个Y分量,但是如果这个源是准确的,有四种可能的方式放置YUVY组件。但要保持乐观,就有1/4的可能性。
Otherwise you might also transform the image using PNGU or something similar before you transform it to JPEG, as this library is able to "save YCbYCr images in png RGB8 format."
否则,您也可以使用PNGU或类似的方法对图像进行转换,然后将其转换为JPEG,因为这个库能够“以png RGB8格式保存YCbYCr图像”。