Solving native open cv code error in for developing panorama on android

asked 2015-02-18 09:03:49 -0600

I am trying to develop an android application for generating panoramic images usig feature of image stitching in Open CV.

I have used the code give on the site given below.

There is an error shown in the log cat shown below. Please guide me how to solve the error.

enter image description here

This is the Native call for stitching images.


#include < jni.h >
#include <opencv2/core/core.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/calib3d/calib3d.hpp>
#include <opencv2/stitching/stitcher.hpp>

#include < vector >
#include < iostream >
#include < stdio.h >
#include < list >
#include< sstream >
#include< string >

using namespace std;
using namespace cv;

extern "C" {
//JNIEXPORT Mat JNICALL Java_org_opencv_samples_tutorial3_Sample3Native_FindFeatures(JNIEnv*, jobject, jlong addrGray, jlong addrRgba)

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;
    // New testing
    Mat& temp1 = *((Mat*) im1);
    Mat& temp2 = *((Mat*) im2);
    Mat& pano = *((Mat*) im3);

    for (int k = 0; k < no_images; ++k) {
        string id;
        ostringstream convert;
        convert << k;
        id = convert.str();
        Mat img = imread("/storage/emulated/0/panoTmpImage/im" + id + ".jpeg");


    Stitcher stitcher = Stitcher::createDefault(try_use_gpu);
    Stitcher::Status status = stitcher.stitch(imgs, pano);



This is the file which i have created having no idea on how to generate it.

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

include ../../android-development/OpenCV-2.4.10-android-sdk/OpenCV-2.4.10-android-sdk/sdk/native/jni/

LOCAL_MODULE    := native_activity
LOCAL_SRC_FILES := native.cpp
LOCAL_LDLIBS    += -lm -llog -landroid
LOCAL_STATIC_LIBRARIES += android_native_app_glue


$(call import-module,android/native_app_glue)

And this is the Main Android code that has main GUI and calls the OpenCV function

package org.opencv.samples.tutorial3;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.core.Point;
import org.opencv.core.Scalar;
import org.opencv.highgui.Highgui;

import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;

public class Sample3Native extends Activity implements CvCameraViewListener {
    private static final String TAG = "OCVSample::Activity";

    public static final int VIEW_MODE_RGBA = 0;
    public static final int SAVE_IMAGE_MAT = 1;
    public static final int CAPT_STILL_IM = 2;
    private static int viewMode = VIEW_MODE_RGBA;
//  public static int image_count = 0;
    private MenuItem mStitch;
    private MenuItem mItemCaptureImage;
    private Mat mRgba;
    private Mat mGrayMat;
    private Mat panorama;
    private Mat mtemp;
    private List < Mat > images_to_be_stitched = new ArrayList < Mat >();
    private CameraBridgeViewBase mOpenCvCameraView;
    private long mPrevTime = new Date().getTime();
    private static final int FRAME2GRAB = 10;
    private int mframeNum = 0;
    private static ...
edit retag flag offensive close merge delete