First time here? Check out the FAQ!

Ask Your Question
0

java.lang.exceptionininitializererror

asked May 14 '14

Nabeel Ahmed gravatar image

updated May 14 '14

Hi foolks, I am new here in this form and new in OpenCV. I am making a project of eyes detection followed by http://romanhosek.cz/android-eye-detection-and-tracking-with-opencv/ tutorial. But at the end I got logcat wrror java.lang.exceptionininitializererror

Please help.... Thanks in Advance. . .

private BaseLoaderCallback mOpenCVCallBack = new BaseLoaderCallback(this) { @Override public void onManagerConnected(int status) { switch (status) { case LoaderCallbackInterface.SUCCESS: { Log.i(TAG, "OpenCV loaded successfully");

            // Load native libs after OpenCV initialization
            // System.loadLibrary("detection_based_tracker");

            // Create and set View
            mView = new FdView(mAppContext);
            mView.setDetectorType(mDetectorType);
            mView.setMinFaceSize(0.2f);

            VerticalSeekBar VerticalseekBar = new VerticalSeekBar(
                    getApplicationContext());
            VerticalseekBar.setMax(5);
            VerticalseekBar.setPadding(20, 20, 20, 20);
            RelativeLayout.LayoutParams vsek = new RelativeLayout.LayoutParams(
                    RelativeLayout.LayoutParams.WRAP_CONTENT, 400);
            vsek.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
            VerticalseekBar.setId(1);
            VerticalseekBar
                    .setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

                        public void onProgressChanged(SeekBar seekBar,
                                int progress, boolean fromUser) {

                            method = progress;
                            switch (method) {
                            case 0:
                                matching_method.setText("TM_SQDIFF");
                                break;
                            case 1:
                                matching_method.setText("TM_SQDIFF_NORMED");
                                break;
                            case 2:
                                matching_method.setText("TM_CCOEFF");
                                break;
                            case 3:
                                matching_method.setText("TM_CCOEFF_NORMED");
                                break;
                            case 4:
                                matching_method.setText("TM_CCORR");
                                break;
                            case 5:
                                matching_method.setText("TM_CCORR_NORMED");
                                break;
                            }

                        }

                        public void onStartTrackingTouch(SeekBar seekBar) {
                        }

                        public void onStopTrackingTouch(SeekBar seekBar) {
                        }
                    });

            matching_method = new TextView(getApplicationContext());
            matching_method.setText("TM_SQDIFF");
            matching_method.setTextColor(Color.YELLOW);
            RelativeLayout.LayoutParams matching_method_param = new RelativeLayout.LayoutParams(
                    RelativeLayout.LayoutParams.WRAP_CONTENT,
                    RelativeLayout.LayoutParams.WRAP_CONTENT);
            matching_method_param
                    .addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
            matching_method_param.addRule(RelativeLayout.BELOW,
                    VerticalseekBar.getId());

            Button btn = new Button(getApplicationContext());
            btn.setText("Create template");
            RelativeLayout.LayoutParams btnp = new RelativeLayout.LayoutParams(
                    RelativeLayout.LayoutParams.WRAP_CONTENT,
                    RelativeLayout.LayoutParams.WRAP_CONTENT);
            btnp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
            btn.setId(2);

            btn.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                    mView.resetLearFramesCount();
                }
            });

            RelativeLayout frameLayout = new RelativeLayout(
                    getApplicationContext());
            frameLayout.addView(mView, 0);
            frameLayout.addView(btn, btnp);

            frameLayout.addView(VerticalseekBar, vsek);
            frameLayout.addView(matching_method, matching_method_param);

            setContentView(frameLayout);

            // Check native OpenCV camera
            if (!mView.openCamera()) {
                AlertDialog ad = new AlertDialog.Builder(mAppContext)
                        .create();
                ad.setCancelable(false); // This blocks the 'BACK' button
                ad.setMessage("Fatal error: can't open camera!");
                ad.setButton("OK", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        finish();
                    }
                });
                ad.show();
            }
        }
            break;
        default: {
            super.onManagerConnected(status);
        }
            break;
        }
    }
};

private int mDetectorType = 0;
private String[] mDetectorName;

public FdActivity() {
    Log.i(TAG, "Instantiated new " + this.getClass());
    mDetectorName = new String[2];
    mDetectorName[FdView.JAVA_DETECTOR] = "Java";
    mDetectorName[FdView.NATIVE_DETECTOR] = "Native (tracking)";
}

@Override
protected void onPause() {
    Log.i(TAG, "onPause");
    super.onPause();
    if (mView != null)
        mView.releaseCamera();
}

@Override
protected void onResume() {
    Log.i(TAG, "onResume");
    super.onResume();
    if (mView != null && !mView.openCamera()) {
        AlertDialog ad = new AlertDialog.Builder(this).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("Fatal error: can't open camera!");
        ad.setButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                finish();
            }
        });
        ad.show();
    }
}

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "onCreate");
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    Log.i(TAG, "Trying to load OpenCV library");
    if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this,
            mOpenCVCallBack)) {
        Log.e(TAG, "Cannot connect to OpenCV Manager");
    }
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    Log.i(TAG, "onCreateOptionsMenu");
    mItemFace50 = menu.add("Face size 50%");
    mItemFace40 = menu.add("Face ...
(more)
Preview: (hide)

Comments

how should we know without your code and a stacktrace ?

berak gravatar imageberak (May 14 '14)edit

Actully I have many classis. . . .which class me have to share with you....

Nabeel Ahmed gravatar imageNabeel Ahmed (May 14 '14)edit

By the way I shared a link in my question I am following all that coding....

Nabeel Ahmed gravatar imageNabeel Ahmed (May 14 '14)edit

you're supposed to come up with a minimal testcase, that shows the error, and the resp. stacktrace.

no, we don't want all of your classes. but a link to an external blog isn't helpful either. (see it worked for that person, but not for you, so your situation is different already.)

read the FAQ, please.

berak gravatar imageberak (May 14 '14)edit

Ok check I have edited my post and send my main Activity

Nabeel Ahmed gravatar imageNabeel Ahmed (May 14 '14)edit

far too much. anyway, the exact exception is still missing.

(btw, why did you comment System.loadLibrary("detection_based_tracker"); ? )

berak gravatar imageberak (May 14 '14)edit

If I unComment that line then I got error Find library return null. . . why is it so?

Nabeel Ahmed gravatar imageNabeel Ahmed (May 15 '14)edit

i'm giving up.

berak gravatar imageberak (May 15 '14)edit

no need to. nice that you got it solved ;)

berak gravatar imageberak (May 15 '14)edit

I just got the problem but I am fail how to resolve it? I need your help because this is mine first project on OpenCV. . . I send you my code please give me the way to PM you. . . .

Nabeel Ahmed gravatar imageNabeel Ahmed (May 15 '14)edit

1 answer

Sort by » oldest newest most voted
0

answered May 15 '14

Nabeel Ahmed gravatar image

Ok Berak I have Identify the error The error is in another class. . . How I can send you a PM apologize I am new in this forum

Preview: (hide)

Question Tools

Stats

Asked: May 14 '14

Seen: 686 times

Last updated: May 14 '14