Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
yushulx committed Sep 5, 2024
1 parent 0c9cc53 commit 83b8541
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
5 changes: 5 additions & 0 deletions examples/10.x/mrz/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ if(WINDOWS)
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${PROJECT_SOURCE_DIR}/../sdk/platforms/win/bin/"
$<TARGET_FILE_DIR:main>)
else()
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${PROJECT_SOURCE_DIR}/../sdk/platforms/linux/"
$<TARGET_FILE_DIR:main>)
endif()

add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
Expand Down
4 changes: 4 additions & 0 deletions examples/10.x/mrz/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ This C/C++ sample demonstrates how to implement **MRZ (Machine Readable Zone)**
mkdir build
cd build
cmake ..
# For OpenCV
# cmake -DCMAKE_GENERATOR_PLATFORM=x64 -DENABLE_OPENCV=TRUE ..
cmake --build .
```



## Blog
[Passport MRZ Recognition with Dynamsoft C++ OCR SDK](https://www.dynamsoft.com/codepool/passport-mrz-recognition-cpp-windows-linux.html)
23 changes: 14 additions & 9 deletions examples/10.x/mrz/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,18 +240,23 @@ int main(int argc, char *argv[])
float costTime = 0.0;
int errorCode = 0;

CCapturedResult *result = cvr->Capture(pszImageFile);
CParsedResult *results = result->GetParsedResult();

if (results)
CCapturedResult *captureResult = cvr->Capture(pszImageFile);
if (captureResult)
{
for (int i = 0; i < results->GetItemsCount(); i++)
CParsedResult *parsedResult = captureResult->GetParsedResult();
if (parsedResult)
{
const CParsedResultItem *item = results->GetItem(i);
MRZResult result;
result.FromParsedResultItem(item);
cout << result.ToString() << endl;
for (int i = 0; i < parsedResult->GetItemsCount(); i++)
{
const CParsedResultItem *item = parsedResult->GetItem(i);
MRZResult result;
result.FromParsedResultItem(item);
cout << result.ToString() << endl;
}
parsedResult->Release();
}

captureResult->Release();
}
}

Expand Down
7 changes: 7 additions & 0 deletions examples/10.x/mrz/maincv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ class MyCapturedResultReceiver : public CCapturedResultReceiver

virtual void OnParsedResultsReceived(CParsedResult *pResult)
{
if (pResult == nullptr)
{
return;
}

const CFileImageTag *tag = dynamic_cast<const CFileImageTag *>(pResult->GetOriginalImageTag());

if (pResult->GetErrorCode() != EC_OK)
Expand All @@ -232,6 +237,8 @@ class MyCapturedResultReceiver : public CCapturedResultReceiver
}

cout << endl;

pResult->Release();
}
};

Expand Down

0 comments on commit 83b8541

Please sign in to comment.