mediapipe icon indicating copy to clipboard operation
mediapipe copied to clipboard

C++ get the coordinates of the hand, how do tell if it's left or right?

Open kyn817046 opened this issue 1 year ago • 1 comments

Have I written custom code (as opposed to using a stock example script provided in MediaPipe)

Yes

OS Platform and Distribution

windows

MediaPipe Tasks SDK version

0.10.14

Task name (e.g. Image classification, Gesture recognition etc.)

hand recongnistion

Programming Language and version (e.g. C++, Python, Java)

C++

Describe the actual behavior

get the coordinates of the hand

Describe the expected behaviour

how do tell if it's left or right?

Standalone code/steps you may have used to try to get what you need

// Wrap Mat into an ImageFrame.
	auto input_frame = absl::make_unique<mediapipe::ImageFrame>(
		mediapipe::ImageFormat::SRGB, camera_frame_RGB.cols, camera_frame_RGB.rows,
		mediapipe::ImageFrame::kDefaultAlignmentBoundary);

	camera_frame_RGB.copyTo(mediapipe::formats::MatView(input_frame.get()));

	//std::cout << "Wrap Mat into an ImageFrame." << std::endl;

	// Send image packet into the graph.
	size_t frame_timestamp_us =
		(double)cv::getTickCount() / (double)cv::getTickFrequency() * 1e6;

	MP_RETURN_IF_ERROR(m_Graph.AddPacketToInputStream(
		m_kInputStream, mediapipe::Adopt(input_frame.release())
		.At(mediapipe::Timestamp(frame_timestamp_us))));
	//std::cout << "Send image packet into the graph." << std::endl;


	// Get the graph result packet, or stop if that fails.
	mediapipe::Packet packet;
	mediapipe::Packet packet_landmarks;
	if (!m_pPoller->Next(&packet))
		return absl::OkStatus();

	if (m_pPoller_landmarks->QueueSize() > 0)
	{
		if (m_pPoller_landmarks->Next(&packet_landmarks))
		{

			std::vector<mediapipe::NormalizedLandmarkList> output_landmarks = packet_landmarks.Get<std::vector<mediapipe::NormalizedLandmarkList>>();
			//GestureRecognitionResult tempGestureResult;
			//auto handness= output_landmarks[0].classification().label();
			for (int m = 0; m < output_landmarks.size(); ++m)
			{
				mediapipe::NormalizedLandmarkList single_hand_NormalizedLandmarkList = output_landmarks[m];
				//single_hand_NormalizedLandmarkList.mutable_landmark()
				std::vector<PoseInfo> singleHandGestureInfo;
				singleHandGestureInfo.clear();
				for (int i = 0; i < single_hand_NormalizedLandmarkList.landmark_size(); ++i)
				{
					PoseInfo info;
					const mediapipe::NormalizedLandmark landmark = single_hand_NormalizedLandmarkList.landmark(i);
					info.x = landmark.x() * camera_frame.cols;
					info.y = landmark.y() * camera_frame.rows;
					singleHandGestureInfo.push_back(info);
				}
}

Other info / Complete Logs

No response

kyn817046 avatar May 16 '24 09:05 kyn817046

0.0 Please help me ....

kyn817046 avatar May 22 '24 03:05 kyn817046

Hi @kyn817046,

Apologies for the delayed response. Could you please let us know if this has been resolved on your end, or if you are still seeking a resolution?

Thank you!!

kuaashish avatar Jul 29 '24 09:07 kuaashish

Checked some information, it's already solved! Thank you

kyn817046 avatar Jul 29 '24 09:07 kyn817046

Hi @kyn817046,

Thank you for your response. Can we now mark the status as resolved?

kuaashish avatar Jul 29 '24 09:07 kuaashish

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.

github-actions[bot] avatar Aug 06 '24 01:08 github-actions[bot]

This issue was closed due to lack of activity after being marked stale for past 7 days.

github-actions[bot] avatar Aug 13 '24 01:08 github-actions[bot]