diff --git a/.claude/settings.local.json b/.claude/settings.local.json index c74e35c..681bb46 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -5,7 +5,9 @@ "Bash(xargs grep:*)", "Bash(grep -n \"~Engine\\\\|TRTEngineCache::release\\\\|EnginePoolManager::release\\\\|destructor\" /c/Projects/CLionProjects/ANSCORE/engines/TensorRTAPI/include/engine/*.inl /c/Projects/CLionProjects/ANSCORE/modules/ANSODEngine/*.h)", "Bash(grep -l \"EnginePoolManager\" /c/Projects/CLionProjects/ANSCORE/modules/ANSODEngine/*.cpp)", - "Bash(grep -n \"g_processExiting\" /c/Projects/CLionProjects/ANSCORE/engines/TensorRTAPI/include/engine/*.h /c/Projects/CLionProjects/ANSCORE/modules/ANSODEngine/engine.h)" + "Bash(grep -n \"g_processExiting\" /c/Projects/CLionProjects/ANSCORE/engines/TensorRTAPI/include/engine/*.h /c/Projects/CLionProjects/ANSCORE/modules/ANSODEngine/engine.h)", + "Bash(ssh -T git@anscenter.ddns.net -p 2222)", + "Bash(ssh-add -l)" ] } } diff --git a/core/ANSLicensingSystem/ANSLicense.h b/core/ANSLicensingSystem/ANSLicense.h index 5ce77cb..d965579 100644 --- a/core/ANSLicensingSystem/ANSLicense.h +++ b/core/ANSLicensingSystem/ANSLicense.h @@ -132,6 +132,15 @@ namespace ANSCENTER AMD_GPU = 3, AUTO_DETECT = 99 // default: hardware auto-detection }; + enum Country { + VIETNAM = 0, + CHINA = 1, + AUSTRALIA = 2, + USA = 3, + INDONESIA = 4, + JAPAN = 5 + }; + enum DetectionType { CLASSIFICATION = 0, DETECTION = 1, diff --git a/modules/ANSLPR/ANSLPR.h b/modules/ANSLPR/ANSLPR.h index f317ce5..46824e8 100644 --- a/modules/ANSLPR/ANSLPR.h +++ b/modules/ANSLPR/ANSLPR.h @@ -15,14 +15,8 @@ #define MAX_ALPR_FRAME 60 namespace ANSCENTER { - enum Country { - VIETNAM = 0, - CHINA = 1, - AUSTRALIA = 2, - USA = 3, - INDONESIA = 4, - JAPAN =5 - }; + // Country enum is now defined in ANSLicense.h (ANSCENTER namespace) + class ALPRChecker { private: int maxFrames; diff --git a/modules/ANSOCR/ANSOCRBase.cpp b/modules/ANSOCR/ANSOCRBase.cpp index bbcb24f..a98a38d 100644 --- a/modules/ANSOCR/ANSOCRBase.cpp +++ b/modules/ANSOCR/ANSOCRBase.cpp @@ -298,11 +298,11 @@ namespace ANSCENTER { void ANSOCRBase::SetOCRMode(OCRMode mode) { _ocrMode = mode; } OCRMode ANSOCRBase::GetOCRMode() const { return _ocrMode; } - void ANSOCRBase::SetALPRCountry(ALPRCountry country) { + void ANSOCRBase::SetCountry(Country country) { _alprCountry = country; LoadDefaultFormats(country); } - ALPRCountry ANSOCRBase::GetALPRCountry() const { return _alprCountry; } + Country ANSOCRBase::GetCountry() const { return _alprCountry; } void ANSOCRBase::SetALPRFormat(const ALPRPlateFormat& format) { _alprFormats.clear(); _alprFormats.push_back(format); @@ -313,12 +313,12 @@ namespace ANSCENTER { void ANSOCRBase::ClearALPRFormats() { _alprFormats.clear(); } const std::vector& ANSOCRBase::GetALPRFormats() const { return _alprFormats; } - void ANSOCRBase::LoadDefaultFormats(ALPRCountry country) { + void ANSOCRBase::LoadDefaultFormats(Country country) { _alprFormats.clear(); - if (country == ALPR_JAPAN) { + if (country == JAPAN) { ALPRPlateFormat fmt; fmt.name = "JAPAN_STANDARD"; - fmt.country = ALPR_JAPAN; + fmt.country = JAPAN; fmt.numRows = 2; fmt.rowSplitThreshold = 0.3f; @@ -832,13 +832,16 @@ namespace ANSCENTER { auto& jsonResults = root["results"] = nlohmann::json::array(); for (const auto& res : results) { + // Build extra_info as JSON string with ALPR parts nlohmann::json alprInfo; alprInfo["valid"] = res.valid; alprInfo["format"] = res.formatName; for (const auto& part : res.parts) { alprInfo[part.first] = part.second; } + std::string extraInfoStr = alprInfo.dump(); + // Use the same field layout as OCRDetectionToJsonString jsonResults.push_back({ {"class_id", "0"}, {"track_id", "0"}, @@ -849,11 +852,10 @@ namespace ANSCENTER { {"width", std::to_string(res.plateBox.width)}, {"height", std::to_string(res.plateBox.height)}, {"mask", ""}, - {"extra_info", ""}, + {"extra_info", extraInfoStr}, {"camera_id", ""}, {"polygon", ""}, - {"kps", ""}, - {"alpr_info", alprInfo} + {"kps", ""} }); } return root.dump(); diff --git a/modules/ANSOCR/ANSOCRBase.h b/modules/ANSOCR/ANSOCRBase.h index 42629af..a7460cf 100644 --- a/modules/ANSOCR/ANSOCRBase.h +++ b/modules/ANSOCR/ANSOCRBase.h @@ -19,15 +19,6 @@ namespace ANSCENTER { OCR_ALPR = 1 }; - enum ALPRCountry { - ALPR_JAPAN = 0, - ALPR_VIETNAM = 1, - ALPR_CHINA = 2, - ALPR_USA = 3, - ALPR_AUSTRALIA = 4, - ALPR_CUSTOM = 99 - }; - enum ALPRCharClass { CHAR_DIGIT = 0, CHAR_LATIN_ALPHA = 1, @@ -53,7 +44,7 @@ namespace ANSCENTER { struct ALPRPlateFormat { std::string name; - ALPRCountry country = ALPR_JAPAN; + Country country = JAPAN; int numRows = 2; std::vector zones; float rowSplitThreshold = 0.3f; @@ -152,7 +143,7 @@ namespace ANSCENTER { // ALPR settings OCRMode _ocrMode = OCR_GENERAL; - ALPRCountry _alprCountry = ALPR_JAPAN; + Country _alprCountry = JAPAN; std::vector _alprFormats; void CheckLicense(); @@ -171,12 +162,12 @@ namespace ANSCENTER { // ALPR configuration methods void SetOCRMode(OCRMode mode); OCRMode GetOCRMode() const; - void SetALPRCountry(ALPRCountry country); - ALPRCountry GetALPRCountry() const; + void SetCountry(Country country); + Country GetCountry() const; void SetALPRFormat(const ALPRPlateFormat& format); void AddALPRFormat(const ALPRPlateFormat& format); void ClearALPRFormats(); - void LoadDefaultFormats(ALPRCountry country); + void LoadDefaultFormats(Country country); const std::vector& GetALPRFormats() const; ~ANSOCRBase() { @@ -249,7 +240,7 @@ extern "C" ANSOCR_API int RunInferencesComplete_LV(ANSCENTER::ANSOCRBase** H // ALPR configuration API extern "C" ANSOCR_API int SetANSOCRMode(ANSCENTER::ANSOCRBase** Handle, int ocrMode); -extern "C" ANSOCR_API int SetANSOCRALPRCountry(ANSCENTER::ANSOCRBase** Handle, int country); +extern "C" ANSOCR_API int SetANSOCRCountry(ANSCENTER::ANSOCRBase** Handle, int country); extern "C" ANSOCR_API int SetANSOCRALPRFormat(ANSCENTER::ANSOCRBase** Handle, const char* formatJson); // V2 Create / Release — handle as uint64_t by value (no pointer-to-pointer) diff --git a/modules/ANSOCR/dllmain.cpp b/modules/ANSOCR/dllmain.cpp index 7dae22f..11a4a9f 100644 --- a/modules/ANSOCR/dllmain.cpp +++ b/modules/ANSOCR/dllmain.cpp @@ -374,9 +374,9 @@ extern "C" ANSOCR_API int SetANSOCRMode(ANSCENTER::ANSOCRBase** Handle, int ocrM return 0; } -extern "C" ANSOCR_API int SetANSOCRALPRCountry(ANSCENTER::ANSOCRBase** Handle, int country) { +extern "C" ANSOCR_API int SetANSOCRCountry(ANSCENTER::ANSOCRBase** Handle, int country) { if (!Handle || !*Handle) return -1; - (*Handle)->SetALPRCountry(static_cast(country)); + (*Handle)->SetCountry(static_cast(country)); return 0; } @@ -386,7 +386,7 @@ extern "C" ANSOCR_API int SetANSOCRALPRFormat(ANSCENTER::ANSOCRBase** Handle, co nlohmann::json j = nlohmann::json::parse(formatJson); ANSCENTER::ALPRPlateFormat fmt; fmt.name = j.value("name", "CUSTOM"); - fmt.country = static_cast(j.value("country", 99)); + fmt.country = static_cast(j.value("country", 99)); fmt.numRows = j.value("num_rows", 2); fmt.rowSplitThreshold = j.value("row_split_threshold", 0.3f); diff --git a/tests/ANSOCR-UnitTest/ANSOCR-UnitTest.cpp b/tests/ANSOCR-UnitTest/ANSOCR-UnitTest.cpp index 6b35813..c3250d6 100644 --- a/tests/ANSOCR-UnitTest/ANSOCR-UnitTest.cpp +++ b/tests/ANSOCR-UnitTest/ANSOCR-UnitTest.cpp @@ -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 diff --git a/tests/ANSUtilities-UnitTest/ANSUtilities-UnitTest.cpp b/tests/ANSUtilities-UnitTest/ANSUtilities-UnitTest.cpp index 659d772..d992913 100644 --- a/tests/ANSUtilities-UnitTest/ANSUtilities-UnitTest.cpp +++ b/tests/ANSUtilities-UnitTest/ANSUtilities-UnitTest.cpp @@ -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) {