0

私はバージョン 2.3.5 と 4.0.4 の Android で作業していますが、同じコードの実行時に両方のバージョンがクラッシュします。ビデオからフレームを取得して保存し、HSV に変換しようとしています。

(私はこの同じ質問をopencvウェブサイトに投稿しましたこちら

これは私のコードであり、私が得るエラーです。

  public void process(){
        IplImage orgImg = this.getFrame(2);
                cvSaveImage(Environment.getExternalStorageDirectory().toString() + "/openCV/orgimg.jpg", orgImg);
                IplImage hsv = hsv(orgImg);
    }

    private IplImage getFrame(int id){
            File testfile = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + videoFile);

            if(testfile.canRead()){ 

                FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(testfile);  
                try {
                    grabber.start();
                    grabber.setFrameNumber(id);
                    final int height=grabber.getImageHeight();
                    final int width=grabber.getImageWidth();
                    IplImage frame = IplImage.create(width, height, 8, 4);
                    frame = grabber.grab();
                    //grabber.stop();
                    return frame;
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return null;
        }

private IplImage hsv(IplImage orgImg) {
        // 8-bit, 3- color =(RGB)
        IplImage imgHSV = cvCreateImage(cvGetSize(orgImg), 8, 3);
        Log.e(TAG,"hsvThreshold - Image size" + cvGetSize(orgImg));
        cvCvtColor(orgImg, imgHSV, CV_BGR2HSV);

        return imgHSV;
    }

これは、4.0.4 を実行しているデバイスで cvSaveImage または cvCvtColor を実行したときに取得する logcat です。

08-07 12:26:25.974: I/dalvikvm(6719): "main" prio=5 tid=1 NATIVE
08-07 12:26:25.974: I/dalvikvm(6719):   | group="main" sCount=0 dsCount=0 obj=0x40bf1460 self=0x101aca8
08-07 12:26:25.974: I/dalvikvm(6719):   | sysTid=6719 nice=0 sched=0/0 cgrp=default handle=1074673032
08-07 12:26:25.974: I/dalvikvm(6719):   | schedstat=( 0 0 0 ) utm=710 stm=34 core=0
08-07 12:26:25.974: I/dalvikvm(6719):   at java.lang.Runtime.nativeLoad(Native Method)
08-07 12:26:25.974: I/dalvikvm(6719):   at java.lang.Runtime.nativeLoad(Native Method)
08-07 12:26:25.974: I/dalvikvm(6719):   at java.lang.Runtime.loadLibrary(Runtime.java:368)
08-07 12:26:25.974: I/dalvikvm(6719):   at java.lang.System.loadLibrary(System.java:535)
08-07 12:26:25.974: I/dalvikvm(6719):   at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:593)
08-07 12:26:25.974: I/dalvikvm(6719):   at com.googlecode.javacpp.Loader.load(Loader.java:489)
08-07 12:26:25.974: I/dalvikvm(6719):   at com.googlecode.javacpp.Loader.load(Loader.java:431)
08-07 12:26:25.974: I/dalvikvm(6719):   at com.googlecode.javacv.cpp.opencv_imgproc.<clinit>(opencv_imgproc.java:97)
08-07 12:26:25.974: I/dalvikvm(6719):   at java.lang.Class.classForName(Native Method)
08-07 12:26:25.974: I/dalvikvm(6719):   at java.lang.Class.forName(Class.java:217)
08-07 12:26:25.974: I/dalvikvm(6719):   at com.googlecode.javacpp.Loader.load(Loader.java:453)
08-07 12:26:25.974: I/dalvikvm(6719):   at com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:85)
08-07 12:26:25.974: I/dalvikvm(6719):   at ch.golfer.TrackSpot.process(TrackSpot.java:-1)
08-07 12:26:25.974: I/dalvikvm(6719):   at ch.golfer.FullscreenActivity$7.onClick(FullscreenActivity.java:196)
08-07 12:26:25.974: I/dalvikvm(6719):   at android.view.View.performClick(View.java:3627)
08-07 12:26:25.974: I/dalvikvm(6719):   at android.view.View$PerformClick.run(View.java:14305)
08-07 12:26:25.974: I/dalvikvm(6719):   at android.os.Handler.handleCallback(Handler.java:605)
08-07 12:26:25.974: I/dalvikvm(6719):   at android.os.Handler.dispatchMessage(Handler.java:92)
08-07 12:26:25.974: I/dalvikvm(6719):   at android.os.Looper.loop(Looper.java:137)
08-07 12:26:25.974: I/dalvikvm(6719):   at android.app.ActivityThread.main(ActivityThread.java:4511)
08-07 12:26:25.974: I/dalvikvm(6719):   at java.lang.reflect.Method.invokeNative(Native Method)
08-07 12:26:25.974: I/dalvikvm(6719):   at java.lang.reflect.Method.invoke(Method.java:511)
08-07 12:26:25.974: I/dalvikvm(6719):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:976)
08-07 12:26:25.974: I/dalvikvm(6719):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:743)
08-07 12:26:25.974: I/dalvikvm(6719):   at dalvik.system.NativeStart.main(Native Method)
08-07 12:26:25.974: E/dalvikvm(6719): VM aborting
08-07 12:26:25.974: A/libc(6719): Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1)

