math function code fixes for Windows compatibility

This commit is contained in:
Matt Hill
2016-06-17 10:12:07 -04:00
parent 403bff6859
commit 1efabe35bd
2 changed files with 8 additions and 3 deletions

View File

@@ -19,6 +19,7 @@
#include "edgefinder.h"
#include "textlinecollection.h"
#include "support/timing.h"
using namespace std;
using namespace cv;
@@ -325,7 +326,7 @@ namespace alpr
{
for (unsigned int x = 0; x < crop.cols; x += stride)
{
contrast += pow( ((crop.at<unsigned char>(y,x) / 255.0) - avg_intensity), 2.0f);
contrast += pow( ((crop.at<unsigned char>(y,x) / 255.0) - avg_intensity), 2.0);
}
}
contrast /= ((float) rows) * ((float)cols);

View File

@@ -124,6 +124,10 @@ Point LineSegment::midpoint()
return Point(midX, midY);
}
int round_int(double r) {
return (r > 0.0) ? (r + 0.5) : (r - 0.5);
}
LineSegment LineSegment::getParallelLine(float distance)
{
float diff_x = p2.x - p1.x;
@@ -132,8 +136,8 @@ LineSegment LineSegment::getParallelLine(float distance)
float dist_x = distance * cos(angle);
float dist_y = -distance * sin(angle);
int offsetX = (int)round(dist_x);
int offsetY = (int)round(dist_y);
int offsetX = (int)round_int(dist_x);
int offsetY = (int)round_int(dist_y);
LineSegment result(p1.x + offsetX, p1.y + offsetY,
p2.x + offsetX, p2.y + offsetY);