00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef PIC_RANDOMIZER_H
00021 #define PIC_RANDOMIZER_H
00022
00023 #include <cv.h>
00024 #include <vector>
00025 #include <stdio.h>
00026 #include <polyora/kpttracker.h>
00027
00028 struct Corners {
00029 float p[4][2];
00030
00031 void random_homography(float src_width, float src_height, float min_angle, float max_angle, float min_scale, float max_scale, float h_range, float v_range);
00032 void get_min_max(float *minx, float *miny, float *maxx, float *maxy);
00033 void fit_in_image(int *width, int *height);
00034 void get_homography(CvMat *H, int src_width, int src_height);
00035
00036 void interpolate(const Corners &a, const Corners &b, float t);
00037 };
00038
00039 class SyntheticViewPath {
00040 public:
00041
00042 SyntheticViewPath(IplImage *im) : im(im) {}
00043 void generatePath(int nbLoc, float min_angle, float max_angle, float min_scale, float max_scale, float h_range, float v_range);
00044
00045
00046 void genView(float t, IplImage *dst);
00047 void getDstImSize(int *width, int *height);
00048
00049 protected:
00050 IplImage *im;
00051 std::vector<Corners> path;
00052 };
00053
00054
00055 class pic_randomizer {
00056 public:
00057 pic_randomizer();
00058 ~pic_randomizer();
00059
00060 bool load_image(const char *fn);
00061
00062 bool run();
00063
00064 IplImage *gen_view();
00065 void detect_kpts();
00066 void group_ids();
00067 bool save_points();
00068 void prune();
00069 bool save_keypoints();
00070
00071 int nb_views;
00072 float min_view_rate;
00073
00074 bool save_descriptors_only;
00075
00076 const char *tree_fn;
00077 const char *output_fn;
00078 const char *visualdb_fn;
00079 private:
00080
00081 float H[3][3];
00082 CvMat mH;
00083 IplImage *base_image;
00084 IplImage *view;
00085
00086 class point_cluster : public point2d, public id_cluster {
00087 public:
00088 int n;
00089
00090 mlist_elem<point_cluster> points_in_frame;
00091 };
00092
00093 bucket2d<point_cluster> *points;
00094
00095 point_cluster *find_cluster(const point2d &p, float r);
00096
00097 kpt_tracker *tracker;
00098 };
00099
00100 #endif