diff options
Diffstat (limited to 'source/application/api/use_case/object_detection')
3 files changed, 37 insertions, 38 deletions
diff --git a/source/application/api/use_case/object_detection/include/DetectorPostProcessing.hpp b/source/application/api/use_case/object_detection/include/DetectorPostProcessing.hpp index 30bc123..6a53688 100644 --- a/source/application/api/use_case/object_detection/include/DetectorPostProcessing.hpp +++ b/source/application/api/use_case/object_detection/include/DetectorPostProcessing.hpp @@ -26,7 +26,6 @@ namespace arm { namespace app { - namespace object_detection { struct Branch { diff --git a/source/application/api/use_case/object_detection/include/YoloFastestModel.hpp b/source/application/api/use_case/object_detection/include/YoloFastestModel.hpp index 4c64433..16d0715 100644 --- a/source/application/api/use_case/object_detection/include/YoloFastestModel.hpp +++ b/source/application/api/use_case/object_detection/include/YoloFastestModel.hpp @@ -19,13 +19,16 @@ #include "Model.hpp" -extern const int originalImageSize; -extern const int channelsImageDisplayed; -extern const float anchor1[]; -extern const float anchor2[]; - namespace arm { namespace app { + namespace object_detection { + extern const int originalImageSize; + extern const int channelsImageDisplayed; + /* NOTE: anchors are different for any given input model size, estimated during training + * phase */ + extern const float anchor1[]; + extern const float anchor2[]; + } /* namespace object_detection */ class YoloFastestModel : public Model { diff --git a/source/application/api/use_case/object_detection/src/DetectorPostProcessing.cc b/source/application/api/use_case/object_detection/src/DetectorPostProcessing.cc index fb1606a..7610c4f 100644 --- a/source/application/api/use_case/object_detection/src/DetectorPostProcessing.cc +++ b/source/application/api/use_case/object_detection/src/DetectorPostProcessing.cc @@ -43,45 +43,42 @@ namespace app { m_topN(topN) { /* Init PostProcessing */ - this->m_net = - object_detection::Network { - .inputWidth = inputImgCols, + this->m_net = object_detection::Network{ + .inputWidth = inputImgCols, .inputHeight = inputImgRows, - .numClasses = numClasses, - .branches = { - object_detection::Branch { - .resolution = inputImgCols/32, - .numBox = 3, - .anchor = anchor1, - .modelOutput = this->m_outputTensor0->data.int8, - .scale = (static_cast<TfLiteAffineQuantization*>( - this->m_outputTensor0->quantization.params))->scale->data[0], - .zeroPoint = (static_cast<TfLiteAffineQuantization*>( - this->m_outputTensor0->quantization.params))->zero_point->data[0], - .size = this->m_outputTensor0->bytes - }, - object_detection::Branch { - .resolution = inputImgCols/16, - .numBox = 3, - .anchor = anchor2, - .modelOutput = this->m_outputTensor1->data.int8, - .scale = (static_cast<TfLiteAffineQuantization*>( - this->m_outputTensor1->quantization.params))->scale->data[0], - .zeroPoint = (static_cast<TfLiteAffineQuantization*>( - this->m_outputTensor1->quantization.params))->zero_point->data[0], - .size = this->m_outputTensor1->bytes - } - }, - .topN = m_topN - }; + .numClasses = numClasses, + .branches = + {object_detection::Branch{.resolution = inputImgCols / 32, + .numBox = 3, + .anchor = arm::app::object_detection::anchor1, + .modelOutput = this->m_outputTensor0->data.int8, + .scale = (static_cast<TfLiteAffineQuantization*>( + this->m_outputTensor0->quantization.params)) + ->scale->data[0], + .zeroPoint = (static_cast<TfLiteAffineQuantization*>( + this->m_outputTensor0->quantization.params)) + ->zero_point->data[0], + .size = this->m_outputTensor0->bytes}, + object_detection::Branch{.resolution = inputImgCols / 16, + .numBox = 3, + .anchor = arm::app::object_detection::anchor2, + .modelOutput = this->m_outputTensor1->data.int8, + .scale = (static_cast<TfLiteAffineQuantization*>( + this->m_outputTensor1->quantization.params)) + ->scale->data[0], + .zeroPoint = (static_cast<TfLiteAffineQuantization*>( + this->m_outputTensor1->quantization.params)) + ->zero_point->data[0], + .size = this->m_outputTensor1->bytes}}, + .topN = m_topN}; /* End init */ } bool DetectorPostProcess::DoPostProcess() { /* Start postprocessing */ - int originalImageWidth = originalImageSize; - int originalImageHeight = originalImageSize; + int originalImageWidth = arm::app::object_detection::originalImageSize; + int originalImageHeight = arm::app::object_detection::originalImageSize; std::forward_list<image::Detection> detections; GetNetworkBoxes(this->m_net, originalImageWidth, originalImageHeight, m_threshold, detections); |