Magick++ and YUYV
Posted: 2016-07-28T09:49:53-07:00
Using magick++6.q16-5 on Debian running on ARM7 device. Reading from V4L2 (Video 4 Linux 2) USB camera, the input stream identifies itself as follows:
The size of 614400 seems right, since 640x480x2 (2 bytes per pixel) gives 614400. I'd like to take these 614400 bytes of data and convert them to a Magick::Image object. This is what I've tried:
But this doesn't work. the img.read(blob) line throws a C++ exception:
So hunting around, I see that Magick needs the data in UYVY format instead. I swap every byte around in the buffer to be UYVY, change this line:
...and while this now runs to completion, the images it produces aren't right. Pointing the camera out the window to a bunch of green shrubs and trees produces this:
Anyone have insight into what I'm doing wrong? In case it is relevant, I also ran into a problem including Magick++.h:
Not knowing what to do, I've tried to set -DMAGICKCORE_QUANTUM_DEPTH=8 and to 16 when building my code, but this doesn't seem to change my problem.
Code: Select all
Video input : 0 (Camera 1: ok)
Format Video Capture:
Width/Height : 640/480
Pixel Format : 'YUYV'
Field : None
Bytes per Line: 1280
Size Image : 614400
Colorspace : SRGB
Flags :
Code: Select all
Magick::Blob blob( buffer, buffer_len );
Magick::Image img;
img.size( Magick::Geometry(640, 480) );
img.magick( "YUYV" );
img.read( blob );
img.write( "test.jpg" );
Code: Select all
terminate called after throwing an instance of 'Magick::ErrorMissingDelegate'
what(): Magick: no decode delegate for this image format `YUYV' @ error/blob.c/BlobToImage/361
Code: Select all
img.magick( "UYVY" );
Anyone have insight into what I'm doing wrong? In case it is relevant, I also ran into a problem including Magick++.h:
Code: Select all
/usr/include/ImageMagick-6/magick/magick-config.h:29:3: warning: #warning "you should set MAGICKCORE_QUANTUM_DEPTH to sensible default set it to configure time default" [-Wcpp]
# warning "you should set MAGICKCORE_QUANTUM_DEPTH to sensible default set it to configure time default"