Skip to content

The facial landmarks via IE sample is added for dnn module#15137

Closed
OrestChura wants to merge 5 commits intoopencv:masterfrom
OrestChura:my_sample
Closed

The facial landmarks via IE sample is added for dnn module#15137
OrestChura wants to merge 5 commits intoopencv:masterfrom
OrestChura:my_sample

Conversation

@OrestChura
Copy link
Copy Markdown
Contributor

This pullrequest changes

  • adds new sample that uses two models from IE: face detector (face-detection-adas-0001) and facial landmarks detector (facial-landmarks-35-adas-0002). The goal of the sample is to show how to inference IE models via dnn API. The sample detects described features on the source and then shows the result.
  • added IE build flag check in samples/dnn/CMakeLists.txt as the sample requires IE.

@OrestChura
Copy link
Copy Markdown
Contributor Author

@dmatveev, @AsyaPronina, @andrey-golubev, @rgarnov, @dkurt Hello! Please, review my PR

using namespace cv::dnn;

#include <iostream>
//#include "common.hpp"
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.

Please remove

"{ b | | The color to draw face rectangle and landmarks in format \"(b, g, r)\".}"
"{ g | | The color to draw face rectangle and landmarks in format \"(b, g, r)\".}"
"{ r | | The color to draw face rectangle and landmarks in format \"(b, g, r)\".}"
"{ faceframework | | Optional name of an origin framework of the facedetector. Detect it automatically if it does not set. }"
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.

is not set

"3: VPU }"
);

parser.about("Use this script to run classification deep learning networks using OpenCV.");
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.

About message need to be fixed

//Models' definition & initialization
Net faceNet = readNet(facexmlPath, facebinPath);
faceNet.setPreferableTarget(faceTarget);
faceNet.setPreferableBackend(faceBackend);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There is only DNN_INFERENCE_ENGINE_BACKEND is supported fo IR models so you can emit faceBackend argument

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Have I got it right that it has no sense even to ask the user about backends as there is only one of them available, so I can delete parser keys too?

@dmatveev
Copy link
Copy Markdown
Contributor

@AsyaPronina I asked to make an MR in our internal Gitlab, not here. Not sure if it makes sense to start merging it right now in any form. Please make an integration branch in Gitlab and move the MRs there (open against that integration branch).

@AsyaPronina AsyaPronina requested a review from dmatveev July 25, 2019 20:57
@dmatveev
Copy link
Copy Markdown
Contributor

Still, if you think it is more useful and productive to continue here (and while a build is green), please continue here.

Not sure if any builder actually tests this code now, though (some custom builder configurations is required AFAIK).

- In addition to the Dmitry's issue, framework parser key is cut;
- Work with color changed, choosing by user is cut;
- Some fixes about Point() declarations;
- Comment fixes
const unsigned int landmrows = 60;
const float bb_enlarge_coefficient = 1.0f;

const std::string win1 = "FaceLandmarkDetector";
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.

win1 is not a good name in my opinion, why do you use 1?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Because there was another window some time ago.. My mistake, thank you

@@ -0,0 +1,195 @@
// This file is part of OpenCV project.
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.

Sorry for confuse but license header is not need in the samples folder

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The strings 1-7 should be removed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There is the license header in, for example, colorization sample..

}

//Parsing input arguments
const std::string facexmlPath = parser.get<std::string>("facestruct");
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.

If you use Camel case for variable naming please follow standard rules for this:
CamelCase Notation
CamelCase (sometimes called "CamelBack") notation is the practice of writing compound words or phrases in which the parts are joined without spaces, with each part's initial letter capitalized and the first letter in either upper or lower case. For example: SampleDataTable, computeExpr

if (parser.has("input"))
cap.open(parser.get<String>("input"));
else if (!cap.open(0))
{
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.

Please align braces

break;
}

Mat shwimg; //Image to show
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.

I suggest to stick to one naming style

Mat inputImg;
resize(img, inputImg, Size(facecols, facerows));

//Infering Facedetector
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.

Face detector or FaceDetector

Mat outFaces = faceNet.forward();

