Go to the documentation of this file.00001
00002
00003 #include <stdlib.h>
00004 #include <assert.h>
00005 #include <sys/time.h>
00006
00007 #include "CV.hpp"
00008 #include "File.hpp"
00009 #include "Fiducials.hpp"
00010 #include "Map.hpp"
00011 #include "String.hpp"
00012
00019
00020 int main(int arguments_size, char *arguments[]) {
00021 struct timeval start_time_value_struct;
00022 struct timeval end_time_value_struct;
00023 struct timeval difference_time_value_struct;
00024 Time_Value start_time_value = &start_time_value_struct;
00025 Time_Value end_time_value = &end_time_value_struct;
00026 Time_Value difference_time_value = &difference_time_value_struct;
00027
00028 assert (gettimeofday(start_time_value, (struct timezone *)0) == 0);
00029
00030 bool image_log = (bool)0;
00031 std::vector<String> image_file_names;
00032 String lens_calibrate_file_name = (String)0;
00033 String log_file_name = (String)0;
00034
00035 if (arguments_size <= 1) {
00036 File__format(stderr, "Usage: Demo lens.txt *.pnm\n");
00037 } else {
00038 for (unsigned int index = 1; index < arguments_size; index++) {
00039 String argument = arguments[index];
00040 unsigned int size = String__size(argument);
00041 if (String__equal(argument, "--image_log")) {
00042 image_log = (bool)1;
00043 } else if (size > 4 && String__equal(argument + size - 4, ".txt")) {
00044 lens_calibrate_file_name = argument;
00045 } else if (size > 4 && String__equal(argument + size - 4, ".log")) {
00046 log_file_name = argument;
00047 } else if (size > 4 && String__equal(argument + size - 4, ".pnm")) {
00048 image_file_names.push_back(argument);
00049 } else if (size > 4 && String__equal(argument + size - 4, ".chk")) {
00050
00051 } else {
00052 File__format(stderr, "Unrecoginized file '%s'\n", argument);
00053 }
00054 }
00055 }
00056
00057 unsigned int size = image_file_names.size();
00058 if (size > 0) {
00059 String image_file_name0 = image_file_names[0];
00060 CV_Image image = (CV_Image)0;
00061 image = CV_Image__pnm_read(image_file_name0);
00062 assert (image != (CV_Image)0);
00063
00064
00065 Fiducials_Create fiducials_create = Fiducials_Create__one_and_only();
00066 fiducials_create->fiducials_path = ".";
00067 fiducials_create->lens_calibrate_file_name = lens_calibrate_file_name;
00068 fiducials_create->announce_object = (Memory)0;
00069 fiducials_create->arc_announce_routine = Fiducials__arc_announce;
00070 fiducials_create->location_announce_routine =
00071 Fiducials__location_announce;
00072 fiducials_create->tag_announce_routine = Fiducials__tag_announce;
00073 fiducials_create->log_file_name = log_file_name;
00074 fiducials_create->map_base_name = "Demo_Map";
00075 fiducials_create->tag_heights_file_name = "Tag_Heights.xml";
00076
00077 Fiducials fiducials = Fiducials__create(image, fiducials_create);
00078 fiducials->map->image_log = image_log;
00079
00080 for (unsigned int index = 0; index < size; index++) {
00081 String image_file_name = image_file_names[index];
00082 image = CV_Image__pnm_read(image_file_name);
00083 Fiducials__image_set(fiducials, image);
00084 Fiducials__process(fiducials);
00085 }
00086
00087 assert (gettimeofday(end_time_value, (struct timezone *)0) == 0);
00088
00089 double start_time = (double)start_time_value->tv_usec / 1000000.0;
00090 double end_time =
00091 (double)(end_time_value->tv_sec - start_time_value->tv_sec) +
00092 (double)end_time_value->tv_usec / 1000000.0;
00093 double time = end_time - start_time;
00094 double frames_per_second = (double)size / time;
00095
00096 File__format(stderr, "%d frames / %f sec = %f Frame/sec\n",
00097 size, time, frames_per_second);
00098
00099 if (size == 1) {
00100 Fiducials__image_show(fiducials, (bool)1);
00101 } else {
00102 Map map = fiducials->map;
00103 Map__save(map);
00104 File__format(stderr,
00105 "Outputing %d locations\n", fiducials->locations_path.size());
00106 Map__svg_write(map, "Demo", fiducials->locations_path);
00107 }
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120 }
00121
00122 return 0;
00123 }
00124