本文整理汇总了C++中FaceTracker::NewFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ FaceTracker::NewFrame方法的具体用法?C++ FaceTracker::NewFrame怎么用?C++ FaceTracker::NewFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FaceTracker
的用法示例。
在下文中一共展示了FaceTracker::NewFrame方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_facial_points
int get_facial_points(Mat& face, vector<Point_<double> >& points)
{
FaceTracker * tracker = LoadFaceTracker(DefaultFaceTrackerModelPathname().c_str());
FaceTrackerParams *tracker_params = LoadFaceTrackerParams(DefaultFaceTrackerParamsPathname().c_str());
Mat frame_gray;
cvtColor(face, frame_gray, CV_RGB2GRAY );
int result = tracker->NewFrame(frame_gray, tracker_params);
vector<Point_<double> > shape;
Pose pose;
if (result >= 1) {
points = tracker->getShape();
pose = tracker->getPose();
} else {
return 0;
}
delete tracker;
delete tracker_params;
return 1;
}
示例2: LoadFaceTracker
int
run_image_mode(const Configuration &cfg,
const CommandLineArgument<std::string> &image_argument,
const CommandLineArgument<std::string> &landmarks_argument)
{
FaceTracker * tracker = LoadFaceTracker(cfg.model_pathname.c_str());
FaceTrackerParams *tracker_params = LoadFaceTrackerParams(cfg.params_pathname.c_str());
cv::Mat image;
cv::Mat_<uint8_t> gray_image = load_grayscale_image(image_argument->c_str(), &image);
int result = tracker->NewFrame(gray_image, tracker_params);
std::vector<cv::Point_<double> > shape;
std::vector<cv::Point3_<double> > shape3;
Pose pose;
if (result >= cfg.tracking_threshold) {
shape = tracker->getShape();
shape3 = tracker->get3DShape();
pose = tracker->getPose();
}
if (!have_argument_p(landmarks_argument)) {
display_data(cfg, image, shape, pose);
} else if (shape.size() > 0) {
if (cfg.save_3d_points)
save_points3(landmarks_argument->c_str(), shape3);
else
save_points(landmarks_argument->c_str(), shape);
}
delete tracker;
delete tracker_params;
return 0;
}
示例3: make_runtime_error
// Helpers
int
run_lists_mode(const Configuration &cfg,
const CommandLineArgument<std::string> &image_argument,
const CommandLineArgument<std::string> &landmarks_argument)
{
FaceTracker * tracker = LoadFaceTracker(cfg.model_pathname.c_str());
FaceTrackerParams *tracker_params = LoadFaceTrackerParams(cfg.params_pathname.c_str());
std::list<std::string> image_pathnames = read_list(image_argument->c_str());
std::list<std::string> landmark_pathnames;
if (have_argument_p(landmarks_argument)) {
landmark_pathnames = read_list(landmarks_argument->c_str());
if (landmark_pathnames.size() != image_pathnames.size())
throw make_runtime_error("Number of pathnames in list '%s' does not match the number in '%s'",
image_argument->c_str(), landmarks_argument->c_str());
}
std::list<std::string>::const_iterator image_it = image_pathnames.begin();
std::list<std::string>::const_iterator landmarks_it = landmark_pathnames.begin();
const int number_of_images = image_pathnames.size();
int current_image_index = 1;
for (; image_it != image_pathnames.end(); image_it++) {
if (cfg.verbose) {
printf(" Image %d/%d\r", current_image_index, number_of_images);
fflush(stdout);
}
current_image_index++;
cv::Mat image;
cv::Mat_<uint8_t> gray_image = load_grayscale_image(image_it->c_str(), &image);
int result = tracker->NewFrame(gray_image, tracker_params);
std::vector<cv::Point_<double> > shape;
std::vector<cv::Point3_<double> > shape3D;
Pose pose;
if (result >= cfg.tracking_threshold) {
shape = tracker->getShape();
shape3D = tracker->get3DShape();
pose = tracker->getPose();
} else {
tracker->Reset();
}
if (!have_argument_p(landmarks_argument)) {
display_data(cfg, image, shape, pose);
} else if (shape.size() > 0) {
if (cfg.save_3d_points)
save_points3(landmarks_it->c_str(), shape3D);
else
save_points(landmarks_it->c_str(), shape);
if (cfg.verbose)
display_data(cfg, image, shape, pose);
} else if (cfg.verbose) {
display_data(cfg, image, shape, pose);
}
if (have_argument_p(landmarks_argument))
landmarks_it++;
}
delete tracker;
delete tracker_params;
return 0;
}