小编bob*_*rus的帖子

面对地标和使用光流稳定

我在窗口露脸和一些特殊点时编写程序(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, …
Run Code Online (Sandbox Code Playgroud)

c++ opencv computer-vision

2
推荐指数
1
解决办法
984
查看次数

标签 统计

c++ ×1

computer-vision ×1

opencv ×1