|
11 | 11 |
|
12 | 12 | namespace op |
13 | 13 | { |
| 14 | + /** |
| 15 | + * Hand keypoint extractor class. |
| 16 | + */ |
14 | 17 | class OP_API HandExtractor |
15 | 18 | { |
16 | 19 | public: |
| 20 | + /** |
| 21 | + * Constructor of the HandExtractor class. |
| 22 | + * @param netInputSize Size at which the cropped image (where the hand is located) is resized. |
| 23 | + * @param netOutputSize Size of the final results. At the moment, it must be equal than netOutputSize. |
| 24 | + * @param modelFolder Folder where the models are located. |
| 25 | + * @param gpuId The GPU index (0-based) which the deep net will use. |
| 26 | + * @param numberScales Number of scales to run. The more scales, the slower it will be but possibly also more accurate. |
| 27 | + * @param rangeScales The range between the smaller and bigger scale. |
| 28 | + */ |
17 | 29 | explicit HandExtractor(const Point<int>& netInputSize, const Point<int>& netOutputSize, const std::string& modelFolder, const int gpuId, |
18 | 30 | const unsigned short numberScales = 1, const float rangeScales = 0.4f); |
19 | 31 |
|
| 32 | + /** |
| 33 | + * This function must be call before using any other function. It must also be called inside the thread in which the functions are going |
| 34 | + * to be used. |
| 35 | + */ |
20 | 36 | void initializationOnThread(); |
21 | 37 |
|
| 38 | + /** |
| 39 | + * This function extracts the hand keypoints for each detected hand in the image. |
| 40 | + * @param fpsMode handRectangles Location of the hands in the image. It is a length-variable std::vector, where each index corresponds to |
| 41 | + * a different person in the image. Internally the std::vector, a std::array of 2 elements: index 0 and 1 for left and right hand |
| 42 | + * respectively. Inside each array element, a op::Rectangle<float> (similar to cv::Rect for floating values) with the position of that hand |
| 43 | + * (or 0,0,0,0 if some hand is missing, e.g. if a specific person has only half of the body inside the image). |
| 44 | + * @param cvInputData Original image in cv::Mat format and BGR format. |
| 45 | + * @param scaleInputToOutput Desired scale of the final keypoints. Set to 1 if the desired size is the cvInputData size. |
| 46 | + */ |
22 | 47 | void forwardPass(const std::vector<std::array<Rectangle<float>, 2>> handRectangles, const cv::Mat& cvInputData, |
23 | 48 | const float scaleInputToOutput); |
24 | 49 |
|
| 50 | + /** |
| 51 | + * This function returns the hand keypoins. VERY IMPORTANT: use getHandKeypoints().clone() if the keypoints are going to be edited |
| 52 | + * in a different thread. |
| 53 | + * @return And std::array with all the left hand keypoints (index 0) and all the right ones (index 1). Each Array<float> follows the pose |
| 54 | + * structure, i.e. the first dimension corresponds to all the people in the image, the second to each specific keypoint, and the third |
| 55 | + * one to (x, y, score). |
| 56 | + */ |
25 | 57 | std::array<Array<float>, 2> getHandKeypoints() const; |
26 | 58 |
|
27 | 59 | private: |
|
0 commit comments