Opencv-structured-forest or Fast-edge-detection (Android onPreviewFrame) too slow

asked 2017-11-17 07:48:35 -0500

shyam kumar gravatar image

I am using Java wrapper class to do this feature by opencv extra modules(Ximgproc) . this is the code below,

Mat resizeMat = /* frames from android camera */ ;              
StructuredEdgeDetection pDollar = createStructuredEdgeDetection("path_of_model.yml.gz");
Mat src = new Mat();
resizeMat.convertTo(src, CV_32F, 1.0 / 255.0);
Mat edges = new Mat(src.size(), src.type());
pDollar.detectEdges(src, edges);
Mat output = new Mat();
edges.convertTo(output, CV_8UC1, 255.0);
Imgproc.findContours(output, contours, new Mat(),Imgproc.RETR_TREE, Imgproc.CHAIN_APPROX_SIMPLE);

It's getting too slow to process for each frame (900 - 1000 ms) referred link in stack-overflow

Blockquote

edit retag flag offensive close merge delete

Comments

Are you re-creating the structured edge detection object every time? Move that to a variable and construct it once.

Are you including the contours in your time? How about all those conversions? How much time is spent in the edge detection and how much is in the other processing?

Tetragramm gravatar imageTetragramm ( 2017-11-17 20:45:27 -0500 )edit

structured edge detection object moved to global variable , still i am facing the same,

pDollar.detectEdges(src, edges);`//this line alone takes too much time(0.9 - 1) secs

normally when i try to use grey conversion,blur,canny,morph operations algorithm simultaneously it performs faster(0.4 - 0.5) secs but I need accuracy so I moved to SED

shyam kumar gravatar imageshyam kumar ( 2017-11-18 06:20:01 -0500 )edit

Well, that may just be how long it takes. I can't say I've benchmarked it, but since it's more accurate, it probably takes longer.

Do you have a particular reason for saying it takes too long? Or is it just too long for what you need?

Tetragramm gravatar imageTetragramm ( 2017-11-18 08:43:37 -0500 )edit