ReadFramework
LSDDetector.h
Go to the documentation of this file.
1 /*M///////////////////////////////////////////////////////////////////////////////////////
2  //
3  // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4  //
5  // By downloading, copying, installing or using the software you agree to this license.
6  // If you do not agree to this license, do not download, install,
7  // copy or use the software.
8  //
9  //
10  // License Agreement
11  // For Open Source Computer Vision Library
12  //
13  // Copyright (C) 2014, Biagio Montesano, all rights reserved.
14  // Third party copyrights are property of their respective owners.
15  //
16  // Redistribution and use in source and binary forms, with or without modification,
17  // are permitted provided that the following conditions are met:
18  //
19  // * Redistribution's of source code must retain the above copyright notice,
20  // this list of conditions and the following disclaimer.
21  //
22  // * Redistribution's in binary form must reproduce the above copyright notice,
23  // this list of conditions and the following disclaimer in the documentation
24  // and/or other materials provided with the distribution.
25  //
26  // * The name of the copyright holders may not be used to endorse or promote products
27  // derived from this software without specific prior written permission.
28  //
29  // This software is provided by the copyright holders and contributors "as is" and
30  // any express or implied warranties, including, but not limited to, the implied
31  // warranties of merchantability and fitness for a particular purpose are disclaimed.
32  // In no event shall the Intel Corporation or contributors be liable for any direct,
33  // indirect, incidental, special, exemplary, or consequential damages
34  // (including, but not limited to, procurement of substitute goods or services;
35  // loss of use, data, or profits; or business interruption) however caused
36  // and on any theory of liability, whether in contract, strict liability,
37  // or tort (including negligence or otherwise) arising in any way out of
38  // the use of this software, even if advised of the possibility of such damage.
39  //
40  //M*/
41 
42 #pragma once
43 
44 #include <map>
45 #include <vector>
46 #include <list>
47 
48 #if defined _MSC_VER && _MSC_VER <= 1700
49 #include <stdint.h>
50 #else
51 #include <inttypes.h>
52 #endif
53 
54 #include <stdio.h>
55 #include <iostream>
56 
57 //#include "opencv2/core/utility.hpp"
58 //#include "opencv2/core/private.hpp"
59 #include <opencv2/imgproc.hpp>
60 #include <opencv2/features2d.hpp>
61 #include <opencv2/core.hpp>
62 
63 /* define data types */
64 typedef uint64_t UINT64;
65 typedef uint32_t UINT32;
66 typedef uint16_t UINT16;
67 typedef uint8_t UINT8;
68 
69 /* define constants */
70 #define UINT64_1 ((UINT64)0x01)
71 #define UINT32_1 ((UINT32)0x01)
72 
73 namespace lsd
74 {
75 
78 
101 struct CV_EXPORTS KeyLine
102 {
103  public:
105  float angle;
106 
108  int class_id;
109 
111  int octave;
112 
114  cv::Point2f pt;
115 
119  float response;
120 
122  float size;
123 
125  float startPointX;
126  float startPointY;
127  float endPointX;
128  float endPointY;
129 
135 
137  float lineLength;
138 
141 
143  cv::Point2f getStartPoint() const
144  {
145  return cv::Point2f(startPointX, startPointY);
146  }
147 
149  cv::Point2f getEndPoint() const
150  {
151  return cv::Point2f(endPointX, endPointY);
152  }
153 
155  cv::Point2f getStartPointInOctave() const
156  {
157  return cv::Point2f(sPointInOctaveX, sPointInOctaveY);
158  }
159 
161  cv::Point2f getEndPointInOctave() const
162  {
163  return cv::Point2f(ePointInOctaveX, ePointInOctaveY);
164  }
165 
168  {
169  }
170 };
171 
189 class CV_EXPORTS LSDDetector : public cv::Algorithm
190 {
191 public:
192 
193 /* constructor */
194 /*CV_WRAP*/
196 {
197 }
198 ;
199 
202 static cv::Ptr<LSDDetector> createLSDDetector();
203 
212 void detect( const cv::Mat& image, CV_OUT std::vector<KeyLine>& keypoints, int scale, int numOctaves, const cv::Mat& mask = cv::Mat() );
213 
221 void detect( const std::vector<cv::Mat>& images, std::vector<std::vector<KeyLine> >& keylines, int scale, int numOctaves,
222 const std::vector<cv::Mat>& masks = std::vector<cv::Mat>() ) const;
223 
224 private:
225 /* compute Gaussian pyramid of input image */
226 void computeGaussianPyramid( const cv::Mat& image, int numOctaves, int scale );
227 
228 /* implementation of line detection */
229 void detectImpl( const cv::Mat& imageSrc, std::vector<KeyLine>& keylines, int numOctaves, int scale, const cv::Mat& mask ) const;
230 
231 /* matrices for Gaussian pyramids */
232 std::vector<cv::Mat> gaussianPyrs;
233 };
234 
235 }
cv::Point2f getStartPoint() const
Definition: LSDDetector.h:143
float startPointY
Definition: LSDDetector.h:126
LSDDetector()
Definition: LSDDetector.h:195
uint16_t UINT16
Definition: LSDDetector.h:66
float startPointX
Definition: LSDDetector.h:125
float angle
Definition: LSDDetector.h:105
cv::Point2f getStartPointInOctave() const
Definition: LSDDetector.h:155
float endPointX
Definition: LSDDetector.h:127
cv::Point2f getEndPoint() const
Definition: LSDDetector.h:149
KeyLine()
Definition: LSDDetector.h:167
int numOfPixels
Definition: LSDDetector.h:140
float sPointInOctaveX
Definition: LSDDetector.h:131
uint64_t UINT64
Definition: LSDDetector.h:64
Definition: LSDDetector.h:189
float lineLength
Definition: LSDDetector.h:137
cv::Point2f pt
Definition: LSDDetector.h:114
float ePointInOctaveX
Definition: LSDDetector.h:133
int octave
Definition: LSDDetector.h:111
cv::Point2f getEndPointInOctave() const
Definition: LSDDetector.h:161
uint8_t UINT8
Definition: LSDDetector.h:67
float response
Definition: LSDDetector.h:119
Definition: LSDDetector.cpp:45
float ePointInOctaveY
Definition: LSDDetector.h:134
float size
Definition: LSDDetector.h:122
uint32_t UINT32
Definition: LSDDetector.h:65
float sPointInOctaveY
Definition: LSDDetector.h:132
int class_id
Definition: LSDDetector.h:108
float endPointY
Definition: LSDDetector.h:128
A class to represent a line.
Definition: LSDDetector.h:101