/Codigo Antigo - Nao apagar/Interface PDI/PDI/sift/siftfeat.c

# · C · 89 lines · 54 code · 14 blank · 21 comment · 8 complexity · 86c92d466d1b6f3564c09d2d5366acf9 MD5 · raw file

  1. /*
  2. This program detects image features using SIFT keypoints. For more info,
  3. refer to:
  4. Lowe, D. Distinctive image features from scale-invariant keypoints.
  5. International Journal of Computer Vision, 60, 2 (2004), pp.91--110.
  6. Copyright (C) 2006 Rob Hess <hess@eecs.oregonstate.edu>
  7. Note: The SIFT algorithm is patented in the United States and cannot be
  8. used in commercial products without a license from the University of
  9. British Columbia. For more information, refer to the file LICENSE.ubc
  10. that accompanied this distribution.
  11. Version: 1.1.1-20070913
  12. */
  13. #include "sift.h"
  14. #include "imgfeatures.h"
  15. #include "utils.h"
  16. #include <highgui.h>
  17. #include <stdio.h>
  18. /******************************** Globals ************************************/
  19. char* img_file_name = ""; //"..\\beaver.png"; //"..\\amanda.jpg";
  20. char* out_file_name = ""; //"..\\beaver.sift"; //"..\\amanda.sift";
  21. char* out_img_name = NULL;
  22. int display = 1;
  23. int intvls = SIFT_INTVLS;
  24. double sigma = SIFT_SIGMA;
  25. double contr_thr = SIFT_CONTR_THR;
  26. int curv_thr = SIFT_CURV_THR;
  27. int img_dbl = SIFT_IMG_DBL;
  28. int descr_width = SIFT_DESCR_WIDTH;
  29. int descr_hist_bins = SIFT_DESCR_HIST_BINS;
  30. /********************************** Main *************************************/
  31. int main( int argc, char** argv )
  32. {
  33. IplImage* img;
  34. struct feature* features;
  35. int n = 0;
  36. // Trata argumentos
  37. if (argc != 3)
  38. {
  39. fprintf( stderr, "Wrong number of arguments. Two arguments are expected: image file and features output file.\n");
  40. exit( 1 );
  41. }
  42. else
  43. {
  44. // Trata arquivo de imagem
  45. img_file_name = argv[1];
  46. // Trata arquivo de saída das features
  47. out_file_name = argv[2];
  48. }
  49. fprintf( stderr, "Finding SIFT features...\n" );
  50. img = cvLoadImage( img_file_name, 1 );
  51. if( ! img )
  52. {
  53. fprintf( stderr, "Unable to load image from file %s", img_file_name );
  54. exit( 1 );
  55. }
  56. n = _sift_features( img, &features, intvls, sigma, contr_thr, curv_thr,
  57. img_dbl, descr_width, descr_hist_bins );
  58. fprintf( stderr, "Found %d features.\n", n );
  59. if( display )
  60. {
  61. draw_features( img, features, n );
  62. cvNamedWindow( img_file_name, 1 );
  63. cvShowImage( img_file_name, img );
  64. cvWaitKey( 0 );
  65. }
  66. if( out_file_name != NULL )
  67. export_features( out_file_name, features, n );
  68. if( out_img_name != NULL )
  69. cvSaveImage( out_img_name, img );
  70. return 0;
  71. }