summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTae-Young Chung <ty83.chung@samsung.com>2020-08-25 18:24:22 +0900
committerInki Dae <inki.dae@samsung.com>2020-09-03 12:28:46 +0900
commitf7c5237701af8592a696997e44049a5c932abe0c (patch)
treed153f47f1729ea1641b48b270884bbee74b27aec
parent939175938edb44b934e7cf92abe2cc83dce657c6 (diff)
downloadmediavision-f7c5237701af8592a696997e44049a5c932abe0c.tar.gz
mediavision-f7c5237701af8592a696997e44049a5c932abe0c.tar.bz2
mediavision-f7c5237701af8592a696997e44049a5c932abe0c.zip
Fix division or modulo by float zero
Change-Id: I857aa3fc409ebb1fbaa35262eb771ebb6c92a700 Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
-rw-r--r--mv_inference/inference/src/Posture.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/mv_inference/inference/src/Posture.cpp b/mv_inference/inference/src/Posture.cpp
index c61f9e56..3fd54d35 100644
--- a/mv_inference/inference/src/Posture.cpp
+++ b/mv_inference/inference/src/Posture.cpp
@@ -294,7 +294,7 @@ float Posture::getSimilarity(int parts,
std::vector<std::pair<bool, std::vector<cv::Vec2f>>>& actionPart)
{
float score = 0.0f;
- int bodyCount = 0;
+ unsigned int bodyCount = 0;
std::vector<int> index;
if (parts & MV_INFERENCE_HUMAN_BODY_PART_HEAD) {
@@ -327,11 +327,13 @@ float Posture::getSimilarity(int parts,
score += cosineSimilarity(posePart[(*it)].second, actionPart[(*it)].second, posePart[(*it)].second.size());
bodyCount += posePart[(*it)].second.size();
- LOGI("body[%d], score[%f], count[%d]", (*it), score, bodyCount);
+ LOGI("body[%d], score[%f], count[%u]", (*it), score, bodyCount);
}
}
- score /= (float)bodyCount;
+ if (bodyCount > 0)
+ score /= (float)bodyCount;
+
LOGD("score: %1.3f", score);
return score;