Don't convert nullptr to std::string in C layer
PiperOrigin-RevId: 569232756
This commit is contained in:
parent
a577dc3043
commit
33d6143a1a
|
@ -14,6 +14,7 @@ limitations under the License.
|
||||||
==============================================================================*/
|
==============================================================================*/
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "mediapipe/tasks/c/components/processors/classifier_options.h"
|
#include "mediapipe/tasks/c/components/processors/classifier_options.h"
|
||||||
|
@ -24,7 +25,8 @@ namespace mediapipe::tasks::c::components::processors {
|
||||||
void CppConvertToClassifierOptions(
|
void CppConvertToClassifierOptions(
|
||||||
const ClassifierOptions& in,
|
const ClassifierOptions& in,
|
||||||
mediapipe::tasks::components::processors::ClassifierOptions* out) {
|
mediapipe::tasks::components::processors::ClassifierOptions* out) {
|
||||||
out->display_names_locale = in.display_names_locale;
|
out->display_names_locale =
|
||||||
|
in.display_names_locale ? std::string(in.display_names_locale) : "";
|
||||||
out->max_results = in.max_results;
|
out->max_results = in.max_results;
|
||||||
out->score_threshold = in.score_threshold;
|
out->score_threshold = in.score_threshold;
|
||||||
out->category_allowlist =
|
out->category_allowlist =
|
||||||
|
|
|
@ -15,6 +15,9 @@ limitations under the License.
|
||||||
|
|
||||||
#include "mediapipe/tasks/c/core/base_options_converter.h"
|
#include "mediapipe/tasks/c/core/base_options_converter.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "mediapipe/tasks/c/core/base_options.h"
|
#include "mediapipe/tasks/c/core/base_options.h"
|
||||||
#include "mediapipe/tasks/cc/core/base_options.h"
|
#include "mediapipe/tasks/cc/core/base_options.h"
|
||||||
|
|
||||||
|
@ -23,8 +26,11 @@ namespace mediapipe::tasks::c::components::containers {
|
||||||
void CppConvertToBaseOptions(const BaseOptions& in,
|
void CppConvertToBaseOptions(const BaseOptions& in,
|
||||||
mediapipe::tasks::core::BaseOptions* out) {
|
mediapipe::tasks::core::BaseOptions* out) {
|
||||||
out->model_asset_buffer =
|
out->model_asset_buffer =
|
||||||
std::make_unique<std::string>(in.model_asset_buffer);
|
in.model_asset_buffer
|
||||||
out->model_asset_path = in.model_asset_path;
|
? std::make_unique<std::string>(in.model_asset_buffer)
|
||||||
|
: nullptr;
|
||||||
|
out->model_asset_path =
|
||||||
|
in.model_asset_path ? std::string(in.model_asset_path) : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mediapipe::tasks::c::components::containers
|
} // namespace mediapipe::tasks::c::components::containers
|
||||||
|
|
Loading…
Reference in New Issue
Block a user