Cheers Gordon - it's something I've been meaning to look at for a good while.
At line 688 in raspividyuv.c, modify with this:
Code: Select all
if (buffer->length)
{
mmal_buffer_header_mem_lock(buffer);
//write one row number width of greyscale pixels from centre of view
//do we need to round up to strides/multiples of 32/16 on width/height?
bytes_written = fwrite(buffer->data+width*(height>>1), 1, width, pData->file_handle);
mmal_buffer_header_mem_unlock(buffer);
if (bytes_written != width)
{
vcos_log_error("Failed to write buffer data (%d from %d)- aborting", bytes_written, buffer->length);
pData->abort = 1;
}
}
Here, the firmware gives us a buffer in memory with planar YUV 420 data at the requested dimensions. The luminance data for the whole image is first, followed by 2 x chroma blocks. For speed & ease of hacking, we can ignore the colour info & take a slice of grayscale pixels. I took a row from the centre of the image, hence buffer->data+width*(height>>1)
That's all the mods to raspividyuv - I assemble a valid image file afterwards.
Capture some data:
Code: Select all
/opt/vc/bin/raspividyuv -w 320 -h 240 -fps 100 -t 10000 -o ydata.bin
Ideally I'd convert the .bin into at valid image file before exiting within raspividyuv. For testing, I used Mathematica instead:
Code: Select all
imgdat = Import["~/ydata.bin", "Byte"]
height = 320
slices = Length[imgdat]/height
im = Array[0 &, {slices, height}]
Do[im[[i, j]] = imgdat[[(slices - i)*height + j]]/255, {i, slices}, {j, height}]
im2 = Transpose[im]
Export["~/ypic.png", Image[im2]]
If you use the above, place the camera on its side with the ribbon on the right or left as you look at it, and arrange for the motion to be left<->right in front of the camera.