我在窗口露脸和一些特殊点时编写程序(68)。我使用Haar Casscade和FaceLandmarkLBF。我的程序有问题。当脸部位置稳定时,脸部点会抖动(抖动)。我该如何解决?谢谢。
#include <iostream>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/face.hpp>
using cv::Scalar;
using cv::Point;
int main(int argc, char** argv)
{
    cv::CascadeClassifier faceDetector("haarcascade_frontalface_alt2.xml");
    cv::Ptr<cv::face::Facemark>facemark = cv::face::FacemarkLBF::create();
    facemark->loadModel("lbfmodel.yaml");
    cv::VideoCapture vc(0);
    while (true)
    {
        cv::Mat frame, gray;
        vc.read(frame);
        cv::cvtColor(frame, gray, cv::COLOR_BGR2GRAY);
        //
        std::vector<cv::Rect> faces;
        faceDetector.detectMultiScale(gray, faces);
        std::vector< std::vector<cv::Point2f> > landmarks;
        bool success = facemark->fit(frame, faces, landmarks);
        for (size_t i = 0; i < landmarks.size(); i++)
        {
            for (size_t j = 0; j < landmarks[i].size(); j++)
            {
                cv::circle(frame, cv::Point(landmarks[i][j].x, landmarks[i][j].y), 2, Scalar(255, …