1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
/**
* Copyright (c) 2019 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 __MEDIA_VISION_POSE_H__
#define __MEDIA_VISION_POSE_H__
#include <map>
#include <string>
#include "Bvh.h"
#include "BvhParser.h"
#include "Inference.h"
#include "mv_common.h"
#include <mv_inference_type.h>
#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
/**
* @file Pose.h
* @brief This file contains the pose class definition
*/
namespace mediavision
{
namespace inference
{
class Posture
{
public:
/**
* @brief Creates an Posture class instance.
*
* @since_tizen 6.0
*/
Posture();
/**
* @brief Destroys an Posture class instance including
* its all resources.
*
* @since_tizen 6.0
*/
~Posture();
/**
* @brief Sets file path
*
* @since_tizen 6.0
*/
int setPoseFromFile(const std::string motionCaptureFilePath, const std::string motionMappingFilePath);
/**
* @brief Compares a pose for @a part and returns score
*
* @since_tizen 6.0
*/
int compare(int parts, std::vector<std::pair<bool, cv::Point> > action, float *score);
private:
cv::Vec2f getUnitVectors(cv::Point point1, cv::Point point2);
int getParts(int parts, std::vector<std::pair<bool, cv::Point> > &pose,
std::vector<std::pair<bool, std::vector<cv::Vec2f> > > &posePart);
float getSimilarity(int parts, std::vector<std::pair<bool, std::vector<cv::Vec2f> > > &posePart,
std::vector<std::pair<bool, std::vector<cv::Vec2f> > > &actionPart);
float cosineSimilarity(std::vector<cv::Vec2f> vec1, std::vector<cv::Vec2f> vec2, int size);
private:
BvhParser mBvhParser;
Bvh mBvh;
std::map<std::string, int> mMotionToPoseMap; /**< name, index */
std::vector<std::pair<bool, cv::Point> > mPose;
std::vector<std::pair<bool, std::vector<cv::Vec2f> > > mPoseParts;
};
} /* Inference */
} /* MediaVision */
#endif /* __MEDIA_VISION_INFERENCE_H__ */
|