24 #include <fvcams/fileloader.h> 25 #include <fvutils/writers/fvraw.h> 27 # include <fvutils/writers/jpeg.h> 30 # include <fvutils/writers/png.h> 32 #include <fvutils/writers/pnm.h> 34 #include <fvutils/readers/fvraw.h> 35 #include <fvutils/readers/jpeg.h> 37 #include <fvutils/color/conversions.h> 38 #include <utils/system/argparser.h> 47 print_usage(
const char *program_name)
49 printf(
"Usage: %s [-u -c colorspace -w width -h height] <infile> <outfile>\n\n" 50 " -u Unformatted raw, you must supply -c, -w and -h\n" 51 " -c colorspace colorspace string\n" 52 " -w width width of image in pixels\n" 53 " -h height height of image in pixels\n",
59 main(
int argc,
char** argv)
62 if ( argp.num_items() != 2 )
64 print_usage(argp.program_name());
65 printf(
"\nInvalid number of files given\n\n");
69 const char *fn_in = argp.items()[0];
70 const char *fn_out = argp.items()[1];
72 char* fn_out_copy = strdup(fn_out);
74 printf(
"Input file: %s\n" 79 char *t = strtok(fn_out_copy,
".");
82 printf(
"invalid filename");
90 t = strtok(NULL,
".");
96 if ( argp.has_arg(
"u") )
98 if (argp.has_arg(
"c") && argp.has_arg(
"w") && argp.has_arg(
"h"))
100 fl =
new FileLoader(colorspace_by_name(argp.arg(
"c")), fn_in,
101 argp.parse_int(
"w"), argp.parse_int(
"h"));
102 printf(
"Input image: %s, %lix%li\n", argp.arg(
"c"),
103 argp.parse_int(
"w"), argp.parse_int(
"h"));
107 printf(
"You have to supply all of -w, -h, -c when using -u.\n");
124 if ( 0 == strcmp(ext_out,
"raw") )
126 printf(
"Format for out file %s is FvRaw\n", fn_out);
131 else if ( 0 == strcmp(ext_out,
"jpeg") || 0 == strcmp(ext_out,
"jpg") )
133 printf(
"Format for out file %s is Jpeg\n", fn_out);
139 else if ( 0 == strcmp(ext_out,
"png") )
141 printf(
"Format for out file %s is PNG\n", fn_out);
146 else if ( 0 == strcmp(ext_out,
"pnm") )
148 printf(
"Format for out file %s is PNM\n", fn_out);
153 printf(
"Unknown output file format\n");
virtual colorspace_t colorspace()
Colorspace of returned image.
virtual void set_buffer(colorspace_t cspace, unsigned char *buffer)
Set image buffer.
Fawkes library namespace.
Interface to write images.
virtual void write()=0
Write to file.
Parse command line arguments.
virtual unsigned int pixel_height()
Height of image in pixels.
FvRaw Writer implementation.
virtual void open()
Open the camera.
virtual void set_filename(const char *filename)
Set filename.
virtual unsigned char * buffer()
Get access to current image buffer.
virtual unsigned int pixel_width()
Width of image in pixels.
virtual void set_dimensions(unsigned int width, unsigned int height)
Set dimensions of image in pixels.
virtual void start()
Start image transfer from the camera.