|
|
|
@ -70,6 +70,25 @@ public: |
|
|
|
|
ASSERT_NEAR(prediction.second, ref.second, norm); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void testKeypointsModel(const std::string& weights, const std::string& cfg, |
|
|
|
|
const Mat& frame, const Mat& exp, float norm, |
|
|
|
|
const Size& size = {-1, -1}, Scalar mean = Scalar(), |
|
|
|
|
double scale = 1.0, bool swapRB = false, bool crop = false) |
|
|
|
|
{ |
|
|
|
|
checkBackend(); |
|
|
|
|
|
|
|
|
|
std::vector<Point2f> points; |
|
|
|
|
|
|
|
|
|
KeypointsModel model(weights, cfg); |
|
|
|
|
model.setInputSize(size).setInputMean(mean).setInputScale(scale) |
|
|
|
|
.setInputSwapRB(swapRB).setInputCrop(crop); |
|
|
|
|
|
|
|
|
|
points = model.estimate(frame, 0.5); |
|
|
|
|
|
|
|
|
|
Mat out = Mat(points).reshape(1); |
|
|
|
|
normAssert(exp, out, "", norm, norm); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void testSegmentationModel(const std::string& weights_file, const std::string& config_file, |
|
|
|
|
const std::string& inImgPath, const std::string& outImgPath, |
|
|
|
|
float norm, const Size& size = {-1, -1}, Scalar mean = Scalar(), |
|
|
|
@ -221,6 +240,38 @@ TEST_P(Test_Model, DetectionMobilenetSSD) |
|
|
|
|
scoreDiff, iouDiff, confThreshold, nmsThreshold, size, mean, scale); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(Test_Model, Keypoints_pose) |
|
|
|
|
{ |
|
|
|
|
Mat inp = imread(_tf("pose.png")); |
|
|
|
|
std::string weights = _tf("lightweight_pose_estimation.onnx"); |
|
|
|
|
Mat exp = blobFromNPY(_tf("keypoints_exp.npy")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Size size{256, 256}; |
|
|
|
|
float norm = 1e-4; |
|
|
|
|
double scale = 1.0/255; |
|
|
|
|
Scalar mean = Scalar(128, 128, 128); |
|
|
|
|
bool swapRB = false; |
|
|
|
|
|
|
|
|
|
testKeypointsModel(weights, "", inp, exp, norm, size, mean, scale, swapRB); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(Test_Model, Keypoints_face) |
|
|
|
|
{ |
|
|
|
|
Mat inp = imread(_tf("gray_face.png"), 0); |
|
|
|
|
std::string weights = _tf("facial_keypoints.onnx"); |
|
|
|
|
Mat exp = blobFromNPY(_tf("facial_keypoints_exp.npy")); |
|
|
|
|
|
|
|
|
|
Size size{224, 224}; |
|
|
|
|
float norm = 1e-4; |
|
|
|
|
double scale = 1.0/255; |
|
|
|
|
Scalar mean = Scalar(); |
|
|
|
|
bool swapRB = false; |
|
|
|
|
|
|
|
|
|
testKeypointsModel(weights, "", inp, exp, norm, size, mean, scale, swapRB); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(Test_Model, Detection_normalized) |
|
|
|
|
{ |
|
|
|
|
std::string img_path = _tf("grace_hopper_227.png"); |
|
|
|
|