i developing app detects yellow object , whenever object detected speaks object detected. here code:
package org.opencv.samples.imagemanipulations; import org.opencv.android.baseloadercallback; import org.opencv.android.camerabridgeviewbase.cvcameraviewframe; import org.opencv.android.loadercallbackinterface; import org.opencv.android.opencvloader; import org.opencv.core.mat; import org.opencv.core.size; import org.opencv.android.camerabridgeviewbase; import org.opencv.android.camerabridgeviewbase.cvcameraviewlistener2; import android.app.activity; import android.content.intent; import android.os.bundle; import android.speech.tts.texttospeech; import android.speech.tts.texttospeech.oninitlistener; import android.util.log; import android.view.windowmanager; public abstract class imagemanipulationsactivity extends activity implements cvcameraviewlistener2, texttospeech.oninitlistener { private static final string tag = "ocvsample::activity"; private camerabridgeviewbase mopencvcameraview; private mat mrgba; int count = 0; int a=0; int b=0; int c=0; private texttospeech mytts; private int my_data_check_code = 0; private baseloadercallback mloadercallback = new baseloadercallback(this) { @override public void onmanagerconnected(int status) { switch (status) { case loadercallbackinterface.success: { log.i(tag, "opencv loaded successfully"); mopencvcameraview.enableview(); } break; default: { super.onmanagerconnected(status); } break; } } }; public imagemanipulationsactivity() { log.i(tag, "instantiated new " + this.getclass()); } /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { log.i(tag, "called oncreate"); super.oncreate(savedinstancestate); getwindow().addflags(windowmanager.layoutparams.flag_keep_screen_on); setcontentview(r.layout.image_manipulations_surface_view); mytts= new texttospeech(this,this); intent checkttsintent = new intent(); checkttsintent.setaction(texttospeech.engine.action_check_tts_data); startactivityforresult(checkttsintent, my_data_check_code); mopencvcameraview = (camerabridgeviewbase) findviewbyid(r.id.image_manipulations_activity_surface_view); mopencvcameraview.setcvcameraviewlistener(this); } @override public void onpause() { super.onpause(); if (mopencvcameraview != null) mopencvcameraview.disableview(); } @override public void onresume() { super.onresume(); opencvloader.initasync(opencvloader.opencv_version_2_4_3, this, mloadercallback); } public void ondestroy() { super.ondestroy(); if (mopencvcameraview != null) mopencvcameraview.disableview(); } public void oncameraviewstarted(int width, int height) { mrgba = new mat(); new size(); new mat(); } public void oncameraviewstopped() { // explicitly deallocate mats if (mrgba != null) mrgba.release(); mrgba = null; } public mat oncameraframe(cvcameraviewframe inputframe) { mrgba = inputframe.rgba(); size s=mrgba.size(); (int = 0; < s.height; i++) { (int j = 0; j < s.width; j++) { double[] rgb=mrgba.get(i,j); a=(int) rgb[0]; b=(int) rgb[1]; c=(int) rgb[2]; if ((a>=225) && (a<=240) && (b>=215) && (b<= 230) && (c>=90) && (c<= 150)) { count=count++; } } } if (count>1000) { mytts.speak("object detected", texttospeech.queue_flush, null); } return mrgba; } }
i getting following error in logcat. please me in solving this:
07-15 23:22:56.733: e/androidruntime(13661): fatal exception: main 07-15 23:22:56.733: e/androidruntime(13661): java.lang.runtimeexception: unable instantiate activity componentinfo{org.opencv.samples.imagemanipulations/org.opencv.samples.imagemanipulations.imagemanipulationsactivity}: java.lang.instantiationexception: can't instantiate class org.opencv.samples.imagemanipulations.imagemanipulationsactivity 07-15 23:22:56.733: e/androidruntime(13661): @ android.app.activitythread.performlaunchactivity(activitythread.java:2034) 07-15 23:22:56.733: e/androidruntime(13661): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2135) 07-15 23:22:56.733: e/androidruntime(13661): @ android.app.activitythread.access$700(activitythread.java:140) 07-15 23:22:56.733: e/androidruntime(13661): @ android.app.activitythread$h.handlemessage(activitythread.java:1237) 07-15 23:22:56.733: e/androidruntime(13661): @ android.os.handler.dispatchmessage(handler.java:99) 07-15 23:22:56.733: e/androidruntime(13661): @ android.os.looper.loop(looper.java:137) 07-15 23:22:56.733: e/androidruntime(13661): @ android.app.activitythread.main(activitythread.java:4921) 07-15 23:22:56.733: e/androidruntime(13661): @ java.lang.reflect.method.invokenative(native method) 07-15 23:22:56.733: e/androidruntime(13661): @ java.lang.reflect.method.invoke(method.java:511) 07-15 23:22:56.733: e/androidruntime(13661): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1027) 07-15 23:22:56.733: e/androidruntime(13661): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:794) 07-15 23:22:56.733: e/androidruntime(13661): @ dalvik.system.nativestart.main(native method) 07-15 23:22:56.733: e/androidruntime(13661): caused by: java.lang.instantiationexception: can't instantiate class org.opencv.samples.imagemanipulations.imagemanipulationsactivity 07-15 23:22:56.733: e/androidruntime(13661): @ java.lang.class.newinstanceimpl(native method) 07-15 23:22:56.733: e/androidruntime(13661): @ java.lang.class.newinstance(class.java:1319) 07-15 23:22:56.733: e/androidruntime(13661): @ android.app.instrumentation.newactivity(instrumentation.java:1068) 07-15 23:22:56.733: e/androidruntime(13661): @ android.app.activitythread.performlaunchactivity(activitythread.java:2025) 07-15 23:22:56.733: e/androidruntime(13661): ... 11 more
the imagemanipulationsactivity
class abstract
, cannot instantiated. either remove abstract
keyword or extend imagemanipulationsactivity
non-abstract class.
Comments
Post a Comment