Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added utils UAV test images

  • Loading branch information...
commit 7abb18accd7ea65eba409adc27dca54066c9e326 1 parent 398abfb
Abhinav Gupta authored

Showing 4 changed files with 0 additions and 197 deletions. Show diff stats Hide diff stats

  1. +0 52 README~
  2. +0 133 SIFT_Descriptor.cpp~
  3. +0 6 utils.h~
  4. +0 6 zoomout.h~
52 README~
... ... @@ -1,52 +0,0 @@
1   -********************
2   -* SIFT BASED DSMAC *
3   -********************
4   -
5   -README:
6   -
7   -
8   -This code is a SIFT based trackers for UAV applications. The tracker is meant for DMSAC purposes
9   -
10   -DSMAC: Digital Scene Matcher and Area Co-relator
11   -
12   -What it tries to do is to match a given input from a UAV and match it to a large map.
13   -
14   -Since the input object is highly scaled out in the map scene. It is necessary to use PryDown functions to make it easier for them to match.
15   -
16   -Certain other boosts in the SIFT codes makes the performance in this DMSAC to around 30ms. The upgrades are already pulled into the new OpenCV 2.4.2
17   - (For reference, this pulls involved changes in the Lehviestien distance measurement and the feature calculations)
18   -
19   -REQUIREMENTS:
20   -
21   -OpenCV 2.4.2
22   -CMake 2.8
23   -
24   -BUILDIING FROM SOURCE:
25   -
26   -1. USE CMAKE
27   -
28   -mkdir build
29   -cd build
30   -cmake ..
31   -make
32   -
33   -This should make the required files and the executable as well
34   -
35   -
36   -RUNNING THE CODE:
37   -
38   -./SIFT_descriptor <img1> <img2> <resize parameter in power of two> <threshold multiplier for min distance>
39   -
40   -img1 : Object Image (This will be the zoomed in version)
41   -img2 : Scene Image (This will be the Map version, scaled out as compared to the object image)
42   -resize parameter : This parameter is to give a power index to scale down the image. An input k will scale down by 2^k (In an UAV, this parameter will be a function of height of the UAV)
43   -Threshold multipler for min distance: Depending on the number of "good matches" recived, this parameter will give an appropriate multipler to filter out the best possible matches. Heuristically can be made a function of the resize parameter and consequently the height.
44   -
45   -
46   -AUTHORS:
47   -
48   -Abhinav Gupta
49   -
50   -CONSTRBUTORS:
51   -
52   -Ritesh Ranjan
133 SIFT_Descriptor.cpp~
... ... @@ -1,133 +0,0 @@
1   -
2   -#include <stdio.h>
3   -#include <math.h>
4   -#include <stdlib.h>
5   -#include <iostream>
6   -#include <assert.h>
7   -#include "opencv2/core/core.hpp"
8   -#include "opencv2/features2d/features2d.hpp"
9   -#include "opencv2/nonfree/features2d.hpp"
10   -#include "opencv2/highgui/highgui.hpp"
11   -#include "opencv2/calib3d/calib3d.hpp"
12   -#include "opencv2/nonfree/features2d.hpp"
13   -#include "opencv2/imgproc/imgproc.hpp"
14   -#include "utils.hpp"
15   -
16   -#define ASSERT(condition, message) \
17   - if (! (condition)) { \
18   - std::cerr << "\nAssertion `" #condition "` failed " \
19   - << "\nLine : " << __LINE__ << "\n" << message << std::endl; \
20   - std::exit(EXIT_FAILURE); \
21   - } \
22   -
23   -
24   -using namespace cv;
25   -
26   -void readme(); //README function for showing usage
27   -
28   -
29   -int main (int argc, char** argv)
30   -
31   -{
32   - if(argc != 5)
33   - {
34   - readme(); //Arguments less than five triggers README function
35   - return -1;
36   - }
37   -
38   - Mat img_object;
39   - Mat img_object_temp = imread( argv[1], CV_LOAD_IMAGE_GRAYSCALE); //Loading Object, scene images
40   - Mat img_scene = imread( argv[2], CV_LOAD_IMAGE_GRAYSCALE);
41   -
42   - if(!img_object.data && !img_scene.data)
43   - {
44   - std::cout<< " ---(!) ERROR READING IMAGES " <<std::endl; //Faulty images or no files of the names detected
45   - return -1;
46   - }
47   -
48   - img_object = zoomout(img_object_temp, atoi(argv[3]));
49   -
50   - std::vector<KeyPoint> keypoints_object, keypoints_scene; //Initializing data structures for keypoints & descriptors
51   - Mat descriptors_object, descriptors_scene;
52   -
53   - SiftFeatureDetector detector;
54   - SiftDescriptorExtractor extractor; //Initializing SIFT functions
55   -
56   -
57   - detector.detect(img_object, keypoints_object); //Using the SIFT detector for keypoints
58   - detector.detect(img_scene, keypoints_scene);
59   -
60   - extractor.compute(img_object, keypoints_object, descriptors_object); //Using SIFT descriptor extractor
61   - extractor.compute(img_scene, keypoints_scene, descriptors_scene);
62   -
63   - FlannBasedMatcher matcher;
64   - std::vector <DMatch> matches; //Initializing matcher and vector for matches extracted
65   - matcher.match( descriptors_object, descriptors_scene, matches);
66   -
67   - double max_dist = 0;
68   - double min_dist = 100; //Initializing distance measuremenets for matches
69   -
70   - for (int i = 0; i <descriptors_object.rows; i++)
71   - {
72   - double dist = matches[i].distance;
73   - if( dist < min_dist) min_dist = dist; // finding max and min distance values
74   - if( dist > max_dist) max_dist = dist;
75   - }
76   -
77   - printf ("-- Max Distance : %f \n", max_dist);
78   - printf ("-- Min Distance : %f \n", min_dist);
79   -
80   - std::vector<DMatch> good_matches;
81   -
82   - for(int i = 0; i < descriptors_object.rows; i++)
83   - {
84   - if (matches[i].distance < atoi(argv[4])*min_dist) //Classifying good matches from generic matches by defining a threshold
85   - {
86   - good_matches.push_back(matches[i]);
87   - }
88   - }
89   -
90   - std::cout<<good_matches.size()<<std::endl;
91   - ASSERT(good_matches.size() >= 4 , "Not enough good matches were detected!"); // Checking whether good matches were found
92   -
93   - Mat img_matches;
94   -
95   - drawMatches (img_object, keypoints_object, img_scene, keypoints_scene, good_matches, img_matches, Scalar::all(-1), Scalar::all(-1), vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS);
96   -
97   - std::vector<Point2f> obj;
98   - std::vector<Point2f> scene;
99   -
100   - for (std::vector<DMatch>::iterator it = good_matches.begin(); it != good_matches.end(); it++ )
101   - {
102   - obj.push_back(keypoints_object[ (*it).queryIdx ].pt);
103   - scene.push_back(keypoints_scene[ (*it).trainIdx ].pt);
104   - }
105   -
106   -
107   - Mat H = findHomography( obj, scene, CV_RANSAC );
108   - //-- Get the corners from the image_1 ( the object to be "detected" )
109   - std::vector<Point2f> obj_corners(4);
110   - obj_corners[0] = cvPoint(0,0); obj_corners[1] = cvPoint( img_object.cols, 0 );
111   - obj_corners[2] = cvPoint( img_object.cols, img_object.rows ); obj_corners[3] = cvPoint( 0, img_object.rows );
112   - std::vector<Point2f> scene_corners(4);
113   -
114   - perspectiveTransform( obj_corners, scene_corners, H);
115   -
116   - //-- Draw lines between the corners (the mapped object in the scene - image_2 )
117   - line( img_matches, scene_corners[0] + Point2f( img_object.cols, 0), scene_corners[1] + Point2f( img_object.cols, 0), Scalar(0, 255, 0), 4 );
118   - line( img_matches, scene_corners[1] + Point2f( img_object.cols, 0), scene_corners[2] + Point2f( img_object.cols, 0), Scalar( 0, 255, 0), 4 );
119   - line( img_matches, scene_corners[2] + Point2f( img_object.cols, 0), scene_corners[3] + Point2f( img_object.cols, 0), Scalar( 0, 255, 0), 4 );
120   - line( img_matches, scene_corners[3] + Point2f( img_object.cols, 0), scene_corners[0] + Point2f( img_object.cols, 0), Scalar( 0, 255, 0), 4 );
121   -
122   - //-- Show detected matches
123   - imshow( "Good Matches & Object detection", img_matches );
124   -
125   - waitKey(0);
126   - return 0;
127   - }
128   -
129   - /**
130   - * @function readme
131   - */
132   -void readme()
133   - { std::cout << " Usage: ./SIFT_descriptor <img1> <img2> <resize parameter in power of two> <threshold multiplier for min distance> \n FOR FURTHER INFO CHECK README \n" << std::endl; }
6 utils.h~
... ... @@ -1,6 +0,0 @@
1   -#ifndef UTILS_H
2   -#define UTILS_H
3   -
4   -cv::Mat zoomout( cv::Mat src, int iterations );
5   -
6   -#endif
6 zoomout.h~
... ... @@ -1,6 +0,0 @@
1   -#ifndef ZOOMOUT_H
2   -#define ZOOMOUT_H
3   -
4   -cv::Mat zoomout( cv::Mat src, int iterations );
5   -
6   -#endif

0 comments on commit 7abb18a

Please sign in to comment.
Something went wrong with that request. Please try again.