class cmImport_cogptmx cc_PMRunParams
{
public:
virtual ~cc_PMRunParams();
double acceptThreshold() const { return accept_; }
void acceptThreshold(double acceptThreshold);
// effect Get/set the threshold on score of results. Used to set the
// "accepted" field of each result as follows:
// accepted = (score >= acceptThreshold);
// default 0.5
// throws BadParams if the setter is given a value less then zero
// or greater than one.
// 粗糙度接受阈值法
bool useCoarseAcceptFrac() const { return useCoarseAcceptFrac_; }
void useCoarseAcceptFrac(bool useCoarseAcceptFrac);
// effect Get/Set whether to use the coarse accept fraction.
// If set to true will cause the coarse search to run with a
// different accept threshold to the fine search, according to:
// coarseAcceptThreshold = coarseAcceptFrac x acceptThreshold
// If set to false then the coarse accept threshold will revert
// to the default value chosen automatically by PatMax.
// default false
double coarseAcceptFrac() const { return coarseAcceptFrac_; }
void coarseAcceptFrac(double coarseAcceptFrac);
// effect Get/set the coarse accept fraction which is applied to the
// accept threshold to facilitate a different internal coarse
// threshold to be used when useCoarseAcceptFrac is set to true.
// i.e.
// if (useCoarseAcceptFrac)
// coarseAcceptThreshold = coarseAcceptFrac x acceptThreshold
// else
// coarseAcceptThreshold = acceptThreshold
// default 0.66
// throws BadParams if the setter is given a value less than zero
// or greater than one.
double contrastThreshold() const { return contrastThreshold_; }
void contrastThreshold(double contrast);
// effect Get/set the minimum amount of contrast
// (in run-time image grey levels) that a result must
// have to be accepted.
// note Setting to 0 effectively disables the threshold
// default 10
// throws BadParams if the setter is given a value less than zero
bool useEdgeThreshold() const { return useEdgeThreshold_; }
void useEdgeThreshold(bool useEdgeThreshold);
// effect Get/Set whether to use the user supplied edge threshold.
// If set to true, tells PatQuick and PatMax to ignore the
// automatic edge detection threshold computed at train time and
// use the user supplied edge threshold.
// If set to false, PatQuick and PatMax will choose their own
// edge thresholds, automatically.
// default false
// note useEdgeThreshold is an advanced parameter, and should
// usually be left as the default.
double edgeThreshold() const { return edgeThreshold_; }
void edgeThreshold(double edgeThreshold);
// effect Get/set the edge detection threshold. This supplies PatQuick
// and PatMax run time with a fixed edge detection threshold
// which will override that calculated automatically at train
// time. This threshold will be used if useTrainEdgeThreshold
// has been set to true.
// throws BadParams if the setter is given a value < 0.0 or > 255.0
// default 5.0
// note If running on an 8-bit image and useEdgeThreshold() is true
// then an edgeThreshold greater than 255.0 will cause
// the run function to throw BadParams. The full range, from
// 0.0 - 65535.0 is intended for use when running on a 16-bit
// image.
// note The edgeThreshold is an advanced parameter, and should
// usually be left as the default.
// 计分时考虑杂斑
bool scoreUsingClutter() const { return useClutter_; }
void scoreUsingClutter(bool);
// effect Get/Set whether clutter is used in PatMax scoring.
// PatMax scoring adjustment. Available for PatMax only.
// If scoreUsingClutter is true, PatMax will report lower scores
// for found instances which contain features not present in
// the model (clutter).
// If scoreUsingClutter is false, PatMax will ignore extra
// features when computing score.
// default true
c_Int32 numToFind() const { return numToFind_; }
void numToFind(c_Int32 n);
// effect Get/set the number of results to look for. The
// ccPM*Pattern::run() functions may not return exactly
// numToFind() results. More results will be returned if
// available, fewer results will be returned if less than
// numToFind were found.
// default 1
// throws BadParams if the setter is given a value <= zero.
c_UInt32 zoneEnable() const;
void zoneEnable(c_UInt32 enable);
// effect Get/set the zone enable for each degree of freedom. Non-zero
// bits in "enable" indicate degrees of freedom to be searched.
//
// If zoneEnable is set for a given DOF, ccPM*Pattern::run() will
// search between zoneLow and zoneHigh. Otherwise, run() will
// use the nominal value. "nominal" and "zone" are two
// separate search modes.
// default 0 (no DOFs are enabled).
// note If zoneEnable is set for a given DOF, results produced by
// run() may fall outside the zoneLow and zoneHigh. If a nominal
// is used for a given DOF, results produced by run() will always
// be at exactly the nominal for that DOF.
// throws BadParams if the setter is given a value which was not:
// 1) zero or
// 2) created by a bitwise-OR of the values from cc_PMDefs::DOF.
double nominal(cc_PMDefs::DOF dof) const;
void nominal(cc_PMDefs::DOF dof, double val);
// effect Get/set the nominal value for the given DOF. The nominal
// value is only used if the given DOF is not enabled by
// zoneEnable(). The nominal value need not be related in any
// way to the values of zoneLow() and zoneHigh().
// throws BadParams if a setter is given an illegal value for the
// given DOF - see below.
// default Angle: 0.0. Uniform, X, and Y scales: 1.0.
double zoneLow (cc_PMDefs::DOF dof) const;
double zoneHigh(cc_PMDefs::DOF dof) const;
void zone(cc_PMDefs::DOF dof, double low, double high);
// effect Get/set the low and high zone parameters for the given DOF.
// throws BadParams if either the getters or the setter is given an
// illegal value for the given DOF (see table below).
// default see table below.
// default
// DOF unit Lo Hi range restrictions
// --------------------------------------------------------------
// angle degrees -45 +45 any none
// uniform scale multiplier 0.8 1.2 > 0 zoneLow <= zoneHigh
// xscale multiplier 0.8 1.2 > 0 zoneLow <= zoneHigh
// yscale multiplier 0.8 1.2 > 0 zoneLow <= zoneHigh
//
// - Uniform scale is equal scale in both the x and y dimensions.
// - X scale and Y scale only scale in the given dimension.
// - All scales are specified as a multiplier of the trained pattern size.
// For example, a uniform scale of 1.25 implies that the runtime (client
// coordinate) size of the pattern will be 25% larger in both dimensions
// than the trained pattern.
// - The angle zone is always searched _from_ the zoneLow _to_ the
// zoneHigh. So, setting zoneLow to 0 and zoneHigh to 180 searches one
// half of the 360 degree angle range - setting zoneHigh to 0 and
// zoneLow to 180 searches the other half.
double xyOverlap() const { return xyOverlap_; }
void xyOverlap(double overlapThresh);
// effect Get/set the required xy overlap to consider two instances
// to be the same result.
//
// Two results are considered overlapping if the Overlap value
// is > overlapThresh.
//
// note Overlap is (approximately) the ratio of overlap area to
// total area of the pattern.
//
// note Meaningful values range from 0.0 to 1.0
//
// overlapThresh effect
// 0 results with non-null intersection overlap
// 1 no results overlap (overlap disabled)
//
// throws BadParams if setter argument is outside the range 0.0 to 1.0.
// default 0.8
double zoneOverlap(cc_PMDefs::DOF dof) const;
void zoneOverlap(cc_PMDefs::DOF dof, double overlapThresh);
// effect Get/set the zone overlap parameter for the given DOF.
// Angle and Scale overlap values are specified in different
// units.
//
// For cc_PMDefs::kAngle, two results are considered
// overlapping if the absolute difference between their
// angles is <= overlapThresh. Therefore, if dof is
// kAngle, overlapThresh must be >= 0.
//
// For any scale DOF, overlapThresh is a ratio which is
// compared to the ratio of the result with greater scale to
// the one with smaller scale. If the ratio of the two
// results is <= the overlapThresh ratio, the results are
// considered overlapping. Since the ratio is compared to the
// greater scale over the smaller scale, the overlapThresh
// must be >= 1.0.
// For example, if dof is one of the scale degrees of freedom,
// and overlapThresh = 1.2, then two results, one with a scale
// of 1.25 and one with a scale of 2.5, would not overlap in
// scale since 2.5/1.25 is greater than 1.2.
//
// throws BadParams if setter is given an illegal value for the DOF.
// default Angle: 360.0. Uniform, X, and Y scales: 1.4.
double timeOut() const { return timeOut_; }
void timeOut(double timeInSeconds);
// effect Get/set the maximum execution time (in seconds) allowed
// for the run() function. If run() has not finished
// by the end of the timeout period, it will exit soon
// thereafter by throwing "ccTimeout::Expired". When
// this occurs, no valid results are produced by the tool.
// note The timeout value is intended as an approximate upper limit.
// Due to internal latencies, the actual execution time
// can exceed the requested maximum by up to 0.02 seconds (on
// a 200 Mhz Pentium I). Typical latencies are much lower.
// Latencies will also be lower on faster CPUs.
// note Setting the value to HUGE_VAL allows infinite execution time.
// note The timeout is implemented using the ccTimeout class
// in ch_cvl/attent.h. User-created ccTimeout objects
// can also terminate the run() function.
// default HUGE_VAL
// throws BadParams if the setter is given a value less than zero.
ccPMFlexRunParams flexRunParams() const { return flexRunParams_; };
void flexRunParams(const ccPMFlexRunParams ¶ms);
// effect Get/set the run params object used by the PatFlex algorithm.
// note flexRunParams has no effect unless the algorithm is kPatflex.
// Has no effect on normal PatMax patterns.
double outsideRegionThreshold() const { return outsideRegionThreshold_;}
void outsideRegionThreshold(double outsideRegionThreshold);
// effect Get/Set the outside region threshold used by PatQuick
// and PatMax. Setting outsideRegionThreshold to > 0
// enables patterns which extend outside the search
// region to be found by PatMax without penalizing the
// score (in other words, a pattern which partially
// extends out the image can achieve a score of
// 1.0). Setting outsideRegionThreshold also
// significantly increases running time.
//
// The outsideRegionThreshold parameter specifies what
// proportion of the pattern features can be outside the
// search region without penalizing the score. If the
// proportion of the pattern features lying outside the
// search region is greater than this parameter, then the
// pattern will not be found.
//
// In some cases, this threshold parameter must be set
// 0.05 to 0.10 larger than the measured
// cc_PMResult::outsideRegionFeatureProportion() in order
// for the pattern to be found. For this reason, we
// recommend this threshold parameter always be set so
// that it exceeds the maximum expected outside region
// proportion by 0.10 (i.e., use maximum expected outside
// region proportion + 0.10).
//
// This outsideRegionThreshold parameter trades off speed
// for robustness. PatMax will run faster when a smaller
// outsideRegionThreshold is used, but PatMax may miss
// the pattern if the threshold is too small.
//
// This functionality allows users to train an entire
// field of view, and then search for that trained field
// of view on a runtime image. By setting the
// outsideRegionThreshold, PatMax can accommodate
// translation between the trained field of view and the
// runtime scene.
//
// Often, using a larger training region improves
// discrimination between candidate matches. This
// functionality allows users to train larger patterns
// without worrying that the entire pattern must appear
// in the runtime image.
//
// throws BadParams if values are < 0.0 or > 0.999
// default 0.0
// note ccPMAlignPattern::run() will throw NotImplemented if you
// specify both an algorithm of kPatflex/kPatpersp and
// outsideRegionThreshold > 0.0
bool treatMaskedPelsAsOutsideRegion() const
{ return treatMaskedPelsAsOutsideRegion_;}
void treatMaskedPelsAsOutsideRegion(bool treatMaskedPelsAsOutsideRegion);
// effect Get/Set whether runtime masked pels are considered "outside
// Region" pels for the purpose of normalizing coverage scores
// and computing the outsideRegionFeatureProportion.
//
// default false
//
// note This parameter is ignored if outsideRegionThreshold == 0.0
// note This parameter does not affect the outsideRegionAreaProportion
// measurement
friend cmImport_cogptmx ccArchive& operator|| (ccArchive&, cc_PMRunParams&);
// The following functions are for Cognex internal use only.
void customizeDOFs(const void* dofInfo);
void getDOFs(void* dofInfo) const;
protected:
cc_PMRunParams();
// effect Constructs object using the default values.
cc_PMRunParams(const cc_PMRunParams&);
cc_PMRunParams& operator=(const cc_PMRunParams&);
// effect Copy/assign
// These two are protected (not private) for backward compatibility
// of persistence (in the derived classes).
bool useClutter_;
cc_PMDefs::Algorithm algorithm_;
class cc_DofInfo* dofInfo_;
private:
double accept_;
bool useCoarseAcceptFrac_;
double coarseAcceptFrac_;
c_Int32 numToFind_;
double contrastThreshold_;
bool useEdgeThreshold_;
double edgeThreshold_;
double xyOverlap_;
double timeOut_; // In seconds
ccPMFlexRunParams flexRunParams_;
double outsideRegionThreshold_;
bool treatMaskedPelsAsOutsideRegion_;
bool fitAffineDOFs_;
void init_();
void cleanup_();
void assign_(const cc_PMRunParams&);
friend class cc_PMPattern;
public:
// Cognex internal use only
bool fitAffineDOFs() const { return fitAffineDOFs_;}
void fitAffineDOFs(bool fitAffineDOFs);
};
cmOtherSerializeOps(cc_PMRunParams);
![image]()