tesseract::ResultIterator* ri = tesseract->GetIterator();
it cannot recognise ResultIterator.
Do you have any idea how to solve this problem?
#include "opencv2/opencv.hpp"
#include "alpr.h"
#include "support/filesystem.h"
#include "support/timing.h"
#include "NativeAlpr.h"
Alpr* g_alpr = NULL;
std::string g_path;
JNIEXPORT void JNICALL Java_fr_alcopa_rec_NativeAlprWorker_init(JNIEnv* env, jobject obj, jstring sdPath) {
g_path = env->GetStringUTFChars(sdPath, JNI_FALSE);
g_alpr = new Alpr("eu", g_path + "openalpr.conf", g_path + "runtime_data");
g_alpr->setTopN(1);
g_alpr->setDefaultRegion("eu");
if (g_alpr->isLoaded() == false) {
std::cout << "Could not load ALPR" << std::endl;
}
}
std::string detectandshow( Alpr* alpr, cv::Mat frame, std::string region, bool writeJson)
{
std::vector<uchar> buffer;
cv::imencode(".bmp", frame, buffer);
std::vector<AlprResult> results = alpr->recognize(buffer);
if (writeJson) {
return alpr->toJson(results);
}
else {
if (results.size() > 0 && results[0].topNPlates.size() > 0) {
return results[0].topNPlates[0].characters;
}
}
return "Détection en cours...";
}
JNIEXPORT jstring JNICALL Java_fr_alcopa_rec_NativeAlprWorker_getPlateNumber(JNIEnv *env, jobject obj, jstring photoPath)
{
cv::Mat frame;
std::string nativePhotoPath = g_path + env->GetStringUTFChars(photoPath, JNI_FALSE);
if (fileExists(nativePhotoPath.c_str())) {
frame = cv::imread(nativePhotoPath);
std::string plate = detectandshow(g_alpr, frame, "", false);
return env->NewStringUTF(plate.c_str());
} else {
return env->NewStringUTF("Photo does not exist !");
}
return env->NewStringUTF("Détection en cours...");
}
JNIEXPORT jstring JNICALL Java_fr_alcopa_rec_NativeAlprWorker_getPlateNumberFromMat(JNIEnv* env, jobject obj, jlong matAddr)
{
cv::Mat& frame = *(cv::Mat*)matAddr;
return env->NewStringUTF(detectandshow(g_alpr, frame, "", false).c_str());
}