Coder Social home page Coder Social logo

frotms / line_detector Goto Github PK

View Code? Open in Web Editor NEW
187.0 12.0 66.0 542 KB

line segment detector(lsd) &. edge drawing line detector(edl) &. hough line detector(standard &. probabilistic) for detection

License: Apache License 2.0

C++ 100.00%
edge-drawing edlines lsd hough-lines line-detection line-detector c

line_detector's Introduction

Three mainstream line detectors: lsd-lines, ed-lines and hough-lines

  • segment line detector (lsd)
  • edge drawing line detector (edlines)
  • hough line detector (standard and probabilistic)

All original dependencies have been removed. Code could be run independently:

  • line segment detector with a scale in vertical and horizontal direction in boundingbox, respectively
  • edge drawing line detector with a scale in vertical and horizontal direction in boundingbox, respectively
  • hough line detector(standard and probabilistic) with a scale in vertical and horizontal direction in boundingbox, respectively

EDLines

EDLines Simple Interface with Scale in Boundingbox

@param src         				image,single channel.

@param w           				width of image.

@param h           				height of image.

@param scaleX      				downscale factor in X-axis.

@param scaleY      				downscale factor in Y-axis.

@param bbox        				boundingbox to detect.

@param lines      				result.

@return            				0:ok; 1:error
int EdgeDrawingLineDetector(unsigned char *src, int w, int h,float scaleX, scaleY, boundingbox_t bbox, std::vector<line_float_t> &lines);

LSD

LSD Simple Interface with Scale in Boundingbox

@param src         				image,single channel.

@param w           				width of image.

@param h           				height of image.

@param scaleX      				downscale factor in X-axis.

@param scaleY      				downscale factor in Y-axis.

@param bbox       			 	boundingbox to detect.

@param lines       				result.

@return            				0:ok; 1:error
int LsdLineDetector(unsigned char *src, int w, int h, float scaleX, float scaleY, boundingbox_t bbox, std::vector<line_float_t> &lines);

Houghline

Houghline Simple Interface with Scale in Boundingbox

@param src         				image,single channel.

@param w           				width of image.

@param h           				height of image.

@param scaleX      			 	downscale factor in X-axis.

@param scaleY      			 	downscale factor in Y-axis.

@param canny_low_thresh      	lower threshold for the hysteresis procedure in canny operator.

@param canny_high_thresh      	higher threshold for the hysteresis procedure in canny operator.

@param hough_rho      			distance resolution of the accumulator in pixels.

@param hough_theta      		angle resolution of the accumulator in radians.

@param min_theta_linelength     standard: for standard and multi-scale hough transform, minimum angle to check for lines; propabilistic: minimum line length. Line segments shorter than that are rejected.

@param max_theta_gap      		standard: for standard and multi-scale hough transform, maximum angle to check for lines; propabilistic: maximum allowed gap between points on the same line to link them.

@param hough_thresh      		accumulator threshold parameter. only those lines are returned that get enough votes ( >threshold ).

@param _type      				hough line method: HOUGH_LINE_STANDARD or HOUGH_LINE_PROBABILISTIC

@param bbox        				boundingbox to detect.

@param lines       				result.

@return            				0:ok; 1:error
int HoughLineDetector(unsigned char *src, int w, int h, float scaleX, float scaleY, float CannyLowThresh, float CannyHighThresh, float HoughRho, float HoughTheta, float MinThetaLinelength, float MaxThetaGap, int HoughThresh, HOUGH_LINE_TYPE_CODE _type, boundingbox_t bbox, std::vector<line_float_t> &lines);

Reference

line_detector's People

Contributors

curiositykilledfrotms avatar frotms avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

line_detector's Issues

memory error

When I use the following image as input, the algorithm meets with a memory error in function
int EDLineDetector::EDline(image_int8u_p image, LineChains &lines, bool smoothed)
It seems to be a memory out of range error.
@frotms Could you please have a try and resolve the problem?
2

The wrong line segment

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

OpenCV version

Dear sir,

I am trying to use opencv c++ to implement paper title "Edge Drawing – A Combined Real-Time Edge/Edge Segment Detector" but I still can not make it done for part "anchor smart routing algorithm". Could you please help me by sharing the opencv version of this paper?

Thank you so much.

I don't know what the problem is

input image:
3
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:
QQ截图20201021162744

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.

Project license?

Hello, I'm interested in using this implementation for a project I'm working on, and I don't want to use your code without permission though, so I was wondering if it'd be possible for you to add a license to this repo. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.