001//
002// This file is auto-generated. Please don't modify it!
003//
004package org.opencv.imgproc;
005
006import org.opencv.core.Algorithm;
007import org.opencv.core.Mat;
008import org.opencv.core.Size;
009
010// C++: class LineSegmentDetector
011/**
012 * Line segment detector class
013 *
014 * following the algorithm described at CITE: Rafael12 .
015 *
016 * <b>Note:</b> Implementation has been removed from OpenCV version 3.4.6 to 3.4.15 and version 4.1.0 to 4.5.3 due original code license conflict.
017 * restored again after [Computation of a NFA](https://github.com/rafael-grompone-von-gioi/binomial_nfa) code published under the MIT license.
018 */
019public class LineSegmentDetector extends Algorithm {
020
021    protected LineSegmentDetector(long addr) { super(addr); }
022
023    // internal usage only
024    public static LineSegmentDetector __fromPtr__(long addr) { return new LineSegmentDetector(addr); }
025
026    //
027    // C++:  void cv::LineSegmentDetector::detect(Mat image, Mat& lines, Mat& width = Mat(), Mat& prec = Mat(), Mat& nfa = Mat())
028    //
029
030    /**
031     * Finds lines in the input image.
032     *
033     *     This is the output of the default parameters of the algorithm on the above shown image.
034     *
035     *     ![image](pics/building_lsd.png)
036     *
037     *     @param image A grayscale (CV_8UC1) input image. If only a roi needs to be selected, use:
038     *     {@code lsd_ptr-&gt;detect(image(roi), lines, ...); lines += Scalar(roi.x, roi.y, roi.x, roi.y);}
039     *     @param lines A vector of Vec4f elements specifying the beginning and ending point of a line. Where
040     *     Vec4f is (x1, y1, x2, y2), point 1 is the start, point 2 - end. Returned lines are strictly
041     *     oriented depending on the gradient.
042     *     @param width Vector of widths of the regions, where the lines are found. E.g. Width of line.
043     *     @param prec Vector of precisions with which the lines are found.
044     *     @param nfa Vector containing number of false alarms in the line region, with precision of 10%. The
045     *     bigger the value, logarithmically better the detection.
046     * <ul>
047     *   <li>
048     *      -1 corresponds to 10 mean false alarms
049     *   </li>
050     *   <li>
051     *      0 corresponds to 1 mean false alarm
052     *   </li>
053     *   <li>
054     *      1 corresponds to 0.1 mean false alarms
055     *     This vector will be calculated only when the objects type is #LSD_REFINE_ADV.
056     *   </li>
057     * </ul>
058     */
059    public void detect(Mat image, Mat lines, Mat width, Mat prec, Mat nfa) {
060        detect_0(nativeObj, image.nativeObj, lines.nativeObj, width.nativeObj, prec.nativeObj, nfa.nativeObj);
061    }
062
063    /**
064     * Finds lines in the input image.
065     *
066     *     This is the output of the default parameters of the algorithm on the above shown image.
067     *
068     *     ![image](pics/building_lsd.png)
069     *
070     *     @param image A grayscale (CV_8UC1) input image. If only a roi needs to be selected, use:
071     *     {@code lsd_ptr-&gt;detect(image(roi), lines, ...); lines += Scalar(roi.x, roi.y, roi.x, roi.y);}
072     *     @param lines A vector of Vec4f elements specifying the beginning and ending point of a line. Where
073     *     Vec4f is (x1, y1, x2, y2), point 1 is the start, point 2 - end. Returned lines are strictly
074     *     oriented depending on the gradient.
075     *     @param width Vector of widths of the regions, where the lines are found. E.g. Width of line.
076     *     @param prec Vector of precisions with which the lines are found.
077     *     bigger the value, logarithmically better the detection.
078     * <ul>
079     *   <li>
080     *      -1 corresponds to 10 mean false alarms
081     *   </li>
082     *   <li>
083     *      0 corresponds to 1 mean false alarm
084     *   </li>
085     *   <li>
086     *      1 corresponds to 0.1 mean false alarms
087     *     This vector will be calculated only when the objects type is #LSD_REFINE_ADV.
088     *   </li>
089     * </ul>
090     */
091    public void detect(Mat image, Mat lines, Mat width, Mat prec) {
092        detect_1(nativeObj, image.nativeObj, lines.nativeObj, width.nativeObj, prec.nativeObj);
093    }
094
095    /**
096     * Finds lines in the input image.
097     *
098     *     This is the output of the default parameters of the algorithm on the above shown image.
099     *
100     *     ![image](pics/building_lsd.png)
101     *
102     *     @param image A grayscale (CV_8UC1) input image. If only a roi needs to be selected, use:
103     *     {@code lsd_ptr-&gt;detect(image(roi), lines, ...); lines += Scalar(roi.x, roi.y, roi.x, roi.y);}
104     *     @param lines A vector of Vec4f elements specifying the beginning and ending point of a line. Where
105     *     Vec4f is (x1, y1, x2, y2), point 1 is the start, point 2 - end. Returned lines are strictly
106     *     oriented depending on the gradient.
107     *     @param width Vector of widths of the regions, where the lines are found. E.g. Width of line.
108     *     bigger the value, logarithmically better the detection.
109     * <ul>
110     *   <li>
111     *      -1 corresponds to 10 mean false alarms
112     *   </li>
113     *   <li>
114     *      0 corresponds to 1 mean false alarm
115     *   </li>
116     *   <li>
117     *      1 corresponds to 0.1 mean false alarms
118     *     This vector will be calculated only when the objects type is #LSD_REFINE_ADV.
119     *   </li>
120     * </ul>
121     */
122    public void detect(Mat image, Mat lines, Mat width) {
123        detect_2(nativeObj, image.nativeObj, lines.nativeObj, width.nativeObj);
124    }
125
126    /**
127     * Finds lines in the input image.
128     *
129     *     This is the output of the default parameters of the algorithm on the above shown image.
130     *
131     *     ![image](pics/building_lsd.png)
132     *
133     *     @param image A grayscale (CV_8UC1) input image. If only a roi needs to be selected, use:
134     *     {@code lsd_ptr-&gt;detect(image(roi), lines, ...); lines += Scalar(roi.x, roi.y, roi.x, roi.y);}
135     *     @param lines A vector of Vec4f elements specifying the beginning and ending point of a line. Where
136     *     Vec4f is (x1, y1, x2, y2), point 1 is the start, point 2 - end. Returned lines are strictly
137     *     oriented depending on the gradient.
138     *     bigger the value, logarithmically better the detection.
139     * <ul>
140     *   <li>
141     *      -1 corresponds to 10 mean false alarms
142     *   </li>
143     *   <li>
144     *      0 corresponds to 1 mean false alarm
145     *   </li>
146     *   <li>
147     *      1 corresponds to 0.1 mean false alarms
148     *     This vector will be calculated only when the objects type is #LSD_REFINE_ADV.
149     *   </li>
150     * </ul>
151     */
152    public void detect(Mat image, Mat lines) {
153        detect_3(nativeObj, image.nativeObj, lines.nativeObj);
154    }
155
156
157    //
158    // C++:  void cv::LineSegmentDetector::drawSegments(Mat& image, Mat lines)
159    //
160
161    /**
162     * Draws the line segments on a given image.
163     *     @param image The image, where the lines will be drawn. Should be bigger or equal to the image,
164     *     where the lines were found.
165     *     @param lines A vector of the lines that needed to be drawn.
166     */
167    public void drawSegments(Mat image, Mat lines) {
168        drawSegments_0(nativeObj, image.nativeObj, lines.nativeObj);
169    }
170
171
172    //
173    // C++:  int cv::LineSegmentDetector::compareSegments(Size size, Mat lines1, Mat lines2, Mat& image = Mat())
174    //
175
176    /**
177     * Draws two groups of lines in blue and red, counting the non overlapping (mismatching) pixels.
178     *
179     *     @param size The size of the image, where lines1 and lines2 were found.
180     *     @param lines1 The first group of lines that needs to be drawn. It is visualized in blue color.
181     *     @param lines2 The second group of lines. They visualized in red color.
182     *     @param image Optional image, where the lines will be drawn. The image should be color(3-channel)
183     *     in order for lines1 and lines2 to be drawn in the above mentioned colors.
184     * @return automatically generated
185     */
186    public int compareSegments(Size size, Mat lines1, Mat lines2, Mat image) {
187        return compareSegments_0(nativeObj, size.width, size.height, lines1.nativeObj, lines2.nativeObj, image.nativeObj);
188    }
189
190    /**
191     * Draws two groups of lines in blue and red, counting the non overlapping (mismatching) pixels.
192     *
193     *     @param size The size of the image, where lines1 and lines2 were found.
194     *     @param lines1 The first group of lines that needs to be drawn. It is visualized in blue color.
195     *     @param lines2 The second group of lines. They visualized in red color.
196     *     in order for lines1 and lines2 to be drawn in the above mentioned colors.
197     * @return automatically generated
198     */
199    public int compareSegments(Size size, Mat lines1, Mat lines2) {
200        return compareSegments_1(nativeObj, size.width, size.height, lines1.nativeObj, lines2.nativeObj);
201    }
202
203
204    @Override
205    protected void finalize() throws Throwable {
206        delete(nativeObj);
207    }
208
209
210
211    // C++:  void cv::LineSegmentDetector::detect(Mat image, Mat& lines, Mat& width = Mat(), Mat& prec = Mat(), Mat& nfa = Mat())
212    private static native void detect_0(long nativeObj, long image_nativeObj, long lines_nativeObj, long width_nativeObj, long prec_nativeObj, long nfa_nativeObj);
213    private static native void detect_1(long nativeObj, long image_nativeObj, long lines_nativeObj, long width_nativeObj, long prec_nativeObj);
214    private static native void detect_2(long nativeObj, long image_nativeObj, long lines_nativeObj, long width_nativeObj);
215    private static native void detect_3(long nativeObj, long image_nativeObj, long lines_nativeObj);
216
217    // C++:  void cv::LineSegmentDetector::drawSegments(Mat& image, Mat lines)
218    private static native void drawSegments_0(long nativeObj, long image_nativeObj, long lines_nativeObj);
219
220    // C++:  int cv::LineSegmentDetector::compareSegments(Size size, Mat lines1, Mat lines2, Mat& image = Mat())
221    private static native int compareSegments_0(long nativeObj, double size_width, double size_height, long lines1_nativeObj, long lines2_nativeObj, long image_nativeObj);
222    private static native int compareSegments_1(long nativeObj, double size_width, double size_height, long lines1_nativeObj, long lines2_nativeObj);
223
224    // native support for java finalize()
225    private static native void delete(long nativeObj);
226
227}