Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any disadvantages about the Android OpenCV port?

I've worked with OpenCV in combination with Android before and what I always tried to do is to use as few calls as possible between my native code and my java code. When I look at the OpenCV port for Android though, it seems like they just create a wrapper function for every native function and call these from java. Now unless I totally misunderstand the principal of swig wrappers and the whole idea of this port, won't this be a lot slower than doing the actual coding in native code? I noticed that passing data between native code and java code is really slow, so I don't get why it seems to be the most normal thing in this port.

I did use it myself, but I just decided to ignore all the wrappers and use the code as it is and create my own wrapper using the normal way presented by Android tutorials.

So my question is, am I just wrong about the disadvantages? Or are they actually there and what is the real advantage of using OpenCV in this was? I know these questions are somewhat informal, but I hope you guys can help me out.

like image 350
Pandoro Avatar asked Dec 09 '10 13:12

Pandoro


1 Answers

I can't give you the answer you're looking for, but here's what I think: there are many examples of JNI layers that wrap every native function - OpenGL, Android's Canvas, etc. Calling trough JNI is slower than working entirely in native code, but the question is does it make any difference for a concrete application? I believe in the majority of cases this time penalty is ignorable in comparison with the time spent inside the native functions. However I favor doing as much work as possible in native code for Android apps, not mainly because of the faster execution, but because Java is awkward language compared to C and C++.

like image 149
ognian Avatar answered Oct 09 '22 11:10

ognian