opencv samples - face detection StrictMode Error

84 views
Skip to first unread message

Karthik

unread,
Aug 17, 2012, 11:55:40 PM8/17/12
to
I am working in opencv samples - face detection with Strict Mode. When I create the instance for FdActivity.java, getting error.

In FdActivity.java,

   
public static boolean MODE = true;

   
private void setupStrictMode() {
       
if (!FdActivity.MODE)
           
return;

       
try {
           
Class<?> strictMode = Class.forName("android.os.StrictMode");
           
Method enableDefaults = strictMode.getMethod("enableDefaults");
            enableDefaults
.invoke(strictMode);
       
}

       
catch (Exception e) {
           
Log.v(FdActivity.LOG_TAG, "Failed to turn on strict mode", e);
       
}

   
}

   
public nextActivity(int val) {
       
Intent i = new Intent(getApplicationContext(), FinalActivity.class);
        startActivity
(i);
   
}




In FdView.java,

    public void next() {
       
FdActivity mFdActivity = new FdActivity();
        mFdActivity
.nextActivity();
   
}




Error in LogCat.

    StrictMode ->  class org.opencv.samples.fd.FdActivity; instances=2; limit=1
   
   
StrictMode ->  android.os.StrictMode$InstanceCountViolation: class
    org
.opencv.samples.fd.FdActivity; instances=2; limit=1
   
   
StrictMode ->  at android.os.StrictMode.setClassInstanceLimit(StrictMode.java:1)



How can I fix this?

Rui Marques

unread,
Aug 17, 2012, 11:55:52 AM8/17/12
to
By turning off the StrictMode (joking) :P

Now seriously, sorry for my ignorance, but why do you want to use that strictmode?

It is likely that the opencv developers did not enforce the strictmode to the sample so it just won't work as-is if you enforce it.


On Friday, 17 August 2012 16:11:32 UTC+1, Karthik wrote:

I am working in opencv samples - face detection with Strict Mode. When I create the instance for FdActivity.java

FdActivity mFdActivity = new FdActivity();
mFdActivity
.nextActivity();

I am getting following error in LogCat.

Reply all
Reply to author
Forward
0 new messages