Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The wrong line segment #5

Open
MrLihj opened this issue Apr 29, 2019 · 2 comments
Open

The wrong line segment #5

MrLihj opened this issue Apr 29, 2019 · 2 comments

Comments

@MrLihj
Copy link

MrLihj commented Apr 29, 2019

This is my code:


`void main()
{
	Mat image;
	image = imread("1.png");
	Mat gray_image;
	cvtColor(image, gray_image, CV_BGR2GRAY);
	int W = image.rows;
	int H = image.cols;
	int image_size = W* H;
	unsigned char* input = new unsigned char[image_size];
	memcpy(input, gray_image.data, image_size);
	vector<line_float_t> Lines;
	boundingbox_t Bbox = { 0,0,W,H };
	float scalex =0.5;
	float scaley =0.5;
	int Flag = 0;
	Flag = LsdLineDetector(input, W, H, scalex, scaley, Bbox, Lines);
	cout << Flag << endl;
	for (int i = 0; i < Lines.size(); i++)
	{
		line(image, Point(Lines[i].startx, Lines[i].starty), Point(Lines[i].endx, Lines[i].endy), Scalar(0, 0, 255), 2);
	}
	imshow("image1", image);
	waitKey(0);
	system("pause");
}`


%`M}6JATF}_J4@GG2GN5PIT

@frotms
Copy link
Owner

frotms commented Apr 29, 2019

This is my code:


`void main()
{
	Mat image;
	image = imread("1.png");
	Mat gray_image;
	cvtColor(image, gray_image, CV_BGR2GRAY);
	int W = image.rows;
	int H = image.cols;
	int image_size = W* H;
	unsigned char* input = new unsigned char[image_size];
	memcpy(input, gray_image.data, image_size);
	vector<line_float_t> Lines;
	boundingbox_t Bbox = { 0,0,W,H };
	float scalex =0.5;
	float scaley =0.5;
	int Flag = 0;
	Flag = LsdLineDetector(input, W, H, scalex, scaley, Bbox, Lines);
	cout << Flag << endl;
	for (int i = 0; i < Lines.size(); i++)
	{
		line(image, Point(Lines[i].startx, Lines[i].starty), Point(Lines[i].endx, Lines[i].endy), Scalar(0, 0, 255), 2);
	}
	imshow("image1", image);
	waitKey(0);
	system("pause");
}`

%`M}6JATF}_J4@GG2GN5PIT

Maybe image.rows means H, and image.cols means W in your code. @MrLihj

@ondrejvalusek
Copy link

This is my code:


`void main()
{
	Mat image;
	image = imread("1.png");
	Mat gray_image;
	cvtColor(image, gray_image, CV_BGR2GRAY);
	int W = image.rows;
	int H = image.cols;
	int image_size = W* H;
	unsigned char* input = new unsigned char[image_size];
	memcpy(input, gray_image.data, image_size);
	vector<line_float_t> Lines;
	boundingbox_t Bbox = { 0,0,W,H };
	float scalex =0.5;
	float scaley =0.5;
	int Flag = 0;
	Flag = LsdLineDetector(input, W, H, scalex, scaley, Bbox, Lines);
	cout << Flag << endl;
	for (int i = 0; i < Lines.size(); i++)
	{
		line(image, Point(Lines[i].startx, Lines[i].starty), Point(Lines[i].endx, Lines[i].endy), Scalar(0, 0, 255), 2);
	}
	imshow("image1", image);
	waitKey(0);
	system("pause");
}`

%`M}6JATF}_J4@GG2GN5PIT

Maybe image.rows means H, and image.cols means W in your code. @MrLihj

Thanks,this solved it for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants