Ask Your Question
2

Performance issues on porting warpPerspective into my project

asked 2012-06-29 10:55:07 -0600

erdna gravatar image

updated 2012-06-29 10:59:20 -0600

Hello all,

I wanted to create a modified version of OpenCV warpPerspective to run on my tablet. To begin, I downloaded the OpenCV source code, located the warpPerspective function inside the imgwarp.cpp and copied it into mine JNI file.

I changed the arguments as follows:

    JNIEXPORT void JNICALL Java_com_myproject_project_Sample4View_WarpPerspective2( JNIEnv* env, jobject thiz, jlong _src, jlong _dst, jlong _M0,
jdouble dsizeRows, jdouble dsizeCols, int flags, int borderType, jint scalar0, jint scalar1, jint scalar2, jint scalar3 )
    {

        Scalar borderValue = Scalar(scalar0, scalar1, scalar2, scalar3);
        Size dsize = Size(dsizeRows,dsizeCols);
        Mat* src = (Mat*)_src, *M0 = (Mat*)_M0;
        //_dst.create( dsize.area() == 0 ? src.size() : dsize, src.type() );
        Mat* dst = (Mat*)_dst;


        CV_Assert( (*src).cols > 0 && (*src).rows > 0 );
        if( (*dst).data == (*src).data )
            *src = (*src).clone();


    (...)

    }

This function is working as it is. But a noticeable performance loss occurs when comparing with the original warpPerspective.

Can anyone explain me why is this happening? Could it be the way it is being compiled?I am really struggling with this and have no idea....

Thank you!

edit retag flag offensive close merge delete

Comments

Could you specify how much is that 'noticeable performance loss'? How long the original and modified warpPerspective() take on your device?

Andrey Pavlenko gravatar imageAndrey Pavlenko ( 2012-07-06 08:26:25 -0600 )edit

Thank you for asking. With the original warpPerspective I get around 7 fps while with de modified one I get 5 Fps. It is a loss of around 30%...

erdna gravatar imageerdna ( 2012-07-09 06:59:22 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2012-07-11 04:29:56 -0600

Andrey Pavlenko gravatar image

The prebuilt binaries distributed with OpenCV for Android SDK are built with CMake + Android toolchain file that uses a bit different (and possibly more effective) compilation and linking options than the ndk-build script.

edit flag offensive delete link more

Comments

Can you say more about these compilation options?

Adi gravatar imageAdi ( 2012-07-18 04:59:55 -0600 )edit

Question Tools

Stats

Asked: 2012-06-29 10:55:07 -0600

Seen: 867 times

Last updated: Jul 11 '12