Code: Select all
v4l2-ctl -d /dev/video0 -i 0 -s NTSC --set-fmt-video=width=720,height=480,pixelformat=0
v4l2-ctl --device /dev/video0 --stream-mmap --stream-to=frame.raw --stream-count=1
Code: Select all
import Image
import sys
image_name = sys.argv[1]
width = int(sys.argv[2])
height = int(sys.argv[3])
f_yuyv = open(image_name, "rb")
image_out = Image.new("RGB", (width, height))
pix = image_out.load()
print "width=", width, "height=", height
for i in range(0,height):
for j in range(0, width/2):
y1 = ord(f_yuyv.read(1));
u = ord(f_yuyv.read(1));
y2 = ord(f_yuyv.read(1));
v = ord(f_yuyv.read(1));
B = 1.164 * (y1-16) + 2.018 * (u - 128)
G = 1.164 * (y1-16) - 0.813 * (v - 128) - 0.391 * (u - 128)
R = 1.164 * (y1-16) + 1.596 * (v - 128)
pix[j*2, i] = int(R), int(G), int(B)
B = 1.164 * (y2-16) + 2.018 * (u - 128)
G = 1.164 * (y2-16) - 0.813 * (v - 128) - 0.391 * (u - 128)
R = 1.164 * (y2-16) + 1.596 * (v - 128)
pix[j*2+1, i] = int(R), int(G), int(B)
image_out.save("out.bmp")
image_out.show()

Anyone who has an idea where's the problem?
Furthermore, here the properties of the video device I am using to capture the raw YUYV 4:2:2 image:
Code: Select all
pi@raspberrypi:~ $ v4l2-ctl --all
Driver Info (not using libv4l2):
Driver name : usbtv
Card type : usbtv
Bus info : usb-3f980000.usb-1.3
Driver version: 4.4.11
Capabilities : 0x85200001
Video Capture
Read/Write
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x05200001
Video Capture
Read/Write
Streaming
Extended Pix Format
Priority: 2
Video input : 0 (Composite: ok)
Video Standard = 0x0000f900
PAL-M/60
NTSC-M/M-JP/443/M-KR
Format Video Capture:
Width/Height : 720/480
Pixel Format : 'YUYV'
Field : Interlaced
Bytes per Line: 1440
Size Image : 691200
Colorspace : Broadcast NTSC/PAL (SMPTE170M/ITU601)
Flags :
Streaming Parameters Video Capture:
Frames per second: 29.970 (30000/1001)
Read buffers : 2
pi@raspberrypi:~ $ v4l2-ctl -d /dev/video0 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: 'YUYV'
Name : YUYV 4:2:2
Daniel.














