Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libprotobuf repeated_field.h CHECK failed: (total_size_) > (0) trying to extract multi_palm_detections proto #5198

Open
dizcza opened this issue Mar 6, 2024 · 0 comments
Assignees
Labels
legacy:hands Hand tracking/gestures/etc os:linux-non-arm Issues on linux distributions which run on x86-64 architecture. DOES NOT include ARM devices. platform:c++ Issues specific to C++ framework in mediapipe stat:awaiting googler Waiting for Google Engineer's Response

Comments

@dizcza
Copy link

dizcza commented Mar 6, 2024

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

Yes

OS Platform and Distribution

Ubuntu 22.04

MediaPipe Tasks SDK version

legacy tflite models

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

HandLandmarks & pose estimation

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

C++

Describe the actual behavior

crash when palm score is extracted from proto messages

Describe the expected behaviour

palm score is extracted from proto messages without a crash

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

ASSIGN_OR_RETURN(mediapipe::OutputStreamPoller multi_palm_detections_poller,
                   graph.AddOutputStreamPoller("multi_palm_detections"));
      mediapipe::Packet multi_palm_detections_packet;

        // Palm detection scores.
        // If no detection, set to 1.0 because the palm detector runs on the first frame only.
        float palm_score[] = {1.0f, 1.0f};

        // crash happens somewhere here
        // if I remove this if-statement, everything works fine with either 1 or 2 num_hands
        if (multi_palm_detections_poller.QueueSize() && multi_palm_detections_poller.Next(&multi_palm_detections_packet)) {
          const auto& multi_palm_detections = multi_palm_detections_packet.Get<std::vector<mediapipe::Detection>>();

          for (int palm_id = 0; palm_id < num_hands_found; palm_id++) {
            const mediapipe::Detection& det = multi_palm_detections[palm_id];
            if (det.score_size() > 0) {
              palm_score[palm_id] = det.score(0);
              LOG(INFO) << palm_id << " palm score: " << palm_score[palm_id];
            }
          }

        }

Graph:

# MediaPipe graph that performs hands tracking on desktop with TensorFlow
# Lite on CPU.
# Used in the example in
# mediapipe/examples/desktop/hand_tracking:hand_tracking_cpu.

# CPU image. (ImageFrame)
input_stream: "input_video"

input_stream: "input_video_visualize"

input_side_packet: "NUM_HANDS:num_hands"

# CPU image. (ImageFrame)
output_stream: "output_video"

node {
  calculator: "ConstantSidePacketCalculator"
  output_side_packet: "PACKET:use_prev_landmarks"
  node_options: {
    [type.googleapis.com/mediapipe.ConstantSidePacketCalculatorOptions]: {
      packet { bool_value: true }
    }
  }
}

# Detects/tracks hand landmarks.
node {
  calculator: "HandLandmarkTrackingCpu"
  input_stream: "IMAGE:input_video"
  input_side_packet: "NUM_HANDS:num_hands"
  input_side_packet: "USE_PREV_LANDMARKS:use_prev_landmarks"
  output_stream: "LANDMARKS:landmarks"
  output_stream: "WORLD_LANDMARKS:world_landmarks"
  output_stream: "HANDEDNESS:handedness"
  output_stream: "PALM_DETECTIONS:multi_palm_detections"
  output_stream: "HAND_ROIS_FROM_LANDMARKS:multi_hand_rects"
  output_stream: "HAND_ROIS_FROM_PALM_DETECTIONS:multi_palm_rects"
}

# Subgraph that renders annotations and overlays them on top of the input
# images (see hand_renderer_cpu.pbtxt).
node {
  calculator: "HandRendererSubgraph"
  
  # Change to "input_video" to see the changes in
  # the colorspace (color glove swaps R-G-B channels)
  # input_stream: "IMAGE:input_video"
  input_stream: "IMAGE:input_video_visualize"

  input_stream: "DETECTIONS:multi_palm_detections"
  input_stream: "LANDMARKS:landmarks"
  input_stream: "HANDEDNESS:handedness"
  input_stream: "NORM_RECTS:0:multi_palm_rects"
  input_stream: "NORM_RECTS:1:multi_hand_rects"
  output_stream: "IMAGE:output_video"
}

# need to detect packet presense
node {
  calculator: "PacketPresenceCalculator"
  input_stream: "PACKET:landmarks"
  output_stream: "PRESENCE:landmark_presence"
}

Other info / Complete Logs

I20240306 18:44:07.606578  8018 airtouch_main.cc:778] 0 palm score: 0.6661
[libprotobuf FATAL external/com_google_protobuf/src/google/protobuf/repeated_field.h:353] CHECK failed: (total_size_) > (0):
@ayushgdev ayushgdev added legacy:hands Hand tracking/gestures/etc platform:c++ Issues specific to C++ framework in mediapipe os:linux-non-arm Issues on linux distributions which run on x86-64 architecture. DOES NOT include ARM devices. labels Mar 7, 2024
@ayushgdev ayushgdev added the stat:awaiting googler Waiting for Google Engineer's Response label Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy:hands Hand tracking/gestures/etc os:linux-non-arm Issues on linux distributions which run on x86-64 architecture. DOES NOT include ARM devices. platform:c++ Issues specific to C++ framework in mediapipe stat:awaiting googler Waiting for Google Engineer's Response
Projects
None yet
Development

No branches or pull requests

3 participants