Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

face::FaceRecognizer now returns a map associating labels with their confidence #359

Closed
wants to merge 1 commit into from
Closed

face::FaceRecognizer now returns a map associating labels with their confidence #359

wants to merge 1 commit into from

Conversation

Cylix
Copy link

@Cylix Cylix commented Sep 2, 2015

I'm currently working on a face recognition software based on OpenCV face recognition engine.

However, openCV face recognition library predict functions return only the label with the minimum distance to the unknown face. There is no way to get the list of all the labels with the result of the prediction (distance) for each of these labels.

I've added this feature that can be quite useful (it is in my case) by changing the prototype of void predict(InputArray src, CV_OUT int &label, CV_OUT double &confidence) const to std::map<int, double> predict(InputArray src, CV_OUT int &label, CV_OUT double &confidence) const.

Predict function now return an std::map associating a label to its distance to the face on which we are making prediction.

@berak
Copy link
Contributor

berak commented Sep 6, 2015

unfortunately now, this breaks the python bindings, because there is no pyopencv_from/pyopencv_to for map<int,double> in cv2.cpp

@Cylix
Copy link
Author

Cylix commented Sep 7, 2015

Ok, so what is the best option? Adding the binding or changing the container used to return the results?

In the second case, what are the containers with a binding (for example, can we replace std::map by std::list<std::pair<int, double>> or std::vector<std::pair<int, double>>);

@berak
Copy link
Contributor

berak commented Sep 7, 2015

hmm, using something, which is already supported from cv2.cpp ofc. is the most easy option, like returning a vector<Vec2d> , but it will make the internal handling very clumsy (since you have to access/search for the label quite often there, same problem as your vector<pair<int,double>>).

changing the bindings would require another pr in main trunk, and if you look at the vector bindings in cv2.cpp, - not a piece of cake.

no real good idea atm. here.

@berak
Copy link
Contributor

berak commented Oct 14, 2015

btw, you could overload it instead of changing the existing signature, and remove the CV_WRAP .

it would not be available in python/java/matlab, but at least the c++ functionality would compile.

@comdiv
Copy link
Contributor

comdiv commented Oct 14, 2015

Have alternation look on this problem with same tasks: #401
with implementation in #402

The only difference that i sugguset to use "collector delegate" in form "void(int,double)" that caller side can supply to "predict" - this notation cover all scenarios (current "best" and your "all") but allow use statistical( min-max, avg) and relevance (top 10 and so on) without need to create full list of results.

Good luck.

@mshabunin
Copy link
Contributor

Another implementation has been accepted: #402

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.

None yet

4 participants