From 9d78b8003ebf9877a3bf47be73d52e5c26551f9a Mon Sep 17 00:00:00 2001 From: Daniel Angelov Date: Sat, 31 Aug 2013 13:39:38 +0300 Subject: [PATCH] Update on LSD no to use any Mat* (IOArrays instead). Updated to new license. --- modules/imgproc/include/opencv2/imgproc.hpp | 13 +++++---- modules/imgproc/src/lsd.cpp | 41 ++++++++++++++--------------- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/modules/imgproc/include/opencv2/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc.hpp index 24d9f44..581ba14 100644 --- a/modules/imgproc/include/opencv2/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc.hpp @@ -904,7 +904,7 @@ class LineSegmentDetector : public Algorithm { public: /** - * Detect lines in the input image with the specified ROI. + * Detect lines in the input image. * * @param _image A grayscale(CV_8UC1) input image. * If only a roi needs to be selected, use @@ -913,8 +913,6 @@ public: * @param _lines Return: A vector of Vec4i elements specifying the beginning and ending point of a line. * Where Vec4i is (x1, y1, x2, y2), point 1 is the start, point 2 - end. * Returned lines are strictly oriented depending on the gradient. - * @param _roi Return: ROI of the image, where lines are to be found. If specified, the returning - * lines coordinates are image wise. * @param width Return: Vector of widths of the regions, where the lines are found. E.g. Width of line. * @param prec Return: Vector of precisions with which the lines are found. * @param nfa Return: Vector containing number of false alarms in the line region, with precision of 10%. @@ -935,18 +933,19 @@ public: * Should have the size of the image, where the lines were found * @param lines The lines that need to be drawn */ - virtual void drawSegments(InputOutputArray image, InputArray lines) = 0; + virtual void drawSegments(InputOutputArray _image, const InputArray lines) = 0; /** * Draw both vectors on the image canvas. Uses blue for lines 1 and red for lines 2. * - * @param image The image, where lines will be drawn. - * Should have the size of the image, where the lines were found + * @param size The size of the image, where lines were found. * @param lines1 The first lines that need to be drawn. Color - Blue. * @param lines2 The second lines that need to be drawn. Color - Red. + * @param image Optional image, where lines will be drawn. + * Should have the size of the image, where the lines were found * @return The number of mismatching pixels between lines1 and lines2. */ - virtual int compareSegments(const Size& size, InputArray lines1, InputArray lines2, Mat* image = 0) = 0; + virtual int compareSegments(const Size& size, const InputArray lines1, const InputArray lines2, InputOutputArray _image = noArray()) = 0; virtual ~LineSegmentDetector() {}; }; diff --git a/modules/imgproc/src/lsd.cpp b/modules/imgproc/src/lsd.cpp index 58d226f..8cfe2b2 100644 --- a/modules/imgproc/src/lsd.cpp +++ b/modules/imgproc/src/lsd.cpp @@ -1,5 +1,6 @@ /*M/////////////////////////////////////////////////////////////////////////////////////// -// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. // // By downloading, copying, installing or using the software you agree to this license. // If you do not agree to this license, do not download, install, @@ -9,8 +10,7 @@ // License Agreement // For Open Source Computer Vision Library // -// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. -// Copyright (C) 2008-2011, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. // Third party copyrights are property of their respective owners. // // Redistribution and use in source and binary forms, with or without modification, @@ -185,7 +185,7 @@ public: double _log_eps = 0, double _density_th = 0.7, int _n_bins = 1024); /** - * Detect lines in the input image with the specified ROI. + * Detect lines in the input image. * * @param _image A grayscale(CV_8UC1) input image. * If only a roi needs to be selected, use @@ -194,8 +194,6 @@ public: * @param _lines Return: A vector of Vec4i elements specifying the beginning and ending point of a line. * Where Vec4i is (x1, y1, x2, y2), point 1 is the start, point 2 - end. * Returned lines are strictly oriented depending on the gradient. - * @param _roi Return: ROI of the image, where lines are to be found. If specified, the returning - * lines coordinates are image wise. * @param width Return: Vector of widths of the regions, where the lines are found. E.g. Width of line. * @param prec Return: Vector of precisions with which the lines are found. * @param nfa Return: Vector containing number of false alarms in the line region, with precision of 10%. @@ -216,18 +214,19 @@ public: * Should have the size of the image, where the lines were found * @param lines The lines that need to be drawn */ - void drawSegments(InputOutputArray image, InputArray lines); + void drawSegments(InputOutputArray _image, const InputArray lines); /** * Draw both vectors on the image canvas. Uses blue for lines 1 and red for lines 2. * - * @param image The image, where lines will be drawn. - * Should have the size of the image, where the lines were found + * @param size The size of the image, where lines1 and lines2 were found. * @param lines1 The first lines that need to be drawn. Color - Blue. * @param lines2 The second lines that need to be drawn. Color - Red. + * @param image An optional image, where lines will be drawn. + * Should have the size of the image, where the lines were found * @return The number of mismatching pixels between lines1 and lines2. */ - int compareSegments(const Size& size, InputArray lines1, InputArray lines2, Mat* image = 0); + int compareSegments(const Size& size, const InputArray lines1, const InputArray lines2, InputOutputArray _image = noArray()); private: Mat image; @@ -1186,10 +1185,10 @@ void LineSegmentDetectorImpl::drawSegments(InputOutputArray _image, const InputA } -int LineSegmentDetectorImpl::compareSegments(const Size& size, const InputArray lines1, const InputArray lines2, Mat* _image) +int LineSegmentDetectorImpl::compareSegments(const Size& size, const InputArray lines1, const InputArray lines2, InputOutputArray _image) { Size sz = size; - if (_image && _image->size() != size) sz = _image->size(); + if (_image.needed() && _image.size() != size) sz = _image.size(); CV_Assert(sz.area()); Mat_ I1 = Mat_::zeros(sz); @@ -1219,14 +1218,14 @@ int LineSegmentDetectorImpl::compareSegments(const Size& size, const InputArray bitwise_xor(I1, I2, Ixor); int N = countNonZero(Ixor); - if (_image) + if (_image.needed()) { Mat Ig; - if (_image->channels() == 1) + if (_image.channels() == 1) { - cvtColor(*_image, *_image, CV_GRAY2BGR); + cvtColor(_image, _image, CV_GRAY2BGR); } - CV_Assert(_image->isContinuous() && I1.isContinuous() && I2.isContinuous()); + CV_Assert(_image.getMatRef().isContinuous() && I1.isContinuous() && I2.isContinuous()); for (unsigned int i = 0; i < I1.total(); ++i) { @@ -1234,11 +1233,11 @@ int LineSegmentDetectorImpl::compareSegments(const Size& size, const InputArray uchar i2 = I2.data[i]; if (i1 || i2) { - _image->data[3*i + 1] = 0; - if (i1) _image->data[3*i] = 255; - else _image->data[3*i] = 0; - if (i2) _image->data[3*i + 2] = 255; - else _image->data[3*i + 2] = 0; + _image.getMatRef().data[3*i + 1] = 0; + if (i1) _image.getMatRef().data[3*i] = 255; + else _image.getMatRef().data[3*i] = 0; + if (i2) _image.getMatRef().data[3*i + 2] = 255; + else _image.getMatRef().data[3*i + 2] = 0; } } } -- 2.7.4