openCV cvSaveImage and cvCvtColor crash on android -


i'm working on android version 2.3.5 , 4.0.4 both version crash on execution of same code. have been trying frame video, save it, , convert hsv.

(i posted same question on opencv website here)

this code , error get.

  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;     } 

here logcat when cvsaveimage or cvcvtcolor executed on device running 4.0.4

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):   @ java.lang.runtime.nativeload(native method) 08-07 12:26:25.974: i/dalvikvm(6719):   @ java.lang.runtime.nativeload(native method) 08-07 12:26:25.974: i/dalvikvm(6719):   @ java.lang.runtime.loadlibrary(runtime.java:368) 08-07 12:26:25.974: i/dalvikvm(6719):   @ java.lang.system.loadlibrary(system.java:535) 08-07 12:26:25.974: i/dalvikvm(6719):   @ com.googlecode.javacpp.loader.loadlibrary(loader.java:593) 08-07 12:26:25.974: i/dalvikvm(6719):   @ com.googlecode.javacpp.loader.load(loader.java:489) 08-07 12:26:25.974: i/dalvikvm(6719):   @ com.googlecode.javacpp.loader.load(loader.java:431) 08-07 12:26:25.974: i/dalvikvm(6719):   @ com.googlecode.javacv.cpp.opencv_imgproc.<clinit>(opencv_imgproc.java:97) 08-07 12:26:25.974: i/dalvikvm(6719):   @ java.lang.class.classforname(native method) 08-07 12:26:25.974: i/dalvikvm(6719):   @ java.lang.class.forname(class.java:217) 08-07 12:26:25.974: i/dalvikvm(6719):   @ com.googlecode.javacpp.loader.load(loader.java:453) 08-07 12:26:25.974: i/dalvikvm(6719):   @ com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:85) 08-07 12:26:25.974: i/dalvikvm(6719):   @ ch.golfer.trackspot.process(trackspot.java:-1) 08-07 12:26:25.974: i/dalvikvm(6719):   @ ch.golfer.fullscreenactivity$7.onclick(fullscreenactivity.java:196) 08-07 12:26:25.974: i/dalvikvm(6719):   @ android.view.view.performclick(view.java:3627) 08-07 12:26:25.974: i/dalvikvm(6719):   @ android.view.view$performclick.run(view.java:14305) 08-07 12:26:25.974: i/dalvikvm(6719):   @ android.os.handler.handlecallback(handler.java:605) 08-07 12:26:25.974: i/dalvikvm(6719):   @ android.os.handler.dispatchmessage(handler.java:92) 08-07 12:26:25.974: i/dalvikvm(6719):   @ android.os.looper.loop(looper.java:137) 08-07 12:26:25.974: i/dalvikvm(6719):   @ android.app.activitythread.main(activitythread.java:4511) 08-07 12:26:25.974: i/dalvikvm(6719):   @ java.lang.reflect.method.invokenative(native method) 08-07 12:26:25.974: i/dalvikvm(6719):   @ java.lang.reflect.method.invoke(method.java:511) 08-07 12:26:25.974: i/dalvikvm(6719):   @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:976) 08-07 12:26:25.974: i/dalvikvm(6719):   @ com.android.internal.os.zygoteinit.main(zygoteinit.java:743) 08-07 12:26:25.974: i/dalvikvm(6719):   @ 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) @ 0xdeadd00d (code=1) 