float* faceData = (float*)(outFaces.data);
for (size_t i = 0; i < outFaces.total(); i += faceObjectSize)
Copy link
Copy Markdown
Contributor

@AsyaPronina AsyaPronina Jul 26, 2019

Choose a reason for hiding this comment

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

Very minor suggestion: if you use size_t it is better to use 0ul

int top = int(faceData[i + 4] * img.rows);
top = std::max(top, 0);
int right = int(faceData[i + 5] * img.cols);
right = std::min(right, img.cols-2);
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.

Please stick to the one convention about using or not the spaces between operators and operands


//Postprocessing for landmarks
int max_of_sizes = std::max(width, height);
int add_width = int(max_of_sizes*bb_enlarge_coefficient) - width;
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.

max_of_sizes and bb_enlarge_coefficient namings differ from Camel Case code convention you use in other code

@AsyaPronina
Copy link
Copy Markdown
Contributor

@AsyaPronina I asked to make an MR in our internal Gitlab, not here. Not sure if it makes sense to start merging it right now in any form. Please make an integration branch in Gitlab and move the MRs there (open against that integration branch).

Okay will sort out with this today

@bhack
Copy link
Copy Markdown

bhack commented Jul 26, 2019

IMHO it is better to re-edit this with High Level API #14780
@dvd42 is going to extend high level API proposal also for landmarks quite soon with a new PR.

@dmatveev
Copy link
Copy Markdown
Contributor

IMHO it is better to re-edit this with High Level API #14780
@dvd42 is going to extend high level API proposal also for landmarks quite soon with a new PR.

@bhack thanks for the pointer, but the idea of this is to trial #15090

@bhack
Copy link
Copy Markdown

bhack commented Jul 26, 2019

So what it means? Why high level API is not using G-API?

@dmatveev
Copy link
Copy Markdown
Contributor

So what it means? Why high level API is not using G-API?

To be fair, I am not sure what the "high-level API" is. G-API has its own programming model so we're adding inference there now, and this one should be among the early samples.

@dkurt
Copy link
Copy Markdown
Member

dkurt commented Jul 26, 2019

@bhack, @dmatveev, It's just an abstraction over dnn::Net which lets to emit some preprocessing or postprocessing stuff. dnn::Model could as be as a node of G-API as use G-API internally so there is no conflict between two approaches.

@dmatveev
Copy link
Copy Markdown
Contributor

@dkurt thanks! Actually, efficient pipelining of preprocessing, inference, postprocessing, and other stuff is the reason why we add inference & streaming extensions in G-API. So what's the point and value-add of High-level API?

@bhack meanwhile, if you're interested, here's some sample code and some more general info on G-API.

@dkurt
Copy link
Copy Markdown
Member

dkurt commented Jul 26, 2019

@dmatveev, Due with this high-level API user do not use blobFromImage, we can use G-API as an optional dependency. It'll be transparent for user.

- Some small issues
@dvd42 dvd42 mentioned this pull request Jul 30, 2019
@dvd42
Copy link
Copy Markdown
Contributor

dvd42 commented Jul 30, 2019

I created 1 PR for the DNN high_level api, adding a keypoints module. Maybe this chain of detection->landmarking could be implemented as part of said module by chaining the detection and keypointing module?

@OrestChura
Copy link
Copy Markdown
Contributor Author

I created 1 PR for the DNN high_level api, adding a keypoints module. Maybe this chain of detection->landmarking could be implemented as part of said module by chaining the detection and keypointing module?

Thanks a lot! Have seen your PR, it looks reasonable to integrate our sample into your module, but is there any sense to add the InferenceEngine dependence into it? In my opinion, the sample is more intented to reflect the IE models usage in DNN API.

@dvd42
Copy link
Copy Markdown
Contributor

dvd42 commented Jul 30, 2019

It seems that this won't be done yet as per dkurts's comment.

@OrestChura
Copy link
Copy Markdown
Contributor Author

The PR is closed as a similar sample exists already, so there's no need in this sample.

@OrestChura OrestChura closed this Aug 29, 2019
@OrestChura OrestChura deleted the my_sample branch August 29, 2019 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants