Skip to content

G-API MTCNN demo hotfix to align overall pipeline accuracy with the reference Python code output.#20065

Merged
alalek merged 4 commits intoopencv:masterfrom
dbudniko:dbudniko/G-API_mtcnn_demo_PR_hotfix2
May 18, 2021
Merged

G-API MTCNN demo hotfix to align overall pipeline accuracy with the reference Python code output.#20065
alalek merged 4 commits intoopencv:masterfrom
dbudniko:dbudniko/G-API_mtcnn_demo_PR_hotfix2

Conversation

@dbudniko
Copy link
Copy Markdown

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

force_builders=Custom,Custom Win,Custom Mac
build_gapi_standalone:Linux x64=ade-0.1.1f
build_gapi_standalone:Win64=ade-0.1.1f
build_gapi_standalone:Mac=ade-0.1.1f
build_gapi_standalone:Linux x64 Debug=ade-0.1.1f

build_image:Custom=centos:7
buildworker:Custom=linux-1
build_gapi_standalone:Custom=ade-0.1.1f

Xbuild_image:Custom=ubuntu-openvino-2020.3.0:16.04
build_image:Custom Win=openvino-2021.3.0
build_image:Custom Mac=openvino-2021.3.0

test_modules:Custom=gapi,python2,python3,java
test_modules:Custom Win=gapi,python2,python3,java
test_modules:Custom Mac=gapi,python2,python3,java

buildworker:Custom=linux-1
// disabled due high memory usage: test_opencl:Custom=ON
test_opencl:Custom=OFF
test_bigdata:Custom=1
test_filter:Custom=*

@mpashchenkov
Copy link
Copy Markdown
Contributor

I think, sample should have another name, because this isn't simple face detection, this is MTCNN face detection.
For example, if i want to get information about g-api then i go to samples and select face_detection, i will see that it is very difficult.

@dbudniko
Copy link
Copy Markdown
Author

@mpashchenkov I think it's to late to change name of already published sample. This PR is just hot fix.

const float* reg_data = regressions.ptr<float>();

auto out_side = std::max(h, w);
auto in_side = 2 * out_side + 11;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic values (2, 11)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as the original demo

float bboxWidth = static_cast<float>(x2 - x1);
float bboxHeight = static_cast<float>(y2 - y1);
float side = std::max(bboxWidth, bboxHeight);
bbox.x1 = static_cast<int>(static_cast<float>(x1) + (bboxWidth - side) * 0.5f);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if side = bboxHeight and x1 will be less 0? It is out of image bbox.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as the original demo

@dmatveev dmatveev self-assigned this May 17, 2021
Copy link
Copy Markdown
Contributor

@dmatveev dmatveev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TolyaTalamanov @mpashchenkov do you have any other feedback here? Probably we should go ahead w/the merge

const float interX1 = std::max(static_cast<float>(faces[idx].bbox.x1), static_cast<float>(faces[tmpIdx].bbox.x1));
const float interY1 = std::max(static_cast<float>(faces[idx].bbox.y1), static_cast<float>(faces[tmpIdx].bbox.y1));
const float interX2 = std::min(static_cast<float>(faces[idx].bbox.x2), static_cast<float>(faces[tmpIdx].bbox.x2));
const float interY2 = std::min(static_cast<float>(faces[idx].bbox.y2), static_cast<float>(faces[tmpIdx].bbox.y2));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably static_cast<float> can be applied only once on the result of std::min or std::max.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@mpashchenkov
Copy link
Copy Markdown
Contributor

Please, move tm.start() to 747 line. This step include cv::imshow and kill part of performance.

@dbudniko
Copy link
Copy Markdown
Author

@alalek can we merge it?

@alalek alalek merged commit 4753206 into opencv:master May 18, 2021
@alalek alalek mentioned this pull request Jun 4, 2021
a-sajjad72 pushed a commit to a-sajjad72/opencv that referenced this pull request Mar 30, 2023
…mo_PR_hotfix2

G-API MTCNN demo hotfix to align overall pipeline accuracy with the reference Python code output.

* MTCNN G-API demo aligned with Python from OMZ

* clean up

* more comments from Maxim are addressed.

* address comment from Dmitry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants