mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-05 13:26:53 +08:00
math function code fixes for Windows compatibility
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "edgefinder.h"
|
#include "edgefinder.h"
|
||||||
#include "textlinecollection.h"
|
#include "textlinecollection.h"
|
||||||
|
#include "support/timing.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
@@ -325,7 +326,7 @@ namespace alpr
|
|||||||
{
|
{
|
||||||
for (unsigned int x = 0; x < crop.cols; x += stride)
|
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);
|
contrast /= ((float) rows) * ((float)cols);
|
||||||
|
@@ -124,6 +124,10 @@ Point LineSegment::midpoint()
|
|||||||
return Point(midX, midY);
|
return Point(midX, midY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int round_int(double r) {
|
||||||
|
return (r > 0.0) ? (r + 0.5) : (r - 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
LineSegment LineSegment::getParallelLine(float distance)
|
LineSegment LineSegment::getParallelLine(float distance)
|
||||||
{
|
{
|
||||||
float diff_x = p2.x - p1.x;
|
float diff_x = p2.x - p1.x;
|
||||||
@@ -132,8 +136,8 @@ LineSegment LineSegment::getParallelLine(float distance)
|
|||||||
float dist_x = distance * cos(angle);
|
float dist_x = distance * cos(angle);
|
||||||
float dist_y = -distance * sin(angle);
|
float dist_y = -distance * sin(angle);
|
||||||
|
|
||||||
int offsetX = (int)round(dist_x);
|
int offsetX = (int)round_int(dist_x);
|
||||||
int offsetY = (int)round(dist_y);
|
int offsetY = (int)round_int(dist_y);
|
||||||
|
|
||||||
LineSegment result(p1.x + offsetX, p1.y + offsetY,
|
LineSegment result(p1.x + offsetX, p1.y + offsetY,
|
||||||
p2.x + offsetX, p2.y + offsetY);
|
p2.x + offsetX, p2.y + offsetY);
|
||||||
|
Reference in New Issue
Block a user