PageRenderTime 64ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/FDCM/Fitline/fitline.cpp

https://gitlab.com/tomtana/PalletDetectionCpp
C++ | 73 lines | 31 code | 14 blank | 28 comment | 3 complexity | b6841cb63780cfd9d9abd48d51f869be MD5 | raw file
  1. /*
  2. Copyright 2011, Ming-Yu Liu
  3. All Rights Reserved
  4. Permission to use, copy, modify, and distribute this software and
  5. its documentation for any non-commercial purpose is hereby granted
  6. without fee, provided that the above copyright notice appear in
  7. all copies and that both that copyright notice and this permission
  8. notice appear in supporting documentation, and that the name of
  9. the author not be used in advertising or publicity pertaining to
  10. distribution of the software without specific, written prior
  11. permission.
  12. THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  13. INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  14. ANY PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  15. ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  16. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
  17. AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  18. OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  19. */
  20. #include <iostream>
  21. #include <string>
  22. #include "Image/Image.h"
  23. #include "Image/ImageIO.h"
  24. #include "LFLineFitter.h"
  25. using namespace std;
  26. void main(int argc, char *argv[])
  27. {
  28. //IplImage *inputImage=NULL;
  29. Image<uchar> *inputImage=NULL;
  30. LFLineFitter lf;
  31. if(argc != 4)
  32. {
  33. std::cerr<<"[Syntax] fitline input_edgeMap.pgm output_line.txt output_edgeMap.pgm"<<std::endl;
  34. exit(0);
  35. }
  36. string imageName(argv[1]);
  37. string outFilename(argv[2]);
  38. string outputImageName(argv[3]);
  39. //string imageName("data/hat_edges.pgm");
  40. //string outFilename("data/hat_edges.txt");
  41. //string outputImageName("data/hat_edges_display.pgm");
  42. //inputImage = cvLoadImage(imageName.c_str(),0);
  43. inputImage = ImageIO::LoadPGM(imageName.c_str());
  44. if(inputImage==NULL)
  45. {
  46. std::cerr<<"[ERROR] Fail in reading image "<<imageName<<std::endl;
  47. exit(0);
  48. }
  49. lf.Init();
  50. lf.Configure("para_template_line_fitter.txt");
  51. lf.FitLine(inputImage);
  52. lf.DisplayEdgeMap(inputImage,outputImageName.c_str());
  53. lf.SaveEdgeMap(outFilename.c_str());
  54. //cvReleaseImage(&inputImage);
  55. delete inputImage;
  56. };