Question

in my project I need to detect lines in image. I actually have to detect rows and columns inside rectangle. I use OpenCV to accomplish this. I have done it succesfuly but it's kinda slow. I use many functions to preprocess the image - e.g. thresholding, canny, dilation, gaussian blur etc.

I use HoughLines like this

Imgproc.HoughLines(image, lines, 1, Math.PI/90 , threshold, minLineSize, maxGap);

It takes about 2.5 s to complete my program which has ~ 600 lines. But on this one line it takes 2.2 s. As you can see I use Java interface for OpenCV. Is it possible to optimize it someway? Would rewriting my program to NDK make it faster? If I understand OpenCV4Android, than it's just wrapper for functions written in NDK, so I don't think it would be faster. Or is there better and faster approach to detect lines in image? Thanks for any advice.

Was it helpful?

Solution

Can you count the number of lines returned from HoughLines - if there are 1000's then it will likely take that sort of time to generate.

I'd recommend changing your Canny settings to reduce the number of edges that HoughLines needs to work on if possible.

Also, you can try different parameters for HoughLines. My values of 80, 30 and 10 respectively for the call to HoughLines seems to give manageable results.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top