Ask Your Question
0

Understanding traincascade code

asked 2013-11-19 23:40:07 -0600

SelmaGUZEL gravatar image

updated 2013-11-19 23:43:17 -0600

Hello,

I want to understand traincascade method code in detail. I need to save some information related to extracted features and sliding window coordinates, scale, etc. I have examined the code a bit; but it seems complex to me to understand without getting more information from experts.

For example, if I understand correctly, generateFeatures() only calculates the functions to be used. Namely, intensity is not used. fillPassedSamples method reads the image files and CvFeatureEvaluator::setImage determines the classes. updateweights should be related to weights. But where are all of them related and where is calculation done?

Or in short, how can I understand the code? What must I read first if required?

Thanks a lot. Sincerely,

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2013-11-24 05:37:12 -0600

SelmaGUZEL gravatar image

updated 2013-11-24 05:37:45 -0600

Hello again,

I have still been trying to understand the code. For this reason, as it was suggested, I am running the code in debug mode. However, without ml 's source code, it seems nearly impossible to understand the code exactly.

I can't understand the info in cascade.xml output file exactly, too. I can understand something of course, but it is not sufficient to comprehend the code totally.

I especially wonder how the weak classifiers are constructed as decision trees and formulated to calculate the error?

Could you explain or at least suggest any sources to understand how the decision trees are formulated to be used in adaboost training?

Thanks.

edit flag offensive delete link more
0

answered 2013-11-20 02:22:02 -0600

updated 2013-11-20 02:56:10 -0600

I would start reading this forum for a starter. At the start page type in traincascade in the search option. There are some pretty nice guidelines out there. For example, read this and this to understand the training parameters better.

For the actual implementation, there is a topic here somewhere with the response of the original author, lemme see if I can find it and I will get back to you!

Also reading through the Viola & Jones paper, seems logical to me, to get the grasp of the actual algorithm.

EDIT 1:

I have looked up some extra information. Basically searching for traincascade and @Maria Dimashova gives you tons of good topics with alot of information, since she is the one who created the documentation and the algorithm.

Click here for more info.

edit flag offensive delete link more

Comments

1

Thank you for your valuable suggestions. However, in fact, I both searched and read most of the sources what you recommended. I also read the Viola and Jones's paper about this. But, I still haven't been able to comprehend the code exactly. I have read http://docs.opencv.org/modules/objdetect/doc/cascade_classification.html. But in the opencv/apps/traincascade, some of the methods are not the same with this doc. The CvCascadeClassifier class in the traincascade folder is different from the class presented in the link. Where can I find the descriptions about all the methods in the code under opencv/apps/traincascade folder?

Thanks in advance.

Edit:1. The training data is prepared by fillPassedSamples and only neg. images are scaled. 2.The window size is equal to pos.image size. ??

SelmaGUZEL gravatar imageSelmaGUZEL ( 2013-11-20 08:59:59 -0600 )edit

To your edit: correct, since negative images can be of any size, and subwindows are used, whereas the positives have been resized to a data vector of fixed w and h by the createsamples utility and thus don't need extra scaling anymore. Most of the processing also goes to retrieving negative images that are classified as positives by the t-1 detector model that has been produced. So the later the stage of training, the longer it will take. About the algorithm itself, the problem with all machine learning is that it uses the old C api internally but with a C++ compatible skin around it. This makes indeed using the guidelines in the function calls dificult to match to the code. Best way to go, build the library yourself then start debugging and go into every single function :)

StevenPuttemans gravatar imageStevenPuttemans ( 2013-11-21 02:05:40 -0600 )edit
1

It would be wonderful if there were more comments for functions! Anyway, thanks for the code, of course.. Thank you.

SelmaGUZEL gravatar imageSelmaGUZEL ( 2013-11-21 03:42:28 -0600 )edit

Well yeah, since it is open source, OpenCV doesn't require tons of comments in code, expecially not in the past. Guess we have to live with that. However, if you would place explanations in code like this, feel free to submit it with a pull request.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-11-21 03:54:01 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2013-11-19 23:40:07 -0600

Seen: 614 times

Last updated: Nov 24 '13