Skip to content

Commit d9dc1e5

Browse files
MengqingCaohipudding
authored andcommitted
Add perf test for crop
1 parent 7ab8521 commit d9dc1e5

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

modules/cannops/include/opencv2/cann_interface.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ CV_EXPORTS_W void resize(InputArray _src, OutputArray _dst, Size dsize, double i
484484
CV_EXPORTS_W void resize(const AscendMat& src, CV_OUT AscendMat& dst, Size dsize, double inv_scale_x,
485485
double inv_scale_y, int interpolation,
486486
AscendStream& stream = AscendStream::Null());
487+
487488
//! @} cannops_core
488489

489490
//! @addtogroup cannimgproc

modules/cannops/perf/perf_core.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,16 @@ PERF_TEST_P(CPU, CROP, TYPICAL_ASCEND_MAT_SIZES)
146146
SANITY_CHECK_NOTHING();
147147
}
148148

149+
PERF_TEST_P(NPU, CROP_OVERLOAD, TYPICAL_ASCEND_MAT_SIZES)
150+
{
151+
Mat mat(GET_PARAM(0), CV_8UC3);
152+
Mat dst;
153+
declare.in(mat, WARMUP_RNG);
154+
Rect b(1, 2, 4, 4);
155+
cv::cann::setDevice(DEVICE_ID);
156+
TEST_CYCLE() { cv::cann::crop(mat, b); }
157+
cv::cann::resetDevice();
158+
SANITY_CHECK_NOTHING();
159+
}
149160
} // namespace
150161
} // namespace opencv_test

modules/cannops/test/test_core.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ TEST(CORE, RESIZE)
189189
// only support {2 INTER_CUBIC} and {3 INTER_AREA}
190190
// only the resize result of INTER_AREA is close to CV's.
191191
int flags = 3;
192+
cv::cann::setDevice(0);
192193
cv::resize(cpuMat, resized_cv, dsize, 0, 0, flags);
193194
cv::cann::resize(cpuMat, checker, dsize, 0, 0, flags);
194195
EXPECT_MAT_NEAR(resized_cv, checker, 1e-4);
@@ -208,6 +209,7 @@ TEST(CORE, RESIZE)
208209
cv::cann::resize(npuMat, npuChecker, Size(), 0.5, 0.5, flags);
209210
npuChecker.download(checker);
210211
EXPECT_MAT_NEAR(resized_cv, checker, 1e-4);
212+
cv::cann::resetDevice();
211213
}
212214

213215

0 commit comments

Comments
 (0)