Using the Caliper Tool

This section describes the steps you follow to use the Caliper tool.

  1. Construct a ccAffineRectangle and ccAffineSamplingParams that specify the projection region for the caliper tool.
  2. cc2Vect po(20,20),
    px(40,20),
    py( 20,40);
    ccAffineRectangle affRect(po, px, py);
    ccAffineSamplingParams sample(affRect, 20,20);

  3. Construct a vector that contains pointers one or more scoring functions to determine how edge candidates in the image will be scored.
  4. ccScoreContrast aScoringFunction; // Use default values
    cmStd vector<ccCaliperScore *> scoringFunctions(1);
    scoringFunctions[0] = & aScoringFunction;

  5. Construct a ccCaliperRunParams that specifies the number and position of the expected edges. Add the scoring functions to the ccCaliperRunParams by calling the scoringMethods() function.
  6. // Set the run parameters. Search for one edge, any polarity.
    ccCaliperRunParams runParams(0.0, ceDontCare);
    runParams.scoringMethods(scoringFunctions);

    If you do not specify any scoring function for the ccCaliperRunParams, the ccCaliperRunParams will use a single default-constructed ccScoreContrast to score results.

  7. Construct a ccCaliperResultSet to hold the results.
  8. ccCaliperResultSet rslt;

  9. Call the cfCaliperRun() global function supplying the ccAffineSamplingParams, an input image, the ccCaliperRunParams, and the ccCaliperResultSet.
  10. cfCaliperRun(searchImage, sample, runParams, rslt);

  11. Extract the results.
  12. for (int i = 0; i < rslt.results().size(); i++)
    {
    cogOut << "Caliper result " << i+1 << ": "
    << "Score = " << rslt.results()[i].score()
    << ", "
    << "Model Origin at " << rslt.results()[i].position()
    << std::endl;
    for (int j = 0; j < rslt.results()[i].resultEdges().size();
    j++)
    {
    cogOut << " Result edge " << j+1 << ": "
    << "location = "
    << rslt.results()[i].resultEdges()[j].position()
    << std::endl;
    }
    }