Commit 25c0d597 authored by Daniel Angelov's avatar Daniel Angelov

Update on the compare lines method.

parent b5e1eb7d
...@@ -598,7 +598,7 @@ Draws two groups of lines in blue and red, counting the non overlapping (mismatc ...@@ -598,7 +598,7 @@ Draws two groups of lines in blue and red, counting the non overlapping (mismatc
:param lines2: The second group of lines. They visualized in red color. :param lines2: The second group of lines. They visualized in red color.
:param image: Optional image, where the lines will be drawn. The image is converted to grayscale before displaying, leaving lines1 and lines2 in the above mentioned colors. :param image: Optional image, where the lines will be drawn. The image should be color in order for lines1 and lines2 to be drawn in the above mentioned colors.
......
...@@ -1220,12 +1220,9 @@ int LineSegmentDetectorImpl::compareSegments(const Size& size, InputArray lines1 ...@@ -1220,12 +1220,9 @@ int LineSegmentDetectorImpl::compareSegments(const Size& size, InputArray lines1
if (_image.needed()) if (_image.needed())
{ {
Mat Ig; CV_Assert(_image.channels() == 3);
if (_image.channels() == 1) Mat img = _image.getMatRef();
{ CV_Assert(img.isContinuous() && I1.isContinuous() && I2.isContinuous());
cvtColor(_image, _image, CV_GRAY2BGR);
}
CV_Assert(_image.getMatRef().isContinuous() && I1.isContinuous() && I2.isContinuous());
for (unsigned int i = 0; i < I1.total(); ++i) for (unsigned int i = 0; i < I1.total(); ++i)
{ {
...@@ -1233,11 +1230,12 @@ int LineSegmentDetectorImpl::compareSegments(const Size& size, InputArray lines1 ...@@ -1233,11 +1230,12 @@ int LineSegmentDetectorImpl::compareSegments(const Size& size, InputArray lines1
uchar i2 = I2.data[i]; uchar i2 = I2.data[i];
if (i1 || i2) if (i1 || i2)
{ {
_image.getMatRef().data[3*i + 1] = 0; unsigned int base_idx = i * 3;
if (i1) _image.getMatRef().data[3*i] = 255; if (i1) img.data[base_idx] = 255;
else _image.getMatRef().data[3*i] = 0; else img.data[base_idx] = 0;
if (i2) _image.getMatRef().data[3*i + 2] = 255; img.data[base_idx + 1] = 0;
else _image.getMatRef().data[3*i + 2] = 0; if (i2) img.data[base_idx + 2] = 255;
else img.data[base_idx + 2] = 0;
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment