23 #include <fvcams/bumblebee2.h> 24 #include <fvutils/writers/jpeg.h> 25 #include <fvutils/readers/fvraw.h> 26 #include <fvutils/color/conversions.h> 33 #include <sys/types.h> 46 interleave_yuv422planar(
unsigned char *yuv422_first,
unsigned char *yuv422_second,
48 unsigned int width,
unsigned int height)
50 unsigned char *y1, *y2, *yo, *u1, *u2, *uo, *v1, *v2, *vo;
51 unsigned int half_width = width / 2;
53 u1 = y1 + width * height;
54 v1 = u1 + (width * height / 2);
56 u2 = y2 + width * height;
57 v2 = u2 + (width * height / 2);
59 uo = yo + width * height * 2;
60 vo = uo + width * height;
62 for (
unsigned int i = 0; i < height; ++i) {
64 memcpy(yo, y1, width);
68 memcpy(yo, y2, width);
72 memcpy(uo, u1, half_width);
76 memcpy(uo, u2, half_width);
80 memcpy(vo, v1, half_width);
84 memcpy(vo, v2, half_width);
111 main(
int argc,
char **argv)
115 printf(
"Usage: %s <dir>\n", argv[0]);
119 string dirname = argv[1];
127 if ( NULL == (dir = opendir(dirname.c_str())) ) {
128 printf(
"Failed to open directory %s\n", dirname.c_str());
132 while ( NULL != (dirp = readdir(dir)) ) {
133 if ( NULL != strstr(dirp->d_name,
".raw") ) {
134 files.push_back(dirp->d_name);
161 for (list<string>::iterator f = files.begin(); f != files.end(); ++f) {
163 printf(
"%4u Converting %s (%s) ", ++in, (dirname +
"/" + (*f)).c_str(), colorspace_to_string(fvraw->
colorspace()));
165 unsigned char *rgb = (
unsigned char *)malloc(colorspace_buffer_size(RGB, fvraw->
pixel_width(), fvraw->
pixel_height()) * 2);
167 unsigned char *yuv = (
unsigned char *)malloc_buffer(YUV422_PLANAR, fvraw->
pixel_width(), fvraw->
pixel_height() * 2);
168 unsigned char *yuv_interleaved = (
unsigned char *)malloc_buffer(YUV422_PLANAR, fvraw->
pixel_width(), fvraw->
pixel_height() * 2);
174 Bumblebee2Camera::deinterlace_stereo(raw16, deinterlaced,
176 Bumblebee2Camera::decode_bayer(deinterlaced, rgb,
185 convert(RGB, YUV422_PLANAR,
190 convert(RGB, YUV422_PLANAR,
195 interleave_yuv422planar(yuv + colorspace_buffer_size(YUV422_PLANAR, fvraw->
pixel_width(), fvraw->
pixel_height()),
199 printf(
"to %s\n", (dirname +
"/orig_jpeg/" + (*f)).c_str());
201 jpeg->
set_filename((dirname +
"/orig_jpeg/" + (*f)).c_str());
202 jpeg->
set_buffer(YUV422_PLANAR, yuv_interleaved);
212 free(yuv_interleaved);
virtual void set_buffer(colorspace_t cspace, unsigned char *buffer)
Set image buffer.
virtual void set_buffer(unsigned char *yuv422planar_buffer)
Set buffer that the read image should be written to.
Fawkes library namespace.
virtual void read()
Read data from file.
virtual void write()
Write to file.
Base class for exceptions in Fawkes.
virtual void set_filename(const char *filename)
Set filename.
virtual unsigned int pixel_width()
Get width of read image in pixels.
void print_trace()
Prints trace to stderr.
virtual colorspace_t colorspace()
Get colorspace from the just read image.
virtual unsigned int pixel_height()
Get height of read image in pixels.
virtual void set_dimensions(unsigned int width, unsigned int height)
Set dimensions of image in pixels.
FvRaw image reader implementation.