MCPcopy Create free account
hub / github.com/CVCUDA/CV-CUDA / TEST

Function TEST

tests/cvcuda/system/TestOpMinAreaRect.cpp:94–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92}
93
94TEST(OpMinAreaRect, MinAreaRect_sanity)
95{
96 int batchsize = 3;
97
98 std::vector<std::vector<short>> contourPointsData;
99
100 contourPointsData.push_back(
101 {845, 600, 845, 601, 847, 603, 859, 603, 860, 604, 865, 604, 866, 603, 867, 603, 868, 602, 868, 601, 867, 600});
102 contourPointsData.push_back({965, 489, 964, 490, 963, 490, 962, 491, 962, 494, 963, 495,
103 963, 499, 964, 500, 964, 501, 966, 503, 1011, 503, 1012, 504,
104 1013, 503, 1027, 503, 1027, 502, 1028, 501, 1028, 490, 1027, 489});
105 contourPointsData.push_back({1050, 198, 1049, 199, 1040, 199, 1040, 210, 1041, 211, 1040, 212, 1040, 214, 1045, 214,
106 1046, 213, 1049, 213, 1050, 212, 1051, 212, 1052, 211, 1053, 211, 1054, 210, 1055, 210,
107 1056, 209, 1058, 209, 1059, 208, 1059, 200, 1058, 200, 1057, 199, 1051, 199});
108 //
109 std::vector<std::vector<float>> openCV_minAreaRect_results;
110 openCV_minAreaRect_results.push_back({868.0, 604.0, 845.0, 604.0, 845.0, 600.0, 868.0, 600.0});
111 openCV_minAreaRect_results.push_back({962.0, 504.0, 962.0, 489.0, 1028.0, 489.0, 1028.0, 504.0});
112 openCV_minAreaRect_results.push_back({1040.0, 214.0, 1040.0, 198.0, 1059.0, 198.0, 1059.0, 214.0});
113
114 // point number in each contour
115 nvcv::Tensor inPointNumInContour{
116 nvcv::TensorShape{{1, batchsize}, nvcv::TENSOR_NW},
117 nvcv::TYPE_S32
118 };
119 auto inPointNumInContourAccess = nvcv::TensorDataAccessStrided::Create(inPointNumInContour.exportData());
120 auto numPointNumInContourElements = inPointNumInContourAccess->sampleStride() / sizeof(int);
121 std::vector<int> inPointNumInContourValues(numPointNumInContourElements, 0);
122
123 for (int i = 0; i < batchsize; i++)
124 {
125 inPointNumInContourValues[i] = contourPointsData[i].size() / 2;
126 }
127 int maxPointsNumInCountour = *std::max_element(inPointNumInContourValues.begin(), inPointNumInContourValues.end());
128
129 // inTensor
130 auto tshapeIn = nvcv::TensorShape{
131 {batchsize, maxPointsNumInCountour, 2},
132 nvcv::TENSOR_NWC
133 };
134 nvcv::DataType dtypeIn = nvcv::TYPE_S16;
135 nvcv::Tensor inContours{tshapeIn, dtypeIn};
136 auto inContursAccess = nvcv::TensorDataAccessStrided::Create(inContours.exportData());
137 auto numContoursElements = inContursAccess->sampleStride() / (2 * dtypeIn.strideBytes());
138
139 // outTensor
140 // 8 is the tl tr bl br cooridinates
141 auto tshapeOut = nvcv::TensorShape{
142 {batchsize, 8},
143 nvcv::TENSOR_NW
144 };
145 auto dtypeOut = nvcv::TYPE_F32;
146 nvcv::Tensor outMinAreaRect{tshapeOut, dtypeOut};
147 std::vector<std::vector<float>> testVec(batchsize, std::vector<float>(8, 0));
148 auto outAccess = nvcv::TensorDataAccessStrided::Create(outMinAreaRect.exportData());
149
150 for (int i = 0; i < batchsize; i++)
151 {

Callers

nothing calls this directly

Calls 8

sampleStrideMethod · 0.80
push_backMethod · 0.45
exportDataMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
strideBytesMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected