当前位置:网站首页>Cmake project under vs2019: calculating binocular parallax using elas method

Cmake project under vs2019: calculating binocular parallax using elas method

2022-04-23 20:37:00 Zhongai0049

ELAS Method to calculate binocular parallax

Due to the need for high-precision binocular parallax algorithm , Found this algorithm , To prevent myself from forgetting , Put its use process , Specially recorded here . It would be better if it was helpful to everyone , Hey ..

ELAS By Andreas Geiger On 2010 A novel stereo matching algorithm proposed in , Its full name is 《Efficient Large Scale Stereo Matching》. The advantage of this algorithm is for high-resolution images , It can give consideration to high matching speed and matching accuracy , In many public data sets ELAS The average matching accuracy is very close to SGM, But faster than SGM faster .

ELAS The basic flow of the algorithm is :
(1) The left and right images are sobel wave filtering , Generate sobel Characteristics of figure ;
(2) be based on sobel Feature matching , Select the matching points with high confidence , As "support points", Support point ;
(3) Build support points Delaunay Triangular grid ;
(4) Build the probability generation model of stereo matching ;
(5) Based on the maximum a posteriori probability density estimation (MAP) Dense stereo matching , Get the initial parallax map ;
(6) Parallax post-processing : Invalid hole interpolation 、( The adaptive ) median filtering 、 Connected domain noise elimination 、 Left and right consistency test .

Here are my specific Using process
The code download address of the algorithm is :ELAS Download address
After the download , You can use matlab and vs Joint programming , It can also be used directly VS function .

use VS The operation process is as follows :

  1. I'm using VS2019, Select open local file , Select the file from CMakeLists.txt Root directory of the file , Add :

 Open local folder  Select the root directory of the file to open
 open
2. After loading successfully , choice main.cpp File run :main
I'm in the process of running , The following problems have been encountered :
 redefinition
After inquiry , It is found that the statement with the problem in the file is changed to typedef signed __int8 int8_t;( Add... In the middle signed And it works ).
 The successful running
3. because ELAS The algorithm can only be used for pgm Format the image for processing , So I took advantage of opencv Read JPG Format image , It's transforming into PGM The format of .
A. First attempt ( No success , You can jump directly to B. A second try )
1) stay CMake Use... In documents opencv, Need to be right CMakeLists.txt Make changes :
a. add to OpenCV The header file
b. add to OpenCV Link library path
c. stay cmake Specify the referenced library file name in the configuration file
a
bc
2) After configuration , After recompilation cmake Still can't find opencv.

B. A second try
Refer to the fourth article at the end of the article , Make the following corrections :

# project
cmake_minimum_required (VERSION 2.6)
project (libelas)
find_package(OpenCV REQUIRED)
# directories
set (LIBELAS_SRC_DIR src)

# include directory
include_directories("${LIBELAS_SRC_DIR}/${OpenCV_INCLUE_DIR}")
include_directories("E:/opencv4.3.0/opencv/build/include")

# use sse3 instruction set
SET(CMAKE_CXX_FLAGS "-msse3")

# sources
FILE(GLOB LIBELAS_SRC_FILES "src/*.cpp")

# make release version
set(CMAKE_BUILD_TYPE Release)

# build demo program
add_executable(elas ${
    LIBELAS_SRC_FILES})

link_directories("E:/opencv4.3.0/opencv/build/x64/vc15/lib")
target_link_libraries(elas opencv_world430 opencv_world430d)

There are the following issues to note :
 Insert picture description here
On every CMakeLists.txt When you edit your file , Press down CTRL+S That is, the key to save the file , Automatic triggering CMake Project configuration process , This time finally succeeded ,cmake Found in the OpenCV, You can start writing your own program !!!

4. Programming in the main function , Will have JPG Batch conversion of image files in format into PGM File format , utilize ELAS The algorithm calculates binocular parallax , The results are as follows :
original image :( On the left )
 On the left
Parallax map :
 Parallax map

*** The joint programming process attempts as follows : ***( unsuccessful , But skip and don't look )

1. Start by opening MATLAB, Configure your MATLAB MEX C++ compiler ( If not already configured )(mex -setup) See my other article for the specific process :
Matlab2016 Use mex Command to find the editor Visual Studio2019
2. When the configuration is complete , Switch to libelas/matlab Catalog , Run... Run “make.m” after , Get one called “elasMex” Of MEX file , Then try to run “demo.m”, It will open a GUI And display some results of the included test images .
unfortunately , I run here , There was a mistake ( I don't know how to change )
PS: If someone knows what the problem is , Ask for advice , Thank you very much !!!

The operation results are as follows :
 Insert picture description here  Insert picture description here
If there is a mistake , Welcome to correct , Thank you very much

Above reference : Explain the binocular stereo matching algorithm in detail ELAS
use vs2017 Of cmake Tools add... To other projects OpenCV library
utilize opencv take JPG And other formats into PGM Function of
Visual Studio 2019 cmake To configure opencv development environment

CMake Specific content of , See below , Speak more clearly :
VS2019 C++ Cross platform development of ——Cmake project ( One )

版权声明
本文为[Zhongai0049]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210547163065.html