afsaredrisy / MediapipeHandtracking_GPU_Bitmap_Input

Handtracking mediapipe sample with bitmap RGB input
31 stars 10 forks source link

How to get the hand landmarks? #1

Open bophancong opened 3 years ago

bophancong commented 3 years ago

@afsaredrisy Hi. It's a nice work. I have tried to run your code with Bitmap image successfully. However, I have a problem in obtaining the hand landmarks. Could you please let's me know how could a obtain the hand landmarks if you have tried? Thank you very much.

CaydenPierce commented 3 years ago

@bophancong

Add this callback to the processor to get landmarks. On my custom graph, this only runs when the graph actually passes the output landmark stream as specified by OUTPUT_LANDMARKS_STREAM_NAME

  processor.addPacketCallback(
      OUTPUT_LANDMARKS_STREAM_NAME,
      (packet) -> {
        Log.d(TAG, "PACKET CALLBACK");
        byte[] landmarksRaw = PacketGetter.getProtoBytes(packet);
        try {
          NormalizedLandmarkList landmarks = NormalizedLandmarkList.parseFrom(landmarksRaw);
          if (landmarks == null) {
            Log.d(TAG, "[TS:" + packet.getTimestamp() + "] No landmarks.");
            return;
          }
        } catch (InvalidProtocolBufferException e) {
          Log.e(TAG, "Couldn't Exception received - " + e);
          return;
        }
      });