OpenCV + Android关键点检测崩溃

时间:2015-04-15 17:47:08

标签: android opencv crash keypoint

我已经对这个问题进行了大量的研究并尝试了所有这些问题,而且没有一个能够发挥作用,所以现在是时候讨论一个新主题了。 我正在制作一个项目,用户可以从设备中选择一张图片,程序将返回相同的图片,并在其上绘制关键点。 我以前用openCV制作了另一个程序,现在在android上使用它的方式完全相同,只改变了显示它的方式而不是窗口,一个imageView。 这是imageView的代码:

public void setPic(View v){
    Intent in=new Intent(Intent.ACTION_GET_CONTENT);
    in.setType("image/*");
    startActivityForResult(in,FILE_REQUEST);
}
protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) { 
    super.onActivityResult(requestCode, resultCode, imageReturnedIntent); 

    switch(requestCode) { 
    case FILE_REQUEST:
        if(resultCode == RESULT_OK){  
            Uri selectedImage = imageReturnedIntent.getData();
            InputStream imageStream;
           // exception handle!!!
            try {
                imageStream = getContentResolver().openInputStream(selectedImage);
                Bitmap yourSelectedImage = BitmapFactory.decodeStream(imageStream);
                img.setImageBitmap(yourSelectedImage);

                keyPointDetection(selectedImage.getPath());
            } 

            catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }
    }
}

这应该是捕获关键点并从imageView输出所选图片的部分,其中包含关键点:

public static KeyPoint[] keyPointDetection(String filename){
    MatOfKeyPoint keypoints = new MatOfKeyPoint();

    FeatureDetector detector = FeatureDetector.create(FeatureDetector.ORB);
    neki = Highgui.imread(filename);

    detector.detect(neki, keypoints);
    KeyPoint[] keypoint = keypoints.toArray();

    Bitmap resultBitmap = Bitmap.createBitmap(keypoints.cols(),keypoints.rows(),Bitmap.Config.ARGB_8888);;
    Features2d.drawKeypoints(neki,keypoints,neki);
    Utils.matToBitmap(keypoints, resultBitmap);

    Highgui.imwrite("keypoints.jpg",neki);


    return keypoint;
}

程序在LogCat中崩溃了以下几行:

04-15 17:27:30.251: E/AndroidRuntime(9915): FATAL EXCEPTION: main
04-15 17:27:30.251: E/AndroidRuntime(9915): Process:  com.example.protorypemk2, PID: 9915
04-15 17:27:30.251: E/AndroidRuntime(9915): java.lang.UnsatisfiedLinkError: No implementation found for long org.opencv.core.Mat.n_Mat() (tried Java_org_opencv_core_Mat_n_1Mat and Java_org_opencv_core_Mat_n_1Mat__)
04-15 17:27:30.251: E/AndroidRuntime(9915):     at org.opencv.core.Mat.n_Mat(Native Method)
04-15 17:27:30.251: E/AndroidRuntime(9915):     at org.opencv.core.Mat.<init>(Mat.java:447)
04-15 17:27:30.251: E/AndroidRuntime(9915):     at org.opencv.core.MatOfKeyPoint.<init>(MatOfKeyPoint.java:14)
04-15 17:27:30.251: E/AndroidRuntime(9915):     at com.example.protorypemk2.MainActivity.keyPointDetection(MainActivity.java:48)
04-15 17:27:30.251: E/AndroidRuntime(9915):     at com.example.protorypemk2.MainActivity.onActivityResult(MainActivity.java:81)
04-15 17:27:30.251: E/AndroidRuntime(9915):     at android.app.Activity.dispatchActivityResult(Activity.java:6135)
04-15 17:27:30.251: E/AndroidRuntime(9915):     at android.app.ActivityThread.deliverResults(ActivityThread.java:3564)
04-15 17:27:30.251: E/AndroidRuntime(9915):     at android.app.ActivityThread.handleSendResult(ActivityThread.java:3611)
04-15 17:27:30.251: E/AndroidRuntime(9915):     at android.app.ActivityThread.access$1400(ActivityThread.java:147)
04-15 17:27:30.251: E/AndroidRuntime(9915):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1345)
04-15 17:27:30.251: E/AndroidRuntime(9915):     at android.os.Handler.dispatchMessage(Handler.java:102)
04-15 17:27:30.251: E/AndroidRuntime(9915):     at android.os.Looper.loop(Looper.java:135)
04-15 17:27:30.251: E/AndroidRuntime(9915):     at android.app.ActivityThread.main(ActivityThread.java:5254)
04-15 17:27:30.251: E/AndroidRuntime(9915):     at java.lang.reflect.Method.invoke(Native Method)
04-15 17:27:30.251: E/AndroidRuntime(9915):     at java.lang.reflect.Method.invoke(Method.java:372)
04-15 17:27:30.251: E/AndroidRuntime(9915):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
04-15 17:27:30.251: E/AndroidRuntime(9915):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
04-15 17:27:35.898: E/art(9915): No implementation found for void org.opencv.core.Mat.n_delete(long) (tried Java_org_opencv_core_Mat_n_1delete and Java_org_opencv_core_Mat_n_1delete__J)
04-15 17:27:35.898: E/System(9915): Uncaught exception thrown by finalizer
04-15 17:27:35.902: E/System(9915): java.lang.UnsatisfiedLinkError: No implementation found for void org.opencv.core.Mat.n_delete(long) (tried Java_org_opencv_core_Mat_n_1delete and Java_org_opencv_core_Mat_n_1delete__J)
04-15 17:27:35.902: E/System(9915):     at org.opencv.core.Mat.n_delete(Native Method)
04-15 17:27:35.902: E/System(9915):     at org.opencv.core.Mat.finalize(Mat.java:2475)
04-15 17:27:35.902: E/System(9915):     at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:190)
04-15 17:27:35.902: E/System(9915):     at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:173)
04-15 17:27:35.902: E/System(9915):     at java.lang.Thread.run(Thread.java:818)

我提前感谢你们。

0 个答案:

没有答案