2

I use opencv stitching in android project.

public class MainActivity extends Activity implements OnClickListener {

    private String mWarpType;
    private String mMatchConf;
    private String mConfThresh;

    private SharedPreferences mSettings;
    public static final String SETTINGS                = "Pano_Settings";

    private final String SETTINGS_WARP_TYPE            = "warp";
    private final String SETTINGS_MATCH_CONF           = "match_conf";
    private final String SETTINGS_CONF_THRESH          = "conf_thresh";

    private String mDefaultWarpType                    = "spherical";
    private String mDefaultMatchConf                   = "0.5";
    private String mDefaultConfThresh                  = "0.8";
    ...

    public native int Stitch(Object[] args);    

    public void onClick(View v) {
      switch (v.getId()) {
      case R.id.GoButton:

          List<String> s = new ArrayList<String>();
          s.add("Stitch");
          s.add("/sdcard/tesseract/images1.jpeg");
          s.add("/sdcard/tesseract/images2.jpeg");

          s.add("--warp");
          s.add(mWarpType);
          s.add("--conf_thresh");
          s.add(mConfThresh);
          s.add("--match_conf");
          s.add(mMatchConf);

          s.add("--work_megapix");
          s.add("0.2");
          s.add("--seam_megapix");
          s.add("0.2");
          s.add("--expos_comp");
          s.add("gain");
          s.add("--output");
          s.add("/sdcard/tesseract/");

          Integer i = Stitch(s.toArray());
          Log.d("1",i.toString());
        break;
      default:
        break;
      }
    }

}

application is started but when Stitch(s.toArray()) is called I get the error:

W/dalvikvm(15392): No implementation found for native Lcom/prototype/MainActivity;.Stitch ([Ljava/lang/Object;)I

OpenCV successfully added in the workplace and my project -> Properties -> Android -> Library add -> OpenCV lib project version OpenCV 2.4.2. sample was taken from the project android-opencv-panorama.

Nar
  • 540
  • 1
  • 9
  • 22

1 Answers1

4

You probably copied the native code "as is" from the sample, but your Java class has a different package and name. Look for the function named Java_<some more>_Stitch() in your cpp file, and rename it to become:

Java_com_prototype_MainActivity_Stitch()
Alex Cohn
  • 56,089
  • 9
  • 113
  • 307