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/color/conversions.h>
33 #include <fvutils/readers/fvraw.h>
34 #include <fvutils/readers/jpeg.h>
35 #include <fvutils/writers/pnm.h>
36 #include <utils/system/argparser.h>
42 using namespace firevision;
45 print_usage(
const char *program_name)
47 printf(
"Usage: %s [-u -c colorspace -w width -h height] <infile> <outfile>\n\n"
48 " -u Unformatted raw, you must supply -c, -w and -h\n"
49 " -c colorspace colorspace string\n"
50 " -w width width of image in pixels\n"
51 " -h height height of image in pixels\n",
56 main(
int argc,
char **argv)
59 if (argp.num_items() != 2) {
60 print_usage(argp.program_name());
61 printf(
"\nInvalid number of files given\n\n");
65 const char *fn_in = argp.items()[0];
66 const char *fn_out = argp.items()[1];
68 char *fn_out_copy = strdup(fn_out);
70 printf(
"Input file: %s\n"
76 char *t = strtok(fn_out_copy,
".");
78 printf(
"invalid filename");
85 t = strtok(NULL,
".");
91 if (argp.has_arg(
"u")) {
92 if (argp.has_arg(
"c") && argp.has_arg(
"w") && argp.has_arg(
"h")) {
93 fl =
new FileLoader(colorspace_by_name(argp.arg(
"c")),
97 printf(
"Input image: %s, %lix%li\n", argp.arg(
"c"), argp.parse_int(
"w"), argp.parse_int(
"h"));
99 printf(
"You have to supply all of -w, -h, -c when using -u.\n");
114 if (0 == strcmp(ext_out,
"raw")) {
115 printf(
"Format for out file %s is FvRaw\n", fn_out);
120 else if (0 == strcmp(ext_out,
"jpeg") || 0 == strcmp(ext_out,
"jpg")) {
121 printf(
"Format for out file %s is Jpeg\n", fn_out);
127 else if (0 == strcmp(ext_out,
"png")) {
128 printf(
"Format for out file %s is PNG\n", fn_out);
133 else if (0 == strcmp(ext_out,
"pnm")) {
134 printf(
"Format for out file %s is PNM\n", fn_out);
137 printf(
"Unknown output file format\n");