位置: IT常识 - 正文
推荐整理分享【无标题】(无标题节啥意思),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:无标题是什么意思,无标题节怎么取消,无标题节啥意思,无标题作文,无标题节怎么取消,无标题行怎么设置,无标题文案,无标题行怎么设置,内容如对您有帮助,希望把文章链接给更多的朋友!
#include <stdio.h>
#include <mediapipe/framework/calculator_framework.h> #include <mediapipe/framework/formats/image_frame.h> #include <mediapipe/framework/formats/image_frame_opencv.h> #include <mediapipe/framework/port/opencv_core_inc.h> #include <mediapipe/framework/port/opencv_imgproc_inc.h> #include <mediapipe/framework/port/parse_text_proto.h> #include <mediapipe/framework/port/status.h> #include <mediapipe/solutions/drawing_utils.h> #include <mediapipe/solutions/face_mesh.h> #include <mediapipe/util/tracking/region_flow.h>
using mediapipe::CalculatorGraphConfig; using mediapipe::ParseTextProtoOrDie; using mediapipe::face_mesh::FaceMesh; using mediapipe::solutions::drawing_utils::DrawingSpec; using mediapipe::solutions::drawing_utils::DrawingStyle;
int main() { // Initialize CalculatorGraph config CalculatorGraphConfig config = ParseTextProtoOrDie(R"( node { calculator: “FaceMeshCalculator” input_stream: “VIDEO:video_frames” output_stream: “FACE_MESH:face_mesh” options { [mediapipe.FaceMeshCalculatorOptions.ext] { min_detection_confidence: 0.5 min_tracking_confidence: 0.5 } } } node { calculator: “VideoToImageCalculator” input_stream: “VIDEO:video_frames” output_stream: “IMAGE:image_frame” } node { calculator: “DrawFaceMeshCalculator” input_stream: “IMAGE:image_frame” input_stream: “FACE_MESH:face_mesh” output_stream: “IMAGE:image_frame_with_mesh” options { [mediapipe.DrawFaceMeshCalculatorOptions.ext] { landmark_drawing_spec { thickness: 1 circle_radius: 1 } tesselation_style: SOLID } } } )");
// Open video capture cv::VideoCapture cap(0); cv::Mat image;
// Initialize FaceMesh FaceMesh face_mesh; face_mesh.Initialize();
// Run the Calculator graph mediapipe::CalculatorGraph graph; MP_RETURN_IF_ERROR(graph.Initialize(config)); MP_RETURN_IF_ERROR(graph.StartRun({{“VIDEO:video_frames”, cap}}));
// Main loop while (cap.read(image)) { // Flip the image horizontally and convert the color space from BGR to RGB image = cv::cvtColor(cv::flip(image, 1), cv::COLOR_BGR2RGB);
// Detect the face landmarksauto results = face_mesh.Process(image);// Convert back to the BGR color spaceimage = cv::cvtColor(image, cv::COLOR_RGB2BGR);// Draw the face mesh annotations on the imageif (results.multi_face_landmarks.size() > 0) { DrawingSpec spec; spec.thickness = 1; spec.circle_radius = 1; mp::solutions::drawing_utils::DrawLandmarks( image, results.multi_face_landmarks, mp::face_mesh::FACEMESH_TESSELATION, spec, mp::solutions::drawing_styles::GetDefaultFaceMeshTesselationStyle());}// Display the imagecv::imshow("MediaPipe FaceMesh", image);// Terminate the processif (cv::waitKey(5) & 0xFF == 27) { break;}}
// Close the Calculator graph MP_RETURN_IF_ERROR(graph.CloseInputStream(“VIDEO:video_frames”)); MP_RETURN_IF_ERROR(graph.WaitUntilDone()); }
上一篇:程序人生 | 与足球共舞的火柴人(致敬格拉利什,赋予足球更深的意义)(程序人是什么意思)
下一篇:如何使用 Axios 中的请求拦截器 和响应拦截器(如何使用axios直接发送GET请求)
友情链接: 武汉网站建设