これは 2.3.5 デバイスの logcat です。

08-07 12:32:05.503: E/javacpp(995): Error loading class com/googlecode/javacpp/Pointer.
08-07 12:32:09.620: I/dalvikvm(995): threadid=4: reacting to signal 3
08-07 12:32:10.620: W/dalvikvm(995): threadid=4: spin on suspend #1 threadid=1 (pcf=0)
08-07 12:32:11.370: W/dalvikvm(995): threadid=4: spin on suspend #2 threadid=1 (pcf=0)
08-07 12:32:11.370: I/dalvikvm(995): "Signal Catcher" daemon prio=5 tid=4 RUNNABLE
08-07 12:32:11.370: I/dalvikvm(995):   | group="system" sCount=0 dsCount=0 obj=0x4050e148 self=0x288d08
08-07 12:32:11.370: I/dalvikvm(995):   | sysTid=999 nice=0 sched=0/0 cgrp=default handle=2078152
08-07 12:32:11.370: I/dalvikvm(995):   at dalvik.system.NativeStart.run(Native Method)
08-07 12:32:11.370: I/dalvikvm(995): "main" prio=5 tid=1 RUNNABLE
08-07 12:32:11.370: I/dalvikvm(995):   | group="main" sCount=1 dsCount=0 obj=0x4001f190 self=0xce60
08-07 12:32:11.370: I/dalvikvm(995):   | sysTid=995 nice=0 sched=0/0 cgrp=default handle=-1345006496
08-07 12:32:11.456: I/dalvikvm(995):   at java.lang.Runtime.nativeLoad(Native Method)
08-07 12:32:11.472: I/dalvikvm(995):   at java.lang.Runtime.nativeLoad(Native Method)
08-07 12:32:11.476: I/dalvikvm(995):   at java.lang.Runtime.loadLibrary(Runtime.java:432)
08-07 12:32:11.488: I/dalvikvm(995):   at java.lang.System.loadLibrary(System.java:554)
08-07 12:32:11.507: I/dalvikvm(995):   at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:593)
08-07 12:32:11.511: I/dalvikvm(995):   at com.googlecode.javacpp.Loader.load(Loader.java:489)
08-07 12:32:11.519: I/dalvikvm(995):   at com.googlecode.javacpp.Loader.load(Loader.java:431)
08-07 12:32:11.527: I/dalvikvm(995):   at com.googlecode.javacv.cpp.opencv_imgproc.<clinit>(opencv_imgproc.java:97)
08-07 12:32:11.530: I/dalvikvm(995):   at java.lang.Class.classForName(Native Method)
08-07 12:32:11.534: I/dalvikvm(995):   at java.lang.Class.forName(Class.java:234)
08-07 12:32:11.542: I/dalvikvm(995):   at com.googlecode.javacpp.Loader.load(Loader.java:453)
08-07 12:32:11.550: I/dalvikvm(995):   at com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:85)
08-07 12:32:11.554: I/dalvikvm(995):   at ch.golfer.TrackSpot.process(TrackSpot.java:-1)
08-07 12:32:11.562: I/dalvikvm(995):   at ch.golfer.FullscreenActivity$7.onClick(FullscreenActivity.java:196)
08-07 12:32:11.570: I/dalvikvm(995):   at android.view.View.performClick(View.java:2538)
08-07 12:32:11.581: I/dalvikvm(995):   at android.view.View$PerformClick.run(View.java:9152)
08-07 12:32:11.589: I/dalvikvm(995):   at android.os.Handler.handleCallback(Handler.java:587)
08-07 12:32:11.593: I/dalvikvm(995):   at android.os.Handler.dispatchMessage(Handler.java:92)
08-07 12:32:11.605: I/dalvikvm(995):   at android.os.Looper.loop(Looper.java:130)
08-07 12:32:11.616: I/dalvikvm(995):   at android.app.ActivityThread.main(ActivityThread.java:3688)
08-07 12:32:11.620: I/dalvikvm(995):   at java.lang.reflect.Method.invokeNative(Native Method)
08-07 12:32:11.624: I/dalvikvm(995):   at java.lang.reflect.Method.invoke(Method.java:507)
08-07 12:32:11.632: I/dalvikvm(995):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
08-07 12:32:11.640: I/dalvikvm(995):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
08-07 12:32:11.648: I/dalvikvm(995):   at dalvik.system.NativeStart.main(Native Method)
08-07 12:32:12.405: W/dalvikvm(995): threadid=4: spin on suspend #3 threadid=1 (pcf=0)
08-07 12:32:12.405: I/dalvikvm(995): "Signal Catcher" daemon prio=5 tid=4 RUNNABLE
08-07 12:32:12.405: I/dalvikvm(995):   | group="system" sCount=0 dsCount=0 obj=0x4050e148 self=0x288d08
08-07 12:32:12.405: I/dalvikvm(995):   | sysTid=999 nice=0 sched=0/0 cgrp=default handle=2078152
08-07 12:32:12.405: I/dalvikvm(995):   at dalvik.system.NativeStart.run(Native Method)
08-07 12:32:12.405: I/dalvikvm(995): "main" prio=5 tid=1 RUNNABLE
08-07 12:32:12.405: I/dalvikvm(995):   | group="main" sCount=1 dsCount=0 obj=0x4001f190 self=0xce60
08-07 12:32:12.405: I/dalvikvm(995):   | sysTid=995 nice=0 sched=0/0 cgrp=default handle=-1345006496
08-07 12:32:12.460: I/dalvikvm(995):   at java.lang.Runtime.nativeLoad(Native Method)
08-07 12:32:12.472: I/dalvikvm(995):   at java.lang.Runtime.nativeLoad(Native Method)
08-07 12:32:12.480: I/dalvikvm(995):   at java.lang.Runtime.loadLibrary(Runtime.java:432)
08-07 12:32:12.484: I/dalvikvm(995):   at java.lang.System.loadLibrary(System.java:554)
08-07 12:32:12.488: I/dalvikvm(995):   at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:593)
08-07 12:32:12.488: I/dalvikvm(995):   at com.googlecode.javacpp.Loader.load(Loader.java:489)
08-07 12:32:12.488: I/dalvikvm(995):   at com.googlecode.javacpp.Loader.load(Loader.java:431)
08-07 12:32:12.488: I/dalvikvm(995):   at com.googlecode.javacv.cpp.opencv_imgproc.<clinit>(opencv_imgproc.java:97)
08-07 12:32:12.488: I/dalvikvm(995):   at java.lang.Class.classForName(Native Method)
08-07 12:32:12.488: I/dalvikvm(995):   at java.lang.Class.forName(Class.java:234)
08-07 12:32:12.488: I/dalvikvm(995):   at com.googlecode.javacpp.Loader.load(Loader.java:453)
08-07 12:32:12.488: I/dalvikvm(995):   at com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:85)
08-07 12:32:12.488: I/dalvikvm(995):   at ch.golfer.TrackSpot.process(TrackSpot.java:-1)
08-07 12:32:12.488: I/dalvikvm(995):   at ch.golfer.FullscreenActivity$7.onClick(FullscreenActivity.java:196)
08-07 12:32:12.488: I/dalvikvm(995):   at android.view.View.performClick(View.java:2538)
08-07 12:32:12.488: I/dalvikvm(995):   at android.view.View$PerformClick.run(View.java:9152)
08-07 12:32:12.488: I/dalvikvm(995):   at android.os.Handler.handleCallback(Handler.java:587)
08-07 12:32:12.488: I/dalvikvm(995):   at android.os.Handler.dispatchMessage(Handler.java:92)
08-07 12:32:12.488: I/dalvikvm(995):   at android.os.Looper.loop(Looper.java:130)
08-07 12:32:12.488: I/dalvikvm(995):   at android.app.ActivityThread.main(ActivityThread.java:3688)
08-07 12:32:12.488: I/dalvikvm(995):   at java.lang.reflect.Method.invokeNative(Native Method)
08-07 12:32:12.488: I/dalvikvm(995):   at java.lang.reflect.Method.invoke(Method.java:507)
08-07 12:32:12.488: I/dalvikvm(995):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
08-07 12:32:12.488: I/dalvikvm(995):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
08-07 12:32:12.488: I/dalvikvm(995):   at dalvik.system.NativeStart.main(Native Method)
08-07 12:32:13.241: W/dalvikvm(995): threadid=4: spin on suspend #4 threadid=1 (pcf=0)
08-07 12:32:13.241: I/dalvikvm(995): "Signal Catcher" daemon prio=5 tid=4 RUNNABLE
08-07 12:32:13.241: I/dalvikvm(995):   | group="system" sCount=0 dsCount=0 obj=0x4050e148 self=0x288d08
08-07 12:32:13.241: I/dalvikvm(995):   | sysTid=999 nice=0 sched=0/0 cgrp=default handle=2078152
08-07 12:32:13.241: I/dalvikvm(995):   at dalvik.system.NativeStart.run(Native Method)
08-07 12:32:13.241: I/dalvikvm(995): "main" prio=5 tid=1 RUNNABLE
08-07 12:32:13.241: I/dalvikvm(995):   | group="main" sCount=1 dsCount=0 obj=0x4001f190 self=0xce60
08-07 12:32:13.241: I/dalvikvm(995):   | sysTid=995 nice=0 sched=0/0 cgrp=default handle=-1345006496
08-07 12:32:13.280: I/dalvikvm(995):   at java.lang.Runtime.nativeLoad(Native Method)
08-07 12:32:13.292: I/dalvikvm(995):   at java.lang.Runtime.nativeLoad(Native Method)
08-07 12:32:13.292: I/dalvikvm(995):   at java.lang.Runtime.loadLibrary(Runtime.java:432)
08-07 12:32:13.292: I/dalvikvm(995):   at java.lang.System.loadLibrary(System.java:554)
08-07 12:32:13.292: I/dalvikvm(995):   at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:593)
08-07 12:32:13.292: I/dalvikvm(995):   at com.googlecode.javacpp.Loader.load(Loader.java:489)
08-07 12:32:13.292: I/dalvikvm(995):   at com.googlecode.javacpp.Loader.load(Loader.java:431)
08-07 12:32:13.292: I/dalvikvm(995):   at com.googlecode.javacv.cpp.opencv_imgproc.<clinit>(opencv_imgproc.java:97)
08-07 12:32:13.292: I/dalvikvm(995):   at java.lang.Class.classForName(Native Method)
08-07 12:32:13.292: I/dalvikvm(995):   at java.lang.Class.forName(Class.java:234)
08-07 12:32:13.292: I/dalvikvm(995):   at com.googlecode.javacpp.Loader.load(Loader.java:453)
08-07 12:32:13.292: I/dalvikvm(995):   at com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:85)
08-07 12:32:13.296: I/dalvikvm(995):   at ch.golfer.TrackSpot.process(TrackSpot.java:-1)
08-07 12:32:13.296: I/dalvikvm(995):   at ch.golfer.FullscreenActivity$7.onClick(FullscreenActivity.java:196)
08-07 12:32:13.296: I/dalvikvm(995):   at android.view.View.performClick(View.java:2538)
08-07 12:32:13.296: I/dalvikvm(995):   at android.view.View$PerformClick.run(View.java:9152)
08-07 12:32:13.296: I/dalvikvm(995):   at android.os.Handler.handleCallback(Handler.java:587)
08-07 12:32:13.296: I/dalvikvm(995):   at android.os.Handler.dispatchMessage(Handler.java:92)
08-07 12:32:13.296: I/dalvikvm(995):   at android.os.Looper.loop(Looper.java:130)
08-07 12:32:13.296: I/dalvikvm(995):   at android.app.ActivityThread.main(ActivityThread.java:3688)
08-07 12:32:13.296: I/dalvikvm(995):   at java.lang.reflect.Method.invokeNative(Native Method)
08-07 12:32:13.296: I/dalvikvm(995):   at java.lang.reflect.Method.invoke(Method.java:507)
08-07 12:32:13.296: I/dalvikvm(995):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
08-07 12:32:13.296: I/dalvikvm(995):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
08-07 12:32:13.296: I/dalvikvm(995):   at dalvik.system.NativeStart.main(Native Method)
08-07 12:32:14.046: W/dalvikvm(995): threadid=4: spin on suspend #5 threadid=1 (pcf=0)
08-07 12:32:14.050: I/dalvikvm(995): "Signal Catcher" daemon prio=5 tid=4 RUNNABLE
08-07 12:32:14.050: I/dalvikvm(995):   | group="system" sCount=0 dsCount=0 obj=0x4050e148 self=0x288d08
08-07 12:32:14.050: I/dalvikvm(995):   | sysTid=999 nice=0 sched=0/0 cgrp=default handle=2078152
08-07 12:32:14.050: I/dalvikvm(995):   at dalvik.system.NativeStart.run(Native Method)
08-07 12:32:14.050: I/dalvikvm(995): "main" prio=5 tid=1 RUNNABLE
08-07 12:32:14.050: I/dalvikvm(995):   | group="main" sCount=1 dsCount=0 obj=0x4001f190 self=0xce60
08-07 12:32:14.050: I/dalvikvm(995):   | sysTid=995 nice=0 sched=0/0 cgrp=default handle=-1345006496
08-07 12:32:14.062: I/dalvikvm(995):   at java.lang.Runtime.nativeLoad(Native Method)
08-07 12:32:14.062: I/dalvikvm(995):   at java.lang.Runtime.nativeLoad(Native Method)
08-07 12:32:14.062: I/dalvikvm(995):   at java.lang.Runtime.loadLibrary(Runtime.java:432)
08-07 12:32:14.066: I/dalvikvm(995):   at java.lang.System.loadLibrary(System.java:554)
08-07 12:32:14.070: I/dalvikvm(995):   at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:593)
08-07 12:32:14.073: I/dalvikvm(995):   at com.googlecode.javacpp.Loader.load(Loader.java:489)
08-07 12:32:14.073: I/dalvikvm(995):   at com.googlecode.javacpp.Loader.load(Loader.java:431)
08-07 12:32:14.077: I/dalvikvm(995):   at com.googlecode.javacv.cpp.opencv_imgproc.<clinit>(opencv_imgproc.java:97)
08-07 12:32:14.077: I/dalvikvm(995):   at java.lang.Class.classForName(Native Method)
08-07 12:32:14.077: I/dalvikvm(995):   at java.lang.Class.forName(Class.java:234)
08-07 12:32:14.077: I/dalvikvm(995):   at com.googlecode.javacpp.Loader.load(Loader.java:453)
08-07 12:32:14.077: I/dalvikvm(995):   at com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:85)
08-07 12:32:14.077: I/dalvikvm(995):   at ch.golfer.TrackSpot.process(TrackSpot.java:-1)
08-07 12:32:14.077: I/dalvikvm(995):   at ch.golfer.FullscreenActivity$7.onClick(FullscreenActivity.java:196)
08-07 12:32:14.077: I/dalvikvm(995):   at android.view.View.performClick(View.java:2538)
08-07 12:32:14.077: I/dalvikvm(995):   at android.view.View$PerformClick.run(View.java:9152)
08-07 12:32:14.077: I/dalvikvm(995):   at android.os.Handler.handleCallback(Handler.java:587)
08-07 12:32:14.077: I/dalvikvm(995):   at android.os.Handler.dispatchMessage(Handler.java:92)
08-07 12:32:14.077: I/dalvikvm(995):   at android.os.Looper.loop(Looper.java:130)
08-07 12:32:14.077: I/dalvikvm(995):   at android.app.ActivityThread.main(ActivityThread.java:3688)
08-07 12:32:14.077: I/dalvikvm(995):   at java.lang.reflect.Method.invokeNative(Native Method)
08-07 12:32:14.077: I/dalvikvm(995):   at java.lang.reflect.Method.invoke(Method.java:507)
08-07 12:32:14.077: I/dalvikvm(995):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
08-07 12:32:14.085: I/dalvikvm(995):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
08-07 12:32:14.085: I/dalvikvm(995):   at dalvik.system.NativeStart.main(Native Method)

助けてくれてありがとう。

4

1 に答える 1