and logcat of 2.3.5 device:

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 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):   @ 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):   @ java.lang.runtime.nativeload(native method) 08-07 12:32:11.472: i/dalvikvm(995):   @ java.lang.runtime.nativeload(native method) 08-07 12:32:11.476: i/dalvikvm(995):   @ java.lang.runtime.loadlibrary(runtime.java:432) 08-07 12:32:11.488: i/dalvikvm(995):   @ java.lang.system.loadlibrary(system.java:554) 08-07 12:32:11.507: i/dalvikvm(995):   @ com.googlecode.javacpp.loader.loadlibrary(loader.java:593) 08-07 12:32:11.511: i/dalvikvm(995):   @ com.googlecode.javacpp.loader.load(loader.java:489) 08-07 12:32:11.519: i/dalvikvm(995):   @ com.googlecode.javacpp.loader.load(loader.java:431) 08-07 12:32:11.527: i/dalvikvm(995):   @ com.googlecode.javacv.cpp.opencv_imgproc.<clinit>(opencv_imgproc.java:97) 08-07 12:32:11.530: i/dalvikvm(995):   @ java.lang.class.classforname(native method) 08-07 12:32:11.534: i/dalvikvm(995):   @ java.lang.class.forname(class.java:234) 08-07 12:32:11.542: i/dalvikvm(995):   @ com.googlecode.javacpp.loader.load(loader.java:453) 08-07 12:32:11.550: i/dalvikvm(995):   @ com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:85) 08-07 12:32:11.554: i/dalvikvm(995):   @ ch.golfer.trackspot.process(trackspot.java:-1) 08-07 12:32:11.562: i/dalvikvm(995):   @ ch.golfer.fullscreenactivity$7.onclick(fullscreenactivity.java:196) 08-07 12:32:11.570: i/dalvikvm(995):   @ android.view.view.performclick(view.java:2538) 08-07 12:32:11.581: i/dalvikvm(995):   @ android.view.view$performclick.run(view.java:9152) 08-07 12:32:11.589: i/dalvikvm(995):   @ android.os.handler.handlecallback(handler.java:587) 08-07 12:32:11.593: i/dalvikvm(995):   @ android.os.handler.dispatchmessage(handler.java:92) 08-07 12:32:11.605: i/dalvikvm(995):   @ android.os.looper.loop(looper.java:130) 08-07 12:32:11.616: i/dalvikvm(995):   @ android.app.activitythread.main(activitythread.java:3688) 08-07 12:32:11.620: i/dalvikvm(995):   @ java.lang.reflect.method.invokenative(native method) 08-07 12:32:11.624: i/dalvikvm(995):   @ java.lang.reflect.method.invoke(method.java:507) 08-07 12:32:11.632: i/dalvikvm(995):   @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:842) 08-07 12:32:11.640: i/dalvikvm(995):   @ com.android.internal.os.zygoteinit.main(zygoteinit.java:600) 08-07 12:32:11.648: i/dalvikvm(995):   @ 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):   @ 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):   @ java.lang.runtime.nativeload(native method) 08-07 12:32:12.472: i/dalvikvm(995):   @ java.lang.runtime.nativeload(native method) 08-07 12:32:12.480: i/dalvikvm(995):   @ java.lang.runtime.loadlibrary(runtime.java:432) 08-07 12:32:12.484: i/dalvikvm(995):   @ java.lang.system.loadlibrary(system.java:554) 08-07 12:32:12.488: i/dalvikvm(995):   @ com.googlecode.javacpp.loader.loadlibrary(loader.java:593) 08-07 12:32:12.488: i/dalvikvm(995):   @ com.googlecode.javacpp.loader.load(loader.java:489) 08-07 12:32:12.488: i/dalvikvm(995):   @ com.googlecode.javacpp.loader.load(loader.java:431) 08-07 12:32:12.488: i/dalvikvm(995):   @ com.googlecode.javacv.cpp.opencv_imgproc.<clinit>(opencv_imgproc.java:97) 08-07 12:32:12.488: i/dalvikvm(995):   @ java.lang.class.classforname(native method) 08-07 12:32:12.488: i/dalvikvm(995):   @ java.lang.class.forname(class.java:234) 08-07 12:32:12.488: i/dalvikvm(995):   @ com.googlecode.javacpp.loader.load(loader.java:453) 08-07 12:32:12.488: i/dalvikvm(995):   @ com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:85) 08-07 12:32:12.488: i/dalvikvm(995):   @ ch.golfer.trackspot.process(trackspot.java:-1) 08-07 12:32:12.488: i/dalvikvm(995):   @ ch.golfer.fullscreenactivity$7.onclick(fullscreenactivity.java:196) 08-07 12:32:12.488: i/dalvikvm(995):   @ android.view.view.performclick(view.java:2538) 08-07 12:32:12.488: i/dalvikvm(995):   @ android.view.view$performclick.run(view.java:9152) 08-07 12:32:12.488: i/dalvikvm(995):   @ android.os.handler.handlecallback(handler.java:587) 08-07 12:32:12.488: i/dalvikvm(995):   @ android.os.handler.dispatchmessage(handler.java:92) 08-07 12:32:12.488: i/dalvikvm(995):   @ android.os.looper.loop(looper.java:130) 08-07 12:32:12.488: i/dalvikvm(995):   @ android.app.activitythread.main(activitythread.java:3688) 08-07 12:32:12.488: i/dalvikvm(995):   @ java.lang.reflect.method.invokenative(native method) 08-07 12:32:12.488: i/dalvikvm(995):   @ java.lang.reflect.method.invoke(method.java:507) 08-07 12:32:12.488: i/dalvikvm(995):   @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:842) 08-07 12:32:12.488: i/dalvikvm(995):   @ com.android.internal.os.zygoteinit.main(zygoteinit.java:600) 08-07 12:32:12.488: i/dalvikvm(995):   @ 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):   @ 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):   @ java.lang.runtime.nativeload(native method) 08-07 12:32:13.292: i/dalvikvm(995):   @ java.lang.runtime.nativeload(native method) 08-07 12:32:13.292: i/dalvikvm(995):   @ java.lang.runtime.loadlibrary(runtime.java:432) 08-07 12:32:13.292: i/dalvikvm(995):   @ java.lang.system.loadlibrary(system.java:554) 08-07 12:32:13.292: i/dalvikvm(995):   @ com.googlecode.javacpp.loader.loadlibrary(loader.java:593) 08-07 12:32:13.292: i/dalvikvm(995):   @ com.googlecode.javacpp.loader.load(loader.java:489) 08-07 12:32:13.292: i/dalvikvm(995):   @ com.googlecode.javacpp.loader.load(loader.java:431) 08-07 12:32:13.292: i/dalvikvm(995):   @ com.googlecode.javacv.cpp.opencv_imgproc.<clinit>(opencv_imgproc.java:97) 08-07 12:32:13.292: i/dalvikvm(995):   @ java.lang.class.classforname(native method) 08-07 12:32:13.292: i/dalvikvm(995):   @ java.lang.class.forname(class.java:234) 08-07 12:32:13.292: i/dalvikvm(995):   @ com.googlecode.javacpp.loader.load(loader.java:453) 08-07 12:32:13.292: i/dalvikvm(995):   @ com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:85) 08-07 12:32:13.296: i/dalvikvm(995):   @ ch.golfer.trackspot.process(trackspot.java:-1) 08-07 12:32:13.296: i/dalvikvm(995):   @ ch.golfer.fullscreenactivity$7.onclick(fullscreenactivity.java:196) 08-07 12:32:13.296: i/dalvikvm(995):   @ android.view.view.performclick(view.java:2538) 08-07 12:32:13.296: i/dalvikvm(995):   @ android.view.view$performclick.run(view.java:9152) 08-07 12:32:13.296: i/dalvikvm(995):   @ android.os.handler.handlecallback(handler.java:587) 08-07 12:32:13.296: i/dalvikvm(995):   @ android.os.handler.dispatchmessage(handler.java:92) 08-07 12:32:13.296: i/dalvikvm(995):   @ android.os.looper.loop(looper.java:130) 08-07 12:32:13.296: i/dalvikvm(995):   @ android.app.activitythread.main(activitythread.java:3688) 08-07 12:32:13.296: i/dalvikvm(995):   @ java.lang.reflect.method.invokenative(native method) 08-07 12:32:13.296: i/dalvikvm(995):   @ java.lang.reflect.method.invoke(method.java:507) 08-07 12:32:13.296: i/dalvikvm(995):   @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:842) 08-07 12:32:13.296: i/dalvikvm(995):   @ com.android.internal.os.zygoteinit.main(zygoteinit.java:600) 08-07 12:32:13.296: i/dalvikvm(995):   @ 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):   @ 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):   @ java.lang.runtime.nativeload(native method) 08-07 12:32:14.062: i/dalvikvm(995):   @ java.lang.runtime.nativeload(native method) 08-07 12:32:14.062: i/dalvikvm(995):   @ java.lang.runtime.loadlibrary(runtime.java:432) 08-07 12:32:14.066: i/dalvikvm(995):   @ java.lang.system.loadlibrary(system.java:554) 08-07 12:32:14.070: i/dalvikvm(995):   @ com.googlecode.javacpp.loader.loadlibrary(loader.java:593) 08-07 12:32:14.073: i/dalvikvm(995):   @ com.googlecode.javacpp.loader.load(loader.java:489) 08-07 12:32:14.073: i/dalvikvm(995):   @ com.googlecode.javacpp.loader.load(loader.java:431) 08-07 12:32:14.077: i/dalvikvm(995):   @ com.googlecode.javacv.cpp.opencv_imgproc.<clinit>(opencv_imgproc.java:97) 08-07 12:32:14.077: i/dalvikvm(995):   @ java.lang.class.classforname(native method) 08-07 12:32:14.077: i/dalvikvm(995):   @ java.lang.class.forname(class.java:234) 08-07 12:32:14.077: i/dalvikvm(995):   @ com.googlecode.javacpp.loader.load(loader.java:453) 08-07 12:32:14.077: i/dalvikvm(995):   @ com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:85) 08-07 12:32:14.077: i/dalvikvm(995):   @ ch.golfer.trackspot.process(trackspot.java:-1) 08-07 12:32:14.077: i/dalvikvm(995):   @ ch.golfer.fullscreenactivity$7.onclick(fullscreenactivity.java:196) 08-07 12:32:14.077: i/dalvikvm(995):   @ android.view.view.performclick(view.java:2538) 08-07 12:32:14.077: i/dalvikvm(995):   @ android.view.view$performclick.run(view.java:9152) 08-07 12:32:14.077: i/dalvikvm(995):   @ android.os.handler.handlecallback(handler.java:587) 08-07 12:32:14.077: i/dalvikvm(995):   @ android.os.handler.dispatchmessage(handler.java:92) 08-07 12:32:14.077: i/dalvikvm(995):   @ android.os.looper.loop(looper.java:130) 08-07 12:32:14.077: i/dalvikvm(995):   @ android.app.activitythread.main(activitythread.java:3688) 08-07 12:32:14.077: i/dalvikvm(995):   @ java.lang.reflect.method.invokenative(native method) 08-07 12:32:14.077: i/dalvikvm(995):   @ java.lang.reflect.method.invoke(method.java:507) 08-07 12:32:14.077: i/dalvikvm(995):   @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:842) 08-07 12:32:14.085: i/dalvikvm(995):   @ com.android.internal.os.zygoteinit.main(zygoteinit.java:600) 08-07 12:32:14.085: i/dalvikvm(995):   @ dalvik.system.nativestart.main(native method) 

thanks in advance help.

i found issue, theory:

this code running through jni; therefore, when grab image , set equal image, passes pointer. additionally, because start grabber in getframe function, grabber gets destroyed when image returned, , weird reason memory gets flushed , passed pointer becomes useless.

the solution issue either set grabber global variable, pass grabber argument getframe function, or (weirdly) execute opencv operation touches memory before returning image (i.e. call cvcvsaveimage or cvcvtcolor on random not have related image).

i hope explanation makes sense, , not know if should reported bug though ?


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -