Ask Your Question
0

setLabelsInfo not existing in opencv3?

asked 2016-06-29 08:27:01 -0600

atv gravatar image

I'm converting some opencv2 code to opencv3. In this i use the setLabelsInfo call, but it doesn't seem to exist in opencv3. As a result, my face recognition doesn't work and flags everyone as unknown (probably because it can't match up the names read from csv with the labels.

Is there a alternate way of doing it ?

Users/alefveld/Downloads/Testingground/philip3/backup2.cpp:180:12: error: no member named 'setLabelsInfo' in 'cv::face::FaceRecognizer' model->setLabelsInfo(labelsInfo);

I can give more code if needed. Alef

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-06-29 08:50:14 -0600

berak gravatar image

updated 2016-06-29 08:51:09 -0600

this is a simple typo , it's setLabelInfo() (without an s in the middle)

(looks like they changed the name, when transitioning to opencv3)

edit flag offensive delete link more

Comments

That's awesome, thanks so much berak!

atv gravatar imageatv ( 2016-06-29 09:35:32 -0600 )edit

Hmm i just noticed the new setLabelInfo has 2 arguments. The old one just had one: std::map<int, string="">& labelsInfo

model->setLabelsInfo(labelsInfo);

How should i change the above line now that it expects 2 arguments?

atv gravatar imageatv ( 2016-06-29 15:59:11 -0600 )edit

hmm, i can only guess, but i think, you're supposed to put that function somewhere, where you read your images, and add a name & label at a time there.

berak gravatar imageberak ( 2016-06-29 20:58:35 -0600 )edit

That's exactly it. In main() it's defined as: std::map<int,string> labelsInfo; Ptr<basicfacerecognizer> model = createFisherFaceRecognizer(0,400.0); //Ptr<facerecognizer> model = createEigenFaceRecognizer(10,6000.0); //Ptr<facerecognizer> model = createLBPHFaceRecognizer(); model->setLabelInfo(labelsInfo);

and in read_csv : static void read_csv(const string& filename, vector<mat>& images, vector<int>& labels, std::map<int, string="">& labelsInfo, char separator = ';') {

It seems the type has changed from std::map <int,string>&labelsInfo to const string& strInfo and to 1 argument.

I'm not sure how to change that so i'm at a bit of a loss. My apologies for not being that proficient with c++ code, i'd appreciate the help.

Is there no conversion guide for opencv2 to 3? I'm

atv gravatar imageatv ( 2016-06-30 02:37:18 -0600 )edit

well, none of this is your fault, actually ;)

this whole interface has become a terrible kludge over time, you know, too many cooks ..

for now, i'd suggest, that you doit like here , that is - fill the map, while you're reading the csv, and later copy things int your model

once, you got it running, and got some feel for what's happenning, -- take the AXE, break it apart, STEAL the good parts, and build something better , really ;)

berak gravatar imageberak ( 2016-06-30 02:52:11 -0600 )edit

Gotcha, that looks like it should work. Thanks again!

atv gravatar imageatv ( 2016-06-30 04:25:19 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-06-29 08:27:01 -0600

Seen: 157 times

Last updated: Jun 29 '16