Skip to content

Commit

Permalink
Add a Qt MRZ example
Browse files Browse the repository at this point in the history
  • Loading branch information
yushulx committed Oct 11, 2024
1 parent 187d739 commit d604120
Show file tree
Hide file tree
Showing 29 changed files with 3,307 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/qt_mrz/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.qt_for_python
build
63 changes: 63 additions & 0 deletions examples/qt_mrz/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
cmake_minimum_required(VERSION 3.5)

project(MRZRecognizer VERSION 0.1 LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if (CMAKE_HOST_WIN32)
link_directories("${PROJECT_SOURCE_DIR}/platform/windows/lib/")
elseif(CMAKE_HOST_UNIX)
link_directories("${PROJECT_SOURCE_DIR}/platform/linux/")
endif()
include_directories("${PROJECT_SOURCE_DIR}/include/")

find_package(Qt5 COMPONENTS Widgets REQUIRED)
find_package(Qt5MultimediaWidgets REQUIRED)

set(PROJECT_SOURCES
main.cpp
mainwindow.cpp
mainwindow.h
mainwindow.ui
myvideosurface.h
myvideosurface.cpp
work.h
work.cpp
mrzinfo.h
mrzinfo.cpp
)

add_executable(${PROJECT_NAME} ${PROJECT_SOURCES})

if (CMAKE_HOST_WIN32)
target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Widgets Qt5::MultimediaWidgets "DynamsoftLabelRecognizerx64")
elseif(CMAKE_HOST_UNIX)
target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Widgets Qt5::MultimediaWidgets "DynamsoftLabelRecognizer")
endif()

# Copy DLLs
if(CMAKE_HOST_WIN32)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${PROJECT_SOURCE_DIR}/platform/windows/bin/"
$<TARGET_FILE_DIR:${PROJECT_NAME}>)
endif()

# Copy template
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${PROJECT_SOURCE_DIR}/template/"
$<TARGET_FILE_DIR:${PROJECT_NAME}>)

# Copy model files
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${PROJECT_SOURCE_DIR}/model"
$<TARGET_FILE_DIR:${PROJECT_NAME}>/model)
49 changes: 49 additions & 0 deletions examples/qt_mrz/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Qt Desktop Passport Scanner
A desktop passport scanner app built with [Dynamsoft OCR SDK](https://www.dynamsoft.com/label-recognition/overview/), [Qt](https://www.qt.io/) and a USB web camera.

## Trial License
Get a [trial license](https://www.dynamsoft.com/customer/license/trialLicense/?product=dcv&package=cross-platform) to activate passport scanning functions.

![sdk license key](https://www.dynamsoft.com/blog/wp-content/uploads/2021/09/passport-scanner-license-key.png)

## Download
- Qt
- [Windows](https://www.qt.io/download)
- Linux

```bash
sudo apt-get install qt5-default qtmultimedia5-dev
```

- [Dynamsoft Label Recognizer 2.0 for Windows and Linux](https://www.dynamsoft.com/barcode-reader/downloads/)

## Build and Run

![Qt desktop passport scanner](https://www.dynamsoft.com/blog/wp-content/uploads/2021/09/passport-scanner-qt-mrz.png)

**Windows**

Add `Qt/5.12.11/mingw73_64/bin` and `Qt/Tools/mingw73_64/bin` to system path.

Run the following commands:

```bash
mkdir build
cd build
cmake -G "MinGW Makefiles" ..
cmake --build .
MRZRecognizer.exe
```

**Linux**

```bash
mkdir build
cd build
cmake ..
cmake --build .
./MRZRecognizer
```

## Blog
[Building Desktop Passport Scanner with Qt and USB Camera](https://www.dynamsoft.com/codepool/passport-scanner-qt-desktop-camera.html)
Binary file added examples/qt_mrz/image/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/qt_mrz/image/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit d604120

Please sign in to comment.