Unify country and ocr mode on both ANSOCR and ANSALPR

This commit is contained in:
2026-03-30 15:21:32 +11:00
parent 08fb2e9adf
commit dd2009d87a
8 changed files with 55 additions and 53 deletions

View File

@@ -323,7 +323,7 @@ int TestOCRv5mage() {
// Enable ALPR mode with Japanese plate format
SetANSOCRMode(&infHandle, 1); // OCR_ALPR
SetANSOCRALPRCountry(&infHandle, 0); // ALPR_JAPAN
SetANSOCRCountry(&infHandle, 5); // JAPAN
cv::Mat input = cv::imread(imagePath, cv::IMREAD_COLOR);
if (input.empty()) {
@@ -391,24 +391,28 @@ int TestOCRv5mage() {
cv::rectangle(frame, cv::Rect(x, y, w, h),
cv::Scalar(0, 255, 0), boxThickness);
// Display ALPR structured info if available
// Display ALPR structured info from extra_info field
std::string displayText = class_name;
if (result.contains("alpr_info")) {
const auto& alpr = result["alpr_info"];
std::cout << "\n=== ALPR Result ===" << std::endl;
std::cout << " Format: " << alpr.value("format", "") << std::endl;
std::cout << " Valid: " << (alpr.value("valid", false) ? "YES" : "NO") << std::endl;
std::cout << " Region: " << alpr.value("region", "") << std::endl;
std::cout << " Classification: " << alpr.value("classification", "") << std::endl;
std::cout << " Kana: " << alpr.value("kana", "") << std::endl;
std::cout << " Designation: " << alpr.value("designation", "") << std::endl;
std::cout << " Full Plate: " << class_name << std::endl;
std::string extraInfo = result.value("extra_info", "");
if (!extraInfo.empty()) {
try {
nlohmann::json alpr = nlohmann::json::parse(extraInfo);
if (alpr.contains("format")) {
std::cout << "\n=== ALPR Result ===" << std::endl;
std::cout << " Format: " << alpr.value("format", "") << std::endl;
std::cout << " Valid: " << (alpr.value("valid", false) ? "YES" : "NO") << std::endl;
std::cout << " Region: " << alpr.value("region", "") << std::endl;
std::cout << " Classification: " << alpr.value("classification", "") << std::endl;
std::cout << " Kana: " << alpr.value("kana", "") << std::endl;
std::cout << " Designation: " << alpr.value("designation", "") << std::endl;
std::cout << " Full Plate: " << class_name << std::endl;
// Build a compact display string for the viewer
displayText = alpr.value("region", "") + " " +
alpr.value("classification", "") + " " +
alpr.value("kana", "") + " " +
alpr.value("designation", "");
displayText = alpr.value("region", "") + " " +
alpr.value("classification", "") + " " +
alpr.value("kana", "") + " " +
alpr.value("designation", "");
}
} catch (...) {}
}
#ifdef WIN32

View File

@@ -161,7 +161,7 @@ int ANSAWSTest() {
}
std::cout << "Connected. AWS path style: " << (awsPath ? "true" : "false") << std::endl;
// Set authentication
// Set authentication (test commit)
std::string accessKey = "AKIAZQ3DPYODSHZCECS4";
std::string secretKey = "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";
if (SetAuthenticationANSAWSHandle(&awsHandle, accessKey.c_str(), secretKey.c_str()) != 1) {