Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 13 commits
  • 6 files changed
  • 0 commit comments
  • 2 contributors
Showing with 44 additions and 78 deletions.
  1. +2 −2 CMakeLists.txt
  2. +3 −3 README
  3. +27 −35 SIFT_Descriptor.cpp
  4. +12 −0 test-images/ideal-parameters-for-images
  5. +0 −6 utils.hpp
  6. +0 −32 zoomout.cpp
View
4 CMakeLists.txt
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 2.3)
-project( zoomout)
+project(SIFT_Descriptor)
find_package (OpenCV REQUIRED)
-add_executable (SIFT_Descriptor SIFT_Descriptor.cpp zoomout.cpp)
+add_executable (SIFT_Descriptor SIFT_Descriptor.cpp)
target_link_libraries ( SIFT_Descriptor ${OpenCV_LIBS} )
View
6 README
@@ -35,12 +35,12 @@ This should make the required files and the executable as well
RUNNING THE CODE:
-./SIFT_descriptor <Object image> <Scene Image> <resize parameter in power of two> <threshold multiplier for min distance>
+./SIFT_descriptor <Object image> <Scene Image> <resize parameter in power of two> <number of matches to be considered>
img1 : Object Image (This will be the zoomed in version)
img2 : Scene Image (This will be the Map version, scaled out as compared to the object image)
-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)
-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.
+resize parameter : This parameter will scale the image. and float value k will change the image size k times. In most cases k < 0 (In an UAV, this parameter will be a function of height of the UAV)
+number of matches to be considered : This parameter defines the number of matches to be used for the purpose of homography calculations.
AUTHORS:
View
62 SIFT_Descriptor.cpp
@@ -1,9 +1,8 @@
-
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <iostream>
-#include <assert.h>
+#include <algorithm>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/nonfree/features2d.hpp"
@@ -11,18 +10,17 @@
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/nonfree/features2d.hpp"
#include "opencv2/imgproc/imgproc.hpp"
-#include "utils.hpp"
-
-#define ASSERT(condition, message) \
- if (! (condition)) { \
- std::cerr << "\nAssertion `" #condition "` failed " \
- << "\nLine : " << __LINE__ << "\n" << message << std::endl; \
- std::exit(EXIT_FAILURE); \
- } \
using namespace cv;
+//Sorting Comparison Function - Added by Ritesh
+bool myobject (const DMatch& i,const DMatch& j)
+{
+ return (i.distance<j.distance);
+}
+
+
void readme(); //README function for showing usage
@@ -45,7 +43,10 @@ int main (int argc, char** argv)
return -1;
}
- img_object = zoomout(img_object_temp, atoi(argv[3]));
+ float size = atof(argv[3]);
+
+ resize(img_object_temp, img_object, Size(), size, size, INTER_AREA);
+
std::vector<KeyPoint> keypoints_object, keypoints_scene; //Initializing data structures for keypoints & descriptors
Mat descriptors_object, descriptors_scene;
@@ -64,35 +65,25 @@ int main (int argc, char** argv)
std::vector <DMatch> matches; //Initializing matcher and vector for matches extracted
matcher.match( descriptors_object, descriptors_scene, matches);
- double max_dist = 0;
- double min_dist = 100; //Initializing distance measuremenets for matches
-
- for (int i = 0; i <descriptors_object.rows; i++)
- {
- double dist = matches[i].distance;
- if( dist < min_dist) min_dist = dist; // finding max and min distance values
- if( dist > max_dist) max_dist = dist;
- }
-
- printf ("-- Max Distance : %f \n", max_dist);
- printf ("-- Min Distance : %f \n", min_dist);
-
std::vector<DMatch> good_matches;
-
- for(int i = 0; i < descriptors_object.rows; i++)
- {
- if (matches[i].distance < atoi(argv[4])*min_dist) //Classifying good matches from generic matches by defining a threshold
+
+ std::sort(matches.begin(),matches.end(),myobject);
+
+ int number_of_matches = atoi(argv[4]);
+
+ if(number_of_matches > matches.size())
{
- good_matches.push_back(matches[i]);
- }
+ number_of_matches = matches.size();
+ }
+
+ for(int i = 0; i < atoi(argv[4]) ; i++)
+ {
+ good_matches.push_back(matches[i]);
}
- std::cout<<good_matches.size()<<std::endl;
- ASSERT(good_matches.size() >= 4 , "Not enough good matches were detected!"); // Checking whether good matches were found
-
Mat img_matches;
- 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);
+ drawMatches (img_object, keypoints_object, img_scene, keypoints_scene, good_matches, img_matches, Scalar::all(-1), Scalar::all(-1), vector<char>(), DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
std::vector<Point2f> obj;
std::vector<Point2f> scene;
@@ -130,4 +121,5 @@ int main (int argc, char** argv)
* @function readme
*/
void readme()
- { std::cout << " Usage: ./SIFT_descriptor <object_image> <scene_image> <resize parameter in power of two> <threshold multiplier for min distance> \n FOR FURTHER INFO CHECK README \n" << std::endl; }
+ { std::cout << " Usage: ./SIFT_descriptor <object_image> <scene_image> <resize parameter> <number of matches to be used (integer)> \n FOR FURTHER INFO CHECK README \n" << std::endl; }
+
View
12 test-images/ideal-parameters-for-images
@@ -0,0 +1,12 @@
+This document will tell you the ideal parameters for the test images here.
+
+1. TEST.png swiss.png -> resize of 0.09 and 10 matches
+2. object.png scene.png -> resize of 0.3 and 5 matches
+3. object2.png scene.png -> resize of 0.1 and 5 matches
+
+
+The box box_in_scene are the best images to try your hands by varying the parameters.
+
+As you can in see the object object2 series, the closer zoomup makes a difference in the resize parameter
+keeping the matches parameter rather constant, thus showing that in a UAV aaplication, once a thorough
+callibration is done, the final output depends on the zoomout parameter and thus the height of the vehicle.
View
6 utils.hpp
@@ -1,6 +0,0 @@
-#ifndef UTILS_HPP
-#define UTILS_HPP
-
-cv::Mat zoomout( cv::Mat src, int iterations );
-
-#endif
View
32 zoomout.cpp
@@ -1,32 +0,0 @@
-#include "opencv2/imgproc/imgproc.hpp"
-#include "opencv2/highgui/highgui.hpp"
-#include <math.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-using namespace cv;
-
-/**
- * @function main
- */
-Mat zoomout( Mat src, int iterations )
-{
-
-
-
-
- Mat dst = src;
-
-
- for( int i = 0; i<iterations; i++)
- {
- pyrDown( src, dst, Size( src.cols/2, src.rows/2 ) );
- src = dst;
- }
-
-
-
-
- return dst;
-}
-

No commit comments for this range

Something went wrong with that request. Please try again.