I am trying to stitch images like Panorama View in android.I am using Android NDK and OpenCv library for that.I am using below code of Jni for stitching images
First Method:
extern "C" {
JNIEXPORT void JNICALL Java_org_opencv_samples_tutorial3_Sample3Native_FindFeatures(
JNIEnv*, jobject, jlong im1, jlong im2, jlong im3, jint no_images) {
vector<Mat> imgs;
bool try_use_gpu = false;
Mat& temp1 = *((Mat*) im1);
Mat& temp2 = *((Mat*) im2);
Mat& pano = *((Mat*) im3);
__android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "Before stitching Images\n...");
if(temp1.empty() || temp2.empty())
{
__android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "Can’t read one of the images\n...");
printf("Can’t read one of the images\n");
}
else{
imgs.push_back(temp1);
imgs.push_back(temp2);
Stitcher stitcher = Stitcher::createDefault(try_use_gpu);
Stitcher::Status status = stitcher.stitch(imgs, pano);
if (status != Stitcher::OK)
{
__android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "Can't stitch images, error code = %i" +status);
}
else
{
__android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "Stitching Image Successfully");
}
Above code is working fine for some images but If I take images using camera and try to stitch that images using above code then it’s not working.I am using below code for calling native code from android
FindFeatures(Highgui.imread(path + "Pano1.jpg").getNativeObjAddr(), Highgui.imread(path+"Pano2.jpg").getNativeObjAddr(),panorama.getNativeObjAddr(), 2);
Highgui.imwrite(StitchImageDir.getPath()+ File.separator + "panoStich"+dateFormat.format(dateNow) +mImageExt, panorama);
Method Declaration
public native void FindFeatures(long image1, long image2, long image3,int count);
Second Method:
I have also tried to stitch images using SurfFeatureDetector whose code available here.In this code i got the compilation error of undefined reference to `cv::SURF::SURF(double, int, int, bool, bool)'.Although I have included all the necessary libraries in header and also in build path of NDK.I can't understand what is the problem is?
Anyone of you have any idea regarding any of the above two methods of image stitching or any other new idea or method for image stitching then please suggest me.Thanks in advance.