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 8874425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:43:05+00:00 2026-06-14T18:43:05+00:00

I am starting with OpenCV and wanted to test some samples. The sample i

  • 0

I am starting with OpenCV and wanted to test some samples. The sample i use puts a rectangle around the faces in the screen. But the resulting detections are jerky and sporadic, how can I improve my code to make the detections smoother? I use haarcascade_frontalface_alt.xml.

void detectAndDisplay( Mat frame )
{
   vector<Rect> faces;
   Mat frame_gray;
   cvtColor( frame, frame_gray, CV_BGR2GRAY );
   equalizeHist( frame_gray, frame_gray );

   face_cascade.detectMultiScale( frame_gray, faces, 1.1, 2, 0, Size(40, 40) );
   for( size_t i = 0; i < faces.size(); i++ )
   {
      Mat faceROI = frame_gray( faces[i] );
      int x = faces[i].x;
      int y = faces[i].y;
      int h = y+faces[i].height;
      int w = x+faces[i].width;
      rectangle(frame,
          Point (x,y),
          Point (w,h),
          Scalar(255,0,255),
          2,
          8,
          0);
    }
imshow( "Capture - Face detection", frame );
}
  • 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-06-14T18:43:06+00:00Added an answer on June 14, 2026 at 6:43 pm

    Judging by your comment, you are actually detecting faces at each frame in a video sequence and that is sporadic, and that is where you are unhappy with the results. Correct me if I’m wrong.

    The clips you see on YouTube are likely tracking based on the detected face. It is very common to detect faces in the first frame of a video sequence, and then use that as seeded input into a tracking algorithm to track faces. OpenCV has many tracking algorithms, such as Mean Shift and Kalman Filter trackers, that will allow you to track the face. The result of these trackers will be much more smooth than detecting at each frame.

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

Sidebar

Related Questions

I am starting with OpenCV on my new laptop, but there are some errors.
Hi I'm just starting to use python and OpenCV, my IDE is eclipse. Now
I'm just now starting to learn how to use the openCV libraries. I've downloaded
I am starting up with OpenCV (using C++) and was playing around with the
I'm playing around some tutorial code from this OpenCV 2 Cookbook . The code
Having successfully installed opencv 2.0 with python bindings I'm starting to run into trouble
this is just kind of a broad question to get some starting points. I
I'm just starting to learn OpenCV programming. May I just ask about how can
I'm trying to use OpenCv 2.2 in Visual Studio 2010. I've configured everything by
I’m trying to figure out how Vec3b works for Opencv (but I think that

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.