Using the PatMax Tool
This section describes how to use the PatMax vision tool. The following steps describe how to train PatMax using training image, and how to run PatMax to find instances of the trained pattern in a run-time image.
- Acquire an image to use for pattern training.
- Create a ccPMAlignPattern and train it using the training image.
- Set the pattern origin to a meaningful location within the training image.
- Create a ccPMAlignResultSet to contain the results of the search.
- Create a ccPMAlignRunParams and configure it with the number of results to find, the zone, and the degrees of freedom.
- Perform the search by calling the ccPMAlignPattern::run() member function and supplying a run-time image, the ccPMAlignRunParams specifying the search parameters, and the ccPMAlignResultSet to contain the results of the search.
- Extract the results from the ccPMAlignResultSet.
ccPMAlignPattern pat;
pat.train(win);
pat.origin(cc2Vect(50,50)); // In client coordinates
ccPMAlignResultSet set;
ccPMAlignRunParams params;
params.numToFind(3);
params.zoneEnable(ccPMAlignDefs::kUniformScale);
params.zone(ccPMAlignDefs::kUniformScale, 1, 1.2);
pat.run(image, params, set);
cogOut << "number found = " << set.numFound() << std::endl;
int i;
for (i=0; i<set.numFound(); i++)
{
ccPMAlignResult r;
set.getResult(i, r);
cogOut << "result " << i << " = (x,y):(" << r.location().x()
<< "," << r.location().y() << ")" << " "
<< (r.accepted() ? "accepted" : "not accepted") << std::endl;
}