Permalink
Browse files

added utils UAV test images

  • Loading branch information...
1 parent 4c0c21f commit 398abfb53bcc7d712d296c7599ebaa47a74b9845 @abhinavgupta committed Oct 11, 2012
Showing with 247 additions and 1,894 deletions.
  1. +3 −3 CMakeLists.txt
  2. +6 −4 README
  3. +52 −0 README~
  4. +3 −7 SIFT_Descriptor.cpp
  5. +133 −0 SIFT_Descriptor.cpp~
  6. +0 −321 build/CMakeCache.txt
  7. +0 −49 build/CMakeFiles/CMakeCCompiler.cmake
  8. +0 −50 build/CMakeFiles/CMakeCXXCompiler.cmake
  9. BIN build/CMakeFiles/CMakeDetermineCompilerABI_C.bin
  10. BIN build/CMakeFiles/CMakeDetermineCompilerABI_CXX.bin
  11. +0 −24 build/CMakeFiles/CMakeDirectoryInformation.cmake
  12. +0 −263 build/CMakeFiles/CMakeOutput.log
  13. +0 −15 build/CMakeFiles/CMakeSystem.cmake
  14. +0 −232 build/CMakeFiles/CompilerIdC/CMakeCCompilerId.c
  15. BIN build/CMakeFiles/CompilerIdC/a.out
  16. +0 −215 build/CMakeFiles/CompilerIdCXX/CMakeCXXCompilerId.cpp
  17. BIN build/CMakeFiles/CompilerIdCXX/a.out
  18. +0 −61 build/CMakeFiles/Makefile.cmake
  19. +0 −96 build/CMakeFiles/Makefile2
  20. +0 −164 build/CMakeFiles/SIFT_Descriptor.dir/CXX.includecache
  21. +0 −13 build/CMakeFiles/SIFT_Descriptor.dir/DependInfo.cmake
  22. BIN build/CMakeFiles/SIFT_Descriptor.dir/SIFT_Descriptor.o
  23. +0 −116 build/CMakeFiles/SIFT_Descriptor.dir/build.make
  24. +0 −10 build/CMakeFiles/SIFT_Descriptor.dir/cmake_clean.cmake
  25. +0 −21 build/CMakeFiles/SIFT_Descriptor.dir/depend.internal
  26. +0 −21 build/CMakeFiles/SIFT_Descriptor.dir/depend.make
  27. +0 −8 build/CMakeFiles/SIFT_Descriptor.dir/flags.make
  28. +0 −1 build/CMakeFiles/SIFT_Descriptor.dir/link.txt
  29. +0 −2 build/CMakeFiles/SIFT_Descriptor.dir/progress.make
  30. +0 −1 build/CMakeFiles/TargetDirectories.txt
  31. +0 −1 build/CMakeFiles/cmake.check_cache
  32. +0 −1 build/CMakeFiles/progress.marks
  33. +0 −151 build/Makefile
  34. BIN build/SIFT_Descriptor
  35. +0 −44 build/cmake_install.cmake
  36. BIN { → test-images}/TEST.JPG
  37. BIN { → test-images}/swiss.png
  38. +6 −0 utils.hpp
  39. +6 −0 utils.h~
  40. +32 −0 zoomout.cpp
  41. +6 −0 zoomout.h~
