Ask Your Question

Can you detect rectangles with OpenCV 2.4.4?

asked 2013-03-15 18:26:28 -0500

MysticBE gravatar image

updated 2013-03-16 19:36:16 -0500

I've been wondering about this since I can't find any solid information about detecting rectangles with the OpenCV Library 2.4.4. Is this possible after a Canny edge detection to find the largest rectangle? I could only find some C code (the top answer of the 2).

Is there a way to do this with Java? Cause I can't get the C-code to work in the Java Native Interface part of the application (I find it kind of confusing). Does anyone have any good tutorials on writing the code from the JNI part (needs to be more then C-code i assume) or a Java/OpenCV Library implementation to do this?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-03-16 08:43:07 -0500

Guanta gravatar image

What is your concrete problem? Maybe you want to post what you have so far and let us know what doesn't work or where you have problems.

The following links may also help you to detect rectangles: and

edit flag offensive delete link more


Finding the C code isn't the problem (although a big thanks for that) but I can't seem to implement it in the JNI part of the Android project. Is there a tutorial on how to do that? Cause when i copy paste the code to my .cpp file in the JNI part everything seems to be an error (even the #include parts)

MysticBE gravatar imageMysticBE ( 2013-03-16 09:27:04 -0500 )edit

So I am not experienced in programming for Android, neither coding in Java. Basically, you need to transfer the code from C/C++ to Java. Or am I wrong? This shouldn't be too difficult. Replace the #includes to imports, e.g. import org.opencv.imgproc.Imgproc and then you can use any imageproc function, e.g. ImgProc.Canny(...) , the structure of the parameters should be the same, of course some data-types are different, e.g. Lists (or ArrayList?) vs std::vector. Some examples you'll find below samples/java and if you search here in the forum or via any search-machine. The java-api you'll find at . Good luck!

Guanta gravatar imageGuanta ( 2013-03-17 13:36:31 -0500 )edit

Question Tools


Asked: 2013-03-15 18:26:28 -0500

Seen: 18,299 times

Last updated: Mar 16 '13