├── .gitignore
├── LICENSE
├── README.txt
├── data
├── 000001.png
├── 000011.png
├── 000046.png
├── 000056.png
├── climb1.png
├── climb2.png
├── dino1.jpg
├── dino2.jpg
├── liberty1.png
└── liberty2.png
├── deepMatching.pro
├── deepMatching.pro.user
├── deepmatching-static
└── src
├── COPYING
├── array_types.h
├── conv.cpp
├── conv.h
├── deep_matching.cpp
├── deep_matching.h
├── deepmatching.i
├── deepmatching.m
├── deepmatching.py
├── deepmatching_matlab.cpp
├── deepmatching_wrap.c
├── deepmtchinfo.cpp
├── deepmtchinfo.h
├── hog.cpp
├── hog.h
├── image.cpp
├── image.h
├── io.cpp
├── io.h
├── main.cpp
├── main.h
├── mainwindow.cpp
├── mainwindow.h
├── mainwindow.ui
├── maxfilter.cpp
├── maxfilter.h
├── pixel_desc.cpp
├── pixel_desc.h
├── rescore.py
├── runDeepMatching.m
├── std.cpp
├── std.h
└── viz.py
/.gitignore:
--------------------------------------------------------------------------------
1 | ### Globally Useful gitignores
2 | #
3 | #This directory contains globally useful gitignores,
4 | #e.g. OS-specific and editor specific.
5 | #
6 | #For more on global gitignores:
7 | #
8 | #
9 | #And a good blog post about 'em:
10 | #
11 | #.redcar
12 | # It's better to unpack these files and commit the raw source because
13 |
14 | # git has its own built in compression methods.
15 | *.7z
16 | *.jar
17 | *.rar
18 | *.zip
19 | *.gz
20 | *.bzip
21 | *.bz2
22 | *.xz
23 | *.lzma
24 | *.cab
25 |
26 | #package management formats
27 | *.dmg
28 | *.xpi
29 | *.gem
30 | *.egg
31 | *.deb
32 | *.rpm
33 | *.msi
34 | *.msm
35 | *.msp
36 |
37 | # -*- mode: gitignore; -*-
38 | *~
39 | \#*\#
40 | /.emacs.desktop
41 | /.emacs.desktop.lock
42 | *.elc
43 | auto-save-list
44 | tramp
45 | .\#*
46 |
47 | ## Delete the backups, we have GIT for that !!
48 | # Windows default autosave extension
49 | *.asv
50 |
51 | # Notepad++ backups #
52 | *.bak
53 | .DS_Store
54 | .AppleDouble
55 | .LSOverride
56 | # C++ objects and libs
57 |
58 | *.slo
59 | *.lo
60 | *.o
61 | *.a
62 | *.la
63 | *.lai
64 | *.so
65 | *.dll
66 | *.dylib
67 | # Qt-es
68 |
69 | /.qmake.cache
70 | /.qmake.stash
71 | *.pro.user
72 | *.pro.user.*
73 | *.qbs.user
74 | *.qbs.user.*
75 | *.moc
76 | moc_*.cpp
77 | qrc_*.cpp
78 | ui_*.h
79 | Makefile*
80 | *-build-*
81 | # Thumbnails
82 | ._*
83 | # Ignore tags created by etags, ctags, gtags (GNU global) and cscope
84 | TAGS
85 | !TAGS/
86 | tags
87 | !tags/
88 | gtags.files
89 | GTAGS
90 | GRTAGS
91 | GPATH
92 | cscope.files
93 | cscope.out
94 | cscope.in.out
95 | cscope.po.out
96 |
97 | *.tmproj
98 | *.tmproject
99 | tmtags
100 | .vagrant/
101 | [._]*.s[a-w][a-z]
102 | [._]s[a-w][a-z]
103 | *.un~
104 | Session.vim
105 | .netrwhist
106 | *~
107 |
108 | # QtCreator
109 |
110 | *.autosave
111 |
112 | #QtCtreator Qml
113 | *.qmlproject.user
114 | *.qmlproject.user.*
115 |
116 | # Compiled Object files
117 | *.slo
118 | *.lo
119 | *.o
120 | *.obj
121 |
122 | # Precompiled Headers
123 | *.gch
124 | *.pch
125 |
126 | # Compiled Dynamic libraries
127 | *.so
128 | *.dylib
129 | *.dll
130 |
131 | # Fortran module files
132 | *.mod
133 |
134 | # Compiled Static libraries
135 | *.lai
136 | *.la
137 | *.a
138 | *.lib
139 |
140 | # Executables
141 | *.exe
142 | *.out
143 | *.app
144 |
145 | #Backup file
146 | *~
147 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 CANSEN JIANG
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.txt:
--------------------------------------------------------------------------------
1 | Implementation of the Deep Matching algorithm, published at ICCV 2013 in
2 | "DeepFlow: Large displacement optical flow with deep matching" by Philippe
3 | Weinzaepfel, Jerome Revaud, Zaid Harchaoui and Cordelia Schmid.
4 | Code and idea by Jerome Revaud, INRIA. The code is only for scientific
5 | or personnal use. Please contact me/INRIA for commercial use.
6 | Email: jerome.revaud@inria.fr
7 |
8 | Copyright (C) 2015 Jerome Revaud
9 |
10 | Version 1.2.2
11 |
12 | License:
13 |
14 | This program is free software: you can redistribute it and/or modify
15 | it under the terms of the GNU General Public License as published by
16 | the Free Software Foundation, either version 3 of the License, or
17 | (at your option) any later version.
18 |
19 | This program is distributed in the hope that it will be useful,
20 | but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | GNU General Public License for more details.
23 |
24 | You should have received a copy of the GNU General Public License
25 | along with this program. If not, see
26 |
27 |
28 | Installation:
29 |
30 | make clean all
31 |
32 | This program has been built on a fedora18 x64 machine and tested on Mac OS X.
33 | *No assistance* will be given to compile the code on other OS. However, if
34 | you are able to sucessfully adapt the code for other platforms (Windows),
35 | please notify me so that I can release these versions on the webpage:
36 |
37 | http://lear.inrialpes.fr/src/deepmatching/
38 |
39 |
40 | Matlab wrapper:
41 | [Prerequisite: to have compiled the executable, see above.]
42 |
43 | 1) Launch matlab by preloading the same 'libatlas' than the one used to compile ./deepmatching:
44 | LD_PRELOAD=/usr/lib64/atlas/libtatlas.so.3 matlab
45 |
46 | 2) Compile the MEX file:
47 | mex deepmatching_matlab.cpp deep_matching.o conv.o hog.o image.o io.o main.o maxfilter.o pixel_desc.o -output deepmatching '-DUSEOMP' CFLAGS="-fPIC -Wall -g -std=c++11 -O3 -fopenmp" LDFLAGS="-fopenmp" -lpng -ljpeg -lm /usr/lib64/atlas/libsatlas.so
48 |
49 | 3) Try executing the code:
50 | >> help deepmatching
51 | >> deepmatching() % show some help about options
52 | >> img1 = single(imread('liberty1.png'));
53 | >> img2 = single(imread('liberty2.png'));
54 | >> matches = deepmatching( img1, img2, '-downscale 2 -v' );
55 | >> matches % print matches, should be as the listing shown below
56 |
57 | Python wrapper:
58 | 1) Compile the python module:
59 | make python
60 |
61 | 2) Try executing the code:
62 | >> import deepmatching as dm
63 | >> help(dm.deepmatching)
64 | >> dm.deepmatching() # show some help about options
65 | >> from PIL import Image
66 | >> import numpy as np
67 | >> img1 = np.array(Image.open('liberty1.png'))
68 | >> img2 = np.array(Image.open('liberty2.png'))
69 | >> matches = dm.deepmatching( img1, img2, '-downscale 2 -v' )
70 | >> matches % print matches, should be as the listing shown below
71 |
72 |
73 |
74 |
75 |
76 |
77 | Example usages and explanations:
78 |
79 | To get detailed information on parameters:
80 | ./deepmatching -h
81 | ./deepmatching --help
82 |
83 |
84 | * Build verification:
85 | ./deepmatching liberty1.png liberty2.png -downscale 2 -v
86 |
87 | should produce the following output:
88 | layer 0, patch_size = 16x16
89 | remaining 16 big cells (actually, 16 are unique)
90 | layer 1, patch_size = 32x32
91 | remaining 25 big cells (actually, 25 are unique)
92 | layer 2, patch_size = 64x64
93 | remaining 25 big cells (actually, 25 are unique)
94 | found 625 local matches
95 | gathering correspondences 96%...
96 | 8 8 0 12 2.6554 10
97 | 8 40 4 48 2.65679 11
98 | 8 24 8 32 2.5486 11
99 | 40 40 40 32 2.64178 0
100 | 40 56 44 52 2.58631 0
101 | 40 24 40 12 2.65065 0
102 | 56 40 56 28 2.64225 0
103 | 56 24 56 12 2.68497 0
104 | 24 40 24 32 2.62045 3
105 | 24 56 28 60 2.5849 12
106 |
107 | * To visualize the output correspondences:
108 | Use the "viz.py" python script provided.
109 | ./deepmatching climb1.png climb2.png -nt 0 | python viz.py climb1.png climb2.png
110 |
111 | * To restrict matching to local neighborhood:
112 | The "-ngh_rad " option restricts the matching to a radius of pixels.
113 | It uses less memory and is faster. For instance, This should produce about
114 | the same output as before but consumes 2 times less memory and cpu:
115 |
116 | ./deepmatching climb1.png climb2.png -nt 0 -ngh_rad 192 | python viz.py climb1.png climb2.png
117 |
118 | * To rescore matches prior to calling deepflow / epicflow:
119 | simply pipe the output correspondences in 'rescore.py'
120 | ./deepmatching img1 img2 [args] | python rescore.py img1 img2
121 |
122 |
123 | * Scale and invariant version: (see the --help)
124 | ./deepmatching dino1.jpg dino2.jpg -nt 0 -downscale 1 -max_scale 2 -rot_range -45 +45 -v | python viz.py dino1.jpg dino2.jpg
125 |
126 | param -max_scale: maximum scale factor (here x2, default = x5)
127 | param -rot_range: rotation range in degrees (default = from 0 to 360)
128 |
129 |
130 | For details about the options, please refer to the help, the papers or the code.
131 |
132 |
133 | Important tip:
134 | If the program stops with "segmentation fault", then it means that your machine
135 | does not have enough memory. In this case, you should consider increasing the
136 | "-downscale" parameter.
137 |
138 |
139 | Version history:
140 |
141 | version 1.0.2:
142 | Many thanks to Bowen Zhang from Tongji University for reporting an issue with the makefile
143 |
144 | version 1.1:
145 | - New mode added for "fully scale & rotation invariant DeepMatching".
146 | - Improved visualisation (viz.py)
147 | - Removed useless/suboptimal options (-iccv_settings)
148 | - Fixed a bug related to memory allocation for large images
149 |
150 | version 1.2:
151 | - Added a new option "-ngh_rad" to restrict the matching to a local neighborhood, which allows
152 | much reduced memory usage and computations.
153 | - static-compiled version is now fully multhi-threaded with BLAS
154 | - few minor bugfix, code cleaning and updates.
155 |
156 | version 1.2.1:
157 | - Now performing the maxpooling and subsampling steps jointly,
158 | which results in 2/3 of memory usage compared to before. Also, it is now a bit faster.
159 | - Removed some useless/confusing options in the executable.
160 |
161 | version 1.2.2:
162 | - Now include a Matlab and a Python wrapper!
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
--------------------------------------------------------------------------------
/data/000001.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CansenJIANG/deepMatchingGUI/1d833f2cc4eee965a93ff65529fe0693cd39c807/data/000001.png
--------------------------------------------------------------------------------
/data/000011.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CansenJIANG/deepMatchingGUI/1d833f2cc4eee965a93ff65529fe0693cd39c807/data/000011.png
--------------------------------------------------------------------------------
/data/000046.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CansenJIANG/deepMatchingGUI/1d833f2cc4eee965a93ff65529fe0693cd39c807/data/000046.png
--------------------------------------------------------------------------------
/data/000056.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CansenJIANG/deepMatchingGUI/1d833f2cc4eee965a93ff65529fe0693cd39c807/data/000056.png
--------------------------------------------------------------------------------
/data/climb1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CansenJIANG/deepMatchingGUI/1d833f2cc4eee965a93ff65529fe0693cd39c807/data/climb1.png
--------------------------------------------------------------------------------
/data/climb2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CansenJIANG/deepMatchingGUI/1d833f2cc4eee965a93ff65529fe0693cd39c807/data/climb2.png
--------------------------------------------------------------------------------
/data/dino1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CansenJIANG/deepMatchingGUI/1d833f2cc4eee965a93ff65529fe0693cd39c807/data/dino1.jpg
--------------------------------------------------------------------------------
/data/dino2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CansenJIANG/deepMatchingGUI/1d833f2cc4eee965a93ff65529fe0693cd39c807/data/dino2.jpg
--------------------------------------------------------------------------------
/data/liberty1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CansenJIANG/deepMatchingGUI/1d833f2cc4eee965a93ff65529fe0693cd39c807/data/liberty1.png
--------------------------------------------------------------------------------
/data/liberty2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CansenJIANG/deepMatchingGUI/1d833f2cc4eee965a93ff65529fe0693cd39c807/data/liberty2.png
--------------------------------------------------------------------------------
/deepMatching.pro:
--------------------------------------------------------------------------------
1 | #-------------------------------------------------
2 | #
3 | # Project created by QtCreator 2015-02-02T15:14:11
4 | #
5 | #-------------------------------------------------
6 |
7 | QT += core
8 | QT += gui
9 |
10 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
11 | QT += widgets
12 | TEMPLATE = app
13 |
14 | TARGET = softwareName
15 |
16 | CONFIG += console
17 | CONFIG -= app_bundle
18 | CONFIG += debug
19 |
20 | PKGCONFIG += opencv-2.4.10
21 | PKGCONFIG += libfreenect
22 | PKGCONFIG += libjpeg
23 | PKGCONFIG += libpng
24 |
25 |
26 | # Enable c++ 11 standard Qt5
27 | #CONFIG += c++11
28 | #CONFIG += gnu++11
29 | # Enable c++ 11 standard Qt 4.8
30 | QMAKE_CXXFLAGS += -std=c++11
31 | #QMAKE_CXXFLAGS += -gnu++11
32 |
33 | TEMPLATE = app
34 |
35 | # add the source files
36 | SOURCES += \
37 | src/main.cpp \
38 | src/deep_matching.cpp \
39 | src/std.cpp \
40 | src/io.cpp \
41 | src/pixel_desc.cpp \
42 | src/maxfilter.cpp \
43 | src/hog.cpp \
44 | src/image.cpp \
45 | src/conv.cpp \
46 | src/mainwindow.cpp \
47 | src/deepmtchinfo.cpp
48 |
49 | # add the headers
50 | HEADERS += \
51 | src/std.h \
52 | src/array_types.h \
53 | src/conv.h \
54 | src/maxfilter.h \
55 | src/image.h \
56 | src/pixel_desc.h \
57 | src/deep_matching.h \
58 | src/io.h \
59 | src/hog.h \
60 | src/mainwindow.h \
61 | src/deepmtchinfo.h
62 |
63 | FORMS += \
64 | src/mainwindow.ui
65 |
66 | # add GUI
67 | # FORMS += src/PclViewer.ui
68 |
69 | ## add ROS opencv libraries
70 | #LIBS += -L/opt/ros/groovy/lib \
71 | # -lopencv_calib3d \
72 | # -lopencv_contrib \
73 | # -lopencv_core \
74 | # -lopencv_features2d \
75 | # -lopencv_flann \
76 | # -lopencv_gpu \
77 | # -lopencv_highgui \
78 | # -lopencv_imgproc \
79 | # -lopencv_legacy \
80 | # -lopencv_ml \
81 | # -lopencv_nonfree \
82 | # -lopencv_objdetect \
83 | # -lopencv_photo \
84 | # -lopencv_stitching \
85 | # -lopencv_ts \
86 | # -lopencv_video \
87 | # -lopencv_videostab
88 |
89 | ## add 2.4.10 opencv libs
90 | #LIBS += -L/usr/local/lib \
91 | # -lopencv_video \
92 | # -lopencv_core \
93 | # -lopencv_highgui \
94 | # -lopencv_imgproc
95 |
96 | ## include opencv path
97 | #INCLUDEPATH += /usr/local/include/opencv-2.4.10/opencv \
98 | # /usr/local/include/opencv-2.4.10/opencv2 \
99 | # /usr/local/include/opencv-2.4.10
100 |
101 | ## include VTK Pcl Eigen Boost Ni path
102 | #INCLUDEPATH += /usr/include/vtk-5.8 \
103 | # /usr/local/include/pcl-1.8 \
104 | # /home/jiang/CvLibs/eigen3.2.3 \
105 | # /usr/include/boost \
106 | # /usr/include/ni
107 |
108 | ## add Pcl libs
109 | #LIBS += -L/usr/local/lib \
110 | # -lpcl_io \
111 | # -lpcl_visualization \
112 | # -lpcl_common \
113 | # -lpcl_filters \
114 | # -lpcl_octree \
115 | # -lpcl_kdtree \
116 | # -lpcl_registration \
117 | # -lpcl_features \
118 | # -lpcl_keypoints \
119 | # -lpcl_recognition \
120 | # -lpcl_sample_consensus \
121 | # -lpcl_search \
122 | # -lpcl_surface \
123 | # -lpcl_ml \
124 | # -lpcl_outofcore \
125 | # -lpcl_people \
126 | # -lpcl_segmentation \
127 | # -lpcl_tracking \
128 | # -lpcl_stereo
129 |
130 | ## add Boost libs
131 | #LIBS += -L/usr/lib \
132 | # -lboost_filesystem \
133 | # -lboost_thread \
134 | # -lboost_system
135 |
136 | ## add VTK libs
137 | #LIBS += -L/usr/lib \
138 | # -lQVTK \
139 | # -lvtkRendering \
140 | # -lvtkIO \
141 | # -lvtkCommon \
142 | # -lvtkWidgets \
143 | # -lvtkFiltering \
144 | # -lvtkGraphics
145 |
146 | # add jpeg library
147 | INCLUDEPATH += /usr/include \
148 | /usr/lib/openmpi/include/openmpi
149 |
150 | LIBS += -L/usr/lib/x86_64-linux-gnu \
151 | -ljpeg \
152 | -lpng \
153 | -lblas
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
--------------------------------------------------------------------------------
/deepMatching.pro.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ProjectExplorer.Project.ActiveTarget
7 | 0
8 |
9 |
10 | ProjectExplorer.Project.EditorSettings
11 |
12 | true
13 | false
14 | true
15 |
16 | Cpp
17 |
18 | CppGlobal
19 |
20 |
21 |
22 | QmlJS
23 |
24 | QmlJSGlobal
25 |
26 |
27 | 2
28 | UTF-8
29 | false
30 | 4
31 | false
32 | true
33 | 1
34 | true
35 | 0
36 | true
37 | 0
38 | 8
39 | true
40 | 1
41 | true
42 | true
43 | true
44 | false
45 |
46 |
47 |
48 | ProjectExplorer.Project.PluginSettings
49 |
50 |
51 |
52 | ProjectExplorer.Project.Target.0
53 |
54 | Qt4
55 | Qt4
56 | {2f4d092c-fac6-4812-9df4-d5704272a46f}
57 | 1
58 | 0
59 | 0
60 |
61 | /home/jiang/CvTools/build-deepMatching-Qt4-Debug
62 |
63 |
64 | true
65 | qmake
66 |
67 | QtProjectManager.QMakeBuildStep
68 | false
69 | true
70 |
71 | false
72 |
73 |
74 | true
75 | Make
76 |
77 | Qt4ProjectManager.MakeStep
78 |
79 | -w
80 | -r
81 |
82 | false
83 |
84 |
85 |
86 | 2
87 | Build
88 |
89 | ProjectExplorer.BuildSteps.Build
90 |
91 |
92 |
93 | true
94 | Make
95 |
96 | Qt4ProjectManager.MakeStep
97 |
98 | -w
99 | -r
100 |
101 | true
102 | clean
103 |
104 |
105 | 1
106 | Clean
107 |
108 | ProjectExplorer.BuildSteps.Clean
109 |
110 | 2
111 | false
112 |
113 | Debug
114 |
115 | Qt4ProjectManager.Qt4BuildConfiguration
116 | 2
117 | true
118 |
119 |
120 | /home/jiang/CvTools/build-deepMatching-Qt4-Release
121 |
122 |
123 | true
124 | qmake
125 |
126 | QtProjectManager.QMakeBuildStep
127 | false
128 | true
129 |
130 | false
131 |
132 |
133 | true
134 | Make
135 |
136 | Qt4ProjectManager.MakeStep
137 |
138 | -w
139 | -r
140 |
141 | false
142 |
143 |
144 |
145 | 2
146 | Build
147 |
148 | ProjectExplorer.BuildSteps.Build
149 |
150 |
151 |
152 | true
153 | Make
154 |
155 | Qt4ProjectManager.MakeStep
156 |
157 | -w
158 | -r
159 |
160 | true
161 | clean
162 |
163 |
164 | 1
165 | Clean
166 |
167 | ProjectExplorer.BuildSteps.Clean
168 |
169 | 2
170 | false
171 |
172 | Release
173 |
174 | Qt4ProjectManager.Qt4BuildConfiguration
175 | 0
176 | true
177 |
178 | 2
179 |
180 |
181 | 0
182 | Deploy
183 |
184 | ProjectExplorer.BuildSteps.Deploy
185 |
186 | 1
187 | Deploy locally
188 |
189 | ProjectExplorer.DefaultDeployConfiguration
190 |
191 | 1
192 |
193 |
194 |
195 | false
196 | false
197 | false
198 | false
199 | true
200 | 0.01
201 | 10
202 | true
203 | 1
204 | 25
205 |
206 | 1
207 | true
208 | false
209 | true
210 | valgrind
211 |
212 | 0
213 | 1
214 | 2
215 | 3
216 | 4
217 | 5
218 | 6
219 | 7
220 | 8
221 | 9
222 | 10
223 | 11
224 | 12
225 | 13
226 | 14
227 |
228 | 2
229 |
230 | deepMatching
231 |
232 | Qt4ProjectManager.Qt4RunConfiguration:/home/jiang/CvTools/deep_Matching_GUI/deepMatching.pro
233 |
234 | deepMatching.pro
235 | false
236 | true
237 |
238 | 3768
239 | true
240 | false
241 | false
242 | false
243 | true
244 |
245 | 1
246 |
247 |
248 |
249 | ProjectExplorer.Project.TargetCount
250 | 1
251 |
252 |
253 | ProjectExplorer.Project.Updater.EnvironmentId
254 | {76727a67-93b2-4850-9de4-dca017a0ba6a}
255 |
256 |
257 | ProjectExplorer.Project.Updater.FileVersion
258 | 15
259 |
260 |
261 |
--------------------------------------------------------------------------------
/deepmatching-static:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CansenJIANG/deepMatchingGUI/1d833f2cc4eee965a93ff65529fe0693cd39c807/deepmatching-static
--------------------------------------------------------------------------------
/src/array_types.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2014 Jerome Revaud
3 |
4 | This program is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | This program is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with this program. If not, see
16 | */
17 | #ifndef ___ARRAY_TYPES_H___
18 | #define ___ARRAY_TYPES_H___
19 |
20 | typedef unsigned char UBYTE;
21 | typedef unsigned int UINT;
22 |
23 |
24 | /************************
25 | * 1D Array
26 |
27 | Equivalences:
28 |
29 | C/Python/numpy: array.shape = (tx,)
30 | array[x] := array->pixels[x]
31 |
32 | Matlab/Fortran: [1, tx] = size(array)
33 | array(x, 1) := array->pixels[x-1]
34 | */
35 |
36 | #define DEFINE_ARRAY(type) \
37 | typedef struct { \
38 | type* pixels; \
39 | int tx; \
40 | } type##_array;
41 |
42 | DEFINE_ARRAY(UBYTE)
43 | DEFINE_ARRAY(int)
44 | DEFINE_ARRAY(UINT)
45 | DEFINE_ARRAY(float)
46 |
47 | #define ASSERT_ARRAY_ZEROS(arr) {int size=arr->tx; assert((arr->pixels[0]==0 && arr->pixels[size/2]==0 && arr->pixels[size-1]==0) || !"error: matrix " #arr "is supposed to be zeros");}
48 |
49 |
50 | /************************
51 | * 2D Image
52 |
53 | Equivalences:
54 |
55 | C/Python/numpy: array.shape = (ty, tx)
56 | array[y, x] := array->pixels[x + y*tx]
57 |
58 | Matlab/Fortran: [tx, ty] = size(array)
59 | array(x, y) := array->pixels[(x-1) + (y-1)*tx]
60 | */
61 |
62 | #define DEFINE_IMG(type) \
63 | typedef struct { \
64 | type* pixels;\
65 | int tx,ty;\
66 | } type##_image;
67 |
68 | DEFINE_IMG(UBYTE)
69 | DEFINE_IMG(int)
70 | DEFINE_IMG(UINT)
71 | DEFINE_IMG(float)
72 |
73 | #define ASSERT_SAME_SIZE ASSERT_SAME_IMG_SIZE
74 | #define ASSERT_IMG_SIZE ASSERT_SAME_IMG_SIZE
75 | #define ASSERT_SAME_IMG_SIZE(im1,im2) if(im1 && im2) assert(im1->tx==im2->tx && im1->ty==im2->ty);
76 |
77 | #define ASSERT_IMAGE_ZEROS
78 | #define ASSERT_IMG_ZEROS(img) {int size=img->tx*img->ty; assert((img->pixels[0]==0 && img->pixels[size/2]==0 && img->pixels[size-1]==0) || !"error: matrix " #img "is supposed to be zeros");}
79 | #define IMG_SIZE(img) (long((img)->tx)*(img)->ty)
80 |
81 |
82 |
83 | /************************
84 | * 3D Image = Cube (Z coordinates are contiguous)
85 |
86 | Equivalences:
87 |
88 | C/Python/numpy: array.shape = (ty, tx, tz)
89 | array[y, x, z] := array->pixels[z + x*tz + y*tx*tz]
90 |
91 | Matlab/Fortran: [tz, tx, ty] = size(array)
92 | array(z, x, y) := array->pixels[(z-1) + (x-1)*tz + (y-1)*tx*tz]
93 | */
94 |
95 | #define DEFINE_CUBE(type) \
96 | typedef struct { \
97 | type* pixels; \
98 | int tx,ty,tz; \
99 | } type##_cube;
100 |
101 | DEFINE_CUBE(UBYTE)
102 | DEFINE_CUBE(short)
103 | DEFINE_CUBE(int)
104 | DEFINE_CUBE(UINT)
105 | DEFINE_CUBE(float)
106 |
107 | #define ASSERT_SAME_CUBE_SIZE(im1, im2) \
108 | if((im1) && (im2)) assert((im1)->tx==(im2)->tx && (im1)->ty==(im2)->ty && (im1)->tz==(im2)->tz);
109 |
110 | #define ASSERT_CUBE_ZEROS(img) {int size=img->tx*img->ty*img->tz; assert((img->pixels[0]==0 && img->pixels[size/2]==0 && img->pixels[size-1]==0) || !"error: matrix " #img "is supposed to be zeros");}
111 | #define CUBE_SIZE(cube) (long((cube)->tx)*(cube)->ty*(cube)->tz)
112 |
113 |
114 |
115 | /************************
116 | * 3D Image = concatenation of XY layers
117 |
118 | Equivalences:
119 |
120 | C/Python/numpy: array.shape = (tz, ty, tx)
121 | array[z, y, x] := array->pixels[x + y*tx + z*tx*ty]
122 |
123 | Matlab/Fortran: [tx, ty, tz] = size(array)
124 | array(x, y, z) := array->pixels[(x-1) + (y-1)*tx + (z-1)*tx*ty]
125 | */
126 |
127 | #define DEFINE_LAYERS(type) \
128 | typedef struct { \
129 | type* pixels; \
130 | int tx,ty,tz; \
131 | } type##_layers; \
132 |
133 | DEFINE_LAYERS(UBYTE)
134 | DEFINE_LAYERS(int)
135 | DEFINE_LAYERS(UINT)
136 | DEFINE_LAYERS(float)
137 |
138 |
139 | #define ASSERT_SAME_LAYERS_SIZE(im1,im2) ASSERT_SAME_CUBE_SIZE(im1,im2)
140 | #define ASSERT_LAYERS_ZEROS ASSERT_CUBE_ZEROS
141 | #define LAYERS_SIZE(layers) CUBE_SIZE(layers)
142 |
143 |
144 |
145 | /*****************
146 | creation, reshaping macros
147 | */
148 |
149 | #define empty_array(type,tx) ((type##_array){NEWA(type,long(tx)),tx})
150 | #define empty_image(type,tx,ty) ((type##_image){NEWA(type,long(tx)*(ty)),tx,ty})
151 | #define empty_cube(type,tx,ty,tz) ((type##_cube ){NEWA(type,long(tx)*(ty)*long(tz)),tx,ty,tz})
152 | #define empty_layers(type,tx,ty,tz) ((type##_layers){NEWA(type,long(tx)*(ty)*(tz)),tx,ty,tz})
153 |
154 | #define zeros_array(type,tx) ((type##_array){NEWAC(type,long(tx)),tx})
155 | #define zeros_image(type,tx,ty) ((type##_image){NEWAC(type,long(tx)*(ty)),tx,ty})
156 | #define zeros_cube(type,tx,ty,tz) ((type##_cube ){NEWAC(type,long(tx)*(ty)*(tz)),tx,ty,tz})
157 | #define zeros_layers(type,tx,ty,tz) ((type##_layers){NEWAC(type,long(tx)*(ty)*(tz)),tx,ty,tz})
158 |
159 | #define array_like(type,l) ((type##_array){NEWA(type,long((l)->tx)),(l)->tx})
160 | #define image_like(type,l) ((type##_image){NEWA(type,long((l)->tx)*(l)->ty),(l)->tx,(l)->ty})
161 | #define cube_like(type,l) ((type##_cube ){NEWA(type,long((l)->tx)*(l)->ty*(l)->tz),(l)->tx,(l)->ty,(l)->tz})
162 | #define layers_like(type,l) ((type##_layers){NEWA(type,long((l)->tx)*(l)->ty*(l)->tz),(l)->tx,(l)->ty,(l)->tz})
163 |
164 |
165 | #define reshape_xy(type, arr) ((type##_array){(arr)->pixels, (arr)->tx*(arr)->ty})
166 | #define reshape_xyz(type, arr) ((type##_array){(arr)->pixels, (arr)->tx*(arr)->ty*(arr)->tz})
167 | #define reshape_xy_z(type, arr) ((type##_image){(arr)->pixels, (arr)->tx*(arr)->ty, (arr)->tz})
168 | #define reshape_z_xy(type, arr) ((type##_image){(arr)->pixels, (arr)->tz, (arr)->tx*(arr)->ty})
169 | #define reshape_x_yz(type, arr) ((type##_image){(arr)->pixels, (arr)->tx, (arr)->ty*(arr)->tz})
170 |
171 |
172 | #define free_image(img) if(img){free(img->pixels); free(img); img=NULL;}
173 | #define free_cube(cube) free_image(cube)
174 | #define free_layers(cube) free_cube(cube)
175 |
176 |
177 | // debugging only
178 | //#include
179 | //inline long hash_arr(char* ptr, int nb, bool show) {
180 | // long res = 0;
181 | // if(show) printf("hashing [");
182 | // for(int i=0; i>17) | (res<<47);
186 | // }
187 | // if(show) printf("]\n");
188 | // return res;
189 | //}
190 | //#define H(arr,val) printf("hash(" #arr ") = %ld\n",val);
191 | //#define hash_array(arr) H(arr,hash_arr((char*)(arr)->pixels,(arr)->tx*sizeof(*(arr)->pixels),0))
192 | //#define hash_image(arr) H(arr,hash_arr((char*)(arr)->pixels,(arr)->tx*(arr)->ty*sizeof(*(arr)->pixels),0))
193 | //#define hash_cube(arr) H(arr,hash_arr((char*)(arr)->pixels,(arr)->tx*(arr)->ty*(arr)->tz*sizeof(*(arr)->pixels),0))
194 | //#define hash_layers(arr) hash_cube(arr)
195 |
196 | //inline void save_raw(const char* fname, int* shape, int ndim, char* ptr, int size) {
197 | // FILE* f = fopen(fname, "w");
198 | // fwrite( &ndim, sizeof(int), 1, f);
199 | // fwrite( shape, sizeof(int), ndim, f);
200 | // fwrite( ptr, sizeof(*ptr), size, f);
201 | // fclose(f);
202 | //}
203 | //#define save_cube(fname,cube) {int sh[3] = {(cube)->ty, (cube)->tx, (cube)->tz}; save_raw(fname, sh, 3, (char*)(cube)->pixels, sizeof(*(cube)->pixels)*CUBE_SIZE(cube));}
204 | //#define save_layers(fname,layers) {int sh[3] = {(layers)->tz, (layers)->ty, (layers)->tx}; save_raw(fname, sh, 3, (char*)(layers)->pixels, sizeof(*(layers)->pixels)*LAYERS_SIZE(layers));}
205 |
206 | #endif
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
--------------------------------------------------------------------------------
/src/conv.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2014 Jerome Revaud
3 |
4 | This program is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | This program is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with this program. If not, see
16 | */
17 | #ifndef ___CONV_H___
18 | #define ___CONV_H___
19 | #include "array_types.h"
20 | #include "deep_matching.h"
21 |
22 |
23 | /* Return the vectorized dimension of a HOG patch
24 | */
25 | int get_patch_desc_dim( float_layers* hog, int patch_size );
26 |
27 |
28 | /* Sample a set of patches from a HOG image.
29 | pos : array of (x,y) position of the patches
30 | size: size of the patches, ie. [x,x+size[ x [y,y+size[
31 | res: result array, n_patches x desc_dim
32 | desc_dim = n_layers * size**2
33 | norms: result, n_patches x 1, norm of each patch
34 | */
35 | void _sample_patches( float_layers* hog, float_layers* color, int_image* pos, int size, float norm,
36 | float_image* res, float_array* norms, int n_thread );
37 |
38 |
39 | /* normalize each pixel of a multi-layers image
40 | norm = {0:nothing, 1:L2-normalization, 0-1: normalization by (L2-norm)** }
41 | */
42 | void norm_layers( float_layers* res, float norm, int n_thread );
43 |
44 |
45 | /* Prepare a grid of cell positions in the first image for a given scale. Big cells inherit the cell at the previous scale.
46 | size = size of cells at current scale
47 | offset, step = grid generator: (offset + i*step, offset + j*step)
48 | child_grid = grid of the previous layer (or None if first layer)
49 | child_norms = image containing the norms of the patch at the previous level
50 | grid = result center positions of cells in current scale
51 | children = index of cells in previous scale used to construct big cells
52 | norms = norms of the cells of this level
53 | */
54 | void _prepare_big_cells( int size, int offset, int step,
55 | int_cube* child_grid, float_image* child_norms,
56 | int_cube* grid, int_cube* children, float_image* norms );
57 |
58 |
59 |
60 | /* Compute the correlation of all patches with the second image (hog).
61 | In case of ngh_rad>0, the correlation is only computed in a small local neighborhood
62 | (whose size is parameterized by ngh_rad).
63 | if extend: width and height of output maps are extended
64 | if norm: correlation are normalized afterwards.
65 | */
66 | void fastconv( float_image* patches, float_layers* hog, int patch_size, int ngh_rad,
67 | int extend, float norm, int nt, res_scale* res );
68 |
69 |
70 |
71 | /* Compute the (sparse) convolutions specified by on