音乐分阶级吗(【无标题】)
#include <stdio.h>
#include
#include
#include
#include
#include
#include
#include
#include
#include
#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 landmarks auto results = face_mesh.Process(image); // Convert back to the BGR color space image = cv::cvtColor(image, cv::COLOR_RGB2BGR); // Draw the face mesh annotations on the image if (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 image cv::imshow("MediaPipe FaceMesh", image); // Terminate the process if (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());
}创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!