Skip to content

Commit

Permalink
float_vector - return vector size
Browse files Browse the repository at this point in the history
  • Loading branch information
mgarbade committed Sep 26, 2022
1 parent 0dc3eb8 commit bad3cd6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
17 changes: 10 additions & 7 deletions mediapipe_api/framework/formats/float_vector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@ MpReturnCode mp_Packet__GetFloatVector(mediapipe::Packet* packet, const float**
CATCH_ALL
}

// TODO: Return with vector size
// MpReturnCode mp_Packet__GetFloatVector(mediapipe::Packet* packet, const float** data_out, int* size_out) {
// TRY_ALL
// *data_out = packet->Get<std::vector<float>>().data();
// RETURN_CODE(MpReturnCode::Success);
// CATCH_ALL
//}
MpReturnCode mp_Packet__GetFloatVector(mediapipe::Packet* packet, const float** data_out, int* size_out) {
TRY_ALL
auto& vector_float = packet->Get<std::vector<float>>();
auto length = vector_float.size();

*data_out = vector_float.data();
*size_out = length;
RETURN_CODE(MpReturnCode::Success);
CATCH_ALL
}

MP_CAPI(MpReturnCode) mp_Packet__ValidateAsFloatVector(mediapipe::Packet* packet, absl::Status** status_out) {
TRY
Expand Down
1 change: 1 addition & 0 deletions mediapipe_api/framework/formats/float_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ extern "C" {
MP_CAPI(MpReturnCode) mp__MakeFloatVectorPacket__PA_i(const float* value, int size, mediapipe::Packet** packet_out);
MP_CAPI(MpReturnCode) mp__MakeFloatVectorPacket_At__PA_i_Rt(const float* value, int size, mediapipe::Timestamp* timestamp, mediapipe::Packet** packet_out);
MP_CAPI(MpReturnCode) mp_Packet__GetFloatVector(mediapipe::Packet* packet, const float** value_out);
MP_CAPI(MpReturnCode) mp_Packet__GetFloatVector(mediapipe::Packet* packet, const float** value_out, int* size_out)
MP_CAPI(MpReturnCode) mp_Packet__ValidateAsFloatVector(mediapipe::Packet* packet, absl::Status** status_out);

} // extern "C"
Expand Down

0 comments on commit bad3cd6

Please sign in to comment.