简体   繁体   中英

C++ native OpenCV to opencv4android port too slow?

I am porting some C++ OpenCV desktop code to Android and using opencv4android. I am planning to switch to NTK eventually but for now, since I am very new to Android development, I thought it would be easier to proceed that way.

The OpenCV function takes 37ms on my i7-4790 desktop (single thread and no GPU). The function on Android Nexus 4 takes 10,557ms. I knew I could expect some slowdown with the java to native call overhead but that huge difference seems hard to explain. I am doing a lot of per-pixel operations with get/put but on relatively small images (about 500x500px).

I put my opencv function in the following method:

private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {

    @Override
    public void onManagerConnected(int status) {

        switch (status) {
            case LoaderCallbackInterface.SUCCESS:
            {
                 // opencv4android code
                 ...
            }
        }
    }
}

Is there something wrong (maybe related to threading) or that performance is normal ? What kind of slowdown should I expect ? How about with NTK ?

Many thanks,

Guillaume

For those interested, I just finished the NTK version. It takes about 125ms, so the speedup is indeed considerable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM