Skip to content

Commit

Permalink
Fix Windows Visual Studio run with DLL path specified
Browse files Browse the repository at this point in the history
  • Loading branch information
zchrissirhcz committed Apr 30, 2022
1 parent 75392c2 commit 1829de6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
14 changes: 11 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(overlook.cmake)

if(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(OpenCV_DIR "D:/lib/opencv/4.5.5/build")
#set(OpenCV_DIR "D:/lib/opencv/4.5.5/build")
set(OpenCV_DIR "D:/artifacts/opencv/4.5.5/build")
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(OpenCV_DIR "/home/zz/artifacts/opencv/linux-x64/4.5.5/lib/cmake/opencv4")
endif()
find_package(OpenCV REQUIRED)

if(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(Qt5_DIR "D:/soft/Qt/Qt5.14.2/5.14.2/msvc2017_64/lib/cmake/Qt5")
set(QT_DIR "D:/soft/Qt/Qt5.14.2/5.14.2/msvc2017_64/lib/cmake/Qt5")
# set(Qt5_DIR "D:/soft/Qt/Qt5.14.2/5.14.2/msvc2017_64/lib/cmake/Qt5")
# set(QT_DIR "D:/soft/Qt/Qt5.14.2/5.14.2/msvc2017_64/lib/cmake/Qt5")
set(QT_INSTALL_DIR "D:/artifacts/Qt/Qt5.14.0/5.14.0/msvc2017_64")
set(Qt5_DIR "${QT_INSTALL_DIR}/lib/cmake/Qt5")
set(QT_DIR "${Qt5_DIR}")
endif()
find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED)
Expand Down Expand Up @@ -73,3 +77,7 @@ add_executable(testbed
testbed.cpp
)
target_link_libraries(testbed image_compare_core)

# On windows, have to manually put those two directories into PATH:
message(STATUS ">>> OpenCV DLL path: ${OpenCV_DIR}/${OpenCV_ARCH}/${OpenCV_RUNTIME}/bin")
message(STATUS ">>> QT DLL path: ${QT_INSTALL_DIR}/bin")
27 changes: 13 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,22 @@ Beyond Compare 的个人重制版。
- 显示差异图
- 鼠标调节差异图阈值

## 缘由
实现和优化图像处理函数时比较结果图差异, 发现 Beyond Compare 加载的图像多次出现结果不对情况,例如要显示[assets/nvidia_logo.bmp](assets/nvidia_logo.bmp):

![](assets/nvidia_logo.bmp)

而 Beyond Compare 显示为棋盘格状的错误结果,进而导致和 [assets/nvidia_logo.png](assets/nvidia_logo.png) 的差异:
![](assets/beyond_compare_show_image.png)

而实际上两张图的像素并无差异(Small Compare比较结果, 基于 OpenCV 4.5 的图像编解码):
![](assets/small_compare_show_image.png)

## Build
假定你熟悉基于 CMake 的 C/C++ 构建(不依赖 qmake)

- 安装 Qt 环境
- Qt 库: 必选
- QtCreator: 可选
- 安装 Qt 环境(Qt 库:必选;QtCreator: 可选)
- 以 VS2022 为例,安装 qt-opensource-windows-x86-5.14.0.exe,勾选 vs2017 x64 工具,安装得到 D:\artifacts\Qt\Qt5.14.0\5.14.0\msvc2017_64 目录)
- 安装 OpenCV
- 4.5.5
- 开始编译
Expand All @@ -24,17 +34,6 @@ Beyond Compare 的个人重制版。
./ImageCompare # 以后会改名叫 SmallCompare
```

## 缘由
实现和优化图像处理函数时比较结果图差异, 发现 Beyond Compare 加载的图像多次出现结果不对情况,例如要显示[assets/nvidia_logo.bmp](assets/nvidia_logo.bmp):

![](assets/nvidia_logo.bmp)

而 Beyond Compare 显示为棋盘格状的错误结果,进而导致和 [assets/nvidia_logo.png](assets/nvidia_logo.png) 的差异:
![](assets/beyond_compare_show_image.png)

而实际上两张图的像素并无差异(Small Compare比较结果, 基于 OpenCV 4.5 的图像编解码):
![](assets/small_compare_show_image.png)

## TODOs
- 图片比较
- 显示像素差异值分布的直方图
Expand Down

0 comments on commit 1829de6

Please sign in to comment.