line_detector
line_detector copied to clipboard
I don't know what the problem is
input image:
my code:
int w = img.cols;
int h = img.rows;
boundingbox_t bbox = { 0,0,w,h };
float scaleX = 0.8;
float scaleY = 0.8;
std::vector<line_float_t> lines;
cv::Point2f pt1, pt2;
cv::Mat result = cv::Mat::zeros(h, w, CV_8UC3);
unsigned char * pImg = img.ptr<uchar>(0);
int ret = LsdLineDetector(pImg, w, h, scaleX, scaleY, bbox, lines);
if (ret < 1)
{
for (int i = 0; i < lines.size(); i++)
{
line_float_t line = lines[i];
pt1.x = line.startx;
pt1.y = line.starty;
pt2.x = line.endx;
pt2.y = line.endy;
int width = 2;
cv::Scalar color(rand() & 255, rand() & 255, rand() & 255);
cv::line(result, pt1, pt2, color, width, CV_AA);
}
}
imshow("img", result);
waitKey();
result:
question: I am sure to load a gray image, but the result is not good, what is the problem? parameter? it is seemed that filter image by gauss can make a good result.