我有原始数据,这是yuv420p帧数据字节。我想使用numpy和scipy将其转换为rgb数据。下面是我的代码:
yuv = np.frombuffer(data, dtype='uint8')
y = yuv[:1920*1080].reshape(1080, 1920)
v = yuv[1920*1080::2].reshape(540, 960)
u = yuv[1920*1080+1::2].reshape(540, 960)
u = ndimage.zoom(u, 2, order=0)
v = ndimage.zoo
为什么ffmpeg中的YUV420转换似乎超出了2x2像素块的范围? # Create a test image.
ffmpeg -f lavfi -i testsrc=duration=1:size=160x120:rate=1 -y original.png
# Create a new image after converting to YUV420 and back to RGB.
ffmpeg -i original.png -pix_fmt yuv420p -f rawvideo - | \
ffmpeg -f rawvideo -pix_fmt yuv420p -s 16
我发现这段代码试图在RGB颜色空间跟踪红色,
// red color detection, turn the detected one into white
if (((red > (0.85 * (green + blue))) && (red > 105))
&& ((red - green > 73)) && (((green < 150)
|| ((green >= 150) && (blue > 140))))) {
// set t