android - JavaCV convertToIplImage return NULL -
in javacv used in android,while converting frame iplimage applying color effect on video,we nullpointerexception.npe encountered of frames in video.
... while (true) { log.d("java_cv", "counting . . . " + count); frame original_frame = ffg.grab(); if (original_frame == null) { log.d("java_cv", "original_frame null at" + count); break; } else { log.d("java_cv", "original_frame not_null at" + count); if (converter == null) { log.d("java_cv", "converter null @ position" +count); continue; } opencv_core.iplimage frame1 = null; if (original_frame != null) { frame1 = converter.converttoiplimage(original_frame); } else { continue; } if (frame1 == null) { log.d("java_cv", "frame1 null at" + count); } else { if (!frame1.isnull() && original_frame.image != null) { int width = frame1.width(); int height = frame1.height(); int channel = frame1.nchannels(); opencv_core.iplimage frame2 = opencv_core.iplimage.create(width, height, opencv_core.ipl_depth_8u, channel); if (frame2 == null) continue; opencv_core.cvcopy(frame1, frame2); opencv_core.iplimage frame3 = opencv_core.iplimage.create(width, height, opencv_core.ipl_depth_8u, 1); if (frame3 == null) continue; opencv_imgproc.cvcvtcolor(frame2, frame3, opencv_imgproc.cv_bgra2gray); log.d("java_cv", "frame1 not_null at" + count + " height " + frame1.height()); frame resultframe = converter.convert(frame3); if (resultframe == null) continue; recorder.record(resultframe); frame1.release(); frame2.release(); frame3.release(); original_frame = null; } else { break; } } } count++; } ...
the exception stack here :
06-20 12:00:57.664 30245-30245/com.appxperts.opencvfirstapp w/system.err﹕ java.lang.nullpointerexception: pointer address null. 06-20 12:00:57.664 30245-30245/com.appxperts.opencvfirstapp w/system.err﹕ @ org.bytedeco.javacpp.opencv_core$iplimage.width(native method) 06-20 12:00:57.664 30245-30245/com.appxperts.opencvfirstapp w/system.err﹕ @ org.bytedeco.javacv.opencvframeconverter.isequal(opencvframeconverter.java:75) 06-20 12:00:57.664 30245-30245/com.appxperts.opencvfirstapp w/system.err﹕ @ org.bytedeco.javacv.opencvframeconverter.converttoiplimage(opencvframeconverter.java:85) 06-20 12:00:57.664 30245-30245/com.appxperts.opencvfirstapp w/system.err﹕ @ org.bytedeco.javacv.opencvframeconverter$toiplimage.convert(opencvframeconverter.java:41) 06-20 12:00:57.664 30245-30245/com.appxperts.opencvfirstapp w/system.err﹕ @ com.appxperts.opencvfirstapp.mainactivitysecond.kaamdg(mainactivitysecond.java:161) 06-20 12:00:57.664 30245-30245/com.appxperts.opencvfirstapp w/system.err﹕ @ com.appxperts.opencvfirstapp.mainactivitysecond$1.onclick(mainactivitysecond.java:62) 06-20 12:00:57.665 30245-30245/com.appxperts.opencvfirstapp w/system.err﹕ @ android.view.view.performclick(view.java:4463) 06-20 12:00:57.665 30245-30245/com.appxperts.opencvfirstapp w/system.err﹕ @ android.view.view$performclick.run(view.java:18789) 06-20 12:00:57.665 30245-30245/com.appxperts.opencvfirstapp w/system.err﹕ @ android.os.handler.handlecallback(handler.java:808) 06-20 12:00:57.665 30245-30245/com.appxperts.opencvfirstapp w/system.err﹕ @ android.os.handler.dispatchmessage(handler.java:103) 06-20 12:00:57.665 30245-30245/com.appxperts.opencvfirstapp w/system.err﹕ @ android.os.looper.loop(looper.java:193)`enter code here` 06-20 12:00:57.665 30245-30245/com.appxperts.opencvfirstapp w/system.err﹕ @ android.app.activitythread.main(activitythread.java:5299) 06-20 12:00:57.665 30245-30245/com.appxperts.opencvfirstapp w/system.err﹕ @ java.lang.reflect.method.invokenative(native method) 06-20 12:00:57.665 30245-30245/com.appxperts.opencvfirstapp w/system.err﹕ @ java.lang.reflect.method.invoke(method.java:515) 06-20 12:00:57.665 30245-30245/com.appxperts.opencvfirstapp w/system.err﹕ @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:825) 06-20 12:00:57.665 30245-30245/com.appxperts.opencvfirstapp w/system.err﹕ @ com.android.internal.os.zygoteinit.main(zygoteinit.java:641)
Comments
Post a Comment