Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Why huge performance gap between opencv c++ native and java code on Android?

Hi guys, just wonder if anybody have hit similar cases?

The strange thing is: the android java code, e.g., GaussianBlur() is stably 4~5x fast, comparing to calling the same function in c++ native code on android.

For a 1920x1080 image, java needs around 40~50ms in HTC820mu (snapdragon 615, https://www.qualcomm.com/products/snapdragon/processors/615) & HTC one M9 (snapdragon 810, https://www.qualcomm.com/products/snapdragon/processors/810 ). The native c++ code needs 200+ ms.

For the same image, iMac with 3GHz i5 processor and opencv with SSE enabled, running the same op (c++ code) costs around ~15 ms.

I thought the android java performance number is reasonable (1/2 ~ 1/3 of that of iMac) considering the float point performance gap between low-freq ARM and high-freq x86-64. However I dont understand why the native c++ API calling is so slow since the java API is implemented with native c/c++ method (GaussianBlur_0(...) - which I failed to locate it in opencv source ).

BTW: I have tried both the OpenCV4Android 3.4.1 and the same version built by myself. Both of them have NEON enabled, VFP3 disabled and use softfp-abi.

Any ideas? Thanks much!

Why huge performance gap between opencv c++ native and java code on Android?

Hi guys, just wonder if anybody have hit similar cases?case?

The strange thing is: the android java code, e.g., GaussianBlur() is stably 4~5x fast, comparing to calling the same function in c++ native code on android.

For a 1920x1080 image, java needs around 40~50ms in HTC820mu (snapdragon 615, https://www.qualcomm.com/products/snapdragon/processors/615) & HTC one M9 (snapdragon 810, https://www.qualcomm.com/products/snapdragon/processors/810 ). The native c++ code needs 200+ ms.

For the same image, iMac with 3GHz i5 processor and opencv with SSE enabled, running the same op (c++ code) costs around ~15 ms.

I thought the android java performance number is reasonable (1/2 ~ 1/3 of that of iMac) considering the float point performance gap between low-freq ARM and high-freq x86-64. However I dont understand why the native c++ API calling is so slow since the java API is implemented with native c/c++ method (GaussianBlur_0(...) - which I failed to locate it in opencv source ).

BTW: I have tried both the OpenCV4Android 3.4.1 and the same version built by myself. Both of them have NEON enabled, VFP3 disabled and use softfp-abi.

Any ideas? Thanks much!