View
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 2.3)
-project( SIFT_Descriptor)
+project( zoomout)
find_package (OpenCV REQUIRED)
-add_executable ( SIFT_Descriptor SIFT_Descriptor )
-target_link_libraries ( SIFT_Descriptor ${OpenCV_LIBS})
+add_executable (SIFT_Descriptor SIFT_Descriptor.cpp zoomout.cpp)
+target_link_libraries ( SIFT_Descriptor ${OpenCV_LIBS} )
View
10 README
@@ -23,17 +23,19 @@ CMake 2.8
BUILDIING FROM SOURCE:
-1. Go to the directory and run the following commands:
+1. USE CMAKE
-cmake .
+mkdir build
+cd build
+cmake ..
make
This should make the required files and the executable as well
RUNNING THE CODE:
-./SIFT_descriptor <img1> <img2> <resize parameter in power of two> <threshold multiplier for min distance>
+./SIFT_descriptor <Object image> <Scene Image> <resize parameter in power of two> <threshold multiplier for min distance>
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)
@@ -47,4 +49,4 @@ Abhinav Gupta
CONSTRBUTORS:
-Ritesh Ranjan
+Ritesh Ranjan
View
52 README~
@@ -0,0 +1,52 @@
+********************
+* SIFT BASED DSMAC *
+********************
+
+README:
+
+
+This code is a SIFT based trackers for UAV applications. The tracker is meant for DMSAC purposes
+
+DSMAC: Digital Scene Matcher and Area Co-relator
+
+What it tries to do is to match a given input from a UAV and match it to a large map.
+
+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.
+
+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
+ (For reference, this pulls involved changes in the Lehviestien distance measurement and the feature calculations)
+
+REQUIREMENTS:
+
+OpenCV 2.4.2
+CMake 2.8
+
+BUILDIING FROM SOURCE:
+
+1. USE CMAKE
+
+mkdir build
+cd build
+cmake ..
+make
+
+This should make the required files and the executable as well
+
+
+RUNNING THE CODE:
+
+./SIFT_descriptor <img1> <img2> <resize parameter in power of two> <threshold multiplier for min distance>
+
+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.
+
+
+AUTHORS:
+
+Abhinav Gupta
+
+CONSTRBUTORS:
+
+Ritesh Ranjan
View
@@ -11,6 +11,7 @@
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/nonfree/features2d.hpp"
#include "opencv2/imgproc/imgproc.hpp"
+#include "utils.hpp"
#define ASSERT(condition, message) \
if (! (condition)) { \
@@ -44,12 +45,7 @@ int main (int argc, char** argv)
return -1;
}
- for (int i =0; i< atoi(argv[3]); i++)
- {
- pyrDown(img_object_temp, img_object, Size( img_object_temp.cols/2, img_object_temp.rows/2)); // Scaling down the object image by a factor of 2^[argv[3]]
-
- img_object_temp = img_object;
- }
+ img_object = zoomout(img_object_temp, atoi(argv[3]));
std::vector<KeyPoint> keypoints_object, keypoints_scene; //Initializing data structures for keypoints & descriptors
Mat descriptors_object, descriptors_scene;
@@ -134,4 +130,4 @@ int main (int argc, char** argv)
* @function readme
*/
void readme()
- { 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; }
+ { 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; }
View
@@ -0,0 +1,133 @@
+
+#include <stdio.h>
+#include <math.h>
+#include <stdlib.h>
+#include <iostream>
+#include <assert.h>
+#include "opencv2/core/core.hpp"
+#include "opencv2/features2d/features2d.hpp"
+#include "opencv2/nonfree/features2d.hpp"
+#include "opencv2/highgui/highgui.hpp"
+#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;
+
+void readme(); //README function for showing usage
+
+
+int main (int argc, char** argv)
+
+{
+ if(argc != 5)
+ {
+ readme(); //Arguments less than five triggers README function
+ return -1;
+ }
+
+ Mat img_object;
+ Mat img_object_temp = imread( argv[1], CV_LOAD_IMAGE_GRAYSCALE); //Loading Object, scene images
+ Mat img_scene = imread( argv[2], CV_LOAD_IMAGE_GRAYSCALE);
+
+ if(!img_object.data && !img_scene.data)
+ {
+ std::cout<< " ---(!) ERROR READING IMAGES " <<std::endl; //Faulty images or no files of the names detected
+ return -1;
+ }
+
+ img_object = zoomout(img_object_temp, atoi(argv[3]));
+
+ std::vector<KeyPoint> keypoints_object, keypoints_scene; //Initializing data structures for keypoints & descriptors
+ Mat descriptors_object, descriptors_scene;
+
+ SiftFeatureDetector detector;
+ SiftDescriptorExtractor extractor; //Initializing SIFT functions
+
+
+ detector.detect(img_object, keypoints_object); //Using the SIFT detector for keypoints
+ detector.detect(img_scene, keypoints_scene);
+
+ extractor.compute(img_object, keypoints_object, descriptors_object); //Using SIFT descriptor extractor
+ extractor.compute(img_scene, keypoints_scene, descriptors_scene);
+
+ FlannBasedMatcher matcher;
+ 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
+ {
+ 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);
+
+ std::vector<Point2f> obj;
+ std::vector<Point2f> scene;
+
+ for (std::vector<DMatch>::iterator it = good_matches.begin(); it != good_matches.end(); it++ )
+ {
+ obj.push_back(keypoints_object[ (*it).queryIdx ].pt);
+ scene.push_back(keypoints_scene[ (*it).trainIdx ].pt);
+ }
+
+
+ Mat H = findHomography( obj, scene, CV_RANSAC );
+ //-- Get the corners from the image_1 ( the object to be "detected" )
+ std::vector<Point2f> obj_corners(4);
+ obj_corners[0] = cvPoint(0,0); obj_corners[1] = cvPoint( img_object.cols, 0 );
+ obj_corners[2] = cvPoint( img_object.cols, img_object.rows ); obj_corners[3] = cvPoint( 0, img_object.rows );
+ std::vector<Point2f> scene_corners(4);
+
+ perspectiveTransform( obj_corners, scene_corners, H);
+
+ //-- Draw lines between the corners (the mapped object in the scene - image_2 )
+ line( img_matches, scene_corners[0] + Point2f( img_object.cols, 0), scene_corners[1] + Point2f( img_object.cols, 0), Scalar(0, 255, 0), 4 );
+ line( img_matches, scene_corners[1] + Point2f( img_object.cols, 0), scene_corners[2] + Point2f( img_object.cols, 0), Scalar( 0, 255, 0), 4 );
+ line( img_matches, scene_corners[2] + Point2f( img_object.cols, 0), scene_corners[3] + Point2f( img_object.cols, 0), Scalar( 0, 255, 0), 4 );
+ line( img_matches, scene_corners[3] + Point2f( img_object.cols, 0), scene_corners[0] + Point2f( img_object.cols, 0), Scalar( 0, 255, 0), 4 );
+
+ //-- Show detected matches
+ imshow( "Good Matches & Object detection", img_matches );
+
+ waitKey(0);
+ return 0;
+ }
+
+ /**
+ * @function readme
+ */
+void readme()
+ { 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; }
Oops, something went wrong.

0 comments on commit 398abfb

Please sign in to comment.