Closed fatarcher closed 1 year ago
Hi @fatarcher , could you please elaborate this issue to investigate further.
`absl::Status RunMPPGraph() {
std::string calculator_graph_config_contents;
MP_RETURN_IF_ERROR(mediapipe::file::GetContents(
absl::GetFlag(FLAGS_calculator_graph_config_file),
&calculator_graph_config_contents));
LOG(INFO) << "Get calculator graph config contents: "
<< calculator_graph_config_contents;
mediapipe::CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie
LOG(INFO) << "Initialize the calculator graph."; mediapipe::CalculatorGraph graph; MP_RETURN_IF_ERROR(graph.Initialize(config));
LOG(INFO) << "Initialize the camera or load the video."; cv::VideoCapture capture; const bool load_video = !absl::GetFlag(FLAGS_input_video_path).empty(); if (load_video) { capture.open(absl::GetFlag(FLAGS_input_video_path)); } else { capture.open(0); } RET_CHECK(capture.isOpened());
cv::VideoWriter writer; const bool save_video = !absl::GetFlag(FLAGS_output_video_path).empty(); if (!save_video) { cv::namedWindow(kWindowName, /flags=WINDOW_AUTOSIZE/ 1);
capture.set(cv::CAP_PROP_FRAME_WIDTH, 640);
capture.set(cv::CAP_PROP_FRAME_HEIGHT, 480);
capture.set(cv::CAP_PROP_FPS, 30);
}
LOG(INFO) << "Start running the calculator graph.";
ASSIGN_OR_RETURN(mediapipe::OutputStreamPoller poller_mark,
graph.AddOutputStreamPoller(kOutputStream_point));
ASSIGN_OR_RETURN(mediapipe::OutputStreamPoller poller,
graph.AddOutputStreamPoller(kOutputStream));
MP_RETURN_IF_ERROR(graph.StartRun({}));
int fream_cnt = 0;
LOG(INFO) << "Start grabbing and processing frames.";
bool grab_frames = true;
while (grab_frames) {
cv::Mat camera_frame_raw;
capture >> camera_frame_raw;
if (camera_frame_raw.empty()) {
if (!load_video) {
LOG(INFO) << "Ignore empty frames from camera.";
continue;
}
LOG(INFO) << "Empty frame, end of video reached.";
break;
}
cv::Mat camera_frame;
cv::cvtColor(camera_frame_raw, camera_frame, cv::COLOR_BGR2RGB);
if (!load_video) {
cv::flip(camera_frame, camera_frame, /flipcode=HORIZONTAL/ 1);
}
LOG(INFO) << "fream_cnt" << fream_cnt;
auto input_frame = absl::make_unique
mediapipe::Packet packet,packet_mark;
if (!poller.Next(&packet)) break;
auto& output_frame = packet.Get<mediapipe::ImageFrame>();
if (!poller_mark.Next(&packet_mark)) break;
auto& pose_landmark = packet_mark.Get<mediapipe::NormalizedLandmarkList>();
cv::Mat output_frame_mat = mediapipe::formats::MatView(&output_frame);
cv::cvtColor(output_frame_mat, output_frame_mat, cv::COLOR_RGB2BGR);
//imwrite("/data/ft_local/work/ft_local/test/pic/"+std::to_string(fream_cnt)+".jpg",camera_frame);
fream_cnt ++;
if (save_video) {
if (!writer.isOpened()) {
LOG(INFO) << "Prepare video writer.";
writer.open(absl::GetFlag(FLAGS_output_video_path),
mediapipe::fourcc('a', 'v', 'c', '1'), // .mp4
capture.get(cv::CAP_PROP_FPS), output_frame_mat.size());
RET_CHECK(writer.isOpened());
}
writer.write(output_frame_mat);
} else {
cv::imshow(kWindowName, output_frame_mat);
const int pressed_key = cv::waitKey(5);
if (pressed_key >= 0 && pressed_key != 255) grab_frames = false;
}
}
LOG(INFO) << "Shutting down."; if (writer.isOpened()) writer.release(); MP_RETURN_IF_ERROR(graph.CloseInputStream(kInputStream)); return graph.WaitUntilDone(); }`
here is my code ,in my test video it stop in "if (!poller_mark.Next(&packet_mark)) break;" and fream_cnt is 23 or 56 or 156 or some fream.But in demo this video is ok.`
what else can I provide.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you.
Closing as stale. Please reopen if you'd like to work on this further.
Closing as stale. Please reopen if you'd like to work on this further.
Hi @ivan-grishchenko , Could you please have look on this issue.
I have the same problem
mediapipe::StatusOrPoller faceLandmarks = m_Graph.AddOutputStreamPoller(m_OutputStreamName,true);
// 5 FaceLandmarks
mediapipe::Packet faceLandmarksPacket;
if (!m_pFaceLandmarksPoller->Next(&faceLandmarksPacket)) {
return absl::InvalidArgumentError("no next packet");
}
if (faceLandmarksPacket.IsEmpty()) {
return absl::InvalidArgumentError("no next packet");
}
Hello @fatarcher, We are upgrading the MediaPipe Legacy Solutions to new MediaPipe solutions However, the libraries, documentation, and source code for all the MediapPipe Legacy Solutions will continue to be available in our GitHub repository and through library distribution services, such as Maven and NPM.
You can continue to use those legacy solutions in your applications if you choose. Though, we would request you to check new MediaPipe solutions which can help you more easily build and customize ML solutions for your applications. These new solutions will provide a superset of capabilities available in the legacy solutions. Thank you
This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.
This issue was closed due to lack of activity after being marked stale for past 7 days.
In same video ,for demo ,it would work out.But I want get pose_landmark, add "constexpr char kOutputStream_point[] = "pose_landmarks";"
" ASSIGN_OR_RETURN(mediapipe::OutputStreamPoller poller_mark, graph.AddOutputStreamPoller(kOutputStream_point));" mediapipe::Packet packet,packet_mark;
"if (!poller_mark.Next(&packet_mark)) break;" in demo. in some frame ,it would stop in "if (!poller_mark.Next(&packet_mark)) break;" and ,it never break, just stop.