OpenCV的使用android系统中图像拼接 [英] Image stitching in android using OpenCV

查看:2422
本文介绍了OpenCV的使用android系统中图像拼接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我使用的是Android NDK和 OpenCV的为that.I库缝合像全景在android.I图片使用下面的JNI code为拼接图像正在

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

第一种方法:

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");
   }

以上code是工作的罚款对一些图像,但如果我把使用摄像机的图像,并尝试使用上面code的图像缝合那就不是working.I现在用低于code调用本地$从Android的C $ç

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);

方法声明

public native void FindFeatures(long image1, long image2, long image3,int count);

第二种方法:

我也尝试使用拼接图像SurfFeatureDetector的$ C提供$ C <一个href=\"http://stackoverflow.com/questions/11134667/some-problems-on-image-stitching-homography\">here.In这$ C $词得到了未定义的参考`CV :: SURF :: SURF(双,INT,INT,布尔,布尔)。虽然我已经包括了所有必要的库中的编译错误头和也NDK.I的构建路径无法理解是什么问题?

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?

你们任何人有任何有关图像拼接或其他任何新的想法或方法的上述两种方法图像拼接的话,请提前提出me.Thanks任何想法。

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.

推荐答案

关于编译错误:看来你没有正确链接OpenCV的,或者你错过添加LIB文件。
检查是否添加这些库,如果您使用的是调试模式OpenCV的2.x.x:

Concerning the compilation error: It seems that you don't link opencv properly, or you miss adding the lib files. check that you add these libs if you are using Debug mode OpenCV 2.x.x:

opencv_nonfree2xxd.lib

opencv_nonfree2xxd.lib

opencv_features2d2xxd.lib

opencv_features2d2xxd.lib

这篇关于OpenCV的使用android系统中图像拼接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