3
我試圖像拼接全景在android.I圖像正在使用的Android NDK和OpenCv庫that.I正在使用JNI下面的代碼拼接圖像圖像拼接
第一種方法:
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");
}
上面的代碼工作正常的一些圖片,但如果我把使用攝像機的圖像,並嘗試縫合,使用上面的代碼圖像,則它不會working.I我使用下面的代碼調用在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其可用的代碼here。在這個代碼我得到的未定義參考編譯錯誤拼接圖像`CV :: SURF :: SURF(雙,INT,INT,BOOL,BOOL)」。雖然我已經包括了所有在頭和也NDK.I的構建路徑必要的庫無法理解的問題是什麼?
任何人的你有關於任何圖像拼接或任何其他新的想法或方法的以上兩種方法對圖像拼接的話,請提前提出me.Thanks任何想法。