+++ /dev/null
-/**
- * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __BACKBONE_MODEL_INFO_H__
-#define __BACKBONE_MODEL_INFO_H__
-
-#include "inference_engine_common_impl.h"
-
-typedef struct {
- std::string layer_name;
- inference_engine_tensor_info tensor_info;
-} model_layer_info;
-
-class IBackboneModelInfo
-{
-public:
- virtual ~IBackboneModelInfo()
- {}
-
- virtual std::vector<model_layer_info> &getInputLayerInfo() = 0;
- virtual std::vector<model_layer_info> &getOutputLayerInfo() = 0;
- virtual std::string getModelFilePath() = 0;
-};
-
-#endif
\ No newline at end of file
#include "inference_engine_common_impl.h"
#include "Inference.h"
#include "label_manager.h"
-#include "backbone_model_info.h"
#include "feature_vector_manager.h"
#include "data_set_manager.h"
#include "simple_shot.h"
unsigned int _status;
std::unique_ptr<mediavision::inference::Inference> _internal;
std::unique_ptr<mediavision::inference::Inference> _backbone;
- std::unique_ptr<IBackboneModelInfo> _backbone_model_info;
std::unique_ptr<TrainingModel> _training_model;
std::unique_ptr<LabelManager> _label_manager;
FaceRecognitionConfig _config;
void checkFeatureVectorFile(std::string fv_file_name, std::string new_fv_file_name);
void storeDataSet(std::unique_ptr<DataSetManager> &data_set, unsigned int label_cnt);
int getAnswer();
- std::vector<model_layer_info> &getBackboneInputLayerInfo();
- int getVecFromMvSource(mv_source_h img_src, std::vector<float> &out_vec);
public:
FaceRecognition();
namespace machine_learning
{
FaceRecognition::FaceRecognition()
- : _status(NONE)
- , _internal()
- , _backbone()
- , _backbone_model_info()
- , _training_model()
- , _label_manager()
- , _config()
- , _result()
+ : _status(NONE), _internal(), _backbone(), _training_model(), _label_manager(), _config(), _result()
{}
FaceRecognition::~FaceRecognition()
_config = config;
}
-std::vector<model_layer_info> &FaceRecognition::getBackboneInputLayerInfo()
-{
- return _backbone_model_info->getInputLayerInfo();
-}
-
-int FaceRecognition::getVecFromMvSource(mv_source_h img_src, std::vector<float> &out_vec)
-{
- mv_colorspace_e colorspace = MEDIA_VISION_COLORSPACE_INVALID;
- unsigned int width = 0, height = 0, bufferSize = 0;
- unsigned char *buffer = NULL;
-
- if (mv_source_get_width(img_src, &width) != MEDIA_VISION_ERROR_NONE ||
- mv_source_get_height(img_src, &height) != MEDIA_VISION_ERROR_NONE ||
- mv_source_get_colorspace(img_src, &colorspace) != MEDIA_VISION_ERROR_NONE ||
- mv_source_get_buffer(img_src, &buffer, &bufferSize))
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
-
- // TODO. Let's support various color spaces.
-
- if (colorspace != MEDIA_VISION_COLORSPACE_RGB888) {
- LOGE("Not Supported format!\n");
- return MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT;
- }
-
- vector<model_layer_info> &input_layer_info = getBackboneInputLayerInfo();
- // TODO. consider multiple tensor info.
- size_t re_width = input_layer_info[0].tensor_info.shape[0];
- size_t re_height = input_layer_info[0].tensor_info.shape[1];
-
- LOGD("Convert mv source(WxH) : %d x %d => %zu x %zu", width, height, re_width, re_height);
-
- FeatureVectorManager::getVecFromRGB(buffer, out_vec, width, height, re_width, re_height);
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
int FaceRecognition::initialize()
{
_training_model = make_unique<SimpleShot>(_config.training_engine_backend_type, _config.training_target_device_type,