Ask Your Question

Android optimization - line detection is slow - Hough Lines

asked 2013-12-14 16:50:38 -0500

NadKuris gravatar image

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.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-12-15 08:45:19 -0500

Java version of HoughLines calls native function from OpenCV. So, if you call it from native code its performance is approximately the same. As alternative you van try HoughLinesP function that uses probabilistic approach. In some cases it is much faster then classic version.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools


Asked: 2013-12-14 16:50:38 -0500

Seen: 2,021 times

Last updated: Dec 15 '13