Merge pull request #20189 from dbudniko:dbudniko/mtcnn_sample_with_regular_transpose_kernel

Remove custom transpose kernel from MTCNN sample
This commit is contained in:
Dmitry Budnikov 2021-06-02 19:26:22 +03:00 committed by GitHub
parent 2610724ee0
commit 826fdaf06c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -305,14 +305,6 @@ G_API_OP(SwapFaces,
}
};
G_API_OP(Transpose,
<cv::GMat(cv::GMat)>,
"sample.custom.mtcnn.transpose") {
static cv::GMatDesc outMeta(const cv::GMatDesc in) {
return in.withSize(cv::Size(in.size.height, in.size.width));
}
};
//Custom kernels implementation
GAPI_OCV_KERNEL(OCVBuildFaces, BuildFaces) {
static void run(const cv::Mat & in_scores,
@ -450,12 +442,6 @@ GAPI_OCV_KERNEL(OCVSwapFaces, SwapFaces) {
}
};// GAPI_OCV_KERNEL(SwapFaces)
GAPI_OCV_KERNEL(OCVTranspose, Transpose) {
static void run(const cv::Mat &in_mat,
cv::Mat &out_mat) {
cv::transpose(in_mat, out_mat);
}
};// GAPI_OCV_KERNEL(Transpose)
} // anonymous namespace
} // namespace custom
@ -613,7 +599,7 @@ int main(int argc, char* argv[]) {
//The very first PNet pyramid layer to init total_faces[0]
in_resized[0] = cv::gapi::resize(in_originalRGB, level_size[0]);
in_transposed[0] = custom::Transpose::on(in_resized[0]);
in_transposed[0] = cv::gapi::transpose(in_resized[0]);
std::tie(regressions[0], scores[0]) = run_mtcnn_p(in_transposed[0], get_pnet_level_name(level_size[0]));
cv::GArray<custom::Face> faces0 = custom::BuildFaces::on(scores[0], regressions[0], static_cast<float>(scales[0]), conf_thresh_p);
cv::GArray<custom::Face> final_p_faces_for_bb2squares = custom::ApplyRegression::on(faces0, true);
@ -624,7 +610,7 @@ int main(int argc, char* argv[]) {
for (int i = 1; i < pyramid_levels; ++i)
{
in_resized[i] = cv::gapi::resize(in_originalRGB, level_size[i]);
in_transposed[i] = custom::Transpose::on(in_resized[i]);
in_transposed[i] = cv::gapi::transpose(in_resized[i]);
std::tie(regressions[i], scores[i]) = run_mtcnn_p(in_transposed[i], get_pnet_level_name(level_size[i]));
cv::GArray<custom::Face> faces = custom::BuildFaces::on(scores[i], regressions[i], static_cast<float>(scales[i]), conf_thresh_p);
cv::GArray<custom::Face> final_p_faces_for_bb2squares_i = custom::ApplyRegression::on(faces, true);
@ -639,7 +625,7 @@ int main(int argc, char* argv[]) {
//Refinement part of MTCNN graph
cv::GArray<cv::Rect> faces_roi_pnet = custom::R_O_NetPreProcGetROIs::on(final_faces_pnet, in_sz);
cv::GArray<cv::GMat> regressionsRNet, scoresRNet;
cv::GMat in_originalRGB_transposed = custom::Transpose::on(in_originalRGB);
cv::GMat in_originalRGB_transposed = cv::gapi::transpose(in_originalRGB);
std::tie(regressionsRNet, scoresRNet) = cv::gapi::infer<custom::MTCNNRefinement>(faces_roi_pnet, in_originalRGB_transposed);
//Refinement post-processing
@ -701,7 +687,6 @@ int main(int argc, char* argv[]) {
, custom::OCVRNetPostProc
, custom::OCVONetPostProc
, custom::OCVSwapFaces
, custom::OCVTranspose
>();
auto mtcnn_args = cv::compile_args(networks_mtcnn, kernels_mtcnn);
if (streaming_queue_capacity != 0)