23#include <core/exception.h>
24#include <fvcams/bumblebee2.h>
25#include <fvutils/color/conversions.h>
26#include <fvutils/readers/fvraw.h>
27#include <fvutils/writers/jpeg.h>
39using namespace firevision;
47interleave_yuv422planar(
unsigned char *yuv422_first,
48 unsigned char *yuv422_second,
53 unsigned char *y1, *y2, *yo, *u1, *u2, *uo, *v1, *v2, *vo;
54 unsigned int half_width = width / 2;
56 u1 = y1 + width * height;
57 v1 = u1 + (width * height / 2);
59 u2 = y2 + width * height;
60 v2 = u2 + (width * height / 2);
62 uo = yo + width * height * 2;
63 vo = uo + width * height;
65 for (
unsigned int i = 0; i < height; ++i) {
66 memcpy(yo, y1, width);
70 memcpy(yo, y2, width);
74 memcpy(uo, u1, half_width);
78 memcpy(uo, u2, half_width);
82 memcpy(vo, v1, half_width);
86 memcpy(vo, v2, half_width);
113main(
int argc,
char **argv)
116 printf(
"Usage: %s <dir>\n", argv[0]);
120 string dirname = argv[1];
128 if (NULL == (dir = opendir(dirname.c_str()))) {
129 printf(
"Failed to open directory %s\n", dirname.c_str());
133 while (NULL != (dirp = readdir(dir))) {
134 if (NULL != strstr(dirp->d_name,
".raw")) {
135 files.push_back(dirp->d_name);
162 for (list<string>::iterator f = files.begin(); f != files.end(); ++f) {
164 printf(
"%4u Converting %s (%s) ",
166 (dirname +
"/" + (*f)).c_str(),
168 unsigned char *raw16 =
170 unsigned char *rgb = (
unsigned char *)malloc(
172 unsigned char *deinterlaced =
174 unsigned char *yuv = (
unsigned char *)malloc_buffer(YUV422_PLANAR,
177 unsigned char *yuv_interleaved = (
unsigned char *)malloc_buffer(YUV422_PLANAR,
185 Bumblebee2Camera::deinterlace_stereo(raw16,
189 Bumblebee2Camera::decode_bayer(
207 interleave_yuv422planar(
215 printf(
"to %s\n", (dirname +
"/orig_jpeg/" + (*f)).c_str());
217 jpeg->
set_filename((dirname +
"/orig_jpeg/" + (*f)).c_str());
218 jpeg->
set_buffer(YUV422_PLANAR, yuv_interleaved);
228 free(yuv_interleaved);
Base class for exceptions in Fawkes.
void print_trace() noexcept
Prints trace to stderr.
FvRaw image reader implementation.
virtual void read()
Read data from file.
virtual unsigned int pixel_width()
Get width of read image in pixels.
virtual colorspace_t colorspace()
Get colorspace from the just read image.
virtual void set_buffer(unsigned char *yuv422planar_buffer)
Set buffer that the read image should be written to.
virtual unsigned int pixel_height()
Get height of read image in pixels.
virtual void write()
Write to file.
virtual void set_buffer(colorspace_t cspace, unsigned char *buffer)
Set image buffer.
virtual void set_dimensions(unsigned int width, unsigned int height)
Set dimensions of image in pixels.
virtual void set_filename(const char *filename)
Set filename.
Fawkes library namespace.