Fixed opencv dependency library bug
This commit is contained in:
+48
-28
@@ -1,13 +1,16 @@
|
|||||||
cmake_minimum_required(VERSION 3.10.2)
|
cmake_minimum_required(VERSION 3.14)
|
||||||
project(HyperLPR3-Source)
|
project(HyperLPR3-Source)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
|
||||||
set(LIBRARY_NAME hyperlpr3)
|
set(LIBRARY_NAME hyperlpr3)
|
||||||
|
|
||||||
option( BUILD_SHARE "Build shared libs" ON )
|
option( LINUX_FETCH_MNN "Fetch and build MNN from git" ON )
|
||||||
option( BUILD_SAMPLES "Build samples demo" OFF )
|
option( LINUX_USE_3RDPARTY_OPENCV "Linux platform using pre-compiled OpenCV library from 3rdparty_hyper_inspire_op" OFF)
|
||||||
option( BUILD_TEST "Build unit-test exec" OFF )
|
option( BUILD_SHARE "Build shared libs" ON )
|
||||||
|
option( BUILD_SAMPLES "Build samples demo" OFF )
|
||||||
|
option( BUILD_TEST "Build unit-test exec" OFF )
|
||||||
|
|
||||||
|
|
||||||
set(PATH_3RDPARTY ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty_hyper_inspire_op)
|
set(PATH_3RDPARTY ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty_hyper_inspire_op)
|
||||||
|
|
||||||
@@ -84,12 +87,36 @@ else ()
|
|||||||
else()
|
else()
|
||||||
set(PLAT linux)
|
set(PLAT linux)
|
||||||
endif ()
|
endif ()
|
||||||
# MNN Third party dependence
|
|
||||||
set(MNN_INCLUDE_DIRS ${PATH_3RDPARTY}/MNN-2.2.0/${PLAT}/include)
|
# Fetch MNN from git if the option is enabled
|
||||||
set(MNN_LIBS ${PATH_3RDPARTY}/MNN-2.2.0/${PLAT}/lib)
|
if (LINUX_FETCH_MNN)
|
||||||
# OpenCV Third party dependence
|
# Include FetchContent module
|
||||||
set(OpenCV_DIR ${PATH_3RDPARTY}/opencv-4.5.1/${PLAT}/lib/cmake/opencv4)
|
include(FetchContent)
|
||||||
set(OpenCV_STATIC_INCLUDE_DIR ${PATH_3RDPARTY}/opencv-4.5.1/${PLAT}/include/opencv4)
|
# Fetch MNN
|
||||||
|
message("Downloading MNN from https://github.com/alibaba/MNN.git, this may take a while.")
|
||||||
|
FetchContent_Declare(
|
||||||
|
mnn
|
||||||
|
GIT_REPOSITORY https://github.com/alibaba/MNN.git
|
||||||
|
GIT_TAG 2.2.0
|
||||||
|
)
|
||||||
|
set(MNN_BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
|
||||||
|
set(MNN_BUILD_TOOLS OFF CACHE BOOL "" FORCE)
|
||||||
|
|
||||||
|
FetchContent_MakeAvailable(mnn)
|
||||||
|
set(MNN_INCLUDE_DIRS ${mnn_SOURCE_DIR}/include)
|
||||||
|
set(MNN_LIBS ${mnn_BINARY_DIR})
|
||||||
|
else()
|
||||||
|
# MNN Third party dependence
|
||||||
|
set(MNN_INCLUDE_DIRS ${PATH_3RDPARTY}/MNN-2.2.0/${PLAT}/include)
|
||||||
|
set(MNN_LIBS ${PATH_3RDPARTY}/MNN-2.2.0/${PLAT}/lib)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
if(LINUX_USE_3RDPARTY_OPENCV)
|
||||||
|
# OpenCV Third party dependence (static)
|
||||||
|
set(OpenCV_DIR ${PATH_3RDPARTY}/opencv-4.5.1/${PLAT}/lib/cmake/opencv4)
|
||||||
|
set(OpenCV_STATIC_INCLUDE_DIR ${PATH_3RDPARTY}/opencv-4.5.1/${PLAT}/include/opencv4)
|
||||||
|
endif()
|
||||||
find_package(OpenCV REQUIRED)
|
find_package(OpenCV REQUIRED)
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
@@ -126,8 +153,6 @@ if (NOT ANDROID)
|
|||||||
message([Test]Open Benchmark Test)
|
message([Test]Open Benchmark Test)
|
||||||
add_definitions(-DENABLE_BENCHMARK_TEST)
|
add_definitions(-DENABLE_BENCHMARK_TEST)
|
||||||
endif ()
|
endif ()
|
||||||
# # catch2
|
|
||||||
include_directories(${PATH_3RDPARTY}/catch2)
|
|
||||||
file(GLOB_RECURSE TEST_C_CPP_FILES ${CMAKE_CURRENT_SOURCE_DIR}/cpp/test/*.cpp)
|
file(GLOB_RECURSE TEST_C_CPP_FILES ${CMAKE_CURRENT_SOURCE_DIR}/cpp/test/*.cpp)
|
||||||
add_executable(UnitTest ${TEST_C_CPP_FILES} ${SRC_C_CPP_FILES} ${CAPI_CC_FILES})
|
add_executable(UnitTest ${TEST_C_CPP_FILES} ${SRC_C_CPP_FILES} ${CAPI_CC_FILES})
|
||||||
target_link_libraries(UnitTest ${OpenCV_LIBS} ${LINK_THIRD_LIBS})
|
target_link_libraries(UnitTest ${OpenCV_LIBS} ${LINK_THIRD_LIBS})
|
||||||
@@ -146,22 +171,17 @@ endif()
|
|||||||
|
|
||||||
set(CMAKE_INSTALL_PREFIX ${PROJECT_BINARY_DIR}/install/hyperlpr3)
|
set(CMAKE_INSTALL_PREFIX ${PROJECT_BINARY_DIR}/install/hyperlpr3)
|
||||||
message(CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX})
|
message(CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX})
|
||||||
install(DIRECTORY resource DESTINATION ./)
|
|
||||||
if (APPLE)
|
|
||||||
install(FILES ${MNN_LIBS}/libMNN.dylib DESTINATION ./lib)
|
|
||||||
else()
|
|
||||||
install(FILES ${MNN_LIBS}/libMNN.so DESTINATION ./lib)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
|
# Add HyperLPR3-related files and directories to the installation list
|
||||||
|
install(TARGETS ${LIBRARY_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
|
||||||
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cpp/c_api/hyper_lpr_sdk.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
|
||||||
|
|
||||||
|
# Install resource file
|
||||||
|
install(DIRECTORY resource DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||||
|
|
||||||
|
# Install Resource files You can also install sample programs if they are available
|
||||||
if (BUILD_SAMPLES)
|
if (BUILD_SAMPLES)
|
||||||
install(TARGETS ContextSample DESTINATION ./bin)
|
install(TARGETS ContextSample DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||||
install(TARGETS CAPISample DESTINATION ./bin)
|
install(TARGETS CAPISample DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||||
install(TARGETS SplitDetSample DESTINATION ./bin)
|
install(TARGETS SplitDetSample DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||||
endif()
|
endif()
|
||||||
if (BUILD_SHARE)
|
|
||||||
install(TARGETS ${LIBRARY_NAME} DESTINATION ./lib)
|
|
||||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cpp/c_api/hyper_lpr_sdk.h DESTINATION ./include)
|
|
||||||
endif ()
|
|
||||||
if (BUILD_TEST)
|
|
||||||
install(TARGETS UnitTest DESTINATION test)
|
|
||||||
endif ()
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
hyperlpr3/
|
||||||
|
build/
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 3.10.2)
|
cmake_minimum_required(VERSION 3.14)
|
||||||
project(HyperLPR3-LinuxDemo)
|
project(HyperLPR3-LinuxDemo)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
@@ -10,12 +10,11 @@ else()
|
|||||||
set(PLAT linux)
|
set(PLAT linux)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# use opencv
|
# You need to link to the opencv library
|
||||||
set(OpenCV_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty_hyper_inspire_op/opencv-4.5.1/${PLAT}/lib/cmake/opencv4)
|
|
||||||
find_package(OpenCV REQUIRED)
|
find_package(OpenCV REQUIRED)
|
||||||
include_directories(${OpenCV_INCLUDE_DIRS})
|
include_directories(${OpenCV_INCLUDE_DIRS})
|
||||||
|
|
||||||
# use hyperlpr3 sdk
|
# You need to compile hyperlpr3 library to use it
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/hyperlpr3/include)
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/hyperlpr3/include)
|
||||||
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/hyperlpr3/lib)
|
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/hyperlpr3/lib)
|
||||||
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
../build/linux/install/hyperlpr3
|
|
||||||
@@ -141,6 +141,7 @@ Compiling C/C++ projects requires the use of third-party dependency libraries. A
|
|||||||
### Linux/Mac Shared Library Compilation
|
### Linux/Mac Shared Library Compilation
|
||||||
|
|
||||||
- Need to place or link dependencies in the project root (same level as CMakeLists.txt)
|
- Need to place or link dependencies in the project root (same level as CMakeLists.txt)
|
||||||
|
- We recommend you to compile OpenCV yourself and install it into the system. This can help reduce compilation errors caused by version mismatches and compiler issues with system dependencies. However, you can also try using the pre-compiled OpenCV static library we provide for compilation. To do this, you need to enable the **LINUX_USE_3RDPARTY_OPENCV** switch.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# execute the script
|
# execute the script
|
||||||
@@ -156,7 +157,7 @@ Copy the files you need into your project
|
|||||||
|
|
||||||
### Linux/Mac Compiling the Demo
|
### Linux/Mac Compiling the Demo
|
||||||
|
|
||||||
- You need to complete the compilation action of the previous step,And ensure that the compilation is successful and the compiled file is placed in the root directory: **build/linux/install/hyperlpr3**
|
- You need to complete the previous compilation step and ensure it's successful. The compiled files will be located in the root directory: **build/linux/install/hyperlpr3**. You will need to manually copy them to the current directory.
|
||||||
- Go to the **Prj-Linux** folder
|
- Go to the **Prj-Linux** folder
|
||||||
```bash
|
```bash
|
||||||
# go to Prj-linux
|
# go to Prj-linux
|
||||||
|
|||||||
+2
-1
@@ -144,6 +144,7 @@ A:此项目来源于作者早期的研究和调试代码,代码缺少一定
|
|||||||
### Linux/Mac动态链接库编译
|
### Linux/Mac动态链接库编译
|
||||||
|
|
||||||
- 需要将依赖库放置或链接在项目根目录下(与CMakeLists.txt同级)
|
- 需要将依赖库放置或链接在项目根目录下(与CMakeLists.txt同级)
|
||||||
|
- 在编译Linux相关平台时,我们推荐您自行编译opencv并安装至系统中,这样可以降低因为系统中一些依赖版本和编译器原因导致的编译错误,当然,你也可以优先尝试使用我们提供的opencv静态库进行编译,需要您把LINUX_USE_3RDPARTY_OPENCV开关打开
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 执行编译脚本
|
# 执行编译脚本
|
||||||
@@ -159,7 +160,7 @@ sh command/build_release_linux_share.sh
|
|||||||
|
|
||||||
### Linux/Mac编译Demo
|
### Linux/Mac编译Demo
|
||||||
|
|
||||||
- 需要完成上一步的编译动作,并保证编译成功且编译完成后的物料放置于根目录下的**build/linux/install/hyperlpr3**路径中
|
- 需要完成上一步的编译动作,并保证编译成功且编译完成后的物料放置于根目录下的**build/linux/install/hyperlpr3**路径中,需要将其拷贝或链接到当前目录
|
||||||
- 需要从根目录中进入到子工程**Prj-Linux**文件夹中进行操作
|
- 需要从根目录中进入到子工程**Prj-Linux**文件夹中进行操作
|
||||||
```bash
|
```bash
|
||||||
# 进入到子工程demo
|
# 进入到子工程demo
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ InferenceHelper* InferenceHelper::Create(const InferenceHelper::HelperType helpe
|
|||||||
#endif
|
#endif
|
||||||
#ifdef INFERENCE_HELPER_ENABLE_MNN
|
#ifdef INFERENCE_HELPER_ENABLE_MNN
|
||||||
case kMnn:
|
case kMnn:
|
||||||
PRINT("Use MNN\n");
|
// PRINT("Use MNN\n");
|
||||||
p = new InferenceHelperMnn();
|
p = new InferenceHelperMnn();
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -109,9 +109,7 @@ void DetArch::Detection(const cv::Mat &bgr, bool is_resize, float scale) {
|
|||||||
cv::Mat resized_img;
|
cv::Mat resized_img;
|
||||||
cv::resize(bgr, resized_img, cv::Size(w, h));
|
cv::resize(bgr, resized_img, cv::Size(w, h));
|
||||||
cv::copyMakeBorder(resized_img, pad, 0, hpad, 0, wpad, cv::BORDER_CONSTANT, cv::Scalar(127.5, 127.5, 127.5));
|
cv::copyMakeBorder(resized_img, pad, 0, hpad, 0, wpad, cv::BORDER_CONSTANT, cv::Scalar(127.5, 127.5, 127.5));
|
||||||
// cv::imwrite("i.jpg", pad);
|
|
||||||
// cv::imshow("pad_border", pad);
|
|
||||||
// cv::waitKey(0);
|
|
||||||
} else {
|
} else {
|
||||||
pad = bgr;
|
pad = bgr;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#ifndef ZEPHYRLPR_TEST_SETTINGS_H
|
#ifndef ZEPHYRLPR_TEST_SETTINGS_H
|
||||||
#define ZEPHYRLPR_TEST_SETTINGS_H
|
#define ZEPHYRLPR_TEST_SETTINGS_H
|
||||||
#include <catch2/catch.hpp>
|
#include "catch2/catch.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace Catch::Detail;
|
using namespace Catch::Detail;
|
||||||
|
|||||||
Reference in New Issue
Block a user