Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Performance issues on porting warpPerspective into my project

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!

Performance issues on porting warpPerspective into my project

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!