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!
Could you specify how much is that 'noticeable performance loss'? How long the original and modified warpPerspective() take on your device?
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%...