mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-06 04:36:50 +08:00
Checking for minimum tesseract version, rather than an explicit match
This commit is contained in:
@@ -29,15 +29,14 @@ namespace alpr
|
||||
OCR::OCR(Config* config)
|
||||
: postProcessor(config)
|
||||
{
|
||||
const string EXPECTED_TESSERACT_VERSION = "3.03";
|
||||
const string MINIMUM_TESSERACT_VERSION = "3.03";
|
||||
|
||||
this->config = config;
|
||||
|
||||
|
||||
if (startsWith(tesseract.Version(), EXPECTED_TESSERACT_VERSION) == false)
|
||||
if (cmpVersion(tesseract.Version(), MINIMUM_TESSERACT_VERSION.c_str()) < 0)
|
||||
{
|
||||
std::cerr << "Warning: You are running an unsupported version of Tesseract." << endl;
|
||||
std::cerr << "Expecting version " << EXPECTED_TESSERACT_VERSION << ", your version is: " << tesseract.Version() << endl;
|
||||
std::cerr << "Expecting at least " << MINIMUM_TESSERACT_VERSION << ", your version is: " << tesseract.Version() << endl;
|
||||
}
|
||||
|
||||
// Tesseract requires the prefix directory to be set as an env variable
|
||||
|
@@ -31,6 +31,7 @@
|
||||
#include "constants.h"
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "support/filesystem.h"
|
||||
#include "support/version.h"
|
||||
|
||||
#include "tesseract/baseapi.h"
|
||||
|
||||
|
@@ -6,6 +6,7 @@ set(support_source_files
|
||||
tinythread.cpp
|
||||
platform.cpp
|
||||
utf8.cpp
|
||||
version.cpp
|
||||
)
|
||||
|
||||
set(regex_source_files
|
||||
|
30
src/openalpr/support/version.cpp
Normal file
30
src/openalpr/support/version.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "version.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
int cmpVersion(const char *v1, const char *v2)
|
||||
{
|
||||
int i;
|
||||
int oct_v1[4], oct_v2[4];
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
oct_v1[i] = 0;
|
||||
oct_v2[i] = 0;
|
||||
}
|
||||
|
||||
sscanf(v1, "%d.%d.%d.%d", &oct_v1[0], &oct_v1[1], &oct_v1[2], &oct_v1[3]);
|
||||
sscanf(v2, "%d.%d.%d.%d", &oct_v2[0], &oct_v2[1], &oct_v2[2], &oct_v2[3]);
|
||||
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (oct_v1[i] > oct_v2[i])
|
||||
return 1;
|
||||
else if (oct_v1[i] < oct_v2[i])
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
17
src/openalpr/support/version.h
Normal file
17
src/openalpr/support/version.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef OPENALPR_VERSION_H
|
||||
#define OPENALPR_VERSION_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* return 1 if v1 > v2
|
||||
* return 0 if v1 = v2
|
||||
* return -1 if v1 < v2
|
||||
*/
|
||||
|
||||
int cmpVersion(const char *v1, const char *v2);
|
||||
|
||||
|
||||
#endif /* OPENALPR_VERSION_H */
|
||||
|
Reference in New Issue
Block a user