Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7539409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:22:25+00:00 2026-05-30T07:22:25+00:00

I have this problem, my code doesn’t work when i try to find eyes

  • 0

I have this problem, my code doesn’t work when i try to find eyes with glasses with openCv library for android.
My code is the following:

         try {
            InputStream is = this.getResources().openRawResource(R.raw.haarcascade_eye_tree_eyeglasses);
            File cascadeDir = this.getDir("cascade"+"occhiOcchiali", Context.MODE_PRIVATE);
            File cascadeFile = new File(cascadeDir, "haarcascade_eye_tree_eyeglasses.xml");
            FileOutputStream os = new FileOutputStream(cascadeFile);
            byte[] buffer = new byte[4096];
            int bytesRead;
            while ((bytesRead = is.read(buffer)) != -1) {
                os.write(buffer, 0, bytesRead);
            }
            is.close();
            os.close();
            mioClassificatoreOcchiOcchiali = new CascadeClassifier(cascadeFile.getAbsolutePath());
            Log.d("metodo1", cascadeFile.getAbsolutePath());
            if (mioClassificatoreOcchiOcchiali.empty()) {
                Log.d("metodo1", "Failed to load cascade classifier");
                mioClassificatoreOcchiOcchiali = null;
            } else
                Log.d("metodo1", "Loaded cascade classifier from " + cascadeFile.getAbsolutePath());

            cascadeFile.delete();
            cascadeDir.delete();

        } catch (IOException e) {
            e.printStackTrace();
            Log.d("metodo1" , "Failed to load cascade. Exception thrown: " + e);
        }

In this way I take my Classifier and with this code i try to find eyes with glasses:

LinkedList<org.opencv.core.Rect> occhi = new LinkedList<org.opencv.core.Rect>();
                    org.opencv.core.Size sOcchi = new org.opencv.core.Size(15, 15);
                    mioClassificatoreOcchiOcchiali.detectMultiScale(matOcchi, occhi,1.1, 2,0,sOcchi);  

The result is always 0 insted if i leave my glasses, the result is always 2.
Anyone can help me??
Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:22:27+00:00Added an answer on May 30, 2026 at 7:22 am

    I haven’t played with the Android implementation of OpenCV, but I have used the normal version. If your code works well with the Haar cascade for eyes and not for the one with glasses, that makes me suspect that the eyes+glasses cascade packaged with openCV isn’t very good. I had the same issue trying to differentiate between front face and side face.

    You can either train a new cascade (which is labor intensive) or look around for cascades that other people have trained for this case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Never thought I'd have this problem :) The following snippet of code works in
i am a beginner and i have a problem : this code doesnt compile
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I have problem with this code: file = tempfile.TemporaryFile(mode='wrb') file.write(base64.b64decode(data)) file.flush() os.fsync(file) # file.seek(0)
Hi i have problem with this code, i found it on the internet and
I have this code, but I have a problem. When I update but do
I have this html code <html> <head> <title>JQuery Problem 2</title> <script type=text/javascript src=jquery-1.4.min.js></script> <script
Problem Hello all! I have this code which takes my jpg image loops through
This is an erlang problem, it seems. I have this code to test the
I'm a beginner with jdbc ... I have a problem running this code :

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.