forked from xmba15/onnx_runtime_cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaskRCNN.cpp
More file actions
57 lines (50 loc) · 1.72 KB
/
MaskRCNN.cpp
File metadata and controls
57 lines (50 loc) · 1.72 KB
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
/**
* @file MaskRCNN.cpp
*
* @author btran
*
*/
#include <cstring>
#include "MaskRCNN.hpp"
namespace Ort
{
MaskRCNN::MaskRCNN(const uint16_t numClasses, //
const std::string& modelPath, //
const std::optional<size_t>& gpuIdx,
const std::optional<std::vector<std::vector<int64_t>>>& inputShapes)
: ImageRecognitionOrtSessionHandlerBase(numClasses, modelPath, gpuIdx, inputShapes)
{
}
MaskRCNN::~MaskRCNN()
{
}
void MaskRCNN::preprocess(float* dst, //
const float* src, //
const int64_t targetImgWidth, //
const int64_t targetImgHeight, //
const int numChannels) const
{
for (int c = 0; c < numChannels; ++c) {
for (int i = 0; i < targetImgHeight; ++i) {
for (int j = 0; j < targetImgWidth; ++j) {
dst[c * targetImgHeight * targetImgWidth + i * targetImgWidth + j] =
src[i * targetImgWidth * numChannels + j * numChannels + c];
}
}
}
}
void MaskRCNN::preprocess(float* dst, //
const cv::Mat& imgSrc, //
const int64_t targetImgWidth, //
const int64_t targetImgHeight, //
const int numChannels) const
{
for (int i = 0; i < targetImgHeight; ++i) {
for (int j = 0; j < targetImgWidth; ++j) {
for (int c = 0; c < numChannels; ++c) {
dst[c * targetImgHeight * targetImgWidth + i * targetImgWidth + j] = imgSrc.ptr<float>(i, j)[c];
}
}
}
}
} // namespace Ort