18 #define _USE_MATH_DEFINES // for M_PI
36 static double_VAR(training_angle_match_scale, 1.0,
"Angle Match Scale ...");
38 static double_VAR(training_similarity_midpoint, 0.0075,
"Similarity Midpoint ...");
40 static double_VAR(training_similarity_curl, 2.0,
"Similarity Curl ...");
43 static double_VAR(training_tangent_bbox_pad, 0.5,
"Tangent bounding box pad ...");
45 static double_VAR(training_orthogonal_bbox_pad, 2.5,
"Orthogonal bounding box pad ...");
47 static double_VAR(training_angle_pad, 45.0,
"Angle pad ...");
79 Angle = p1->
Angle * 2.0 * M_PI;
83 if (Length < 0) Length = 0;
90 if (Evidence < WorstEvidence)
91 WorstEvidence = Evidence;
102 if (Evidence < WorstEvidence)
103 WorstEvidence = Evidence;
110 return (WorstEvidence);
130 TotalWeight = w1 + w2;
134 MergedProto->
X = p1->
X * w1 + p2->
X * w2;
135 MergedProto->
Y = p1->
Y * w1 + p2->
Y * w2;
163 float Match, OldMatch, NewMatch;
169 for (Pid = 0; Pid < Class->
NumProtos; Pid++) {
172 static_cast<float>(NumMerged[Pid]), 1.0, &MergedProto);
175 Match = std::min(OldMatch, NewMatch);
176 if (Match > BestMatch) {
213 if (Dangle < -0.5) Dangle += 1.0;
214 if (Dangle > 0.5) Dangle -= 1.0;
215 Dangle *= training_angle_match_scale;
221 return (
EvidenceOf (Distance * Distance + Dangle * Dangle));
234 Similarity /= training_similarity_midpoint;
236 if (training_similarity_curl == 3)
237 Similarity = Similarity * Similarity * Similarity;
238 else if (training_similarity_curl == 2)
239 Similarity = Similarity * Similarity;
241 Similarity = pow (Similarity, training_similarity_curl);
243 return (1.0 / (1.0 + Similarity));
265 MaxAngleError = training_angle_pad / 360.0;
267 if (AngleError > 0.5)
268 AngleError = 1.0 - AngleError;
270 if (AngleError > MaxAngleError)
294 float OrthogonalPad,
FRECT *BoundingBox) {
295 float Length = Proto->
Length / 2.0 + TangentPad;
296 float Angle = Proto->
Angle * 2.0 * M_PI;
297 float CosOfAngle = fabs(cos(Angle));
298 float SinOfAngle = fabs(sin(Angle));
300 float Pad = std::max(CosOfAngle * Length, SinOfAngle * OrthogonalPad);
301 BoundingBox->
MinX = Proto->
X - Pad;
302 BoundingBox->
MaxX = Proto->
X + Pad;
304 Pad = std::max(SinOfAngle * Length, CosOfAngle * OrthogonalPad);
305 BoundingBox->
MinY = Proto->
Y - Pad;
306 BoundingBox->
MaxY = Proto->
Y + Pad;
318 return (X >= Rectangle->
MinX) &&
319 (X <= Rectangle->
MaxX) &&
320 (Y >= Rectangle->
MinY) &&
321 (Y <= Rectangle->
MaxY);