├── README.md ├── SiftGPU ├── History.txt ├── OpenGL_and_CUDA.txt ├── README.txt ├── bin │ ├── DevIL.dll │ ├── DevIL64.dll │ ├── SiftGPU.dll │ ├── SiftGPU64.dll │ ├── SimpleSIFT.exe │ ├── Speed.exe │ ├── TestWin.exe │ ├── glew32.dll │ └── glew64.dll ├── data │ ├── 1600.jpg │ ├── 640-1.jpg │ ├── 640-2.jpg │ ├── 640-3.jpg │ ├── 640-4.jpg │ ├── 640-5.jpg │ ├── 800-1.jpg │ ├── 800-2.jpg │ ├── 800-3.jpg │ ├── 800-4.jpg │ ├── Thumbs.db │ ├── list640.txt │ └── listx.txt ├── demos │ ├── demo1.bat │ ├── demo2.bat │ ├── demo3.bat │ ├── evaluation-box.bat │ └── instructions.txt ├── doc │ ├── evaluation │ │ ├── box.pgm │ │ ├── box.siftgpu │ │ └── evaluation.jpg │ ├── manual.pdf │ ├── speed_v311.jpg │ ├── speed_v340_v2.jpg │ └── statistics.pdf ├── include │ ├── GL │ │ ├── glew.h │ │ ├── glut.h │ │ └── wglew.h │ └── IL │ │ ├── COPYING │ │ └── il.h ├── lib │ ├── DevIL.lib │ ├── DevIL64.lib │ ├── SIFTGPU.exp │ ├── SIFTGPU.lib │ ├── glew32.lib │ ├── glew32s.lib │ ├── glew64.lib │ ├── glew64s.lib │ ├── glut32.lib │ └── glut64.lib ├── license.txt ├── makefile ├── msvc │ ├── ServerSiftGPU │ │ ├── SiftGPU_Server.dsp │ │ └── SiftGPU_Server.vcxproj │ ├── SiftGPU.dsw │ ├── SiftGPU.sln │ ├── SiftGPU │ │ ├── SiftGPU.def │ │ ├── SiftGPU.dsp │ │ ├── SiftGPU.vcxproj │ │ └── SiftGPU_CUDA_Enabled.vcxproj │ ├── SiftGPU_CUDA_Enabled.sln │ └── TestWin │ │ ├── MultiThreadSIFT.dsp │ │ ├── MultiThreadSIFT.vcxproj │ │ ├── SimpleSIFT.dsp │ │ ├── SimpleSIFT.vcxproj │ │ ├── Speed.dsp │ │ ├── Speed.vcxproj │ │ ├── TestBase.dsp │ │ ├── TestBase.vcxproj │ │ ├── TestWin.dsp │ │ ├── TestWin.vcxproj │ │ ├── TestWinGlut.dsp │ │ └── TestWinGlut.vcxproj ├── speed_and_accuracy.txt └── src │ ├── ServerSiftGPU │ ├── ServerSiftGPU.cpp │ ├── ServerSiftGPU.h │ └── server.cpp │ ├── SiftGPU │ ├── CLTexImage.cpp │ ├── CLTexImage.h │ ├── CuTexImage.cpp │ ├── CuTexImage.h │ ├── FrameBufferObject.cpp │ ├── FrameBufferObject.h │ ├── GLTexImage.cpp │ ├── GLTexImage.h │ ├── GlobalUtil.cpp │ ├── GlobalUtil.h │ ├── LiteWindow.h │ ├── ProgramCG.cpp │ ├── ProgramCG.h │ ├── ProgramCL.cpp │ ├── ProgramCL.h │ ├── ProgramCU.cu │ ├── ProgramCU.h │ ├── ProgramGLSL.cpp │ ├── ProgramGLSL.h │ ├── ProgramGPU.cpp │ ├── ProgramGPU.h │ ├── PyramidCL.cpp │ ├── PyramidCL.h │ ├── PyramidCU.cpp │ ├── PyramidCU.h │ ├── PyramidGL.cpp │ ├── PyramidGL.h │ ├── ShaderMan.cpp │ ├── ShaderMan.h │ ├── SiftGPU.cpp │ ├── SiftGPU.h │ ├── SiftMatch.cpp │ ├── SiftMatch.h │ ├── SiftMatchCU.cpp │ ├── SiftMatchCU.h │ ├── SiftPyramid.cpp │ └── SiftPyramid.h │ └── TestWin │ ├── BasicTestWin.cpp │ ├── BasicTestWin.h │ ├── GLTestWnd.cpp │ ├── GLTestWnd.h │ ├── GLTransform.h │ ├── MultiThreadSIFT.cpp │ ├── SimpleSIFT.cpp │ ├── TestWinGlut.cpp │ ├── TestWinGlut.h │ └── speed.cpp ├── cmvs └── program │ ├── base │ ├── cmvs │ │ ├── bundle.cc │ │ ├── bundle.h │ │ ├── graclus.cc │ │ └── graclus.h │ ├── image │ │ ├── camera.cc │ │ ├── camera.h │ │ ├── image.cc │ │ ├── image.h │ │ ├── photo.cc │ │ ├── photo.h │ │ ├── photoSetS.cc │ │ └── photoSetS.h │ ├── numeric │ │ ├── mat2.h │ │ ├── mat3.h │ │ ├── mat4.h │ │ ├── mylapack.cc │ │ ├── mylapack.h │ │ ├── vec2.h │ │ ├── vec3.h │ │ └── vec4.h │ ├── pmvs │ │ ├── detectFeatures.cc │ │ ├── detectFeatures.h │ │ ├── detector.cc │ │ ├── detector.h │ │ ├── dog.cc │ │ ├── dog.h │ │ ├── expand.cc │ │ ├── expand.h │ │ ├── filter.cc │ │ ├── filter.h │ │ ├── findMatch.cc │ │ ├── findMatch.h │ │ ├── harris.cc │ │ ├── harris.h │ │ ├── optim.cc │ │ ├── optim.h │ │ ├── option.cc │ │ ├── option.h │ │ ├── patch.cc │ │ ├── patch.h │ │ ├── patchOrganizerS.cc │ │ ├── patchOrganizerS.cc~ │ │ ├── patchOrganizerS.h │ │ ├── point.cc │ │ ├── point.h │ │ ├── seed.cc │ │ └── seed.h │ └── stann │ │ ├── .svn │ │ ├── entries │ │ └── text-base │ │ │ ├── assert.hpp.svn-base │ │ │ ├── bruteNN.hpp.svn-base │ │ │ ├── bsearch.hpp.svn-base │ │ │ ├── dpoint.hpp.svn-base │ │ │ ├── pair_iter.hpp.svn-base │ │ │ ├── qknn.hpp.svn-base │ │ │ ├── rand.hpp.svn-base │ │ │ ├── sep_float.hpp.svn-base │ │ │ ├── sfcnn.hpp.svn-base │ │ │ ├── sfcnn_knng.hpp.svn-base │ │ │ ├── test.hpp.svn-base │ │ │ ├── zorder_lt.hpp.svn-base │ │ │ └── zorder_type_traits.hpp.svn-base │ │ ├── Copyright.txt │ │ ├── assert.hpp │ │ ├── assert.hpp~ │ │ ├── bruteNN.hpp │ │ ├── bruteNN.hpp~ │ │ ├── bsearch.hpp │ │ ├── bsearch.hpp~ │ │ ├── dpoint.hpp │ │ ├── pair_iter.hpp │ │ ├── qknn.hpp │ │ ├── rand.hpp │ │ ├── sep_float.hpp │ │ ├── sfcnn.hpp │ │ ├── sfcnn.hpp~ │ │ ├── sfcnn_knng.hpp │ │ ├── sfcnn_knng.hpp~ │ │ ├── test.hpp │ │ ├── test.hpp~ │ │ ├── zorder_lt.hpp │ │ ├── zorder_lt.hpp~ │ │ ├── zorder_type_traits.hpp │ │ └── zorder_type_traits.hpp~ │ └── main │ ├── Dependencies │ ├── Makefile │ ├── cmvs.cc │ ├── genOption.cc │ ├── libblas.so.3 │ ├── libgsl.so.0 │ ├── libgslcblas.so.0 │ ├── liblapack.so.3 │ └── pmvs2.cc ├── graclus1.2 ├── Makefile ├── Makefile.in ├── README_Graclus ├── matlab │ ├── GraclusImageSegmentation.m │ ├── a_times_b_cmplx.dll │ ├── a_times_b_cmplx.mexa64 │ ├── a_times_b_cmplx.mexglx │ ├── a_times_b_cmplx.mexmac │ ├── affinityic.mexa64 │ ├── affinityic.mexglx │ ├── cimgnbmap.mexa64 │ ├── cimgnbmap.mexglx │ ├── discretisation.m │ ├── discretisationEigenVectorData.asv │ ├── discretisationEigenVectorData.m │ ├── eigs2.m │ ├── graclus.m │ ├── graclus_compile_script.m │ ├── graclus_mex.cpp │ ├── graclus_mex.mexa64 │ ├── graclus_mex.mexglx │ ├── graclus_mex.mexw32 │ ├── io.cpp │ ├── mex_w_times_x_symmetric.dll │ ├── mex_w_times_x_symmetric.mexa64 │ ├── mex_w_times_x_symmetric.mexglx │ ├── mex_w_times_x_symmetric.mexmac │ ├── mlkkm.cpp │ ├── ncut.asv │ ├── ncut.m │ ├── ncutW.asv │ ├── ncutW.m │ ├── readMetis.m │ ├── sparsifyc.dll │ ├── sparsifyc.mexa64 │ ├── sparsifyc.mexglx │ ├── sparsifyc.mexmac │ ├── spmtimesd.dll │ ├── spmtimesd.mexa64 │ ├── spmtimesd.mexglx │ ├── spmtimesd.mexmac │ └── wkkm.cpp ├── metisLib │ ├── Makefile │ ├── balance.c │ ├── bucketsort.c │ ├── ccgraph.c │ ├── coarsen.c │ ├── compress.c │ ├── debug.c │ ├── defs.h │ ├── estmem.c │ ├── fm.c │ ├── fortran.c │ ├── frename.c │ ├── graph.c │ ├── initpart.c │ ├── kmetis.c │ ├── kvmetis.c │ ├── kwayfm.c │ ├── kwayrefine.c │ ├── kwayvolfm.c │ ├── kwayvolrefine.c │ ├── macros.h │ ├── match.c │ ├── mbalance.c │ ├── mbalance2.c │ ├── mcoarsen.c │ ├── memory.c │ ├── mesh.c │ ├── meshpart.c │ ├── metis.h │ ├── mfm.c │ ├── mfm2.c │ ├── mincover.c │ ├── minitpart.c │ ├── minitpart2.c │ ├── mkmetis.c │ ├── mkwayfmh.c │ ├── mkwayrefine.c │ ├── mmatch.c │ ├── mmd.c │ ├── mpmetis.c │ ├── mrefine.c │ ├── mrefine2.c │ ├── mutil.c │ ├── myqsort.c │ ├── ometis.c │ ├── parmetis.c │ ├── pmetis.c │ ├── pqueue.c │ ├── proto.h │ ├── refine.c │ ├── rename.h │ ├── separator.c │ ├── sfm.c │ ├── srefine.c │ ├── stat.c │ ├── struct.h │ ├── subdomains.c │ ├── timing.c │ └── util.c ├── multilevelLib │ ├── Makefile │ ├── mlkkm.c │ ├── wkkm.c │ ├── wkkm_boundary_only.c │ ├── wkkm_experiment.c │ └── wkkm_old.c └── programs │ ├── Makefile │ ├── graclus.c │ ├── io.c │ └── io.h ├── pba ├── COPYING ├── History.txt ├── bin │ ├── driver_x64.exe │ ├── pba.dll │ └── pba_x64.dll ├── doc │ ├── manual.pdf │ └── readme.txt ├── makefile ├── makefile_no_gpu ├── msvc │ ├── driver │ │ └── driver.vcxproj │ ├── pba.sln │ ├── pba.suo │ └── pba │ │ ├── pba.def │ │ └── pba.vcxproj └── src │ ├── driver │ └── driver.cpp │ └── pba │ ├── ConfigBA.cpp │ ├── ConfigBA.h │ ├── CuTexImage.cpp │ ├── CuTexImage.h │ ├── DataInterface.h │ ├── ProgramCU.cu │ ├── ProgramCU.h │ ├── SparseBundleCPU.cpp │ ├── SparseBundleCPU.h │ ├── SparseBundleCU.cpp │ ├── SparseBundleCU.h │ ├── interface.h │ ├── pba.cpp │ ├── pba.h │ └── util.h ├── pmvs-2 ├── license │ └── libgfx-license.html └── program │ ├── base │ ├── image │ │ ├── camera.cc │ │ ├── camera.h │ │ ├── image.cc │ │ ├── image.h │ │ ├── photo.cc │ │ ├── photo.h │ │ ├── photoSetS.cc │ │ └── photoSetS.h │ ├── numeric │ │ ├── mat2.h │ │ ├── mat3.h │ │ ├── mat4.h │ │ ├── mylapack.cc │ │ ├── mylapack.h │ │ ├── vec2.h │ │ ├── vec3.h │ │ └── vec4.h │ └── pmvs │ │ ├── detectFeatures.cc │ │ ├── detectFeatures.h │ │ ├── detector.cc │ │ ├── detector.h │ │ ├── dog.cc │ │ ├── dog.h │ │ ├── expand.cc │ │ ├── expand.h │ │ ├── filter.cc │ │ ├── filter.h │ │ ├── findMatch.cc │ │ ├── findMatch.h │ │ ├── harris.cc │ │ ├── harris.h │ │ ├── optim.cc │ │ ├── optim.h │ │ ├── option.cc │ │ ├── option.h │ │ ├── patch.cc │ │ ├── patch.h │ │ ├── patchOrganizerS.cc │ │ ├── patchOrganizerS.h │ │ ├── point.cc │ │ ├── point.h │ │ ├── seed.cc │ │ └── seed.h │ └── main │ ├── Makefile │ ├── camera.o │ ├── detectFeatures.o │ ├── detector.o │ ├── dog.o │ ├── expand.o │ ├── filter.o │ ├── findMatch.o │ ├── harris.o │ ├── image.o │ ├── libblas.so.3 │ ├── libgsl.so.0 │ ├── libgslcblas.so.0 │ ├── liblapack.so.3 │ ├── mylapack.o │ ├── optim.o │ ├── option.o │ ├── patch.o │ ├── patchOrganizerS.o │ ├── photo.o │ ├── photoSetS.o │ ├── pmvs2 │ ├── pmvs2.cc │ ├── pmvs2.o │ ├── point.o │ ├── run0.sh │ ├── run1.sh │ ├── run2.sh │ └── seed.o ├── scripts ├── dependencies.sh └── install.sh └── vsfm ├── README ├── lib ├── VisualSFM.a ├── blas.a ├── lapack.a ├── libf2c.a └── libjpeg.a └── makefile /README.md: -------------------------------------------------------------------------------- 1 | # VisualSFM 2 | 3 | VisualSFM, http://ccwu.me/vsfm/, is a pain to get working "out of the box". This repository will make it slightly easier for you. 4 | 5 | * Source code changes location so now and then, henceforth it is put into folders in this repository. 6 | * In `scripts` there is a bash script `dependencies.sh` which can be used to get all required dependencies from the Ubuntu repositories. 7 | 8 | ## Copyrights 9 | 10 | Check http://ccwu.me/vsfm/ 11 | 12 | ## Warning 13 | 14 | This repository just exists to help you (and it's from source that is 2 years old!). I don't accept pull requests. I don't even have an nvidia card at the moment. 15 | -------------------------------------------------------------------------------- /SiftGPU/README.txt: -------------------------------------------------------------------------------- 1 | A GPU implementation of David Lowe's Scale Invariant Feature Transform 2 | 3 | Changchang wu 4 | 5 | http://cs.unc.edu/~ccwu 6 | 7 | University of North Carolina at Chapel Hill 8 | 9 | 10 | 11 | 12 | 1. SIFT 13 | 14 | SIFTGPU is an implementation of SIFT for GPU. SiftGPU uses GPU to process pixels and features 15 | parallely in Gaussian pyramid construction, DoG keypoint detection and descriptor generation 16 | for SIFT. Compact feature list is efficiently build through a GPU/CPU mixed reduction. 17 | 18 | SIFTGPU is inspired by Andrea Vedaldi's sift++ and Sudipta N Sinha et al's GPU-SIFT. Many 19 | parameters of sift++ ( for example, number of octaves,number of DOG levels, edge threshold, 20 | etc) are available in SiftGPU. 21 | 22 | 23 | SIFTGPU also includes a GPU exhaustive/guided sift matcher SiftMatchGPU. It basically multiplies 24 | the descriptor matrix on GPU and find closest feature matches on GPU. GLSL/CUDA/CG implementations 25 | are all provided. 26 | 27 | NEW: The latest SIFTGPU also enables you to use Multi-GPUs and GPUS on different computers. 28 | Check doc/manual.pdf for more information. You can modify some marcros definition in 29 | SimpleSIFT.cpp and speed.cpp to enable the testing of the new functions. 30 | 31 | 32 | 2. Requirements 33 | 34 | The default implemntation uses GLSL, and it requires a GPU that has large memory and supports 35 | dynamic branching. For nVidia graphic cards, you can optionally use CG(require fp40) or 36 | CUDA implementation. You can try different implementations and to find out the fastest one 37 | for different image sizes and parameters. 38 | 39 | The GLSL version may not work on ATI now. They did compile sucessfully with ATI Catalyst 8.9, 40 | but not any more with 9.x versions. 41 | 42 | SiftGPU uses DevIl Image library, GLEW and GLUT. You'll need to make sure your system has 43 | all the dependening libraries. SiftGPU should be able to run on any operation system that supports 44 | the above libraries 45 | 46 | For windows system visual studio solution are provided as msvc/SiftGPU.dsw, msvc/SiftGPU.sln and 47 | msvc/SiftGPU_CUDA_Enabled.sln. Linux/Mac makefile is in folder Linux of the package. 48 | 49 | 50 | 3. Helps 51 | 52 | Use -help to get parameter information. Check /doc/manual.pdf for samples and explanations. 53 | In the vc workspace, there is a project called SimpleSIF that gives an example of simple 54 | SiftGPU usage. There are more examples of different ways of using SiftGPU in manual.pdf 55 | 56 | 57 | Check /doc/manual.pdf for help on the viewer. 58 | 59 | -------------------------------------------------------------------------------- /SiftGPU/bin/DevIL.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/bin/DevIL.dll -------------------------------------------------------------------------------- /SiftGPU/bin/DevIL64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/bin/DevIL64.dll -------------------------------------------------------------------------------- /SiftGPU/bin/SiftGPU.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/bin/SiftGPU.dll -------------------------------------------------------------------------------- /SiftGPU/bin/SiftGPU64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/bin/SiftGPU64.dll -------------------------------------------------------------------------------- /SiftGPU/bin/SimpleSIFT.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/bin/SimpleSIFT.exe -------------------------------------------------------------------------------- /SiftGPU/bin/Speed.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/bin/Speed.exe -------------------------------------------------------------------------------- /SiftGPU/bin/TestWin.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/bin/TestWin.exe -------------------------------------------------------------------------------- /SiftGPU/bin/glew32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/bin/glew32.dll -------------------------------------------------------------------------------- /SiftGPU/bin/glew64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/bin/glew64.dll -------------------------------------------------------------------------------- /SiftGPU/data/1600.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/data/1600.jpg -------------------------------------------------------------------------------- /SiftGPU/data/640-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/data/640-1.jpg -------------------------------------------------------------------------------- /SiftGPU/data/640-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/data/640-2.jpg -------------------------------------------------------------------------------- /SiftGPU/data/640-3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/data/640-3.jpg -------------------------------------------------------------------------------- /SiftGPU/data/640-4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/data/640-4.jpg -------------------------------------------------------------------------------- /SiftGPU/data/640-5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/data/640-5.jpg -------------------------------------------------------------------------------- /SiftGPU/data/800-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/data/800-1.jpg -------------------------------------------------------------------------------- /SiftGPU/data/800-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/data/800-2.jpg -------------------------------------------------------------------------------- /SiftGPU/data/800-3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/data/800-3.jpg -------------------------------------------------------------------------------- /SiftGPU/data/800-4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/data/800-4.jpg -------------------------------------------------------------------------------- /SiftGPU/data/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/data/Thumbs.db -------------------------------------------------------------------------------- /SiftGPU/data/list640.txt: -------------------------------------------------------------------------------- 1 | 640-1.jpg 2 | 640-2.jpg 3 | 640-3.jpg 4 | 640-4.jpg 5 | 640-5.jpg -------------------------------------------------------------------------------- /SiftGPU/data/listx.txt: -------------------------------------------------------------------------------- 1 | 800-1.jpg 2 | 640-1.jpg 3 | 800-2.jpg 4 | 640-2.jpg 5 | 800-3.jpg 6 | 640-3.jpg 7 | 800-4.jpg 8 | 640-4.jpg 9 | 640-5.jpg -------------------------------------------------------------------------------- /SiftGPU/demos/demo1.bat: -------------------------------------------------------------------------------- 1 | ..\bin\TestWinGlut.exe -i ..\data\1600.jpg -------------------------------------------------------------------------------- /SiftGPU/demos/demo2.bat: -------------------------------------------------------------------------------- 1 | ..\bin\TestWinGlut.exe -il ..\data\list640.txt -------------------------------------------------------------------------------- /SiftGPU/demos/demo3.bat: -------------------------------------------------------------------------------- 1 | ..\bin\TestWinGlut.exe -il ..\data\listx.txt -------------------------------------------------------------------------------- /SiftGPU/demos/evaluation-box.bat: -------------------------------------------------------------------------------- 1 | ..\bin\TestWinGlut.exe -i ..\doc\evaluation\box.pgm -o ..\doc\evaluation\box.siftgpu -w 3 -fo -1 -loweo -exit -------------------------------------------------------------------------------- /SiftGPU/demos/instructions.txt: -------------------------------------------------------------------------------- 1 | after the window shows up, try the following keys 2 | r process the next image 3 | l start/stop loopy processing 4 | space next subview 5 | enter next view 6 | 7 | Check out ../doc/manual.doc for more viewer instructions. 8 | 9 | demo3 process a list of images with varing image sizes 10 | -------------------------------------------------------------------------------- /SiftGPU/doc/evaluation/box.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/doc/evaluation/box.pgm -------------------------------------------------------------------------------- /SiftGPU/doc/evaluation/evaluation.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/doc/evaluation/evaluation.jpg -------------------------------------------------------------------------------- /SiftGPU/doc/manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/doc/manual.pdf -------------------------------------------------------------------------------- /SiftGPU/doc/speed_v311.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/doc/speed_v311.jpg -------------------------------------------------------------------------------- /SiftGPU/doc/speed_v340_v2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/doc/speed_v340_v2.jpg -------------------------------------------------------------------------------- /SiftGPU/doc/statistics.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/doc/statistics.pdf -------------------------------------------------------------------------------- /SiftGPU/lib/DevIL.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/lib/DevIL.lib -------------------------------------------------------------------------------- /SiftGPU/lib/DevIL64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/lib/DevIL64.lib -------------------------------------------------------------------------------- /SiftGPU/lib/SIFTGPU.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/lib/SIFTGPU.exp -------------------------------------------------------------------------------- /SiftGPU/lib/SIFTGPU.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/lib/SIFTGPU.lib -------------------------------------------------------------------------------- /SiftGPU/lib/glew32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/lib/glew32.lib -------------------------------------------------------------------------------- /SiftGPU/lib/glew32s.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/lib/glew32s.lib -------------------------------------------------------------------------------- /SiftGPU/lib/glew64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/lib/glew64.lib -------------------------------------------------------------------------------- /SiftGPU/lib/glew64s.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/lib/glew64s.lib -------------------------------------------------------------------------------- /SiftGPU/lib/glut32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/lib/glut32.lib -------------------------------------------------------------------------------- /SiftGPU/lib/glut64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/SiftGPU/lib/glut64.lib -------------------------------------------------------------------------------- /SiftGPU/license.txt: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (c) 2007 University of North Carolina at Chapel Hill 4 | // All Rights Reserved 5 | // 6 | // Permission to use, copy, modify and distribute this software and its 7 | // documentation for educational, research and non-profit purposes, without 8 | // fee, and without a written agreement is hereby granted, provided that the 9 | // above copyright notice and the following paragraph appear in all copies. 10 | // 11 | // The University of North Carolina at Chapel Hill make no representations 12 | // about the suitability of this software for any purpose. It is provided 13 | // 'as is' without express or implied warranty. 14 | // 15 | // Please send BUG REPORTS to ccwu@cs.unc.edu 16 | // 17 | //////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /SiftGPU/msvc/SiftGPU.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "SiftGPU"=.\SiftGPU\SiftGPU.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Project: "SiftGPU_Server"=.\ServerSiftGPU\SiftGPU_Server.dsp - Package Owner=<4> 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<4> 25 | {{{ 26 | Begin Project Dependency 27 | Project_Dep_Name SiftGPU 28 | End Project Dependency 29 | }}} 30 | 31 | ############################################################################### 32 | 33 | Project: "SimpleSIFT"=.\TestWin\SimpleSIFT.dsp - Package Owner=<4> 34 | 35 | Package=<5> 36 | {{{ 37 | }}} 38 | 39 | Package=<4> 40 | {{{ 41 | Begin Project Dependency 42 | Project_Dep_Name SiftGPU 43 | End Project Dependency 44 | }}} 45 | 46 | ############################################################################### 47 | 48 | Project: "Speed"=.\TestWin\Speed.dsp - Package Owner=<4> 49 | 50 | Package=<5> 51 | {{{ 52 | }}} 53 | 54 | Package=<4> 55 | {{{ 56 | Begin Project Dependency 57 | Project_Dep_Name SiftGPU 58 | End Project Dependency 59 | }}} 60 | 61 | ############################################################################### 62 | 63 | Project: "TestBase"=.\TestWin\TestBase.dsp - Package Owner=<4> 64 | 65 | Package=<5> 66 | {{{ 67 | }}} 68 | 69 | Package=<4> 70 | {{{ 71 | Begin Project Dependency 72 | Project_Dep_Name SiftGPU 73 | End Project Dependency 74 | }}} 75 | 76 | ############################################################################### 77 | 78 | Project: "TestWin"=.\TestWin\TestWin.dsp - Package Owner=<4> 79 | 80 | Package=<5> 81 | {{{ 82 | }}} 83 | 84 | Package=<4> 85 | {{{ 86 | Begin Project Dependency 87 | Project_Dep_Name TestBase 88 | End Project Dependency 89 | }}} 90 | 91 | ############################################################################### 92 | 93 | Project: "TestWinGlut"=.\TestWin\TestWinGlut.dsp - Package Owner=<4> 94 | 95 | Package=<5> 96 | {{{ 97 | }}} 98 | 99 | Package=<4> 100 | {{{ 101 | Begin Project Dependency 102 | Project_Dep_Name TestBase 103 | End Project Dependency 104 | }}} 105 | 106 | ############################################################################### 107 | 108 | Global: 109 | 110 | Package=<5> 111 | {{{ 112 | }}} 113 | 114 | Package=<3> 115 | {{{ 116 | }}} 117 | 118 | ############################################################################### 119 | 120 | -------------------------------------------------------------------------------- /SiftGPU/msvc/SiftGPU/SiftGPU.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | CreateNewSiftGPU @1 3 | CreateNewSiftMatchGPU @2 4 | CreateLiteWindow @3 5 | CreateComboSiftGPU @4 6 | CreateRemoteSiftGPU @5 7 | -------------------------------------------------------------------------------- /SiftGPU/msvc/TestWin/TestBase.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="TestBase" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Static Library" 0x0104 6 | 7 | CFG=TestBase - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "TestBase.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "TestBase.mak" CFG="TestBase - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "TestBase - Win32 Release" (based on "Win32 (x86) Static Library") 21 | !MESSAGE "TestBase - Win32 Debug" (based on "Win32 (x86) Static Library") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | RSC=rc.exe 30 | 31 | !IF "$(CFG)" == "TestBase - Win32 Release" 32 | 33 | # PROP BASE Use_MFC 0 34 | # PROP BASE Use_Debug_Libraries 0 35 | # PROP BASE Output_Dir "Release" 36 | # PROP BASE Intermediate_Dir "Release" 37 | # PROP BASE Target_Dir "" 38 | # PROP Use_MFC 0 39 | # PROP Use_Debug_Libraries 0 40 | # PROP Output_Dir "Release" 41 | # PROP Intermediate_Dir "Release" 42 | # PROP Target_Dir "" 43 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c 44 | # ADD CPP /nologo /W3 /GX /O2 /I "../../Include/" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c 45 | # ADD BASE RSC /l 0x409 /d "NDEBUG" 46 | # ADD RSC /l 0x409 /d "NDEBUG" 47 | BSC32=bscmake.exe 48 | # ADD BASE BSC32 /nologo 49 | # ADD BSC32 /nologo 50 | LIB32=link.exe -lib 51 | # ADD BASE LIB32 /nologo 52 | # ADD LIB32 /nologo /out:"..\..\lib\TestBase.lib" 53 | 54 | !ELSEIF "$(CFG)" == "TestBase - Win32 Debug" 55 | 56 | # PROP BASE Use_MFC 0 57 | # PROP BASE Use_Debug_Libraries 1 58 | # PROP BASE Output_Dir "Debug" 59 | # PROP BASE Intermediate_Dir "Debug" 60 | # PROP BASE Target_Dir "" 61 | # PROP Use_MFC 0 62 | # PROP Use_Debug_Libraries 1 63 | # PROP Output_Dir "Debug" 64 | # PROP Intermediate_Dir "Debug" 65 | # PROP Target_Dir "" 66 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c 67 | # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../Include/" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c 68 | # ADD BASE RSC /l 0x409 /d "_DEBUG" 69 | # ADD RSC /l 0x409 /d "_DEBUG" 70 | BSC32=bscmake.exe 71 | # ADD BASE BSC32 /nologo 72 | # ADD BSC32 /nologo 73 | LIB32=link.exe -lib 74 | # ADD BASE LIB32 /nologo 75 | # ADD LIB32 /nologo /out:"..\..\lib\TestBase_d.lib" 76 | 77 | !ENDIF 78 | 79 | # Begin Target 80 | 81 | # Name "TestBase - Win32 Release" 82 | # Name "TestBase - Win32 Debug" 83 | # Begin Group "Source Files" 84 | 85 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 86 | # Begin Source File 87 | 88 | SOURCE=..\..\src\TestWin\BasicTestWin.cpp 89 | # End Source File 90 | # End Group 91 | # Begin Group "Header Files" 92 | 93 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 94 | # Begin Source File 95 | 96 | SOURCE=..\..\src\TestWin\BasicTestWin.h 97 | # End Source File 98 | # Begin Source File 99 | 100 | SOURCE=..\..\src\TestWin\GLTransform.h 101 | # End Source File 102 | # End Group 103 | # End Target 104 | # End Project 105 | -------------------------------------------------------------------------------- /SiftGPU/src/SiftGPU/CLTexImage.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: CLTexImage.h 3 | // Author: Changchang Wu 4 | // Description : interface for the CLTexImage class. 5 | // class for storing data in CUDA. 6 | // 7 | // Copyright (c) 2007 University of North Carolina at Chapel Hill 8 | // All Rights Reserved 9 | // 10 | // Permission to use, copy, modify and distribute this software and its 11 | // documentation for educational, research and non-profit purposes, without 12 | // fee, and without a written agreement is hereby granted, provided that the 13 | // above copyright notice and the following paragraph appear in all copies. 14 | // 15 | // The University of North Carolina at Chapel Hill make no representations 16 | // about the suitability of this software for any purpose. It is provided 17 | // 'as is' without express or implied warranty. 18 | // 19 | // Please send BUG REPORTS to ccwu@cs.unc.edu 20 | // 21 | //////////////////////////////////////////////////////////////////////////// 22 | #if defined(CL_SIFTGPU_ENABLED) 23 | 24 | #ifndef CL_TEX_IMAGE_H 25 | #define CL_TEX_IMAGE_H 26 | 27 | class GLTexImage; 28 | 29 | class CLTexImage 30 | { 31 | protected: 32 | cl_context _context; 33 | cl_command_queue _queue; 34 | cl_mem _clData; 35 | int _numChannel; 36 | int _imgWidth; 37 | int _imgHeight; 38 | int _texWidth; 39 | int _texHeight; 40 | int _bufferLen; 41 | int _fromGL; 42 | private: 43 | void ReleaseTexture(); 44 | public: 45 | void SetImageSize(int width, int height); 46 | void SetPackedSize(int width, int height, int packed); 47 | void InitBufferTex(int width, int height, int nchannel); 48 | void InitTexture(int width, int height, int nchannel); 49 | void InitPackedTex(int width, int height, int packed); 50 | void InitTextureGL(GLuint tex, int width, int height, int nchannel); 51 | void CopyToHost(void* buf); 52 | void CopyFromHost(const void* buf); 53 | public: 54 | int CopyToPBO(GLuint pbo); 55 | int GetImageDataSize(); 56 | public: 57 | inline operator cl_mem(){return _clData; } 58 | inline int GetImgWidth(){return _imgWidth;} 59 | inline int GetImgHeight(){return _imgHeight;} 60 | inline int GetTexWidth(){return _texWidth;} 61 | inline int GetTexHeight(){return _texHeight;} 62 | inline int GetDataSize(){return _bufferLen;} 63 | inline bool IsImage2D() {return _bufferLen == 0;} 64 | inline int GetImgPixelCount(){return _imgWidth*_imgHeight;} 65 | inline int GetTexPixelCount(){return _texWidth*_texHeight;} 66 | public: 67 | CLTexImage(); 68 | CLTexImage(cl_context context, cl_command_queue queue); 69 | void SetContext(cl_context context, cl_command_queue queue); 70 | virtual ~CLTexImage(); 71 | friend class ProgramCL; 72 | friend class PyramidCL; 73 | friend class ProgramBagCL; 74 | friend class ProgramBagCLN; 75 | }; 76 | 77 | ////////////////////////////////////////////////// 78 | //transfer OpenGL Texture to PBO, then to CUDA vector 79 | //#endif 80 | #endif // !defined(CU_TEX_IMAGE_H) 81 | #endif 82 | 83 | 84 | -------------------------------------------------------------------------------- /SiftGPU/src/SiftGPU/CuTexImage.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: CuTexImage.h 3 | // Author: Changchang Wu 4 | // Description : interface for the CuTexImage class. 5 | // class for storing data in CUDA. 6 | // 7 | // Copyright (c) 2007 University of North Carolina at Chapel Hill 8 | // All Rights Reserved 9 | // 10 | // Permission to use, copy, modify and distribute this software and its 11 | // documentation for educational, research and non-profit purposes, without 12 | // fee, and without a written agreement is hereby granted, provided that the 13 | // above copyright notice and the following paragraph appear in all copies. 14 | // 15 | // The University of North Carolina at Chapel Hill make no representations 16 | // about the suitability of this software for any purpose. It is provided 17 | // 'as is' without express or implied warranty. 18 | // 19 | // Please send BUG REPORTS to ccwu@cs.unc.edu 20 | // 21 | //////////////////////////////////////////////////////////////////////////// 22 | 23 | 24 | #ifndef CU_TEX_IMAGE_H 25 | #define CU_TEX_IMAGE_H 26 | 27 | class GLTexImage; 28 | struct cudaArray; 29 | struct textureReference; 30 | 31 | //using texture2D from linear memory 32 | 33 | #define SIFTGPU_ENABLE_LINEAR_TEX2D 34 | 35 | class CuTexImage 36 | { 37 | protected: 38 | void* _cuData; 39 | cudaArray* _cuData2D; 40 | int _numChannel; 41 | int _numBytes; 42 | int _imgWidth; 43 | int _imgHeight; 44 | int _texWidth; 45 | int _texHeight; 46 | GLuint _fromPBO; 47 | public: 48 | virtual void SetImageSize(int width, int height); 49 | virtual void InitTexture(int width, int height, int nchannel = 1); 50 | void InitTexture2D(); 51 | inline void BindTexture(textureReference& texRef); 52 | inline void BindTexture2D(textureReference& texRef); 53 | void CopyToTexture2D(); 54 | void CopyToHost(void* buf); 55 | void CopyToHost(void* buf, int stream); 56 | void CopyFromHost(const void* buf); 57 | int CopyToPBO(GLuint pbo); 58 | void CopyFromPBO(int width, int height, GLuint pbo); 59 | static int DebugCopyToTexture2D(); 60 | public: 61 | inline int GetImgWidth(){return _imgWidth;} 62 | inline int GetImgHeight(){return _imgHeight;} 63 | inline int GetDataSize(){return _numBytes;} 64 | public: 65 | CuTexImage(); 66 | CuTexImage(int width, int height, int nchannel, GLuint pbo); 67 | virtual ~CuTexImage(); 68 | friend class ProgramCU; 69 | friend class PyramidCU; 70 | }; 71 | 72 | ////////////////////////////////////////////////// 73 | //transfer OpenGL Texture to PBO, then to CUDA vector 74 | //#endif 75 | #endif // !defined(CU_TEX_IMAGE_H) 76 | 77 | -------------------------------------------------------------------------------- /SiftGPU/src/SiftGPU/FrameBufferObject.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: FrameBufferObject.cpp 3 | // Author: Changchang Wu 4 | // Description : Implementation of FrameBufferObject Class 5 | // 6 | // 7 | // 8 | // Copyright (c) 2007 University of North Carolina at Chapel Hill 9 | // All Rights Reserved 10 | // 11 | // Permission to use, copy, modify and distribute this software and its 12 | // documentation for educational, research and non-profit purposes, without 13 | // fee, and without a written agreement is hereby granted, provided that the 14 | // above copyright notice and the following paragraph appear in all copies. 15 | // 16 | // The University of North Carolina at Chapel Hill make no representations 17 | // about the suitability of this software for any purpose. It is provided 18 | // 'as is' without express or implied warranty. 19 | // 20 | // Please send BUG REPORTS to ccwu@cs.unc.edu 21 | // 22 | //////////////////////////////////////////////////////////////////////////// 23 | 24 | 25 | #include "GL/glew.h" 26 | #include 27 | #include "GlobalUtil.h" 28 | #include "FrameBufferObject.h" 29 | 30 | //whether use only one FBO globally 31 | int FrameBufferObject::UseSingleFBO=1; 32 | GLuint FrameBufferObject::GlobalFBO=0; 33 | 34 | ////////////////////////////////////////////////////////////////////// 35 | // Construction/Destruction 36 | ////////////////////////////////////////////////////////////////////// 37 | 38 | FrameBufferObject::FrameBufferObject(int autobind) 39 | { 40 | if(UseSingleFBO && GlobalFBO) 41 | { 42 | _fboID = GlobalFBO; 43 | }else 44 | { 45 | glGenFramebuffersEXT(1, &_fboID); 46 | if(UseSingleFBO )GlobalFBO = _fboID; 47 | } 48 | if(autobind ) glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _fboID); 49 | } 50 | 51 | FrameBufferObject::~FrameBufferObject() 52 | { 53 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 54 | if(!UseSingleFBO ) 55 | { 56 | glDeleteFramebuffersEXT (1,&_fboID); 57 | } 58 | } 59 | 60 | void FrameBufferObject::DeleteGlobalFBO() 61 | { 62 | if(UseSingleFBO) 63 | { 64 | glDeleteFramebuffersEXT (1,&GlobalFBO); 65 | GlobalFBO = 0; 66 | } 67 | } 68 | 69 | void FrameBufferObject::AttachDepthTexture(GLenum textureTarget, GLuint texID) 70 | { 71 | 72 | glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, textureTarget, texID, 0); 73 | } 74 | 75 | void FrameBufferObject::AttachTexture(GLenum textureTarget, GLenum attachment, GLuint texId) 76 | { 77 | glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, attachment, textureTarget, texId, 0); 78 | } 79 | 80 | void FrameBufferObject::BindFBO() 81 | { 82 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _fboID); 83 | } 84 | 85 | void FrameBufferObject::UnbindFBO() 86 | { 87 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 88 | } 89 | 90 | void FrameBufferObject::UnattachTex(GLenum attachment) 91 | { 92 | glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_2D, 0, 0 ); 93 | } 94 | 95 | void FrameBufferObject::AttachRenderBuffer(GLenum attachment, GLuint buffID) 96 | { 97 | glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, attachment, GL_RENDERBUFFER_EXT, buffID); 98 | 99 | } 100 | 101 | void FrameBufferObject:: UnattachRenderBuffer(GLenum attachment) 102 | { 103 | glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, attachment, GL_RENDERBUFFER_EXT, 0); 104 | } 105 | 106 | -------------------------------------------------------------------------------- /SiftGPU/src/SiftGPU/FrameBufferObject.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: FrameBufferObject.h 3 | // Author: Changchang Wu 4 | // Description : interface for the FrameBufferObject class. 5 | // 6 | // 7 | // 8 | // Copyright (c) 2007 University of North Carolina at Chapel Hill 9 | // All Rights Reserved 10 | // 11 | // Permission to use, copy, modify and distribute this software and its 12 | // documentation for educational, research and non-profit purposes, without 13 | // fee, and without a written agreement is hereby granted, provided that the 14 | // above copyright notice and the following paragraph appear in all copies. 15 | // 16 | // The University of North Carolina at Chapel Hill make no representations 17 | // about the suitability of this software for any purpose. It is provided 18 | // 'as is' without express or implied warranty. 19 | // 20 | // Please send BUG REPORTS to ccwu@cs.unc.edu 21 | // 22 | //////////////////////////////////////////////////////////////////////////// 23 | 24 | 25 | #if !defined(_FRAME_BUFFER_OBJECT_H) 26 | #define _FRAME_BUFFER_OBJECT_H 27 | 28 | class FrameBufferObject 29 | { 30 | static GLuint GlobalFBO; //not thread-safe 31 | GLuint _fboID; 32 | public: 33 | static int UseSingleFBO; 34 | public: 35 | static void DeleteGlobalFBO(); 36 | static void UnattachTex(GLenum attachment); 37 | static void UnbindFBO(); 38 | static void AttachDepthTexture(GLenum textureTarget, GLuint texID); 39 | static void AttachTexture( GLenum textureTarget, GLenum attachment, GLuint texID); 40 | static void AttachRenderBuffer(GLenum attachment, GLuint buffID ); 41 | static void UnattachRenderBuffer(GLenum attachment); 42 | public: 43 | void BindFBO(); 44 | FrameBufferObject(int autobind = 1); 45 | ~FrameBufferObject(); 46 | 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /SiftGPU/src/SiftGPU/ProgramCU.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: ProgramCU.h 3 | // Author: Changchang Wu 4 | // Description : interface for the ProgramCU classes. 5 | // It is basically a wrapper around all the CUDA kernels 6 | // 7 | // Copyright (c) 2007 University of North Carolina at Chapel Hill 8 | // All Rights Reserved 9 | // 10 | // Permission to use, copy, modify and distribute this software and its 11 | // documentation for educational, research and non-profit purposes, without 12 | // fee, and without a written agreement is hereby granted, provided that the 13 | // above copyright notice and the following paragraph appear in all copies. 14 | // 15 | // The University of North Carolina at Chapel Hill make no representations 16 | // about the suitability of this software for any purpose. It is provided 17 | // 'as is' without express or implied warranty. 18 | // 19 | // Please send BUG REPORTS to ccwu@cs.unc.edu 20 | // 21 | //////////////////////////////////////////////////////////////////////////// 22 | 23 | #ifndef _PROGRAM_CU_H 24 | #define _PROGRAM_CU_H 25 | #if defined(CUDA_SIFTGPU_ENABLED) 26 | 27 | class CuTexImage; 28 | 29 | class ProgramCU 30 | { 31 | public: 32 | //GPU FUNCTIONS 33 | static void FinishCUDA(); 34 | static int CheckErrorCUDA(const char* location); 35 | static int CheckCudaDevice(int device); 36 | public: 37 | ////SIFTGPU FUNCTIONS 38 | static void CreateFilterKernel(float sigma, float* kernel, int& width); 39 | template static void FilterImage(CuTexImage *dst, CuTexImage *src, CuTexImage* buf); 40 | static void FilterImage(CuTexImage *dst, CuTexImage *src, CuTexImage* buf, float sigma); 41 | static void ComputeDOG(CuTexImage* gus, CuTexImage* dog, CuTexImage* got); 42 | static void ComputeKEY(CuTexImage* dog, CuTexImage* key, float Tdog, float Tedge); 43 | static void InitHistogram(CuTexImage* key, CuTexImage* hist); 44 | static void ReduceHistogram(CuTexImage*hist1, CuTexImage* hist2); 45 | static void GenerateList(CuTexImage* list, CuTexImage* hist); 46 | static void ComputeOrientation(CuTexImage*list, CuTexImage* got, CuTexImage*key, 47 | float sigma, float sigma_step, int existing_keypoint); 48 | static void ComputeDescriptor(CuTexImage*list, CuTexImage* got, CuTexImage* dtex, int rect = 0, int stream = 0); 49 | 50 | //data conversion 51 | static void SampleImageU(CuTexImage *dst, CuTexImage *src, int log_scale); 52 | static void SampleImageD(CuTexImage *dst, CuTexImage *src, int log_scale = 1); 53 | static void ReduceToSingleChannel(CuTexImage* dst, CuTexImage* src, int convert_rgb); 54 | static void ConvertByteToFloat(CuTexImage*src, CuTexImage* dst); 55 | 56 | //visualization 57 | static void DisplayConvertDOG(CuTexImage* dog, CuTexImage* out); 58 | static void DisplayConvertGRD(CuTexImage* got, CuTexImage* out); 59 | static void DisplayConvertKEY(CuTexImage* key, CuTexImage* dog, CuTexImage* out); 60 | static void DisplayKeyPoint(CuTexImage* ftex, CuTexImage* out); 61 | static void DisplayKeyBox(CuTexImage* ftex, CuTexImage* out); 62 | 63 | //SIFTMATCH FUNCTIONS 64 | static void MultiplyDescriptor(CuTexImage* tex1, CuTexImage* tex2, CuTexImage* texDot, CuTexImage* texCRT); 65 | static void MultiplyDescriptorG(CuTexImage* texDes1, CuTexImage* texDes2, 66 | CuTexImage* texLoc1, CuTexImage* texLoc2, CuTexImage* texDot, CuTexImage* texCRT, 67 | float H[3][3], float hdistmax, float F[3][3], float fdistmax); 68 | static void GetRowMatch(CuTexImage* texDot, CuTexImage* texMatch, float distmax, float ratiomax); 69 | static void GetColMatch(CuTexImage* texCRT, CuTexImage* texMatch, float distmax, float ratiomax); 70 | }; 71 | 72 | #endif 73 | #endif 74 | 75 | -------------------------------------------------------------------------------- /SiftGPU/src/SiftGPU/ProgramGPU.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: ProgramGPU.cpp 3 | // Author: Changchang Wu 4 | // Description : Implementation of ProgramGPU and FilterProgram 5 | // This part is independent of GPU language 6 | // 7 | // 8 | // 9 | // Copyright (c) 2007 University of North Carolina at Chapel Hill 10 | // All Rights Reserved 11 | // 12 | // Permission to use, copy, modify and distribute this software and its 13 | // documentation for educational, research and non-profit purposes, without 14 | // fee, and without a written agreement is hereby granted, provided that the 15 | // above copyright notice and the following paragraph appear in all copies. 16 | // 17 | // The University of North Carolina at Chapel Hill make no representations 18 | // about the suitability of this software for any purpose. It is provided 19 | // 'as is' without express or implied warranty. 20 | // 21 | // Please send BUG REPORTS to ccwu@cs.unc.edu 22 | // 23 | //////////////////////////////////////////////////////////////////////////// 24 | 25 | 26 | #include "GL/glew.h" 27 | #include 28 | #include 29 | #include 30 | using namespace std; 31 | 32 | #include "GlobalUtil.h" 33 | #include "GLTexImage.h" 34 | #include "ShaderMan.h" 35 | #include "ProgramGPU.h" 36 | #include "ProgramGLSL.h" 37 | #include "SiftGPU.h" 38 | 39 | -------------------------------------------------------------------------------- /SiftGPU/src/SiftGPU/ProgramGPU.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: ProgramGPU.h 3 | // Author: Changchang Wu 4 | // Description : Based class for GPU programs 5 | // ProgramGPU: base class of ProgramGLSL 6 | // FilterProgram: base class of FilterGLSL, FilterPKSL 7 | // 8 | // Copyright (c) 2007 University of North Carolina at Chapel Hill 9 | // All Rights Reserved 10 | // 11 | // Permission to use, copy, modify and distribute this software and its 12 | // documentation for educational, research and non-profit purposes, without 13 | // fee, and without a written agreement is hereby granted, provided that the 14 | // above copyright notice and the following paragraph appear in all copies. 15 | // 16 | // The University of North Carolina at Chapel Hill make no representations 17 | // about the suitability of this software for any purpose. It is provided 18 | // 'as is' without express or implied warranty. 19 | // 20 | // Please send BUG REPORTS to ccwu@cs.unc.edu 21 | // 22 | //////////////////////////////////////////////////////////////////////////// 23 | 24 | 25 | #ifndef _PROGRAM_GPU_H 26 | #define _PROGRAM_GPU_H 27 | 28 | //////////////////////////////////////////////////////////////////////////// 29 | //class ProgramGPU 30 | //description: pure virtual class 31 | // provides a common interface for shader programs 32 | /////////////////////////////////////////////////////////////////////////// 33 | class ProgramGPU 34 | { 35 | public: 36 | //use a gpu program 37 | virtual int UseProgram() = 0; 38 | virtual void* GetProgramID() = 0; 39 | //not used 40 | virtual ~ProgramGPU(){}; 41 | }; 42 | 43 | /////////////////////////////////////////////////////////////////////////// 44 | //class FilterProgram 45 | /////////////////////////////////////////////////////////////////////////// 46 | class FilterProgram 47 | { 48 | public: 49 | ProgramGPU* s_shader_h; 50 | ProgramGPU* s_shader_v; 51 | int _size; 52 | int _id; 53 | public: 54 | FilterProgram() { s_shader_h = s_shader_v = NULL; _size = _id = 0; } 55 | virtual ~FilterProgram() { if(s_shader_h) delete s_shader_h; if(s_shader_v) delete s_shader_v;} 56 | }; 57 | 58 | #endif 59 | 60 | -------------------------------------------------------------------------------- /SiftGPU/src/SiftGPU/PyramidCL.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: PyramidCL.h 3 | // Author: Changchang Wu 4 | // Description : interface for the PyramdCL 5 | // 6 | // Copyright (c) 2007 University of North Carolina at Chapel Hill 7 | // All Rights Reserved 8 | // 9 | // Permission to use, copy, modify and distribute this software and its 10 | // documentation for educational, research and non-profit purposes, without 11 | // fee, and without a written agreement is hereby granted, provided that the 12 | // above copyright notice and the following paragraph appear in all copies. 13 | // 14 | // The University of North Carolina at Chapel Hill make no representations 15 | // about the suitability of this software for any purpose. It is provided 16 | // 'as is' without express or implied warranty. 17 | // 18 | // Please send BUG REPORTS to ccwu@cs.unc.edu 19 | // 20 | //////////////////////////////////////////////////////////////////////////// 21 | 22 | 23 | 24 | #ifndef _PYRAMID_CL_H 25 | #define _PYRAMID_CL_H 26 | #if defined(CL_SIFTGPU_ENABLED) 27 | 28 | class CLTexImage; 29 | class SiftPyramid; 30 | class ProgramBagCL; 31 | class PyramidCL: public SiftPyramid 32 | { 33 | CLTexImage* _inputTex; 34 | CLTexImage* _allPyramid; 35 | CLTexImage* _histoPyramidTex; 36 | CLTexImage* _featureTex; 37 | CLTexImage* _descriptorTex; 38 | CLTexImage* _orientationTex; 39 | ProgramBagCL* _OpenCL; 40 | GLTexImage* _bufferTEX; 41 | public: 42 | virtual void GetFeatureDescriptors(); 43 | virtual void GenerateFeatureListTex(); 44 | virtual void ReshapeFeatureListCPU(); 45 | virtual void GenerateFeatureDisplayVBO(); 46 | virtual void DestroySharedData(); 47 | virtual void DestroyPerLevelData(); 48 | virtual void DestroyPyramidData(); 49 | virtual void DownloadKeypoints(); 50 | virtual void GenerateFeatureListCPU(); 51 | virtual void GenerateFeatureList(); 52 | virtual GLTexImage* GetLevelTexture(int octave, int level); 53 | virtual GLTexImage* GetLevelTexture(int octave, int level, int dataName); 54 | virtual void BuildPyramid(GLTexInput * input); 55 | virtual void DetectKeypointsEX(); 56 | virtual void ComputeGradient(); 57 | virtual void GetFeatureOrientations(); 58 | virtual void GetSimplifiedOrientation(); 59 | virtual void InitPyramid(int w, int h, int ds = 0); 60 | virtual void ResizePyramid(int w, int h); 61 | 62 | ////////// 63 | void CopyGradientTex(); 64 | void FitPyramid(int w, int h); 65 | 66 | void InitializeContext(); 67 | int ResizeFeatureStorage(); 68 | int FitHistogramPyramid(CLTexImage* tex); 69 | void SetLevelFeatureNum(int idx, int fcount); 70 | void ConvertInputToCL(GLTexInput* input, CLTexImage* output); 71 | GLTexImage* ConvertTexCL2GL(CLTexImage* tex, int dataName); 72 | CLTexImage* GetBaseLevel(int octave, int dataName = DATA_GAUSSIAN); 73 | private: 74 | void GenerateFeatureList(int i, int j, int reduction_count, vector& hbuffer); 75 | public: 76 | PyramidCL(SiftParam& sp); 77 | virtual ~PyramidCL(); 78 | }; 79 | 80 | 81 | #endif 82 | #endif 83 | 84 | -------------------------------------------------------------------------------- /SiftGPU/src/SiftGPU/PyramidCU.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: PyramidCU.h 3 | // Author: Changchang Wu 4 | // Description : interface for the PyramdCU 5 | // 6 | // Copyright (c) 2007 University of North Carolina at Chapel Hill 7 | // All Rights Reserved 8 | // 9 | // Permission to use, copy, modify and distribute this software and its 10 | // documentation for educational, research and non-profit purposes, without 11 | // fee, and without a written agreement is hereby granted, provided that the 12 | // above copyright notice and the following paragraph appear in all copies. 13 | // 14 | // The University of North Carolina at Chapel Hill make no representations 15 | // about the suitability of this software for any purpose. It is provided 16 | // 'as is' without express or implied warranty. 17 | // 18 | // Please send BUG REPORTS to ccwu@cs.unc.edu 19 | // 20 | //////////////////////////////////////////////////////////////////////////// 21 | 22 | 23 | 24 | #ifndef _PYRAMID_CU_H 25 | #define _PYRAMID_CU_H 26 | #if defined(CUDA_SIFTGPU_ENABLED) 27 | 28 | class GLTexImage; 29 | class CuTexImage; 30 | class SiftPyramid; 31 | class PyramidCU:public SiftPyramid 32 | { 33 | CuTexImage* _inputTex; 34 | CuTexImage* _allPyramid; 35 | CuTexImage* _histoPyramidTex; 36 | CuTexImage* _featureTex; 37 | CuTexImage* _descriptorTex; 38 | CuTexImage* _orientationTex; 39 | GLuint _bufferPBO; 40 | GLTexImage* _bufferTEX; 41 | public: 42 | virtual void GetFeatureDescriptors(); 43 | virtual void GenerateFeatureListTex(); 44 | virtual void ReshapeFeatureListCPU(); 45 | virtual void GenerateFeatureDisplayVBO(); 46 | virtual void DestroySharedData(); 47 | virtual void DestroyPerLevelData(); 48 | virtual void DestroyPyramidData(); 49 | virtual void DownloadKeypoints(); 50 | virtual void GenerateFeatureListCPU(); 51 | virtual void GenerateFeatureList(); 52 | virtual GLTexImage* GetLevelTexture(int octave, int level); 53 | virtual GLTexImage* GetLevelTexture(int octave, int level, int dataName); 54 | virtual void BuildPyramid(GLTexInput * input); 55 | virtual void DetectKeypointsEX(); 56 | virtual void ComputeGradient(); 57 | virtual void GetFeatureOrientations(); 58 | virtual void GetSimplifiedOrientation(); 59 | virtual void InitPyramid(int w, int h, int ds = 0); 60 | virtual void ResizePyramid(int w, int h); 61 | virtual int IsUsingRectDescription(){return _existing_keypoints & SIFT_RECT_DESCRIPTION; } 62 | ////////// 63 | void CopyGradientTex(); 64 | void FitPyramid(int w, int h); 65 | 66 | void InitializeContext(); 67 | int ResizeFeatureStorage(); 68 | int FitHistogramPyramid(CuTexImage* tex); 69 | void SetLevelFeatureNum(int idx, int fcount); 70 | void ConvertInputToCU(GLTexInput* input); 71 | GLTexImage* ConvertTexCU2GL(CuTexImage* tex, int dataName); 72 | CuTexImage* GetBaseLevel(int octave, int dataName = DATA_GAUSSIAN); 73 | void TruncateWidth(int& w) { w = GLTexInput::TruncateWidthCU(w); } 74 | ////////////////////////// 75 | static int CheckCudaDevice(int device); 76 | private: 77 | void GenerateFeatureList(int i, int j, int reduction_count, vector& hbuffer); 78 | public: 79 | PyramidCU(SiftParam& sp); 80 | virtual ~PyramidCU(); 81 | }; 82 | 83 | 84 | 85 | #endif 86 | #endif 87 | -------------------------------------------------------------------------------- /SiftGPU/src/SiftGPU/ShaderMan.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: ShaderMan.h 3 | // Author: Changchang Wu 4 | // Description : interface for the ShaderMan class. 5 | // This is a class that manages all the shaders for SIFT 6 | // 7 | // 8 | // Copyright (c) 2007 University of North Carolina at Chapel Hill 9 | // All Rights Reserved 10 | // 11 | // Permission to use, copy, modify and distribute this software and its 12 | // documentation for educational, research and non-profit purposes, without 13 | // fee, and without a written agreement is hereby granted, provided that the 14 | // above copyright notice and the following paragraph appear in all copies. 15 | // 16 | // The University of North Carolina at Chapel Hill make no representations 17 | // about the suitability of this software for any purpose. It is provided 18 | // 'as is' without express or implied warranty. 19 | // 20 | // Please send BUG REPORTS to ccwu@cs.unc.edu 21 | // 22 | //////////////////////////////////////////////////////////////////////////// 23 | 24 | 25 | 26 | #ifndef _SIFT_SHADER_MAN_H 27 | #define _SIFT_SHADER_MAN_H 28 | 29 | 30 | #include "ProgramGPU.h" 31 | #include "ProgramGLSL.h" 32 | /////////////////////////////////////////////////////////////////// 33 | //class ShaderMan 34 | //description: pure static class 35 | // wrapper of shaders from different GPU languages 36 | /////////////////////////////////////////////////////////////////// 37 | class SiftParam; 38 | class FilterGLSL; 39 | 40 | class ShaderMan 41 | { 42 | public: 43 | static ShaderBag* s_bag; 44 | public: 45 | static void SelectInitialSmoothingFilter(int octave_min, SiftParam¶m); 46 | static void UseShaderMarginCopy(int xmax, int ymax); 47 | static void UseShaderOrientation(int gtex, int width, int height, float sigma, int auxtex, float step, int keypoint_list); 48 | static void UseShaderDescriptor(int gtex, int otex, int dwidth, int fwidth, int width, int height, float sigma); 49 | static void UseShaderSimpleOrientation(int oTex, float sigma, float sigma_step); 50 | static void UseShaderCopyKeypoint(); 51 | static void UseShaderGenVBO( float width, float fwidth, float size); 52 | static void UseShaderDebug(); 53 | static void UseShaderZeroPass(); 54 | static void UseShaderGenListStart(float fw, int tex0); 55 | static void UseShaderGenListStep(int tex, int tex0); 56 | static void UseShaderGenListEnd(int ktex); 57 | static void UseShaderGenListHisto(); 58 | static void UseShaderGenListInit(int w, int h, int tight = 1); 59 | static void UseShaderKeypoint(int texU, int texD); 60 | static void UseShaderGradientPass(int texP = 0); 61 | static void UseShaderDisplayKeypoints(); 62 | static void UseShaderDisplayGrad(); 63 | static void UseShaderRGB2Gray(); 64 | static void UseShaderDisplayDOG(); 65 | static void UseShaderDisplayGaussian(); 66 | /////////////////////////////////////////// 67 | static void FilterInitialImage(GLTexImage* tex, GLTexImage* buf); 68 | static void FilterSampledImage(GLTexImage* tex, GLTexImage* buf); 69 | static void FilterImage(FilterProgram* filter, GLTexImage *dst, GLTexImage *src, GLTexImage*tmp); 70 | static void TextureCopy(GLTexImage*dst, GLTexImage*src); 71 | static void TextureDownSample(GLTexImage* dst, GLTexImage*src, int scale = 2); 72 | static void TextureUpSample(GLTexImage* dst, GLTexImage*src, int scale); 73 | /////////////////////////////////////////////// 74 | static void InitShaderMan(SiftParam¶m); 75 | static void DestroyShaders(); 76 | static int HaveShaderMan(){return s_bag != NULL;} 77 | static void UnloadProgram(); 78 | }; 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /SiftGPU/src/SiftGPU/SiftMatch.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: SiftMatch.h 3 | // Author: Changchang Wu 4 | // Description : interface for the SiftMatchGL 5 | //// 6 | // Copyright (c) 2007 University of North Carolina at Chapel Hill 7 | // All Rights Reserved 8 | // 9 | // Permission to use, copy, modify and distribute this software and its 10 | // documentation for educational, research and non-profit purposes, without 11 | // fee, and without a written agreement is hereby granted, provided that the 12 | // above copyright notice and the following paragraph appear in all copies. 13 | // 14 | // The University of North Carolina at Chapel Hill make no representations 15 | // about the suitability of this software for any purpose. It is provided 16 | // 'as is' without express or implied warranty. 17 | // 18 | // Please send BUG REPORTS to ccwu@cs.unc.edu 19 | // 20 | //////////////////////////////////////////////////////////////////////////// 21 | 22 | 23 | #ifndef GPU_SIFT_MATCH_H 24 | #define GPU_SIFT_MATCH_H 25 | class GLTexImage; 26 | class ProgramGPU; 27 | 28 | class SiftMatchGL:public SiftMatchGPU 29 | { 30 | typedef GLint ParameterGL; 31 | private: 32 | //tex storage 33 | GLTexImage _texLoc[2]; 34 | GLTexImage _texDes[2]; 35 | GLTexImage _texDot; 36 | GLTexImage _texMatch[2]; 37 | 38 | //programs 39 | ProgramGPU * s_multiply; 40 | ProgramGPU * s_guided_mult; 41 | ProgramGPU * s_col_max; 42 | ProgramGPU * s_row_max; 43 | 44 | //matching parameters 45 | ParameterGL _param_multiply_tex1; 46 | ParameterGL _param_multiply_tex2; 47 | ParameterGL _param_multiply_size; 48 | ParameterGL _param_rowmax_param; 49 | ParameterGL _param_colmax_param; 50 | 51 | ///guided matching 52 | ParameterGL _param_guided_mult_tex1; 53 | ParameterGL _param_guided_mult_tex2; 54 | ParameterGL _param_guided_mult_texl1; 55 | ParameterGL _param_guided_mult_texl2; 56 | ParameterGL _param_guided_mult_h; 57 | ParameterGL _param_guided_mult_f; 58 | ParameterGL _param_guided_mult_param; 59 | // 60 | int _max_sift; 61 | int _num_sift[2]; 62 | int _id_sift[2]; 63 | int _have_loc[2]; 64 | 65 | //gpu parameter 66 | int _sift_per_stripe; 67 | int _sift_num_stripe; 68 | int _sift_per_row; 69 | int _pixel_per_sift; 70 | int _initialized; 71 | // 72 | vector sift_buffer; 73 | private: 74 | void AllocateSiftMatch(); 75 | void LoadSiftMatchShadersGLSL(); 76 | int GetBestMatch(int max_match, int match_buffer[][2], float distmax, float ratiomax, int mbm); 77 | public: 78 | SiftMatchGL(int max_sift, int use_glsl); 79 | virtual ~SiftMatchGL(); 80 | public: 81 | void InitSiftMatch(); 82 | void SetMaxSift(int max_sift); 83 | void SetDescriptors(int index, int num, const unsigned char * descriptor, int id = -1); 84 | void SetDescriptors(int index, int num, const float * descriptor, int id = -1); 85 | void SetFeautreLocation(int index, const float* locatoins, int gap); 86 | int GetSiftMatch(int max_match, int match_buffer[][2], float distmax, float ratiomax, int mbm); 87 | int GetGuidedSiftMatch(int max_match, int match_buffer[][2], float H[3][3], float F[3][3], 88 | float distmax, float ratiomax, float hdistmax,float fdistmax, int mbm); 89 | }; 90 | 91 | 92 | #endif 93 | 94 | -------------------------------------------------------------------------------- /SiftGPU/src/SiftGPU/SiftMatchCU.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: SiftMatchCU.h 3 | // Author: Changchang Wu 4 | // Description : interface for the SiftMatchCU 5 | //// 6 | // Copyright (c) 2007 University of North Carolina at Chapel Hill 7 | // All Rights Reserved 8 | // 9 | // Permission to use, copy, modify and distribute this software and its 10 | // documentation for educational, research and non-profit purposes, without 11 | // fee, and without a written agreement is hereby granted, provided that the 12 | // above copyright notice and the following paragraph appear in all copies. 13 | // 14 | // The University of North Carolina at Chapel Hill make no representations 15 | // about the suitability of this software for any purpose. It is provided 16 | // 'as is' without express or implied warranty. 17 | // 18 | // Please send BUG REPORTS to ccwu@cs.unc.edu 19 | // 20 | //////////////////////////////////////////////////////////////////////////// 21 | 22 | 23 | 24 | #ifndef CU_SIFT_MATCH_H 25 | #define CU_SIFT_MATCH_H 26 | #if defined(CUDA_SIFTGPU_ENABLED) 27 | 28 | class CuTexImage; 29 | class SiftMatchCU:public SiftMatchGPU 30 | { 31 | private: 32 | //tex storage 33 | CuTexImage _texLoc[2]; 34 | CuTexImage _texDes[2]; 35 | CuTexImage _texDot; 36 | CuTexImage _texMatch[2]; 37 | CuTexImage _texCRT; 38 | 39 | //programs 40 | // 41 | int _max_sift; 42 | int _num_sift[2]; 43 | int _id_sift[2]; 44 | int _have_loc[2]; 45 | 46 | //gpu parameter 47 | int _initialized; 48 | vector sift_buffer; 49 | private: 50 | int GetBestMatch(int max_match, int match_buffer[][2], float distmax, float ratiomax, int mbm); 51 | public: 52 | SiftMatchCU(int max_sift); 53 | virtual ~SiftMatchCU(){}; 54 | void InitSiftMatch(); 55 | void SetMaxSift(int max_sift); 56 | void SetDescriptors(int index, int num, const unsigned char * descriptor, int id = -1); 57 | void SetDescriptors(int index, int num, const float * descriptor, int id = -1); 58 | void SetFeautreLocation(int index, const float* locatoins, int gap); 59 | int GetSiftMatch(int max_match, int match_buffer[][2], float distmax, float ratiomax, int mbm); 60 | int GetGuidedSiftMatch(int max_match, int match_buffer[][2], float H[3][3], float F[3][3], 61 | float distmax, float ratiomax, float hdistmax, float fdistmax, int mbm); 62 | ////////////////////////////// 63 | static int CheckCudaDevice(int device); 64 | }; 65 | 66 | #endif 67 | #endif 68 | 69 | -------------------------------------------------------------------------------- /SiftGPU/src/TestWin/BasicTestWin.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: BasicTestWin.h 3 | // Author: Changchang Wu 4 | // Description : 5 | // BasicTestWin: basic viewer of SiftGPU 6 | // both TestWinGlut and GLTestWndare derived from this 7 | // SiftDriver: A simple driver of SiftGPU 8 | // 9 | // Copyright (c) 2007 University of North Carolina at Chapel Hill 10 | // All Rights Reserved 11 | // 12 | // Permission to use, copy, modify and distribute this software and its 13 | // documentation for educational, research and non-profit purposes, without 14 | // fee, and without a written agreement is hereby granted, provided that the 15 | // above copyright notice and the following paragraph appear in all copies. 16 | // 17 | // The University of North Carolina at Chapel Hill make no representations 18 | // about the suitability of this software for any purpose. It is provided 19 | // 'as is' without express or implied warranty. 20 | // 21 | // Please send BUG REPORTS to ccwu@cs.unc.edu 22 | // 23 | //////////////////////////////////////////////////////////////////////////// 24 | 25 | 26 | #if !defined(BASIC_TEST_WIN_H) 27 | #define BASIC_TEST_WIN_H 28 | 29 | #if _WIN32 && _MSC_VER > 1000 30 | #pragma once 31 | #endif // _MSC_VER > 1000 32 | 33 | 34 | #include "GLTransform.h" 35 | 36 | class SiftParam; 37 | class SiftGPUEX; 38 | 39 | ////////////////////////////////////////////////////////////////////////// 40 | //class TestDriver 41 | //description: simple SiftGPU driver 42 | ///////////////////////////////////////////////////////////////////////// 43 | 44 | 45 | ////////////////////////////////////////////////////////////////////////// 46 | //class BasicTestWin 47 | //description: basic SiftGPU viewer 48 | // two implementations are GLTestWnd and TestWinGlut 49 | /////////////////////////////////////////////////////////////////////////// 50 | 51 | 52 | class BasicTestWin 53 | { 54 | GlTransform _transform; 55 | int _looping; 56 | int _motion; 57 | int _motion_x, _motion_y; 58 | char _title[512]; 59 | int _view; 60 | int _sub_view; 61 | int _win_w, _win_h; 62 | 63 | protected: 64 | float _displayScale; 65 | int _imgWidth, _imgHeight; 66 | int _win_x, _win_y; 67 | int _current; 68 | private: 69 | // 70 | float _stat_tstart; 71 | int _stat_frames; 72 | protected: 73 | SiftGPUEX* _sift; 74 | public: 75 | void SetVerbose(); 76 | void FitWindow(); 77 | void OnIdle(); 78 | void EndMotion(); 79 | void StartMotion(int x, int y); 80 | void SetView(); 81 | void ReShape(int w, int h); 82 | void MoveMouse(int x, int y); 83 | void KeyInput(int key); 84 | void Display(); 85 | virtual void UpdateDisplay()=0; 86 | BasicTestWin(); 87 | virtual ~BasicTestWin(); 88 | void ParseSiftParam(int argc, char** argv); 89 | void RunSiftGPU(); 90 | static float myclock(); 91 | protected: 92 | virtual void SetWindowTitle(char * title)=0; 93 | virtual void SetDisplaySize(int w, int h)=0; 94 | }; 95 | 96 | #endif // !defined(BASIC_TEST_WIN_H) 97 | 98 | -------------------------------------------------------------------------------- /SiftGPU/src/TestWin/GLTestWnd.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: GLTestWnd.h 3 | // Author: Changchang Wu 4 | // Description : interface for the GLTestWnd class. 5 | // Win32-based SiftGPU viewer 6 | // 7 | // 8 | // Copyright (c) 2007 University of North Carolina at Chapel Hill 9 | // All Rights Reserved 10 | // 11 | // Permission to use, copy, modify and distribute this software and its 12 | // documentation for educational, research and non-profit purposes, without 13 | // fee, and without a written agreement is hereby granted, provided that the 14 | // above copyright notice and the following paragraph appear in all copies. 15 | // 16 | // The University of North Carolina at Chapel Hill make no representations 17 | // about the suitability of this software for any purpose. It is provided 18 | // 'as is' without express or implied warranty. 19 | // 20 | // Please send BUG REPORTS to ccwu@cs.unc.edu 21 | // 22 | //////////////////////////////////////////////////////////////////////////// 23 | 24 | 25 | #if !defined(GL_TEST_WND_H) 26 | #define GL_TEST_WND_H 27 | 28 | #if _WIN32 && _MSC_VER > 1000 29 | #pragma once 30 | #endif // _MSC_VER > 1000 31 | 32 | #define WM_MY_IDLE WM_USER+1 33 | 34 | 35 | 36 | 37 | class BasicTestWin; 38 | class GLTestWnd : public BasicTestWin 39 | { 40 | HGLRC _hglrc; 41 | HWND _hWndMain; 42 | private: 43 | static LRESULT CALLBACK ___WndProc(HWND, UINT, WPARAM, LPARAM); 44 | inline LRESULT _WndProc(UINT, WPARAM, LPARAM); 45 | void CreateWindowGL(); 46 | static void RegisterWindowClass(); 47 | public: 48 | void UpdateDisplay(); 49 | void SetWindowTitle(char *title); 50 | void SetDisplaySize(int w, int h); 51 | void ParseCommandLine(LPSTR cmd); 52 | void glPaint(HDC ); 53 | void glResize(int w, int h); 54 | void glCreateRC(HDC hdc); 55 | GLTestWnd(LPSTR cmd); 56 | GLTestWnd(int argc, char**argv); 57 | virtual ~GLTestWnd(); 58 | 59 | }; 60 | 61 | #endif // !defined(GL_TEST_WND_H) 62 | -------------------------------------------------------------------------------- /SiftGPU/src/TestWin/GLTransform.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: GLTransform.h 3 | // Author: Changchang Wu 4 | // Description : GLTransform tookit for opengl display 5 | // 6 | // 7 | // 8 | // Copyright (c) 2007 University of North Carolina at Chapel Hill 9 | // All Rights Reserved 10 | // 11 | // Permission to use, copy, modify and distribute this software and its 12 | // documentation for educational, research and non-profit purposes, without 13 | // fee, and without a written agreement is hereby granted, provided that the 14 | // above copyright notice and the following paragraph appear in all copies. 15 | // 16 | // The University of North Carolina at Chapel Hill make no representations 17 | // about the suitability of this software for any purpose. It is provided 18 | // 'as is' without express or implied warranty. 19 | // 20 | // Please send BUG REPORTS to ccwu@cs.unc.edu 21 | // 22 | //////////////////////////////////////////////////////////////////////////// 23 | #if !defined(GL_TRANSFORM_H) 24 | #define GL_TRANSFORM_H 25 | 26 | #include 27 | class GlTransform 28 | { 29 | public: 30 | double cx, cy; 31 | double q[4]; 32 | double t[3]; 33 | double sc, ds; 34 | GlTransform() 35 | { 36 | q[0] = 1.0; 37 | q[1] = q[2] = q[3] =0; 38 | t[0] = t[1] = t[2] =0; 39 | sc = 1.0; 40 | cx = cy = 0; 41 | } 42 | void reset() 43 | { 44 | q[0] = 1.0; 45 | q[1] = q[2] = q[3] =0; 46 | t[0] = t[1] = t[2] =0; 47 | sc = 1.0; 48 | } 49 | void operator=(GlTransform& v) 50 | { 51 | q[0] = v.q[0]; 52 | q[1] = v.q[1]; 53 | q[2] = v.q[2]; 54 | q[3] = v.q[3]; 55 | t[0] = v.t[0]; 56 | t[1] = v.t[1]; 57 | t[2] = v.t[2]; 58 | sc = v.sc; 59 | } 60 | void operator *=(double scale) 61 | { 62 | sc *= scale; 63 | t[0]*= scale; 64 | t[1]*= scale; 65 | t[2]*= scale; 66 | } 67 | void scaleset(double scale) 68 | { 69 | double ds = scale/sc; 70 | t[0]*= ds; 71 | t[1]*= ds; 72 | t[2]*= ds; 73 | sc = scale; 74 | } 75 | void scaleup() 76 | { 77 | double scale; 78 | if(sc < 6) scale = float(int(sc))+1; 79 | else scale = sc * 2.0; 80 | scaleset(scale); 81 | } 82 | void scaledown() 83 | { 84 | double scale; 85 | if(sc >1.0 &&sc < 2.0) scale = 1.0; 86 | else scale = sc*0.5; 87 | scaleset(scale); 88 | } 89 | void translate(int dx, int dy, int dz =0) 90 | { 91 | t[0] += dx; 92 | t[1] += dy; 93 | t[2] += dz; 94 | } 95 | void setcenter(double x, double y) 96 | { 97 | cx = x; 98 | cy = y; 99 | t[0] = t[1] = t[2] = 0; 100 | } 101 | 102 | void transform(double es = 1.0) 103 | { 104 | double s = sc* es; 105 | glTranslated(cx*es, cy*es, 0.0); 106 | glTranslated(t[0] ,t[1] ,t[2]); 107 | glScaled(s,s,s); 108 | glTranslated(-cx, - cy, 0); 109 | } 110 | }; 111 | 112 | #endif 113 | 114 | -------------------------------------------------------------------------------- /SiftGPU/src/TestWin/TestWinGlut.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: TestWinGlut.h 3 | // Author: Changchang Wu 4 | // Description : interface for the TestWinGlut class. 5 | // GLUT-based SiftGPU viewer 6 | // 7 | // 8 | // Copyright (c) 2007 University of North Carolina at Chapel Hill 9 | // All Rights Reserved 10 | // 11 | // Permission to use, copy, modify and distribute this software and its 12 | // documentation for educational, research and non-profit purposes, without 13 | // fee, and without a written agreement is hereby granted, provided that the 14 | // above copyright notice and the following paragraph appear in all copies. 15 | // 16 | // The University of North Carolina at Chapel Hill make no representations 17 | // about the suitability of this software for any purpose. It is provided 18 | // 'as is' without express or implied warranty. 19 | // 20 | // Please send BUG REPORTS to ccwu@cs.unc.edu 21 | // 22 | //////////////////////////////////////////////////////////////////////////// 23 | 24 | #if !defined(TEST_WIN_GLUT_H) 25 | #define TEST_WIN_GLUT_H 26 | 27 | #if _WIN32 && _MSC_VER > 1000 28 | #pragma once 29 | #endif // _MSC_VER > 1000 30 | 31 | class BasicTestWin; 32 | 33 | class TestWinGlut : public BasicTestWin 34 | { 35 | enum 36 | { 37 | MAX_TEST_WIN_GLUT = 100 38 | }; 39 | static void button(int button, int state,int x, int y); 40 | static void display(); 41 | static void keyboard(unsigned char key, int x, int y); 42 | static void idle(); 43 | void CreateGLUT(); 44 | static void reshape(int w, int h); 45 | 46 | //may also use std::vector 47 | static TestWinGlut * _win[MAX_TEST_WIN_GLUT]; 48 | 49 | public: 50 | void SetDisplaySize(int w, int h); 51 | void UpdateDisplay(); 52 | void SetWindowTitle(char *title); 53 | static void motion(int x, int y); 54 | static void Run(); 55 | TestWinGlut(int argc, char**argv); 56 | virtual ~TestWinGlut(); 57 | 58 | 59 | }; 60 | 61 | #endif // !defined(TEST_WIN_GLUT_H) 62 | 63 | -------------------------------------------------------------------------------- /cmvs/program/base/cmvs/graclus.h: -------------------------------------------------------------------------------- 1 | #ifndef CMVS_GRACLUS_H 2 | #define CMVS_GRACLUS_H 3 | 4 | #include 5 | #include 6 | 7 | /* 8 | 0 -- 1 -- 2 -- 3 -- 4 9 | | | | | | 10 | 5 -- 6 -- 7 -- 8 -- 9 11 | | | | | | 12 | 10 --11 --12 --13 --14 13 | 14 | CSR format 15 | xadj: 0 2 5 8 11 13 16 20 24 28 31 33 36 39 42 44 16 | Size of xadj is the number of vertices plus 1. 17 | 18 | adjncy: 1 5 0 2 6 1 3 7 2 4 8 3 9 0 6 10 1 5 7 11 2 6 8 12 3 7 9 13 4 8 14 5 11 6 10 12 7 11 13 8 12 14 9 13 19 | 20 | Size of adjncy is twice the number of edges. 21 | */ 22 | 23 | namespace CMVS { 24 | class Cgraclus { 25 | public: 26 | Cgraclus(void); 27 | virtual ~Cgraclus(); 28 | 29 | // Threads free. no weights 30 | static void run(std::vector& xadj, 31 | std::vector& adjncy, 32 | const int nparts, const int cutType, 33 | std::vector& part); 34 | 35 | // Threads free. vertex weights 36 | static void runV(std::vector& xadj, 37 | std::vector& adjncy, 38 | std::vector& vwgt, 39 | const int nparts, const int cutType, 40 | std::vector& part); 41 | 42 | // Threads free. edge weights 43 | static void runE(std::vector& xadj, 44 | std::vector& adjncy, 45 | std::vector& adjwgt, 46 | const int nparts, const int cutType, 47 | std::vector& part); 48 | 49 | // Threads free. vertex and edge weights 50 | static void runVE(std::vector& xadj, 51 | std::vector& adjncy, 52 | std::vector& vwgt, 53 | std::vector& adjwgt, 54 | const int nparts, const int cutType, 55 | std::vector& part); 56 | 57 | protected: 58 | static int mylog2(int a); 59 | 60 | static void runSub(GraphType& graph, int nparts, int cutType, 61 | int wgtflag, std::vector& part); 62 | 63 | static void initGraph(GraphType& graph); 64 | }; 65 | }; 66 | 67 | #endif // CMVS_GRACLUS_H 68 | -------------------------------------------------------------------------------- /cmvs/program/base/image/photo.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGE_PHOTO_H 2 | #define IMAGE_PHOTO_H 3 | 4 | #include "../numeric/vec4.h" 5 | #include "image.h" 6 | #include "camera.h" 7 | 8 | namespace Image { 9 | 10 | // Cphoto is an image with camera parameters 11 | class Cphoto : public Cimage, public Ccamera { 12 | public: 13 | Cphoto(void); 14 | virtual ~Cphoto(); 15 | 16 | virtual void init(const std::string name, const std::string mname, 17 | const std::string cname, const int maxLevel = 1); 18 | 19 | virtual void init(const std::string name, const std::string mname, 20 | const std::string ename, 21 | const std::string cname, const int maxLevel = 1); 22 | 23 | // grabTex given 2D sampling information 24 | void grabTex(const int level, const Vec2f& icoord, 25 | const Vec2f& xaxis, const Vec2f& yaxis, const int size, 26 | std::vector& tex, const int normalizef = 1) const; 27 | 28 | // grabTex given 3D sampling information 29 | void grabTex(const int level, const Vec4f& coord, 30 | const Vec4f& pxaxis, const Vec4f& pyaxis, const Vec4f& pzaxis, 31 | const int size, std::vector& tex, float& weight, 32 | const int normalizef = 1) const; 33 | 34 | 35 | inline Vec3f getColor(const float fx, const float fy, const int level) const; 36 | inline Vec3f getColor(const Vec4f& coord, const int level) const; 37 | inline int getMask(const Vec4f& coord, const int level) const; 38 | inline int getEdge(const Vec4f& coord, const int level) const; 39 | 40 | static float idot(const std::vector& tex0, 41 | const std::vector& tex1); 42 | 43 | static void idotC(const std::vector& tex0, 44 | const std::vector& tex1, double* idc); 45 | 46 | static void normalize(std::vector& tex); 47 | 48 | static float ssd(const std::vector& tex0, 49 | const std::vector& tex1); 50 | protected: 51 | }; 52 | 53 | Vec3f Cphoto::getColor(const float fx, const float fy, const int level) const { 54 | return Cimage::getColor(fx, fy, level); 55 | }; 56 | 57 | Vec3f Cphoto::getColor(const Vec4f& coord, const int level) const { 58 | const Vec3f icoord = project(coord, level); 59 | return Cimage::getColor(icoord[0], icoord[1], level); 60 | }; 61 | 62 | int Cphoto::getMask(const Vec4f& coord, const int level) const { 63 | if (m_masks[level].empty()) 64 | return 1; 65 | 66 | const Vec3f icoord = project(coord, level); 67 | return Cimage::getMask(icoord[0], icoord[1], level); 68 | }; 69 | 70 | int Cphoto::getEdge(const Vec4f& coord, const int level) const { 71 | if (m_edges[level].empty()) 72 | return 1; 73 | 74 | const Vec3f icoord = project(coord, level); 75 | 76 | if (icoord[0] < 0 || m_widths[level] - 1 <= icoord[0] || 77 | icoord[1] < 0 || m_heights[level] - 1 <= icoord[1]) 78 | return 0; 79 | 80 | return Cimage::getEdge(icoord[0], icoord[1], level); 81 | }; 82 | 83 | }; 84 | 85 | #endif // PHOTO_H 86 | -------------------------------------------------------------------------------- /cmvs/program/base/numeric/mylapack.h: -------------------------------------------------------------------------------- 1 | #ifndef NUMERIC_MYLAPACK_H 2 | #define NUMERIC_MYLAPACK_H 3 | 4 | #include 5 | 6 | class Cmylapack { 7 | public: 8 | 9 | 10 | // Solve Ax = 0. 11 | // Values contain singular values stored in an increasing order 12 | static void hlls(const std::vector >& A, 13 | std::vector& vec, 14 | std::vector& values); 15 | 16 | static void hlls(const std::vector >& A, 17 | std::vector& vec, 18 | std::vector& values); 19 | 20 | // Solve Ax = b 21 | static void lls(const std::vector >& A, 22 | const std::vector& b, 23 | std::vector& x); 24 | 25 | static void lls(const std::vector >& A, 26 | const std::vector& b, 27 | std::vector& x); 28 | 29 | static void lls(std::vector& A, 30 | std::vector& b, 31 | long int width, long int height); 32 | 33 | static void lls(std::vector& A, 34 | std::vector& b, 35 | long int width, long int height); 36 | 37 | // SVD 38 | // A = U Sigma V^T 39 | static void svd(const std::vector >& A, 40 | std::vector >& U, 41 | std::vector >& VT, 42 | std::vector& S); 43 | 44 | }; 45 | 46 | #endif // NUMERIC_MYLAPACK_H 47 | -------------------------------------------------------------------------------- /cmvs/program/base/pmvs/detectFeatures.h: -------------------------------------------------------------------------------- 1 | #ifndef PMVS3_DETECTFEATURES_H 2 | #define PMVS3_DETECTFEATURES_H 3 | 4 | /* 5 | * A main class to detect features 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include "../image/photoSetS.h" 12 | #include "point.h" 13 | 14 | namespace Image { 15 | class CphotoSetS; 16 | }; 17 | 18 | namespace PMVS3 { 19 | 20 | class CdetectFeatures { 21 | public: 22 | CdetectFeatures(void); 23 | virtual ~CdetectFeatures(); 24 | 25 | void run(const Image::CphotoSetS& pss, 26 | const int num, const int csize, const int level, 27 | const int CPU = 1); 28 | 29 | std::vector > m_points; 30 | 31 | protected: 32 | const Image::CphotoSetS* m_ppss; 33 | int m_csize; 34 | int m_level; 35 | 36 | //---------------------------------------------------------------------- 37 | // thread related 38 | //---------------------------------------------------------------------- 39 | pthread_rwlock_t m_rwlock; 40 | int m_CPU; 41 | 42 | std::list m_jobs; 43 | 44 | void runThread(void); 45 | static void* runThreadTmp(void*arg); 46 | }; 47 | }; 48 | 49 | #endif // PMVS3_DETECTFEATURES_H 50 | -------------------------------------------------------------------------------- /cmvs/program/base/pmvs/detector.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "point.h" 3 | #include "detector.h" 4 | 5 | using namespace PMVS3; 6 | using namespace std; 7 | 8 | void Cdetector::setGaussD(const float sigmaD, std::vector& gaussD) { 9 | //---------------------------------------------------------------------- 10 | const int marginD = (int)ceil(2 * sigmaD); 11 | const int sizeD = 2 * marginD + 1; 12 | 13 | gaussD.resize(sizeD); 14 | 15 | //---------------------------------------------------------------------- 16 | // set m_gaussD 17 | float denom = 0.0; 18 | for (int x = 0; x < sizeD; ++x) { 19 | int xtmp = x - marginD; 20 | const float dtmp = xtmp * exp(- (xtmp * xtmp) / (2 * sigmaD * sigmaD)); 21 | gaussD[x] = dtmp; 22 | if (0.0 < dtmp) 23 | denom += dtmp; 24 | } 25 | 26 | for (int x = 0; x < sizeD; ++x) 27 | gaussD[x] /= denom; 28 | } 29 | 30 | void Cdetector::setGaussI(const float sigmaI, std::vector& gaussI) { 31 | const int marginI = (int)ceil(2 * sigmaI); 32 | const int sizeI = 2 * marginI + 1; 33 | 34 | gaussI.resize(sizeI); 35 | 36 | //---------------------------------------------------------------------- 37 | // set m_gaussI 38 | float denom = 0.0; 39 | for (int x = 0; x < sizeI; ++x) { 40 | int xtmp = x - marginI; 41 | const float dtmp = exp(- (xtmp * xtmp) / (2 * sigmaI * sigmaI)); 42 | gaussI[x] = dtmp; 43 | denom += dtmp; 44 | } 45 | for (int x = 0; x < sizeI; ++x) 46 | gaussI[x] /= denom; 47 | } 48 | 49 | 50 | float Cdetector::setThreshold(std::multiset& grid) { 51 | float ave = 0.0; 52 | float ave2 = 0.0; 53 | multiset::iterator begin = grid.begin(); 54 | multiset::iterator end = grid.end(); 55 | int count = 0; 56 | while (begin != end) { 57 | count++; 58 | ave += begin->m_response; 59 | ave2 += begin->m_response * begin->m_response; 60 | begin++; 61 | } 62 | if (count == 0) 63 | count = 1; 64 | ave /= count; ave2 /= count; 65 | ave2 = sqrt(max(0.0f, ave2 - ave * ave)); 66 | const float threshold = ave + ave2; 67 | 68 | //cout << ave << ' ' << ave2 << endl; 69 | 70 | return threshold; 71 | } 72 | 73 | int Cdetector::isCloseBoundary(const int x, const int y, const int margin) const { 74 | if (m_mask.empty()) 75 | return 0; 76 | 77 | if (x - margin < 0 || m_width <= x + margin || 78 | y - margin < 0 || m_height <= y + margin) 79 | return 1; 80 | 81 | for (int j = -margin; j <= margin; ++j) { 82 | const int ytmp = y + j; 83 | for (int i = -margin; i <= margin; ++i) { 84 | const int xtmp = x + i; 85 | 86 | if (m_mask[ytmp][xtmp] == 0) 87 | return 1; 88 | } 89 | } 90 | return 0; 91 | } 92 | -------------------------------------------------------------------------------- /cmvs/program/base/pmvs/dog.h: -------------------------------------------------------------------------------- 1 | #ifndef PMVS3_DOG_H 2 | #define PMVS3_DOG_H 3 | 4 | #include 5 | #include 6 | #include "../numeric/vec3.h" 7 | #include "detector.h" 8 | #include "point.h" 9 | 10 | namespace PMVS3 { 11 | class Cdog: public Cdetector { 12 | public: 13 | void run (const std::vector& image, 14 | const std::vector& mask, 15 | const std::vector& edge, 16 | const int width, const int height, 17 | const int gspeedup, 18 | const float firstScale, // 1.4f 19 | const float lastScale, // 4.0f 20 | std::multiset & result); 21 | 22 | virtual ~Cdog() { 23 | } 24 | 25 | protected: 26 | float m_firstScale; 27 | float m_lastScale; 28 | 29 | void init(const std::vector& image, 30 | const std::vector& mask, 31 | const std::vector& edge); 32 | 33 | void setRes(const float sigma, 34 | std::vector >& res); 35 | 36 | static int isLocalMax(const std::vector >& pdog, 37 | const std::vector >& cdog, 38 | const std::vector >& ndog, 39 | const int x, const int y); 40 | 41 | static int isLocalMax(const std::vector >& dog, 42 | const int x, const int y); 43 | 44 | static int notOnEdge(const std::vector >& dog, int x, int y); 45 | 46 | static float getResponse(const std::vector >& pdog, 47 | const std::vector >& cdog, 48 | const std::vector >& ndog, 49 | const int x, const int y); 50 | 51 | static float getResponse(const std::vector >& dog, 52 | const int x, const int y); 53 | 54 | static void setDOG(const std::vector >& cres, 55 | const std::vector >& nres, 56 | std::vector >& dog); 57 | 58 | }; 59 | }; 60 | #endif // DOG_H 61 | -------------------------------------------------------------------------------- /cmvs/program/base/pmvs/expand.h: -------------------------------------------------------------------------------- 1 | #ifndef PMVS3_EXPAND_H 2 | #define PMVS3_EXPAND_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "patchOrganizerS.h" 8 | 9 | namespace PMVS3 { 10 | class CfindMatch; 11 | 12 | class Cexpand { 13 | public: 14 | Cexpand(CfindMatch& findMatch); 15 | ~Cexpand() {}; 16 | 17 | void init(void); 18 | void run(void); 19 | 20 | float computeRadius(const Patch::Cpatch& patch); 21 | 22 | protected: 23 | int expandSub(const Patch::Ppatch& orgppatch, const int id, 24 | const Vec4f& canCoord); 25 | 26 | int updateCounts(const Patch::Cpatch& patch); 27 | 28 | int checkCounts(Patch::Cpatch& patch); 29 | 30 | void findEmptyBlocks(const Patch::Ppatch& ppatch, 31 | std::vector >& canCoords); 32 | protected: 33 | 34 | std::priority_queue, P_compare> 35 | m_queue; 36 | 37 | CfindMatch& m_fm; 38 | 39 | //----------------------------------------------------------------- 40 | // thread related 41 | //----------------------------------------------------------------- 42 | void expandThread(void); 43 | static void* expandThreadTmp(void* arg); 44 | 45 | // Number of trials 46 | std::vector m_ecounts; 47 | // Number of failures in the prep 48 | std::vector m_fcounts0; 49 | // Number of failures in the post processing 50 | std::vector m_fcounts1; 51 | // Number passes 52 | std::vector m_pcounts; 53 | }; 54 | }; 55 | 56 | #endif // PMVS3_EXPAND_H 57 | -------------------------------------------------------------------------------- /cmvs/program/base/pmvs/filter.h: -------------------------------------------------------------------------------- 1 | #ifndef PMVS3_FILTER_H 2 | #define PMVS3_FILTER_H 3 | 4 | #include "patch.h" 5 | #include 6 | #include "../numeric/vec2.h" 7 | 8 | namespace PMVS3 { 9 | 10 | class CfindMatch; 11 | 12 | class Cfilter { 13 | public: 14 | Cfilter(CfindMatch& findMatch); 15 | 16 | void init(void); 17 | void run(void); 18 | 19 | float computeGain(const Patch::Cpatch& patch, const int lock); 20 | 21 | int filterQuad(const Patch::Cpatch& patch, 22 | const std::vector& neighbors) const; 23 | 24 | 25 | protected: 26 | void filterOutside(void); 27 | void filterOutsideThread(void); 28 | static void* filterOutsideThreadTmp(void* arg); 29 | 30 | void filterExact(void); 31 | void filterExactThread(void); 32 | static void* filterExactThreadTmp(void* arg); 33 | 34 | void filterNeighbor(const int time); 35 | void filterSmallGroups(void); 36 | void filterSmallGroupsSub(const int pid, const int id, 37 | std::vector& label, 38 | std::list& ltmp) const; 39 | void setDepthMaps(void); 40 | void setDepthMapsVGridsVPGridsAddPatchV(const int additive); 41 | 42 | void setConf(const int image); 43 | 44 | std::vector m_gains; 45 | 46 | std::vector > m_newimages, m_removeimages; 47 | std::vector > > m_newgrids, m_removegrids; 48 | 49 | int m_time; 50 | std::vector m_rejects; 51 | 52 | //---------------------------------------------------------------------- 53 | // Thread related 54 | //---------------------------------------------------------------------- 55 | void setDepthMapsThread(void); 56 | static void* setDepthMapsThreadTmp(void* arg); 57 | 58 | void addPatchVThread(void); 59 | static void* addPatchVThreadTmp(void* arg); 60 | 61 | void setVGridsVPGridsThread(void); 62 | static void* setVGridsVPGridsThreadTmp(void* arg); 63 | 64 | void filterNeighborThread(void); 65 | static void* filterNeighborThreadTmp(void* arg); 66 | 67 | CfindMatch& m_fm; 68 | 69 | }; 70 | }; 71 | 72 | #endif // PMVS3_FILTER_H 73 | -------------------------------------------------------------------------------- /cmvs/program/base/pmvs/harris.h: -------------------------------------------------------------------------------- 1 | #ifndef PMVS3_HARRIS_H 2 | #define PMVS3_HARRIS_H 3 | 4 | #include 5 | #include 6 | #include "../numeric/vec3.h" 7 | #include "detector.h" 8 | #include "point.h" 9 | 10 | namespace PMVS3 { 11 | 12 | class Charris: public Cdetector { 13 | public: 14 | void run(const std::vector& image, 15 | const std::vector& mask, 16 | const std::vector& edge, 17 | const int width, const int height, 18 | const int gspeedup, const float sigma, 19 | std::multiset & result); 20 | 21 | virtual ~Charris() { 22 | } 23 | 24 | protected: 25 | float m_sigmaD; 26 | float m_sigmaI; 27 | 28 | std::vector m_gaussD; 29 | std::vector m_gaussI; 30 | 31 | std::vector > m_dIdx; 32 | std::vector > m_dIdy; 33 | 34 | std::vector > m_dIdxdIdx; 35 | std::vector > m_dIdydIdy; 36 | std::vector > m_dIdxdIdy; 37 | 38 | std::vector > m_response; 39 | 40 | void init(const std::vector& image, 41 | const std::vector& mask, 42 | const std::vector& edge); 43 | 44 | void setDerivatives(void); 45 | void preprocess(void); 46 | void preprocess2(void); 47 | void setResponse(void); 48 | }; 49 | }; 50 | 51 | #endif // PMVS3_HARRIS_H 52 | -------------------------------------------------------------------------------- /cmvs/program/base/pmvs/option.h: -------------------------------------------------------------------------------- 1 | #ifndef PMVS3_OPTION_H 2 | #define PMVS3_OPTION_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace PMVS3 { 9 | 10 | struct Soption{ 11 | public: 12 | int m_level; 13 | int m_csize; 14 | float m_threshold; 15 | int m_wsize; 16 | int m_minImageNum; 17 | int m_CPU; 18 | float m_setEdge; 19 | int m_useBound; 20 | int m_useVisData; 21 | int m_sequence; 22 | 23 | float m_maxAngleThreshold; 24 | float m_quadThreshold; 25 | 26 | std::string m_prefix; 27 | std::string m_option; 28 | int m_tflag; 29 | std::vector m_timages; 30 | int m_oflag; 31 | std::vector m_oimages; 32 | 33 | std::map m_dict; 34 | 35 | std::vector m_bindexes; 36 | std::vector > m_visdata; 37 | std::vector > m_visdata2; 38 | 39 | Soption(void); 40 | 41 | void init(const std::string prefix, const std::string option); 42 | 43 | protected: 44 | void initOimages(void); 45 | void initBindexes(const std::string sbimages); 46 | void initVisdata(void); 47 | void initVisdata2(void); 48 | }; 49 | }; 50 | 51 | #endif // PMVS3_OPTION_H 52 | -------------------------------------------------------------------------------- /cmvs/program/base/pmvs/patch.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../numeric/vec4.h" 3 | #include "patch.h" 4 | 5 | using namespace std; 6 | 7 | std::istream& Patch::operator >>(std::istream& istr, Cpatch& rhs) { 8 | string header; 9 | int itmp; 10 | istr >> header >> rhs.m_coord >> rhs.m_normal >> rhs.m_ncc 11 | >> rhs.m_dscale >> rhs.m_ascale; 12 | 13 | if (header == "PATCHA") { 14 | int type; Vec4f dir; 15 | istr >> type >> dir; 16 | } 17 | 18 | istr >> itmp; 19 | rhs.m_images.resize(itmp); 20 | for (int i = 0; i < itmp; ++i) 21 | istr >> rhs.m_images[i]; 22 | 23 | istr >> itmp; 24 | rhs.m_vimages.resize(itmp); 25 | for (int i = 0; i < itmp; ++i) 26 | istr >> rhs.m_vimages[i]; 27 | 28 | return istr; 29 | } 30 | 31 | std::ostream& Patch::operator <<(std::ostream& ostr, const Cpatch& rhs) { 32 | ostr << "PATCHS" << endl 33 | << rhs.m_coord << endl 34 | << rhs.m_normal << endl 35 | << rhs.m_ncc << ' ' 36 | << rhs.m_dscale << ' ' 37 | << rhs.m_ascale << endl 38 | << (int)rhs.m_images.size() << endl; 39 | for (int i = 0; i < (int)rhs.m_images.size(); ++i) 40 | ostr << rhs.m_images[i] << ' '; 41 | ostr << endl; 42 | 43 | ostr << (int)rhs.m_vimages.size() << endl; 44 | for (int i = 0; i < (int)rhs.m_vimages.size(); ++i) 45 | ostr << rhs.m_vimages[i] << ' '; 46 | ostr << endl; 47 | 48 | return ostr; 49 | } 50 | -------------------------------------------------------------------------------- /cmvs/program/base/pmvs/patch.h: -------------------------------------------------------------------------------- 1 | #ifndef PMVS3_PATCH_H 2 | #define PMVS3_PATCH_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "../numeric/vec4.h" 8 | 9 | namespace Patch { 10 | 11 | class Cpatch { 12 | public: 13 | Cpatch(void) { 14 | m_ncc = -1.0; 15 | m_timages = 0; 16 | m_fix = 0; 17 | // dflag is initialized only once. if failed in one direction, we 18 | // never try that. 19 | m_dflag = 0; 20 | } 21 | 22 | //---------------------------------------------------------------------- 23 | // saved information 24 | // 3D coordinates of the center of the patch 25 | Vec4f m_coord; 26 | // patch outward normal vector 27 | Vec4f m_normal; 28 | 29 | // associated image ids. first image id is the reference one. images 30 | // can be non-targetting image. 31 | std::vector m_images; 32 | std::vector > m_grids; 33 | 34 | // visible images. m_vimages must be targetting images. 35 | std::vector m_vimages; 36 | std::vector > m_vgrids; 37 | 38 | //---------------------------------------------------------------------- 39 | inline float score(const float threshold) const{ 40 | return std::max(0.0f, m_ncc - threshold) * (int)m_images.size(); 41 | } 42 | inline float score2(const float threshold) const{ 43 | return std::max(0.0f, m_ncc - threshold) * m_timages; 44 | } 45 | 46 | // average ncc 47 | float m_ncc; 48 | // number of targetting images in m_images 49 | int m_timages; 50 | 51 | // flat for expansion 52 | // 0: not yet tested 53 | // 1: done 54 | int m_flag; 55 | 56 | // for directional flag 57 | unsigned char m_dflag; 58 | 59 | // fixed patch or not 60 | char m_fix; 61 | 62 | // id number in m_ppatches 63 | int m_id; 64 | 65 | // scaling factor corresponding to one pixel difference 66 | float m_dscale; 67 | float m_ascale; 68 | 69 | float m_tmp; 70 | }; 71 | 72 | typedef boost::shared_ptr Ppatch; 73 | 74 | struct Spatchcmp { 75 | bool operator()(const Ppatch& lhs, const Ppatch& rhs) { 76 | if (lhs.get() < rhs.get()) 77 | return true; 78 | else 79 | return false; 80 | } 81 | }; 82 | 83 | std::istream& operator >>(std::istream& istr, Patch::Cpatch& rhs); 84 | std::ostream& operator <<(std::ostream& ostr, const Patch::Cpatch& rhs); 85 | 86 | }; 87 | 88 | #endif // PMVS3_PATCH_H 89 | -------------------------------------------------------------------------------- /cmvs/program/base/pmvs/patchOrganizerS.h: -------------------------------------------------------------------------------- 1 | #ifndef PMVS3_PATCHORGANIZERS_H 2 | #define PMVS3_PATCHORGANIZERS_H 3 | 4 | #include "patch.h" 5 | #include 6 | 7 | namespace PMVS3 { 8 | 9 | class CfindMatch; 10 | 11 | class P_compare { 12 | public: 13 | bool operator()(const Patch::Ppatch& lhs, const Patch::Ppatch& rhs) const { 14 | return lhs->m_tmp < rhs->m_tmp; 15 | } 16 | }; 17 | 18 | class CpatchOrganizerS { 19 | public: 20 | CpatchOrganizerS(CfindMatch& findMatch); 21 | 22 | void init(void); 23 | void collectPatches(const int target = 0); 24 | void collectPatches(std::priority_queue, 25 | P_compare>& pqpatches); 26 | 27 | void collectPatches(const int index, 28 | std::priority_queue, 29 | P_compare>& pqpatches); 30 | void collectNonFixPatches(const int index, std::vector& ppatches); 31 | 32 | void writePatches(void); 33 | void writePatches2(const std::string prefix); 34 | 35 | void writePLY(const std::vector& patches, 36 | const std::string filename); 37 | void writePLY(const std::vector& patches, 38 | const std::string filename, 39 | const std::vector& colors); 40 | 41 | void readPatches(void); 42 | 43 | void clearCounts(void); 44 | void clearFlags(void); 45 | 46 | void setGridsImages(Patch::Cpatch& patch, 47 | const std::vector& images) const; 48 | void addPatch(Patch::Ppatch& ppatch); 49 | void removePatch(const Patch::Ppatch& ppatch); 50 | void setGrids(Patch::Ppatch& ppatch) const; 51 | void setGrids(Patch::Cpatch& patch) const; 52 | void setVImagesVGrids(Patch::Ppatch& ppatch); 53 | void setVImagesVGrids(Patch::Cpatch& patch); 54 | void updateDepthMaps(Patch::Ppatch& ppatch); 55 | 56 | int isVisible(const Patch::Cpatch& patch, const int image, 57 | const int& ix, const int& iy, 58 | const float strict, const int lock); 59 | int isVisible0(const Patch::Cpatch& patch, const int image, 60 | int& ix, int& iy, 61 | const float strict, const int lock); 62 | 63 | void findNeighbors(const Patch::Cpatch& patch, 64 | std::vector& neighbors, 65 | const int lock, 66 | const float scale = 1.0f, 67 | const int margin = 1, 68 | const int skipvis = 0); 69 | 70 | void setScales(Patch::Cpatch& patch) const; 71 | 72 | float computeUnit(const Patch::Cpatch& patch) const; 73 | 74 | // change the contents of m_images from images to indexes 75 | void image2index(Patch::Cpatch& patch); 76 | // change the contents of m_images from indexes to images 77 | void index2image(Patch::Cpatch& patch); 78 | 79 | //---------------------------------------------------------------------- 80 | // Widths of grids 81 | std::vector m_gwidths; 82 | std::vector m_gheights; 83 | //---------------------------------------------------------------------- 84 | // image, grid 85 | std::vector > > m_pgrids; 86 | // image, grid 87 | std::vector > > m_vpgrids; 88 | // Closest patch 89 | std::vector > m_dpgrids; 90 | 91 | // all the patches in the current level of m_pgrids 92 | std::vector m_ppatches; 93 | 94 | // Check how many times patch optimization was performed for expansion 95 | std::vector > m_counts; 96 | 97 | static Patch::Ppatch m_MAXDEPTH; 98 | static Patch::Ppatch m_BACKGROUND; 99 | 100 | protected: 101 | CfindMatch& m_fm; 102 | }; 103 | }; 104 | 105 | #endif //PMVS3_PATCHORGANIZERS_H 106 | -------------------------------------------------------------------------------- /cmvs/program/base/pmvs/point.cc: -------------------------------------------------------------------------------- 1 | #include "point.h" 2 | 3 | using namespace PMVS3; 4 | using namespace std; 5 | 6 | Cpoint::Cpoint(void) { 7 | m_response = -1.0; 8 | m_type = -1; 9 | } 10 | 11 | Cpoint::~Cpoint() { 12 | } 13 | 14 | std::istream& PMVS3::operator >>(std::istream& istr, Cpoint& rhs) { 15 | string header; 16 | istr >> header; 17 | istr >> rhs.m_icoord[0] >> rhs.m_icoord[1] >> rhs.m_response >> rhs.m_type; 18 | rhs.m_icoord[2] = 1.0f; 19 | return istr; 20 | } 21 | 22 | std::ostream& PMVS3::operator <<(std::ostream& ostr, const Cpoint& rhs) { 23 | ostr << "POINT0" << endl 24 | << rhs.m_icoord[0] << ' ' << rhs.m_icoord[1] << ' ' << rhs.m_response << ' ' 25 | << rhs.m_type; 26 | return ostr; 27 | } 28 | -------------------------------------------------------------------------------- /cmvs/program/base/pmvs/point.h: -------------------------------------------------------------------------------- 1 | #ifndef PMVS3_POINT_H 2 | #define PMVS3_POINT_H 3 | 4 | #include "../numeric/vec4.h" 5 | #include "../numeric/mat3.h" 6 | 7 | namespace PMVS3 { 8 | class Cpoint { 9 | public: 10 | Cpoint(void); 11 | virtual ~Cpoint(); 12 | 13 | Vec3f m_icoord; 14 | float m_response; 15 | 16 | // 0: Harris 17 | // 1: DoG 18 | int m_type; 19 | 20 | // tempporary variable, used to store original imageid in initial match 21 | int m_itmp; 22 | 23 | // 3D coordinate 24 | Vec4f m_coord; 25 | 26 | bool operator < (const Cpoint& rhs) const { 27 | return m_response < rhs.m_response; 28 | } 29 | 30 | friend std::istream& operator >>(std::istream& istr, Cpoint& rhs); 31 | friend std::ostream& operator <<(std::ostream& ostr, const Cpoint& rhs); 32 | }; 33 | 34 | std::istream& operator >>(std::istream& istr, Cpoint& rhs); 35 | std::ostream& operator <<(std::ostream& ostr, const Cpoint& rhs); 36 | }; 37 | 38 | #endif //PMVS3_POINT_H 39 | -------------------------------------------------------------------------------- /cmvs/program/base/pmvs/seed.h: -------------------------------------------------------------------------------- 1 | #ifndef PMVS3_SEED_H 2 | #define PMVS3_SEED_H 3 | 4 | #include 5 | #include 6 | #include "patch.h" 7 | #include "point.h" 8 | 9 | #include 10 | 11 | namespace PMVS3 { 12 | class CfindMatch; 13 | typedef boost::shared_ptr Ppoint; 14 | 15 | class Cseed { 16 | public: 17 | Cseed(CfindMatch& findMatch); 18 | virtual ~Cseed() {}; 19 | 20 | void init(const std::vector >& points); 21 | void run(void); 22 | void clear(void); 23 | 24 | protected: 25 | void readPoints(const std::vector >& points); 26 | int canAdd(const int index, const int x, const int y); 27 | 28 | void initialMatch(const int index, const int id); 29 | void collectCells(const int index0, const int index1, 30 | const Cpoint& p0, std::vector& cells); 31 | 32 | void collectCandidates(const int index, const std::vector& indexes, 33 | const Cpoint& point, std::vector& vcp); 34 | 35 | int initialMatchSub(const int index0, const int index1, 36 | const int id, Patch::Cpatch& patch); 37 | 38 | void unproject(const int index0, const int index1, 39 | const Cpoint& p0, const Cpoint& p1, 40 | Vec4f& coord) const; 41 | 42 | //---------------------------------------------------------------------- 43 | CfindMatch& m_fm; 44 | // points in a grid. For each index, grid 45 | std::vector > > m_ppoints; 46 | 47 | //---------------------------------------------------------------------- 48 | // thread related 49 | //---------------------------------------------------------------------- 50 | void initialMatchThread(void); 51 | static void* initialMatchThreadTmp(void* arg); 52 | 53 | // Number of trials 54 | std::vector m_scounts; 55 | // Number of failures in the prep 56 | std::vector m_fcounts0; 57 | // Number of failures in the post processing 58 | std::vector m_fcounts1; 59 | // Number passes 60 | std::vector m_pcounts; 61 | }; 62 | }; 63 | 64 | #endif // PMVS3_SEED_H 65 | -------------------------------------------------------------------------------- /cmvs/program/base/stann/.svn/text-base/assert.hpp.svn-base: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* */ 3 | /* Header: assert.hpp */ 4 | /* */ 5 | /* Accompanies STANN Version 0.5 Beta */ 6 | /* Aug 05, 2008 */ 7 | /* */ 8 | /* Copyright 2007, 2008 */ 9 | /* Michael Connor and Piyush Kumar */ 10 | /* Florida State University */ 11 | /* Tallahassee FL, 32306-4532 */ 12 | /* */ 13 | /*****************************************************************************/ 14 | 15 | #ifndef REVIVER_ASSERT_HPP 16 | #define REVIVER_ASSERT_HPP 17 | 18 | #include 19 | /*! 20 | \file 21 | \brief Implementation of assert functions 22 | This file contains an assert function implementation 23 | */ 24 | 25 | /*! 26 | \brief Assert function 27 | This function prints error messages along with file and line numbers 28 | \param b bool to be checked 29 | \param desc Error message 30 | \param line Line number 31 | \param file File name 32 | \return True is there is no error 33 | */ 34 | 35 | /* 36 | bool MyAssertFunction( bool b, char* desc, int line, char* file){ 37 | if (b) return true; 38 | std::cerr << "\n\nAssertion Failure\n"; 39 | std::cerr << "Description : " << desc << std::endl; 40 | std::cerr << "Filename : " << file << std::endl; 41 | std::cerr << "Line No : " << line << std::endl; 42 | exit(1); 43 | } 44 | 45 | #if defined( _DEBUG ) 46 | #define Assert( exp, description ) MyAssertFunction( (int)(exp), description, __LINE__, __FILE__ ) 47 | #else 48 | #define Assert( exp, description ) 49 | #endif 50 | */ 51 | 52 | #define Assert( exp, description ) 53 | 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /cmvs/program/base/stann/.svn/text-base/rand.hpp.svn-base: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* */ 3 | /* Header: rand.hpp */ 4 | /* */ 5 | /* Accompanies STANN Version 0.5 Beta */ 6 | /* Aug 05, 2008 */ 7 | /* */ 8 | /* Copyright 2007, 2008 */ 9 | /* Michael Connor and Piyush Kumar */ 10 | /* Florida State University */ 11 | /* Tallahassee FL, 32306-4532 */ 12 | /* */ 13 | /*****************************************************************************/ 14 | 15 | 16 | 17 | #ifndef __RAND_HPP 18 | #define __RAND_HPP 19 | /*! \file rand.hpp 20 | \brief Replacements for srand48 and drand48 21 | 22 | The standard c++ does not have srand48 and drand48 built into it. 23 | this header replaces 24 | them using the standard C++ calls available for random numbers. 25 | */ 26 | 27 | #include 28 | 29 | static double __drand48__() 30 | { 31 | /* We don't have drand48. Use rand() to get the bits. We call 32 | rand() three times since RAND_MAX it at least 16 bits. */ 33 | double f = 1.0 / (RAND_MAX + 1.0); 34 | double x = std::rand(); 35 | x = x * f + std::rand(); 36 | x = x * f + std::rand(); 37 | return x * f; 38 | } 39 | 40 | static void __srand48__(long int seedval) 41 | { 42 | std::srand(seedval); 43 | return; 44 | } 45 | 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /cmvs/program/base/stann/Copyright.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------- 4 | STANN: A Simple Thread-safe Approximate Nearest Neighbor C++ Library 5 | Version: 0.1 6 | Release Date: Dec 1, 2007 7 | -------------------------------------------------------------------------- 8 | Copyright (c) 2006 2007 2008 Florida State University and 9 | Michael Connor and Piyush Kumar: All Rights Reserved. 10 | 11 | 12 | This program may be freely redistributed under the condition that the 13 | copyright notices (including this file) are not removed, and 14 | no compensation is received. Private, research, and institutional 15 | use is free. You may distribute modified versions of this code UNDER 16 | THE CONDITION THAT THIS CODE AND ANY MODIFICATIONS MADE TO IT IN THE 17 | SAME FILE REMAIN UNDER COPYRIGHT OF THE ORIGINAL AUTHOR, BOTH SOURCE 18 | AND OBJECT CODE ARE MADE FREELY AVAILABLE WITHOUT CHARGE, AND CLEAR 19 | NOTICE IS GIVEN OF THE MODIFICATIONS. Distribution of this code as 20 | part of a commercial system is permissible ONLY BY DIRECT ARRANGEMENT 21 | WITH THE AUTHORS. (If you are not directly supplying this code to a 22 | customer, and you are instead telling them how they can obtain it for 23 | free, then you are not required to make any arrangement with us.) 24 | The ideas that are used to construct this software library are 25 | protected by provisional patent number 60986713. 26 | 27 | 28 | Disclaimer 29 | ---------- 30 | 31 | Florida State University and the authors make no representations about 32 | the suitability or fitness of this software for any purpose. 33 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 34 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 35 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 36 | SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, 37 | WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 38 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 39 | 40 | 41 | 42 | Authors 43 | ------- 44 | Michael Connor and Piyush Kumar 45 | Dept of Computer Science 46 | Florida State University 47 | Tallahassee, FL 32306-4532 48 | 49 | Emails: 50 | stann @ compgeom dot com. 51 | 52 | Web Page: 53 | http://compgeom.com/~stann 54 | 55 | -------------------------------------------------------------------------------- /cmvs/program/base/stann/assert.hpp: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* */ 3 | /* Header: assert.hpp */ 4 | /* */ 5 | /* Accompanies STANN Version 0.5 Beta */ 6 | /* Aug 05, 2008 */ 7 | /* */ 8 | /* Copyright 2007, 2008 */ 9 | /* Michael Connor and Piyush Kumar */ 10 | /* Florida State University */ 11 | /* Tallahassee FL, 32306-4532 */ 12 | /* */ 13 | /*****************************************************************************/ 14 | 15 | #ifndef REVIVER_ASSERT_HPP 16 | #define REVIVER_ASSERT_HPP 17 | 18 | #include 19 | /*! 20 | \file 21 | \brief Implementation of assert functions 22 | This file contains an assert function implementation 23 | */ 24 | 25 | /*! 26 | \brief Assert function 27 | This function prints error messages along with file and line numbers 28 | \param b bool to be checked 29 | \param desc Error message 30 | \param line Line number 31 | \param file File name 32 | \return True is there is no error 33 | */ 34 | 35 | /* 36 | bool MyAssertFunction( bool b, char* desc, int line, char* file){ 37 | if (b) return true; 38 | std::cerr << "\n\nAssertion Failure\n"; 39 | std::cerr << "Description : " << desc << std::endl; 40 | std::cerr << "Filename : " << file << std::endl; 41 | std::cerr << "Line No : " << line << std::endl; 42 | exit(1); 43 | } 44 | 45 | #if defined( _DEBUG ) 46 | #define Assert( exp, description ) MyAssertFunction( (int)(exp), description, __LINE__, __FILE__ ) 47 | #else 48 | #define Assert( exp, description ) 49 | #endif 50 | */ 51 | 52 | #define Assert( exp, description ) 53 | 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /cmvs/program/base/stann/assert.hpp~: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* */ 3 | /* Header: assert.hpp */ 4 | /* */ 5 | /* Accompanies STANN Version 0.5 Beta */ 6 | /* Aug 05, 2008 */ 7 | /* */ 8 | /* Copyright 2007, 2008 */ 9 | /* Michael Connor and Piyush Kumar */ 10 | /* Florida State University */ 11 | /* Tallahassee FL, 32306-4532 */ 12 | /* */ 13 | /*****************************************************************************/ 14 | 15 | #ifndef REVIVER_ASSERT_HPP 16 | #define REVIVER_ASSERT_HPP 17 | 18 | #include 19 | /*! 20 | \file 21 | \brief Implementation of assert functions 22 | This file contains an assert function implementation 23 | */ 24 | 25 | /*! 26 | \brief Assert function 27 | This function prints error messages along with file and line numbers 28 | \param b bool to be checked 29 | \param desc Error message 30 | \param line Line number 31 | \param file File name 32 | \return True is there is no error 33 | */ 34 | bool MyAssertFunction( bool b, char* desc, int line, char* file){ 35 | if (b) return true; 36 | std::cerr << "\n\nAssertion Failure\n"; 37 | std::cerr << "Description : " << desc << std::endl; 38 | std::cerr << "Filename : " << file << std::endl; 39 | std::cerr << "Line No : " << line << std::endl; 40 | exit(1); 41 | } 42 | 43 | #if defined( _DEBUG ) 44 | #define Assert( exp, description ) MyAssertFunction( (int)(exp), description, __LINE__, __FILE__ ) 45 | #else 46 | #define Assert( exp, description ) 47 | #endif 48 | 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /cmvs/program/base/stann/rand.hpp: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* */ 3 | /* Header: rand.hpp */ 4 | /* */ 5 | /* Accompanies STANN Version 0.5 Beta */ 6 | /* Aug 05, 2008 */ 7 | /* */ 8 | /* Copyright 2007, 2008 */ 9 | /* Michael Connor and Piyush Kumar */ 10 | /* Florida State University */ 11 | /* Tallahassee FL, 32306-4532 */ 12 | /* */ 13 | /*****************************************************************************/ 14 | 15 | 16 | 17 | #ifndef __RAND_HPP 18 | #define __RAND_HPP 19 | /*! \file rand.hpp 20 | \brief Replacements for srand48 and drand48 21 | 22 | The standard c++ does not have srand48 and drand48 built into it. 23 | this header replaces 24 | them using the standard C++ calls available for random numbers. 25 | */ 26 | 27 | #include 28 | 29 | static double __drand48__() 30 | { 31 | /* We don't have drand48. Use rand() to get the bits. We call 32 | rand() three times since RAND_MAX it at least 16 bits. */ 33 | double f = 1.0 / (RAND_MAX + 1.0); 34 | double x = std::rand(); 35 | x = x * f + std::rand(); 36 | x = x * f + std::rand(); 37 | return x * f; 38 | } 39 | 40 | static void __srand48__(long int seedval) 41 | { 42 | std::srand(seedval); 43 | return; 44 | } 45 | 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /cmvs/program/main/Makefile: -------------------------------------------------------------------------------- 1 | ###################################################################### 2 | # 3 | # The following 2 commands to compile pmvs2. 4 | # > make depend 5 | # > make 6 | # 7 | ###################################################################### 8 | CXX = g++ 9 | 10 | Your INCLUDE path (e.g., -I/usr/include) 11 | YOUR_INCLUDE_PATH = 12 | 13 | Your metis directory (contains header files under graclus1.2/metisLib/) 14 | YOUR_INCLUDE_METIS_PATH = 15 | 16 | Your LDLIBRARY path (e.g., -L/usr/lib) 17 | YOUR_LDLIB_PATH = 18 | 19 | ###################################################################### 20 | CXXFLAGS_PMVS = -O2 -Wall -Wno-deprecated ${YOUR_INCLUDE_PATH} 21 | 22 | CXXFLAGS_CMVS = -O2 -Wall -Wno-deprecated -DNUMBITS=64 \ 23 | ${YOUR_INCLUDE_PATH} ${YOUR_INCLUDE_METIS_PATH} \ 24 | -fopenmp -DNUMBITS=64 ${OPENMP_FLAG} 25 | 26 | 27 | LDFLAGS_PMVS = ${YOUR_LDLIB_PATH} -lXext -lX11 -ljpeg -lm -lpthread \ 28 | -llapack -lgsl -lgslcblas 29 | 30 | LDFLAGS_CMVS = ${YOUR_LDLIB_PATH} -lXext -lX11 -ljpeg -lm -lpthread \ 31 | -llapack -fopenmp -lmultilevel -lmetis -lm 32 | 33 | ###################################################################### 34 | BASE_IMAGE = camera.o image.o photo.o photoSetS.o 35 | BASE_PMVS = detectFeatures.o detector.o dog.o expand.o filter.o \ 36 | findMatch.o harris.o optim.o option.o patch.o patchOrganizerS.o \ 37 | point.o seed.o 38 | BASE_NUMERIC = mylapack.o 39 | BASE_CMVS = bundle.o graclus.o 40 | 41 | ###################################################################### 42 | all: pmvs2 cmvs genOption 43 | 44 | 45 | pmvs2: pmvs2.o ${BASE_IMAGE} ${BASE_PMVS} ${BASE_NUMERIC} 46 | ${CXX} ${LDFLAGS_PMVS} -o $@ $^ ${LDFLAGS_PMVS} 47 | 48 | cmvs: cmvs.o patch.o ${BASE_IMAGE} ${BASE_CMVS} 49 | ${CXX} ${LDFLAGS_CMVS} -o $@ $^ ${LDFLAGS_CMVS} 50 | 51 | genOption: genOption.cc 52 | ${CXX} -o $@ $^ 53 | 54 | 55 | pmvs2.o : pmvs2.cc 56 | $(CXX) -c $(CXXFLAGS_PMVS) $< 57 | 58 | cmvs.o: cmvs.cc 59 | $(CXX) -c $(CXXFLAGS_CMVS) $< 60 | 61 | %.o : ../base/pmvs/%.cc 62 | $(CXX) -c $(CXXFLAGS_PMVS) $< 63 | 64 | %.o : ../base/image/%.cc 65 | $(CXX) -c $(CXXFLAGS_PMVS) $< 66 | 67 | %.o : ../base/numeric/%.cc 68 | $(CXX) -c $(CXXFLAGS_PMVS) $< 69 | 70 | %.o : ../base/cmvs/%.cc 71 | $(CXX) -c $(CXXFLAGS_CMVS) $< 72 | 73 | ###################################################################### 74 | # general commands 75 | clean: 76 | /bin/rm -f core core.* *.o ${TARGET} 77 | 78 | depend: 79 | rm -f Dependencies 80 | for SOURCEFILE in `ls *.cc ../base/*/*.cc ../base/*/*.c ../base/*/*.C ../base/*/*.f`; do \ 81 | echo $$SOURCEFILE; \ 82 | $(CXX) -MM $(CXXFLAGS) $$SOURCEFILE >> Dependencies; \ 83 | done 84 | 85 | -include Dependencies 86 | -------------------------------------------------------------------------------- /cmvs/program/main/cmvs.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "../base/cmvs/bundle.h" 5 | 6 | using namespace std; 7 | 8 | int main(int argc, char* argv[]) { 9 | if (argc < 2) { 10 | cerr << "Usage: " << argv[0] << " prefix maximage[=100] CPU[=4]" << endl 11 | << endl 12 | << "You should choose maximage based on the amount of memory in your machine." << endl 13 | << "CPU should be the number of (virtual) CPUs or cores in your machine." << endl 14 | << "If you want more control of the program, look into the comments inside program/main/cmvs.cc" << endl; 15 | exit (1); 16 | } 17 | 18 | int maximage = 100; 19 | if (3 <= argc) 20 | maximage = atoi(argv[2]); 21 | 22 | int CPU = 4; 23 | if (4 <= argc) 24 | CPU = atoi(argv[3]); 25 | 26 | //---------------------------------------------------------------------- 27 | // If you want more control of the program, you can also change the 28 | // following two parameters. 29 | // scoreRatioThreshold, and coverageThreshold correspond to 30 | // \\lambda and \\delta in our CVPR 2010 paper. 31 | // Please refer to the paper for their definitions. The following are 32 | // brief explanations. 33 | // 34 | // CMVS tries to make sure that multi-view stereo (MVS) 35 | // reconstruction accuracy will be more than a certain threshold at 36 | // Structure-from-Motion (SfM) points. scoreRatioThreshold is this 37 | // threshold on the reconstruction accuracy [0, 1.0]. CMVS makes 38 | // sure that the ratio of "satisfied" SfM points is more than 39 | // coverageThreshold [0 1.0]. 40 | // 41 | // Intuitively, increasing thsse parameters lead to more images and 42 | // clusters in the output. 43 | const float scoreRatioThreshold = 0.7f; 44 | const float coverageThreshold = 0.7f; 45 | 46 | 47 | const int iNumForScore = 4; 48 | const int pnumThreshold = 0; 49 | CMVS::Cbundle bundle; 50 | bundle.run(argv[1], maximage, iNumForScore, 51 | scoreRatioThreshold, coverageThreshold, 52 | pnumThreshold, CPU); 53 | } 54 | -------------------------------------------------------------------------------- /cmvs/program/main/genOption.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | int main(int argc, char* argv[]) { 9 | if (argc < 2) { 10 | cerr << "Usage: " << argv[0] 11 | << " prefix level[=1] csize[=2] threshold[=0.7] wsize[=7]" 12 | << " minImageNum[=3] CPU[=8]" << endl 13 | << endl 14 | << "Parameters are for PMVS2 option files." << endl 15 | << "Please refer to the following URL for the definitions:" << endl 16 | << "http://grail.cs.washington.edu/software/pmvs/documentation.html" << endl; 17 | exit (1); 18 | } 19 | 20 | int level = 1; 21 | if (3 <= argc) 22 | level = atoi(argv[2]); 23 | 24 | int csize = 2; 25 | if (4 <= argc) 26 | csize = atoi(argv[3]); 27 | 28 | float threshold = 0.7; 29 | if (5 <= argc) 30 | threshold = atof(argv[4]); 31 | 32 | int wsize = 7; 33 | if (6 <= argc) 34 | wsize = atoi(argv[5]); 35 | 36 | int minImageNum = 3; 37 | if (7 <= argc) 38 | minImageNum = atoi(argv[6]); 39 | 40 | int CPU = 8; 41 | if (8 <= argc) 42 | CPU = atoi(argv[7]); 43 | 44 | const int setEdge = 0; 45 | const int useBound = 0; 46 | const int useVisData = 1; 47 | const int sequence = -1; 48 | 49 | ifstream ifstr; 50 | char ske[1024]; 51 | sprintf(ske, "%sske.dat", argv[1]); 52 | ifstr.open(ske); 53 | 54 | string header; 55 | int inum, cnum; 56 | ifstr >> header >> inum >> cnum; 57 | 58 | ofstream script; 59 | char pmvsfile[1024]; 60 | sprintf(pmvsfile, "%spmvs.sh", argv[1]); 61 | script.open(pmvsfile); 62 | 63 | for (int c = 0; c < cnum; ++c) { 64 | ofstream ofstr; 65 | char buffer[1024]; 66 | sprintf(buffer, "%soption-%04d", argv[1], c); 67 | ofstr.open(buffer); 68 | 69 | sprintf(buffer, "pmvs2 pmvs/ option-%04d", c); 70 | script << buffer << endl; 71 | 72 | ofstr << "# generated by genOption. mode 1. cluster: " << c << endl 73 | << "level " << level << endl 74 | << "csize " << csize << endl 75 | << "threshold " << threshold << endl 76 | << "wsize " << wsize << endl 77 | << "minImageNum " << minImageNum << endl 78 | << "CPU " << CPU << endl 79 | << "setEdge " << setEdge << endl 80 | << "useBound " << useBound << endl 81 | << "useVisData " << useVisData << endl 82 | << "sequence " << sequence << endl 83 | << "maxAngle 10" << endl 84 | << "quad 2.0" << endl; 85 | 86 | int timagenum, oimagenum; 87 | ifstr >> timagenum >> oimagenum; 88 | 89 | vector timages, oimages; 90 | timages.resize(timagenum); 91 | oimages.resize(oimagenum); 92 | for (int i = 0; i < timagenum; ++i) 93 | ifstr >> timages[i]; 94 | for (int i = 0; i < oimagenum; ++i) 95 | ifstr >> oimages[i]; 96 | 97 | ofstr << "timages " << timagenum << ' '; 98 | for (int i = 0; i < timagenum; ++i) 99 | ofstr << timages[i] << ' '; 100 | ofstr << endl; 101 | ofstr << "oimages " << oimagenum << ' '; 102 | for (int i = 0; i < oimagenum; ++i) 103 | ofstr << oimages[i] << ' '; 104 | ofstr << endl; 105 | ofstr.close(); 106 | } 107 | ifstr.close(); 108 | script << endl; 109 | script.close(); 110 | } 111 | -------------------------------------------------------------------------------- /cmvs/program/main/libblas.so.3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/cmvs/program/main/libblas.so.3 -------------------------------------------------------------------------------- /cmvs/program/main/libgsl.so.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/cmvs/program/main/libgsl.so.0 -------------------------------------------------------------------------------- /cmvs/program/main/libgslcblas.so.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/cmvs/program/main/libgslcblas.so.0 -------------------------------------------------------------------------------- /cmvs/program/main/liblapack.so.3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/cmvs/program/main/liblapack.so.3 -------------------------------------------------------------------------------- /cmvs/program/main/pmvs2.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "../base/pmvs/findMatch.h" 4 | #include "../base/pmvs/option.h" 5 | 6 | using namespace PMVS3; 7 | using namespace std; 8 | 9 | int main(int argc, char* argv[]) { 10 | if (argc < 3) { 11 | cerr << "Usage: " << argv[0] << " prefix option_file" << endl 12 | << endl 13 | << "--------------------------------------------------" << endl 14 | << "level 1 csize 2" << endl 15 | << "threshold 0.7 wsize 7" << endl 16 | << "minImageNum 3 CPU 4" << endl 17 | << "useVisData 0 sequence -1" << endl 18 | << "quad 2.5 maxAngle 10.0" << endl 19 | << "--------------------------------------------------" << endl 20 | << "2 ways to specify targetting images" << endl 21 | << "timages 5 1 3 5 7 9 (enumeration)" << endl 22 | << " -1 0 24 (range specification)" << endl 23 | << "--------------------------------------------------" << endl 24 | << "4 ways to specify other images" << endl 25 | << "oimages 5 0 2 4 6 8 (enumeration)" << endl 26 | << " -1 24 48 (range specification)" << endl; 27 | exit (1); 28 | } 29 | 30 | PMVS3::Soption option; 31 | option.init(argv[1], argv[2]); 32 | 33 | PMVS3::CfindMatch findMatch; 34 | findMatch.init(option); 35 | findMatch.run(); 36 | 37 | char buffer[1024]; 38 | sprintf(buffer, "%smodels/%s", argv[1], argv[2]); 39 | findMatch.write(buffer); 40 | } 41 | -------------------------------------------------------------------------------- /graclus1.2/Makefile: -------------------------------------------------------------------------------- 1 | 2 | 3 | default: 4 | (cd metisLib ; make ) 5 | (cd multilevelLib ; make ) 6 | (cd programs ; make ) 7 | 8 | 9 | clean: 10 | (cd metisLib ; make clean ) 11 | (cd multilevelLib ; make clean ) 12 | (cd programs ; make clean ) 13 | 14 | 15 | realclean: 16 | (cd metisLib ; make realclean ) 17 | (cd multilevelLib ; make realclean ) 18 | (cd programs ; make realclean ) 19 | (rm *.a) -------------------------------------------------------------------------------- /graclus1.2/Makefile.in: -------------------------------------------------------------------------------- 1 | 2 | # Which compiler to use 3 | CC = g++ 4 | # To compile the Matlab interface in Windows using cygwin, I used: 5 | # CC = g++ -mno-cygwin -mwindows 6 | 7 | # What optimization level to use 8 | OPTFLAGS = -O2 -fPIC 9 | 10 | # What options to be used by the compiler 11 | COPTIONS = -DNUMBITS=32 12 | 13 | # What options to be used by the loader 14 | LDOPTIONS = 15 | 16 | # What archiving to use 17 | AR = ar rv 18 | 19 | # What to use for indexing the archive 20 | RANLIB = ranlib 21 | #RANLIB = ar -ts 22 | #RANLIB = 23 | 24 | #LAPACK LIB 25 | ARCH = P4SSE2 26 | LAPACK = -llapack_$(ARCH) 27 | ARPACK = -lcarpack_$(ARCH) 28 | ATLAS = -latlas_$(ARCH) 29 | CBLAS = -lcblaswr -lcblas -lblas -lmyf2c 30 | GSL = -lgslcblas -lgsl 31 | SPARSE = -lsparse 32 | UTIL = -lmyutil 33 | -------------------------------------------------------------------------------- /graclus1.2/matlab/GraclusImageSegmentation.m: -------------------------------------------------------------------------------- 1 | function GraclusImageSegmentation(imgFile,k) 2 | %% function GraclusImageSegmentation(imgFile,k) 3 | % 4 | % Inputs: imgFile (image to segment), k (number of segs) 5 | % 6 | % Note: Make sure you add a path to Jianbo Shi's image segmentation 7 | % code within this function so that the graph can be created from 8 | % the image (via the function ICgraph). 9 | 10 | I = imread(imgFile); 11 | [Inr,Inc,nb] = size(I); 12 | 13 | if (nb>1), 14 | I =double(rgb2gray(I)); 15 | else 16 | I = double(I); 17 | end 18 | 19 | %If you want to resize to nr x nc to make the image smaller: 20 | %I = imresize(I,[nr, nc],'bicubic'); 21 | %Inr = nr; Inc = nc; 22 | 23 | disp('Creating the graph...'); 24 | [W,imageEdges] = ICgraph(I); 25 | maxW = max(max(W)); 26 | spectral = 1; 27 | [n,n] = size(W); 28 | W = sparsifyc(W,1e-6); 29 | W2 = ceil(1e2*W); 30 | [partition,ncutval]=graclus_mex(W2,nnz(W2),k,0,20,spectral); 31 | GraclusDiscrete = zeros(n,k); 32 | for i = 1:k 33 | idx = find(partition == i); 34 | for j = 1:length(idx) 35 | GraclusDiscrete(idx(j),i) = 1; 36 | end 37 | end 38 | GraclusLabel = zeros(Inr,Inc); 39 | for j=1:size(GraclusDiscrete,2), 40 | GraclusLabel = GraclusLabel + j*reshape(GraclusDiscrete(:,j),Inr,Inc); 41 | end 42 | 43 | %Display the segmentation 44 | figure(1);clf; imagesc(I);colormap(gray);axis off; 45 | disp('Figure 1: The input image before segmentation....'); 46 | 47 | figure(2);clf 48 | bw = edge(GraclusLabel,0.01); 49 | J1=showmask(I,imdilate(bw,ones(2,2))); imagesc(J1);axis off 50 | disp('Figure 2: The segmentation using Graclus.'); 51 | -------------------------------------------------------------------------------- /graclus1.2/matlab/a_times_b_cmplx.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/graclus1.2/matlab/a_times_b_cmplx.dll -------------------------------------------------------------------------------- /graclus1.2/matlab/a_times_b_cmplx.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/graclus1.2/matlab/a_times_b_cmplx.mexa64 -------------------------------------------------------------------------------- /graclus1.2/matlab/a_times_b_cmplx.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/graclus1.2/matlab/a_times_b_cmplx.mexglx -------------------------------------------------------------------------------- /graclus1.2/matlab/a_times_b_cmplx.mexmac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/graclus1.2/matlab/a_times_b_cmplx.mexmac -------------------------------------------------------------------------------- /graclus1.2/matlab/affinityic.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/graclus1.2/matlab/affinityic.mexa64 -------------------------------------------------------------------------------- /graclus1.2/matlab/affinityic.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/graclus1.2/matlab/affinityic.mexglx -------------------------------------------------------------------------------- /graclus1.2/matlab/cimgnbmap.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/graclus1.2/matlab/cimgnbmap.mexa64 -------------------------------------------------------------------------------- /graclus1.2/matlab/cimgnbmap.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/graclus1.2/matlab/cimgnbmap.mexglx -------------------------------------------------------------------------------- /graclus1.2/matlab/discretisation.m: -------------------------------------------------------------------------------- 1 | function [EigenvectorsDiscrete,EigenVectors]=discretisation(EigenVectors) 2 | % 3 | % EigenvectorsDiscrete=discretisation(EigenVectors) 4 | % 5 | % Input: EigenVectors = continuous Ncut vector, size = ndata x nbEigenvectors 6 | % Output EigenvectorsDiscrete = discrete Ncut vector, size = ndata x nbEigenvectors 7 | % 8 | % Timothee Cour, Stella Yu, Jianbo Shi, 2004 9 | 10 | [n,k]=size(EigenVectors); 11 | 12 | vm = sqrt(sum(EigenVectors.*EigenVectors,2)); 13 | EigenVectors = EigenVectors./repmat(vm,1,k); 14 | 15 | R=zeros(k); 16 | R(:,1)=EigenVectors(1+round(rand(1)*(n-1)),:)'; 17 | c=zeros(n,1); 18 | for j=2:k 19 | c=c+abs(EigenVectors*R(:,j-1)); 20 | [minimum,i]=min(c); 21 | R(:,j)=EigenVectors(i,:)'; 22 | end 23 | 24 | lastObjectiveValue=0; 25 | exitLoop=0; 26 | nbIterationsDiscretisation = 0; 27 | nbIterationsDiscretisationMax = 20;%voir 28 | while exitLoop== 0 29 | nbIterationsDiscretisation = nbIterationsDiscretisation + 1 ; 30 | EigenvectorsDiscrete = discretisationEigenVectorData(EigenVectors*R); 31 | [U,S,V] = svd(EigenvectorsDiscrete'*EigenVectors,0); 32 | NcutValue=2*(n-trace(S)); 33 | 34 | if abs(NcutValue-lastObjectiveValue) < eps | nbIterationsDiscretisation > nbIterationsDiscretisationMax 35 | exitLoop=1; 36 | else 37 | lastObjectiveValue = NcutValue; 38 | R=V*U'; 39 | end 40 | end -------------------------------------------------------------------------------- /graclus1.2/matlab/discretisationEigenVectorData.asv: -------------------------------------------------------------------------------- 1 | function Y = discretisationEigenVectorData(EigenVector) 2 | % 3 | % Timothee Cour, Stella Yu, Jianbo Shi, 2004 4 | 5 | [n,k]=size(EigenVector); 6 | 7 | 8 | [Maximum,J]=max(EigenVector'); 9 | 10 | Y=sparse(1:n,J',1,n,k); 11 | -------------------------------------------------------------------------------- /graclus1.2/matlab/discretisationEigenVectorData.m: -------------------------------------------------------------------------------- 1 | function Y = discretisationEigenVectorData(EigenVector) 2 | % Y = discretisationEigenVectorData(EigenVector) 3 | % 4 | % discretizes previously rotated eigenvectors in discretisation 5 | % Timothee Cour, Stella Yu, Jianbo Shi, 2004 6 | 7 | [n,k]=size(EigenVector); 8 | 9 | 10 | [Maximum,J]=max(EigenVector'); 11 | 12 | Y=sparse(1:n,J',1,n,k); 13 | -------------------------------------------------------------------------------- /graclus1.2/matlab/graclus.m: -------------------------------------------------------------------------------- 1 | function [partition, obj] = graclus(G, k, cutType, l, spectral) 2 | %% Graclus Matlab interface 3 | % 4 | % [partition, obj] = graclus(G, k, cutType, l, spectral) 5 | % 6 | % G: Graph adjacency matrix 7 | % k: number of clusters 8 | % cutType: 0 for NCut, 1 for RAssoc (default is NCut) 9 | % l: number of local search steps (default is 0) 10 | % spectral: 1 for spectral clustering at coarsest level, 0 11 | % otherwise (default is not to use spectral clustering) 12 | if nargin < 5 13 | spectral = 0; 14 | end 15 | if nargin < 4 16 | l = 0; 17 | end 18 | if nargin < 3 19 | cutType = 0; 20 | end 21 | if nargin < 2 22 | disp('Please specify the adjacency matrix and the number of clusters'); 23 | partition = 0; 24 | obj = 0; 25 | else 26 | if ~issparse(G) 27 | G = sparse(G); 28 | end 29 | %Graclus only accepts integer-valued edge weights, so round here 30 | %Note: may need to round more if more digits of accuracy are needed 31 | G = round(1000*G); 32 | [partition, obj] = graclus_mex(G,nnz(G),k,cutType,l,spectral); 33 | end -------------------------------------------------------------------------------- /graclus1.2/matlab/graclus_compile_script.m: -------------------------------------------------------------------------------- 1 | %compile the graclus mex code 2 | mex -c CFLAGS=-fPIC -DNUMBITS=32 -largeArrayDims mlkkm.cpp -I../multilevelLib -I../metisLib -cxx 3 | mex -c CFLAGS=-fPIC -DNUMBITS=32 -largeArrayDims wkkm.cpp -I../multilevelLib -I../metisLib -cxx 4 | mex -c CFLAGS=-fPIC -DNUMBITS=32 -largeArrayDims graclus_mex.cpp -I../multilevelLib -I../metisLib -cxx 5 | mex -c CFLAGS=-fPIC -DNUMBITS=32 -largeArrayDims io.cpp -I../multilevelLib -I../metisLib -cxx 6 | mex -largeArrayDims CFLAGS=-fPIC -DNUMBITS=32 -L/p/lib -L. -L../ graclus_mex.o mlkkm.o wkkm.o io.o -lmetis -lm -cxx 7 | %for windows, I used the following instead: 8 | %mex -c CFLAGS=-fPIC -largeArrayDims -DNUMBITS=32 mlkkm.cpp -I../multilevelLib -I../metisLib 9 | %mex -c CFLAGS=-fPIC -largeArrayDims -DNUMBITS=32 wkkm.cpp -I../multilevelLib -I../metisLib 10 | %mex -c CFLAGS=-fPIC -largeArrayDims -DNUMBITS=32 graclus_mex.cpp -I../multilevelLib -I../metisLib 11 | %mex -c CFLAGS=-fPIC -largeArrayDims -DNUMBITS=32 io.cpp -I../multilevelLib -I../metisLib 12 | %mex -largeArrayDims CFLAGS=fPIC -DNUMBITS=32 -L/usr/lib -L. -L../ graclus_mex.obj mlkkm.obj wkkm.obj io.obj -lmetis -------------------------------------------------------------------------------- /graclus1.2/matlab/graclus_mex.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/graclus1.2/matlab/graclus_mex.mexa64 -------------------------------------------------------------------------------- /graclus1.2/matlab/graclus_mex.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/graclus1.2/matlab/graclus_mex.mexglx -------------------------------------------------------------------------------- /graclus1.2/matlab/graclus_mex.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/graclus1.2/matlab/graclus_mex.mexw32 -------------------------------------------------------------------------------- /graclus1.2/matlab/mex_w_times_x_symmetric.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/graclus1.2/matlab/mex_w_times_x_symmetric.dll -------------------------------------------------------------------------------- /graclus1.2/matlab/mex_w_times_x_symmetric.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/graclus1.2/matlab/mex_w_times_x_symmetric.mexa64 -------------------------------------------------------------------------------- /graclus1.2/matlab/mex_w_times_x_symmetric.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/graclus1.2/matlab/mex_w_times_x_symmetric.mexglx -------------------------------------------------------------------------------- /graclus1.2/matlab/mex_w_times_x_symmetric.mexmac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/graclus1.2/matlab/mex_w_times_x_symmetric.mexmac -------------------------------------------------------------------------------- /graclus1.2/matlab/ncut.asv: -------------------------------------------------------------------------------- 1 | function [Eigenvectors,Eigenvalues] = ncut(W,nbEigenValues,dataNcut); 2 | % function [Eigenvectors,Eigenvalues] = ncut(W,nbEigenValues,dataNcut); 3 | % 4 | % Input: 5 | % W= symmetric similarity matrix 6 | % nbEigenValues= number of Ncut eigenvectors computed 7 | % dataNcut= optional parameters 8 | % 9 | % default parameters for dataNcut: 10 | % dataNcut.offset = 5e-1; offset in the diagonal of W 11 | % dataNcut.verbose = 0; (0 for 12 | % dataNcut.maxiterations = 100; 13 | % dataNcut.eigsErrorTolerance = 1e-6; 14 | % dataNcut.valeurMin=1e-6; %truncate any values in W less than valeurMin 15 | % 16 | % Output: 17 | % Eigenvectors= continuouse Ncut vectos, size = ndata x nbEigenValues 18 | % Eigenvalues= Ncut value, size = 1x nbEigenValues 19 | % 20 | % Timothee Cour, Stella Yu, Jianbo Shi, 2004. 21 | 22 | if nargin < 2 23 | nbEigenValues = 8; 24 | end 25 | if nargin < 3 26 | dataNcut.offset = 5e-1; 27 | dataNcut.verbose = 0; 28 | dataNcut.maxiterations = 100; 29 | dataNcut.eigsErrorTolerance = 1e-6; 30 | dataNcut.valeurMin=1e-6; 31 | end 32 | 33 | % make W matrix sparse 34 | W = sparsifyc(W,dataNcut.valeurMin); 35 | 36 | % check for matrix symmetry 37 | if max(max(abs(W-W'))) > 1e-10 %voir (-12) 38 | %disp(max(max(abs(W-W')))); 39 | error('W not symmetric'); 40 | end 41 | 42 | n = size(W,1); 43 | nbEigenValues = min(nbEigenValues,n); 44 | offset = dataNcut.offset; 45 | 46 | 47 | % degrees and regularization 48 | d = sum(abs(W),2); 49 | dr = 0.5 * (d - sum(W,2)); 50 | d = d + offset * 2; 51 | dr = dr + offset; 52 | W = W + spdiags(dr,0,n,n); 53 | 54 | Dinvsqrt = 1./sqrt(d+eps); 55 | P = spmtimesd(W,Dinvsqrt,Dinvsqrt); 56 | clear W; 57 | 58 | options.issym = 1; 59 | 60 | if dataNcut.verbose 61 | options.disp = 3; 62 | else 63 | options.disp = 0; 64 | end 65 | options.maxit = dataNcut.maxiterations; 66 | options.tol = dataNcut.eigsErrorTolerance; 67 | 68 | options.v0 = ones(size(P,1),1); 69 | options.p = max(35,2*nbEigenValues); %voir 70 | options.p = min(options.p,n); 71 | 72 | %warning off 73 | [vbar,s,convergence] = eigs2(@mex_w_times_x_symmetric,size(P,1),nbEigenValues,'LA',options,tril(P)); 74 | %warning on 75 | 76 | s = real(diag(s)); 77 | [x,y] = sort(-s); 78 | Eigenvalues = -x; 79 | vbar = vbar(:,y); 80 | Eigenvectors = spdiags(Dinvsqrt,0,n,n) * vbar; 81 | 82 | for i=1:size(Eigenvectors,2) 83 | Eigenvectors(:,i) = (Eigenvectors(:,i) / norm(Eigenvectors(:,i)) )*norm(ones(n,1)); 84 | if Eigenvectors(1,i)~=0 85 | Eigenvectors(:,i) = - Eigenvectors(:,i) * sign(Eigenvectors(1,i)); 86 | end 87 | end 88 | -------------------------------------------------------------------------------- /graclus1.2/matlab/ncut.m: -------------------------------------------------------------------------------- 1 | function [Eigenvectors,Eigenvalues] = ncut(W,nbEigenValues,dataNcut); 2 | % function [Eigenvectors,Eigenvalues] = ncut(W,nbEigenValues,dataNcut); 3 | % 4 | % Input: 5 | % W= symmetric similarity matrix 6 | % nbEigenValues= number of Ncut eigenvectors computed 7 | % dataNcut= optional parameters 8 | % 9 | % default parameters for dataNcut: 10 | % dataNcut.offset = 5e-1; offset in the diagonal of W 11 | % dataNcut.verbose = 0; 0 for verbose off mode, 1,2,3 for verbose on modes 12 | % dataNcut.maxiterations = 100; max number of iterations in eigensolver 13 | % dataNcut.eigsErrorTolerance = 1e-6; error tolerance in eigensolver 14 | % dataNcut.valeurMin=1e-6; % truncates any values in W less than valeurMin 15 | % 16 | % Output: 17 | % Eigenvectors= continuouse Ncut eigenvectos, size = length(W) x nbEigenValues 18 | % Eigenvalues= Ncut eigenvalues, size = 1x nbEigenValues 19 | % 20 | % Timothee Cour, Stella Yu, Jianbo Shi, 2004. 21 | 22 | if nargin < 2 23 | nbEigenValues = 8; 24 | end 25 | if nargin < 3 26 | dataNcut.offset = 5e-1; 27 | dataNcut.verbose = 0; 28 | dataNcut.maxiterations = 100; 29 | dataNcut.eigsErrorTolerance = 1e-6; 30 | dataNcut.valeurMin=1e-6; 31 | end 32 | 33 | % make W matrix sparse 34 | W = sparsifyc(W,dataNcut.valeurMin); 35 | 36 | % check for matrix symmetry 37 | if max(max(abs(W-W'))) > 1e-10 %voir (-12) 38 | %disp(max(max(abs(W-W')))); 39 | error('W not symmetric'); 40 | end 41 | 42 | n = size(W,1); 43 | nbEigenValues = min(nbEigenValues,n); 44 | offset = dataNcut.offset; 45 | 46 | 47 | % degrees and regularization 48 | d = sum(abs(W),2); 49 | dr = 0.5 * (d - sum(W,2)); 50 | d = d + offset * 2; 51 | dr = dr + offset; 52 | W = W + spdiags(dr,0,n,n); 53 | 54 | Dinvsqrt = 1./sqrt(d+eps); 55 | P = spmtimesd(W,Dinvsqrt,Dinvsqrt); 56 | clear W; 57 | 58 | options.issym = 1; 59 | 60 | if dataNcut.verbose 61 | options.disp = 3; 62 | else 63 | options.disp = 0; 64 | end 65 | options.maxit = dataNcut.maxiterations; 66 | options.tol = dataNcut.eigsErrorTolerance; 67 | 68 | options.v0 = ones(size(P,1),1); 69 | options.p = max(35,2*nbEigenValues); %voir 70 | options.p = min(options.p,n); 71 | 72 | %warning off 73 | [vbar,s,convergence] = eigs2(@mex_w_times_x_symmetric,size(P,1),nbEigenValues,'LA',options,tril(P)); 74 | %warning on 75 | 76 | s = real(diag(s)); 77 | [x,y] = sort(-s); 78 | Eigenvalues = -x; 79 | vbar = vbar(:,y); 80 | Eigenvectors = spdiags(Dinvsqrt,0,n,n) * vbar; 81 | 82 | for i=1:size(Eigenvectors,2) 83 | Eigenvectors(:,i) = (Eigenvectors(:,i) / norm(Eigenvectors(:,i)) )*norm(ones(n,1)); 84 | if Eigenvectors(1,i)~=0 85 | Eigenvectors(:,i) = - Eigenvectors(:,i) * sign(Eigenvectors(1,i)); 86 | end 87 | end 88 | -------------------------------------------------------------------------------- /graclus1.2/matlab/ncutW.asv: -------------------------------------------------------------------------------- 1 | function [NcutDiscrete,NcutEigenvectors,NcutEigenvalues] = ncutW(W,nbcluster); 2 | % [NcutDiscrete,NcutEigenvectors,NcutEigenvalues] = ncutW(W,nbcluster); 3 | % 4 | % Calls ncut to compute Ncut eigenvectors of W with 5 | % Timothee Cour, Stella Yu, Jianbo Shi, 2004 6 | 7 | % compute continuous Ncut eigenvectors 8 | [NcutEigenvectors,NcutEigenvalues] = ncut(W,nbcluster); 9 | 10 | % compute discretize Ncut vectors 11 | [NcutDiscrete,NcutEigenvectors] =discretisation(NcutEigenvectors); 12 | 13 | 14 | NcutDiscrete = full(NcutDiscrete); -------------------------------------------------------------------------------- /graclus1.2/matlab/ncutW.m: -------------------------------------------------------------------------------- 1 | function [part] = ncutW(W,nbcluster); 2 | % [NcutDiscrete,NcutEigenvectors,NcutEigenvalues] = ncutW(W,nbcluster); 3 | % 4 | % Calls ncut to compute NcutEigenvectors and NcutEigenvalues of W with nbcluster clusters 5 | % Then calls discretisation to discretize the NcutEigenvectors into NcutDiscrete 6 | % Timothee Cour, Stella Yu, Jianbo Shi, 2004 7 | 8 | % compute continuous Ncut eigenvectors 9 | [NcutEigenvectors,NcutEigenvalues] = ncut(W,nbcluster); 10 | 11 | % compute discretize Ncut vectors 12 | [NcutDiscrete,NcutEigenvectors] =discretisation(NcutEigenvectors); 13 | 14 | 15 | NcutDiscrete = full(NcutDiscrete); 16 | 17 | [n,n] = size(W); 18 | for i = 1:n 19 | tmp(i) = (i-1)*nbcluster; 20 | end 21 | part = find(NcutDiscrete' > 0)' - tmp; -------------------------------------------------------------------------------- /graclus1.2/matlab/readMetis.m: -------------------------------------------------------------------------------- 1 | function [A, m, n] = readMetis(fname) 2 | % read from metix input graph 3 | 4 | fid = fopen(fname,'r'); 5 | if fid == -1 6 | fprintf('readDense: fopen for file %s failed\n',fname); 7 | error('Fatal Error'); 8 | end 9 | 10 | m = fscanf(fid,'%d', 1); % number of vertices 11 | n = fscanf(fid,'%d', 1); % number of edges 12 | %A = zeros(m,m); 13 | A(1,1)=0; 14 | A=sparse(A); 15 | t = fgetl(fid); 16 | format = sscanf(t,'%d'); 17 | if ((length(format) ==0) | (format ==0)) 18 | for i=1:m 19 | t = fgetl(fid); 20 | l = sscanf(t, '%d'); 21 | A(i,l) = 1; 22 | end 23 | else 24 | for i=1:m 25 | t = fgetl(fid); 26 | l = sscanf(t, '%d'); 27 | 28 | A(i,l(1:2:length(l))) = l(2:2:length(l)); 29 | end 30 | end 31 | %A = sparse(A); -------------------------------------------------------------------------------- /graclus1.2/matlab/sparsifyc.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/graclus1.2/matlab/sparsifyc.dll -------------------------------------------------------------------------------- /graclus1.2/matlab/sparsifyc.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/graclus1.2/matlab/sparsifyc.mexa64 -------------------------------------------------------------------------------- /graclus1.2/matlab/sparsifyc.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/graclus1.2/matlab/sparsifyc.mexglx -------------------------------------------------------------------------------- /graclus1.2/matlab/sparsifyc.mexmac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/graclus1.2/matlab/sparsifyc.mexmac -------------------------------------------------------------------------------- /graclus1.2/matlab/spmtimesd.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/graclus1.2/matlab/spmtimesd.dll -------------------------------------------------------------------------------- /graclus1.2/matlab/spmtimesd.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/graclus1.2/matlab/spmtimesd.mexa64 -------------------------------------------------------------------------------- /graclus1.2/matlab/spmtimesd.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/graclus1.2/matlab/spmtimesd.mexglx -------------------------------------------------------------------------------- /graclus1.2/matlab/spmtimesd.mexmac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/graclus1.2/matlab/spmtimesd.mexmac -------------------------------------------------------------------------------- /graclus1.2/metisLib/Makefile: -------------------------------------------------------------------------------- 1 | include ../Makefile.in 2 | 3 | INCLUDES = -I. 4 | 5 | CFLAGS = $(COPTIONS) $(OPTFLAGS) $(INCLUDES) 6 | LD = $(CC) -L. 7 | 8 | 9 | OBJS = coarsen.o fm.o match.o ccgraph.o memory.o \ 10 | pmetis.o pqueue.o refine.o util.o timing.o debug.o \ 11 | bucketsort.o graph.o stat.o kmetis.o kwayrefine.o \ 12 | kwayfm.o balance.o ometis.o srefine.o sfm.o separator.o \ 13 | mincover.o mmd.o mesh.o meshpart.o frename.o fortran.o \ 14 | myqsort.o compress.o parmetis.o estmem.o \ 15 | mpmetis.o mcoarsen.o mmatch.o minitpart.o mbalance.o \ 16 | mrefine.o mutil.o mfm.o mkmetis.o mkwayrefine.o mkwayfmh.o \ 17 | mrefine2.o minitpart2.o mbalance2.o mfm2.o \ 18 | kvmetis.o kwayvolrefine.o kwayvolfm.o subdomains.o initpart.o 19 | 20 | .c.o: 21 | $(CC) $(CFLAGS) -c $*.c 22 | 23 | ../libmetis.a: $(OBJS) 24 | $(AR) $@ $(OBJS) 25 | $(RANLIB) $@ 26 | 27 | clean: 28 | rm -f *.o 29 | 30 | realclean: 31 | rm -f *.o ; rm -f ../libmetis.a 32 | -------------------------------------------------------------------------------- /graclus1.2/metisLib/bucketsort.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1997, Regents of the University of Minnesota 3 | * 4 | * bucketsort.c 5 | * 6 | * This file contains code that implement a variety of counting sorting 7 | * algorithms 8 | * 9 | * Started 7/25/97 10 | * George 11 | * 12 | * $Id: bucketsort.c,v 1.1 1998/11/27 17:59:11 karypis Exp $ 13 | * 14 | */ 15 | 16 | #include 17 | 18 | 19 | 20 | /************************************************************************* 21 | * This function uses simple counting sort to return a permutation array 22 | * corresponding to the sorted order. The keys are assumed to start from 23 | * 0 and they are positive. This sorting is used during matching. 24 | **************************************************************************/ 25 | void BucketSortKeysInc(int n, int max, idxtype *keys, idxtype *tperm, idxtype *perm) 26 | { 27 | int i, ii; 28 | idxtype *counts; 29 | 30 | counts = idxsmalloc(max+2, 0, "BucketSortKeysInc: counts"); 31 | 32 | for (i=0; i 14 | 15 | 16 | /************************************************************************* 17 | * This function takes a graph and creates a sequence of coarser graphs 18 | **************************************************************************/ 19 | GraphType *Coarsen2Way(CtrlType *ctrl, GraphType *graph) 20 | { 21 | int clevel; 22 | GraphType *cgraph; 23 | 24 | IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->CoarsenTmr)); 25 | 26 | cgraph = graph; 27 | 28 | /* The following is ahack to allow the multiple bisections to go through with correct 29 | coarsening */ 30 | if (ctrl->CType > 20) { 31 | clevel = 1; 32 | ctrl->CType -= 20; 33 | } 34 | else 35 | clevel = 0; 36 | 37 | do { 38 | IFSET(ctrl->dbglvl, DBG_COARSEN, printf("%6d %7d [%d] [%d %d]\n", 39 | cgraph->nvtxs, cgraph->nedges, ctrl->CoarsenTo, ctrl->maxvwgt, 40 | (cgraph->vwgt ? idxsum(cgraph->nvtxs, cgraph->vwgt) : cgraph->nvtxs))); 41 | 42 | if (cgraph->adjwgt) { 43 | switch (ctrl->CType) { 44 | case MATCH_RM: 45 | Match_RM(ctrl, cgraph); 46 | break; 47 | case MATCH_HEM: 48 | if (clevel < 1) 49 | Match_RM(ctrl, cgraph); 50 | else 51 | Match_HEM(ctrl, cgraph); 52 | break; 53 | case MATCH_HEMN: 54 | if (clevel < 1) 55 | Match_RM(ctrl, cgraph); 56 | else 57 | Match_HEMN(ctrl, cgraph); 58 | break; 59 | case MATCH_SHEMN: 60 | //if (clevel < 1) 61 | // Match_RM(ctrl, cgraph); 62 | //else 63 | Match_SHEMN(ctrl, cgraph); 64 | break; 65 | case MATCH_SHEM: 66 | if (clevel < 1) 67 | Match_RM(ctrl, cgraph); 68 | else 69 | Match_SHEM(ctrl, cgraph); 70 | break; 71 | case MATCH_SHEMKWAY: 72 | Match_SHEM(ctrl, cgraph); 73 | break; 74 | default: 75 | errexit("Unknown CType: %d\n", ctrl->CType); 76 | } 77 | } 78 | else { 79 | Match_RM_NVW(ctrl, cgraph); 80 | } 81 | 82 | cgraph = cgraph->coarser; 83 | clevel++; 84 | //printf("Coarsening to level %d, number of vertices is %d...\n", clevel, cgraph->nvtxs); 85 | } while (cgraph->nvtxs > ctrl->CoarsenTo && cgraph->nvtxs < COARSEN_FRACTION2*cgraph->finer->nvtxs && cgraph->nedges > cgraph->nvtxs/2); 86 | 87 | 88 | IFSET(ctrl->dbglvl, DBG_COARSEN, printf("%6d %7d [%d] [%d %d]\n", 89 | cgraph->nvtxs, cgraph->nedges, ctrl->CoarsenTo, ctrl->maxvwgt, 90 | (cgraph->vwgt ? idxsum(cgraph->nvtxs, cgraph->vwgt) : cgraph->nvtxs))); 91 | 92 | IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->CoarsenTmr)); 93 | 94 | return cgraph; 95 | } 96 | 97 | -------------------------------------------------------------------------------- /graclus1.2/metisLib/mcoarsen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * mcoarsen.c 3 | * 4 | * This file contains the driving routines for the coarsening process 5 | * 6 | * Started 7/23/97 7 | * George 8 | * 9 | * $Id: mcoarsen.c,v 1.1 1998/11/27 17:59:19 karypis Exp $ 10 | * 11 | */ 12 | 13 | #include 14 | 15 | 16 | /************************************************************************* 17 | * This function takes a graph and creates a sequence of coarser graphs 18 | **************************************************************************/ 19 | GraphType *MCCoarsen2Way(CtrlType *ctrl, GraphType *graph) 20 | { 21 | int i, clevel; 22 | GraphType *cgraph; 23 | 24 | IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->CoarsenTmr)); 25 | 26 | cgraph = graph; 27 | 28 | clevel = 0; 29 | do { 30 | if (ctrl->dbglvl&DBG_COARSEN) { 31 | printf("%6d %7d %10d [%d] [%6.4f", cgraph->nvtxs, cgraph->nedges, 32 | idxsum(cgraph->nvtxs, cgraph->adjwgtsum), ctrl->CoarsenTo, ctrl->nmaxvwgt); 33 | for (i=0; incon; i++) 34 | printf(" %5.3f", ssum_strd(cgraph->nvtxs, cgraph->nvwgt+i, cgraph->ncon)); 35 | printf("]\n"); 36 | } 37 | 38 | switch (ctrl->CType) { 39 | case MATCH_RM: 40 | MCMatch_RM(ctrl, cgraph); 41 | break; 42 | case MATCH_HEM: 43 | if (clevel < 1) 44 | MCMatch_RM(ctrl, cgraph); 45 | else 46 | MCMatch_HEM(ctrl, cgraph); 47 | break; 48 | case MATCH_SHEM: 49 | if (clevel < 1) 50 | MCMatch_RM(ctrl, cgraph); 51 | else 52 | MCMatch_SHEM(ctrl, cgraph); 53 | break; 54 | case MATCH_SHEMKWAY: 55 | MCMatch_SHEM(ctrl, cgraph); 56 | break; 57 | case MATCH_SHEBM_ONENORM: 58 | MCMatch_SHEBM(ctrl, cgraph, 1); 59 | break; 60 | case MATCH_SHEBM_INFNORM: 61 | MCMatch_SHEBM(ctrl, cgraph, -1); 62 | break; 63 | case MATCH_SBHEM_ONENORM: 64 | MCMatch_SBHEM(ctrl, cgraph, 1); 65 | break; 66 | case MATCH_SBHEM_INFNORM: 67 | MCMatch_SBHEM(ctrl, cgraph, -1); 68 | break; 69 | default: 70 | errexit("Unknown CType: %d\n", ctrl->CType); 71 | } 72 | 73 | cgraph = cgraph->coarser; 74 | clevel++; 75 | 76 | } while (cgraph->nvtxs > ctrl->CoarsenTo && cgraph->nvtxs < COARSEN_FRACTION2*cgraph->finer->nvtxs && cgraph->nedges > cgraph->nvtxs/2); 77 | 78 | if (ctrl->dbglvl&DBG_COARSEN) { 79 | printf("%6d %7d %10d [%d] [%6.4f", cgraph->nvtxs, cgraph->nedges, 80 | idxsum(cgraph->nvtxs, cgraph->adjwgtsum), ctrl->CoarsenTo, ctrl->nmaxvwgt); 81 | for (i=0; incon; i++) 82 | printf(" %5.3f", ssum_strd(cgraph->nvtxs, cgraph->nvwgt+i, cgraph->ncon)); 83 | printf("]\n"); 84 | } 85 | 86 | 87 | IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->CoarsenTmr)); 88 | 89 | return cgraph; 90 | } 91 | 92 | -------------------------------------------------------------------------------- /graclus1.2/metisLib/metis.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1997, Regents of the University of Minnesota 3 | * 4 | * metis.h 5 | * 6 | * This file includes all necessary header files 7 | * 8 | * Started 8/27/94 9 | * George 10 | * 11 | * $Id: metis.h,v 1.1 1998/11/27 17:59:21 karypis Exp $ 12 | */ 13 | 14 | 15 | #include 16 | #ifdef __STDC__ 17 | #include 18 | #else 19 | #include 20 | #endif 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #ifdef DMALLOC 29 | #include 30 | #endif 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #if defined(_WIN32) && !defined(__CYGWIN__) 39 | #define random rand 40 | #define drand48() ((double)rand()/RAND_MAX) 41 | #define srand48(n) srand((n)); 42 | #endif 43 | -------------------------------------------------------------------------------- /graclus1.2/metisLib/mrefine2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1997, Regents of the University of Minnesota 3 | * 4 | * mrefine2.c 5 | * 6 | * This file contains the driving routines for multilevel refinement 7 | * 8 | * Started 7/24/97 9 | * George 10 | * 11 | * $Id: mrefine2.c,v 1.1 1998/11/27 17:59:26 karypis Exp $ 12 | */ 13 | 14 | #include 15 | 16 | 17 | /************************************************************************* 18 | * This function is the entry point of refinement 19 | **************************************************************************/ 20 | void MocRefine2Way2(CtrlType *ctrl, GraphType *orggraph, GraphType *graph, float *tpwgts, 21 | float *ubvec) 22 | { 23 | 24 | IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->UncoarsenTmr)); 25 | 26 | /* Compute the parameters of the coarsest graph */ 27 | MocCompute2WayPartitionParams(ctrl, graph); 28 | 29 | for (;;) { 30 | ASSERT(CheckBnd(graph)); 31 | 32 | IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->RefTmr)); 33 | switch (ctrl->RType) { 34 | case RTYPE_FM: 35 | MocBalance2Way2(ctrl, graph, tpwgts, ubvec); 36 | MocFM_2WayEdgeRefine2(ctrl, graph, tpwgts, ubvec, 8); 37 | break; 38 | default: 39 | errexit("Unknown refinement type: %d\n", ctrl->RType); 40 | } 41 | IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->RefTmr)); 42 | 43 | if (graph == orggraph) 44 | break; 45 | 46 | graph = graph->finer; 47 | IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->ProjectTmr)); 48 | MocProject2WayPartition(ctrl, graph); 49 | IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->ProjectTmr)); 50 | } 51 | 52 | IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->UncoarsenTmr)); 53 | } 54 | 55 | 56 | -------------------------------------------------------------------------------- /graclus1.2/metisLib/mutil.c: -------------------------------------------------------------------------------- 1 | /* 2 | * mutil.c 3 | * 4 | * This file contains various utility functions for the MOC portion of the 5 | * code 6 | * 7 | * Started 2/15/98 8 | * George 9 | * 10 | * $Id: mutil.c,v 1.1 1998/11/27 17:59:27 karypis Exp $ 11 | * 12 | */ 13 | 14 | #include 15 | 16 | 17 | /************************************************************************* 18 | * This function checks if the vertex weights of two vertices are below 19 | * a given set of values 20 | **************************************************************************/ 21 | int AreAllVwgtsBelow(int ncon, float alpha, float *vwgt1, float beta, float *vwgt2, float limit) 22 | { 23 | int i; 24 | 25 | for (i=0; i limit) 27 | return 0; 28 | 29 | return 1; 30 | } 31 | 32 | 33 | /************************************************************************* 34 | * This function checks if the vertex weights of two vertices are below 35 | * a given set of values 36 | **************************************************************************/ 37 | int AreAnyVwgtsBelow(int ncon, float alpha, float *vwgt1, float beta, float *vwgt2, float limit) 38 | { 39 | int i; 40 | 41 | for (i=0; i max) 79 | max = npwgts[j*ncon+i]; 80 | } 81 | if (max*nparts > lb) 82 | lb = max*nparts; 83 | } 84 | 85 | return lb; 86 | } 87 | 88 | /************************************************************************* 89 | * This function checks if the vertex weights of two vertices are below 90 | * a given set of values 91 | **************************************************************************/ 92 | int AreAllBelow(int ncon, float *v1, float *v2) 93 | { 94 | int i; 95 | 96 | for (i=0; i v2[i]) 98 | return 0; 99 | 100 | return 1; 101 | } 102 | -------------------------------------------------------------------------------- /graclus1.2/metisLib/timing.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1997, Regents of the University of Minnesota 3 | * 4 | * timing.c 5 | * 6 | * This file contains routines that deal with timing Metis 7 | * 8 | * Started 7/24/97 9 | * George 10 | * 11 | * $Id: timing.c,v 1.1 1998/11/27 17:59:32 karypis Exp $ 12 | * 13 | */ 14 | 15 | #include 16 | 17 | 18 | /************************************************************************* 19 | * This function clears the timers 20 | **************************************************************************/ 21 | void InitTimers(CtrlType *ctrl) 22 | { 23 | cleartimer(ctrl->TotalTmr); 24 | cleartimer(ctrl->InitPartTmr); 25 | cleartimer(ctrl->MatchTmr); 26 | cleartimer(ctrl->ContractTmr); 27 | cleartimer(ctrl->CoarsenTmr); 28 | cleartimer(ctrl->UncoarsenTmr); 29 | cleartimer(ctrl->RefTmr); 30 | cleartimer(ctrl->ProjectTmr); 31 | cleartimer(ctrl->SplitTmr); 32 | cleartimer(ctrl->SepTmr); 33 | cleartimer(ctrl->AuxTmr1); 34 | cleartimer(ctrl->AuxTmr2); 35 | cleartimer(ctrl->AuxTmr3); 36 | cleartimer(ctrl->AuxTmr4); 37 | cleartimer(ctrl->AuxTmr5); 38 | cleartimer(ctrl->AuxTmr6); 39 | } 40 | 41 | 42 | 43 | /************************************************************************* 44 | * This function prints the various timers 45 | **************************************************************************/ 46 | void PrintTimers(CtrlType *ctrl) 47 | { 48 | printf("\nTiming Information -------------------------------------------------"); 49 | printf("\n Multilevel: \t\t %7.3f", gettimer(ctrl->TotalTmr)); 50 | printf("\n Coarsening: \t\t %7.3f", gettimer(ctrl->CoarsenTmr)); 51 | printf("\n Matching: \t\t\t %7.3f", gettimer(ctrl->MatchTmr)); 52 | printf("\n Contract: \t\t\t %7.3f", gettimer(ctrl->ContractTmr)); 53 | printf("\n Initial Partition: \t %7.3f", gettimer(ctrl->InitPartTmr)); 54 | printf("\n Construct Separator: \t %7.3f", gettimer(ctrl->SepTmr)); 55 | printf("\n Uncoarsening: \t\t %7.3f", gettimer(ctrl->UncoarsenTmr)); 56 | printf("\n Refinement: \t\t\t %7.3f", gettimer(ctrl->RefTmr)); 57 | printf("\n Projection: \t\t\t %7.3f", gettimer(ctrl->ProjectTmr)); 58 | printf("\n Splitting: \t\t %7.3f", gettimer(ctrl->SplitTmr)); 59 | printf("\n AUX1: \t\t %7.3f", gettimer(ctrl->AuxTmr1)); 60 | printf("\n AUX2: \t\t %7.3f", gettimer(ctrl->AuxTmr2)); 61 | printf("\n AUX3: \t\t %7.3f", gettimer(ctrl->AuxTmr3)); 62 | printf("\n********************************************************************\n"); 63 | } 64 | 65 | 66 | /************************************************************************* 67 | * This function returns the seconds 68 | **************************************************************************/ 69 | double seconds(void) 70 | { 71 | return((double) clock()/CLOCKS_PER_SEC); 72 | } 73 | 74 | 75 | -------------------------------------------------------------------------------- /graclus1.2/multilevelLib/Makefile: -------------------------------------------------------------------------------- 1 | include ../Makefile.in 2 | 3 | INCLUDES = -I../metisLib -I/p/include 4 | 5 | CFLAGS = $(COPTIONS) $(OPTFLAGS) $(INCLUDES) 6 | LD = $(CC) -L. 7 | 8 | 9 | OBJS = wkkm.o mlkkm.o 10 | 11 | .c.o: 12 | $(CC) $(CFLAGS) -c $*.c 13 | 14 | ../libmultilevel.a: $(OBJS) 15 | $(AR) $@ $(OBJS) 16 | $(RANLIB) $@ 17 | 18 | clean: 19 | rm -f *.o 20 | 21 | realclean: 22 | rm -f *.o ; rm -f ../libmetis.a 23 | -------------------------------------------------------------------------------- /graclus1.2/programs/Makefile: -------------------------------------------------------------------------------- 1 | include ../Makefile.in 2 | 3 | BINDIR = .. 4 | 5 | INCLUDES = -I/p/include -I../multilevelLib -I../metisLib 6 | CFLAGS = $(COPTIONS) $(OPTFLAGS) $(INCLUDES) 7 | 8 | LIBS = -lmultilevel -lmetis -lm 9 | 10 | LD = $(CC) $(LDOPTIONS) -L/p/lib -L. -L.. 11 | METISLIB = ../libmetis.a ../libmultilevel.a 12 | 13 | MLKKMOBJS = graclus.o io.o 14 | 15 | 16 | .c.o: 17 | $(CC) $(CFLAGS) -c $*.c 18 | 19 | default: $(BINDIR)/graclus$(VERNUM) 20 | 21 | 22 | $(BINDIR)/graclus$(VERNUM): $(MLKKMOBJS) $(METISLIB) 23 | $(LD) -o $@ $(CFLAGS) $(MLKKMOBJS) $(LIBS) 24 | chmod 755 $@ 25 | 26 | 27 | 28 | clean: 29 | rm -f *.o 30 | 31 | realclean: 32 | rm -f *.o ;\ 33 | rm -f $(BINDIR)/graclus$(VERNUM) 34 | -------------------------------------------------------------------------------- /graclus1.2/programs/io.h: -------------------------------------------------------------------------------- 1 | int readClustering(char *, int *, int); 2 | void WriteCoarsestGraph(GraphType *graph, char *filename, int *wgtflag); 3 | void ReadCoarsestInit(GraphType *graph, char *filename, int *wgtflag); 4 | void ReadGraph(GraphType *graph, char *filename, int *wgtflag); 5 | -------------------------------------------------------------------------------- /pba/History.txt: -------------------------------------------------------------------------------- 1 | 1.0.5 2 | Fixed a bug (rarely happens) in CUDA kernel configuration 3 | * Symptom: ComputeJtE: invalid configuration argument(9) 4 | Triggers when npoint is within (2 * n * 65505 ~ 2 * n * 65535) for n >= 2 5 | Changed the CUDA error handling 6 | * from exit(0) to throw "error location string" 7 | Added Support for constraints of camera clusters having equal focal lengths 8 | * Call ParallelBA::SetFocalMask(cluster_id_for_each_camera, weight); 9 | * For example, a vector of 0 means all camera should have the same focal length. 10 | * For example, <0,0,1,1,1> gives two groups (0,1,2) and (3,4) for the constraint. 11 | Improved memory allocation 12 | * Reset device and deallocate all data when ReserveStorage(0, 0, 0); 13 | 14 | 1.0.4 15 | Added AVX-based implementation (Use Release_AVX for MSVC, or #define CPUPBA_USE_AVX) 16 | Added function ParallelBA_GetVersion for future changes. 17 | Fixed minor bug in the profiling program 18 | 19 | 1.0.3 20 | Added support of constant cameras (CameraT::SetConstantCamera) 21 | * Causes slight slow-down of standard pipeline 22 | * Can be disabled by defining PBA_DISABLE_CONST_CAMERA 23 | Automatic switching from GPU to CPU if CUDA is not supported 24 | * Will not switch back 25 | Fixed a problem with Windows DLL function name 26 | 27 | 1.0.2 28 | Choosing thread count accoding to the number of CPU cores. 29 | * This might be slightly better than the fixed parameters 30 | * This is still very heruristic and not really optimal. 31 | * The settings are still tunned for very large data. 32 | Added two additional Bundle Adjustment Modes (Motion only & Structure only) 33 | * Call ParallelBA::SetNextBundleMode() to set the mode 34 | 35 | 1.0.1 36 | Converted MSVC solution files to visual studio 2010 37 | Added the first draft of manual 38 | Added CMakeFile (Provided by Pierre Moulon) 39 | 40 | 1.0.0 (06/2011) 41 | The first release -------------------------------------------------------------------------------- /pba/bin/driver_x64.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/pba/bin/driver_x64.exe -------------------------------------------------------------------------------- /pba/bin/pba.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/pba/bin/pba.dll -------------------------------------------------------------------------------- /pba/bin/pba_x64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/pba/bin/pba_x64.dll -------------------------------------------------------------------------------- /pba/doc/manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/pba/doc/manual.pdf -------------------------------------------------------------------------------- /pba/doc/readme.txt: -------------------------------------------------------------------------------- 1 | Multicore Bundle Adjustment 2 | 3 | http://grail.cs.washington.edu/projects/mcba/ 4 | 5 | University of Washington at Seattle 6 | 7 | We present the design and implementation of new inexact Newton type Bundle 8 | Adjustment algorithms that exploit hardware parallelism for efficiently solving 9 | large scale 3D scene reconstruction problems. We explore the use of multicore 10 | CPU as well as multicore GPUs for this purpose. We show that overcoming the 11 | severe memory and bandwidth limitations of current generation GPUs not only 12 | leads to more space efficient algorithms, but also to surprising savings in runtime. 13 | Our CPU based system is up to ten times and our GPU based system is up to thirty 14 | times faster than the current state of the art methods, while maintaining 15 | comparable convergence behavior. 16 | 17 | #################################################################### 18 | The source code is released under GUN GENERAL PUBLIC LICENSE V3. 19 | Please contact ccwu@cs.washington.edu for commercial licensing. 20 | ################################################################# -------------------------------------------------------------------------------- /pba/makefile: -------------------------------------------------------------------------------- 1 | #To use AVX instead of SSE, you need to add -DCPUPBA_USE_AVX to CFLAGS 2 | ################################################################# 3 | 4 | CUDA_INSTALL_PATH = /usr/local/cuda 5 | CUDA_LIB_PATH = $(CUDA_INSTALL_PATH)/lib64 6 | ifdef CUDA_BIN_PATH 7 | NVCC = $(CUDA_BIN_PATH)/nvcc 8 | else 9 | NVCC = $(CUDA_INSTALL_PATH)/bin/nvcc 10 | endif 11 | ifndef CUDA_INC_PATH 12 | CUDA_INC_PATH = $(CUDA_INSTALL_PATH)/include 13 | endif 14 | ################################################################# 15 | 16 | # detect OS 17 | OSUPPER = $(shell uname -s 2>/dev/null | tr [:lower:] [:upper:]) 18 | OSLOWER = $(shell uname -s 2>/dev/null | tr [:upper:] [:lower:]) 19 | DARWIN = $(strip $(findstring DARWIN, $(OSUPPER))) 20 | 21 | 22 | SHELL = /bin/sh 23 | BIN_DIR = ./bin 24 | SRC_PBA = ./src/pba 25 | SRC_DRIVER = ./src/driver 26 | OUT_PBA = ./bin/out 27 | 28 | CC = g++ 29 | CFLAGS = -I$(CUDA_INC_PATH) -L$(CUDA_LIB_PATH) -fPIC -L/usr/lib64 -L/usr/lib -L$(BIN_DIR) -O2 -Wall -Wno-deprecated -pthread -march=native -mfpmath=sse -fpermissive 30 | NVCC_FLAGS = -I$(CUDA_INC_PATH) -O2 -Xcompiler -fPIC 31 | 32 | 33 | # siftgpu header files 34 | _HEADER_PBA = pba.h ConfigBA.h CuTexImage.h DataInterface.h ProgramCU.h SparseBundleCU.h 35 | _HEADER_PBA_LIB = pba.h 36 | _OBJ_PBA = pba.o CuTexImage.o ConfigBA.o SparseBundleCU.o SparseBundleCPU.o 37 | 38 | all: makepath pba driver 39 | 40 | #the dependencies of SiftGPU library 41 | DEPS_PBA = $(patsubst %, $(SRC_PBA)/%, $(_HEADER_PBA)) 42 | 43 | #rules for the rest of the object files 44 | $(OUT_PBA)/%.o: $(SRC_PBA)/%.cpp $(DEPS_PBA) 45 | $(CC) -o $@ $< $(CFLAGS) -c 46 | 47 | #build rule for CUDA 48 | $(OUT_PBA)/ProgramCU.o: $(SRC_PBA)/ProgramCU.cu $(DEPS_PBA) 49 | $(NVCC) $(NVCC_FLAGS) -o $@ $< -c 50 | _OBJ_PBA += ProgramCU.o 51 | 52 | OBJ_PBA = $(patsubst %,$(OUT_PBA)/%,$(_OBJ_PBA)) 53 | LIBS_DRIVER = $(BIN_DIR)/libpba.a $(LIBS_PBA) 54 | 55 | pba: makepath $(OBJ_PBA) 56 | ar rcs $(BIN_DIR)/libpba.a $(OBJ_PBA) 57 | $(CC) -o $(BIN_DIR)/libpba.so $(OBJ_PBA) $(LIBS_PBA) $(CFLAGS) -lcudart -shared -fPIC 58 | 59 | driver: makepath 60 | $(CC) -o $(BIN_DIR)/driver $(SRC_DRIVER)/driver.cpp -lpba -lcudart $(CFLAGS) 61 | 62 | makepath: 63 | mkdir -p $(OUT_PBA) 64 | mkdir -p $(BIN_DIR) 65 | 66 | clean: 67 | rm -f $(OUT_PBA)/*.o 68 | rm -f $(BIN_DIR)/libpba.a 69 | rm -f $(BIN_DIR)/libpba.so 70 | rm -f $(BIN_DIR)/driver 71 | 72 | 73 | -------------------------------------------------------------------------------- /pba/makefile_no_gpu: -------------------------------------------------------------------------------- 1 | #To use AVX instead of SSE, you need to add -DCPUPBA_USE_AVX to CFLAGS 2 | ################################################################# 3 | 4 | 5 | # detect OS 6 | OSUPPER = $(shell uname -s 2>/dev/null | tr [:lower:] [:upper:]) 7 | OSLOWER = $(shell uname -s 2>/dev/null | tr [:upper:] [:lower:]) 8 | DARWIN = $(strip $(findstring DARWIN, $(OSUPPER))) 9 | 10 | 11 | SHELL = /bin/sh 12 | BIN_DIR = ./bin 13 | SRC_PBA = ./src/pba 14 | SRC_DRIVER = ./src/driver 15 | OUT_PBA = ./bin/out_no_gpu 16 | 17 | CC = g++ 18 | CFLAGS = -DPBA_NO_GPU -fPIC -L/usr/lib64 -L/usr/lib -L$(BIN_DIR) -O2 -Wall -Wno-deprecated -pthread -march=native -mfpmath=sse -fpermissive 19 | 20 | 21 | # siftgpu header files 22 | _HEADER_PBA = pba.h ConfigBA.h CuTexImage.h DataInterface.h SparseBundleCU.h 23 | _HEADER_PBA_LIB = pba.h 24 | _OBJ_PBA = pba.o ConfigBA.o SparseBundleCPU.o 25 | 26 | all: makepath pba driver 27 | 28 | #the dependencies of SiftGPU library 29 | DEPS_PBA = $(patsubst %, $(SRC_PBA)/%, $(_HEADER_PBA)) 30 | 31 | #rules for the rest of the object files 32 | $(OUT_PBA)/%.o: $(SRC_PBA)/%.cpp $(DEPS_PBA) 33 | $(CC) -o $@ $< $(CFLAGS) -c 34 | 35 | 36 | OBJ_PBA = $(patsubst %,$(OUT_PBA)/%,$(_OBJ_PBA)) 37 | LIBS_DRIVER = $(BIN_DIR)/libpba_no_gpu.a $(LIBS_PBA) 38 | 39 | pba: makepath $(OBJ_PBA) 40 | ar rcs $(BIN_DIR)/libpba_no_gpu.a $(OBJ_PBA) 41 | $(CC) -o $(BIN_DIR)/libpba_no_gpu.so $(OBJ_PBA) $(LIBS_PBA) $(CFLAGS) -shared -fPIC 42 | 43 | driver: makepath 44 | $(CC) -o $(BIN_DIR)/driver_no_gpu $(SRC_DRIVER)/driver.cpp -lpba_no_gpu $(CFLAGS) 45 | 46 | makepath: 47 | mkdir -p $(OUT_PBA) 48 | mkdir -p $(BIN_DIR) 49 | 50 | clean: 51 | rm -f $(OUT_PBA)/*.o 52 | rm -f $(BIN_DIR)/libpba_no_gpu.a 53 | rm -f $(BIN_DIR)/libpba_no_gpu.so 54 | rm -f $(BIN_DIR)/driver_no_gpu 55 | 56 | 57 | -------------------------------------------------------------------------------- /pba/msvc/pba.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/pba/msvc/pba.suo -------------------------------------------------------------------------------- /pba/msvc/pba/pba.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | NewParallelBA @1 3 | ParallelBA_GetVersion 4 | -------------------------------------------------------------------------------- /pba/src/pba/CuTexImage.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: CuTexImage.h 3 | // Author: Changchang Wu 4 | // Description : interface for the CuTexImage class. 5 | // class for storing data in CUDA. 6 | // 7 | // Copyright (c) 2011 Changchang Wu (ccwu@cs.washington.edu) 8 | // and the University of Washington at Seattle 9 | // 10 | // This library is free software; you can redistribute it and/or 11 | // modify it under the terms of the GNU General Public 12 | // License as published by the Free Software Foundation; either 13 | // Version 3 of the License, or (at your option) any later version. 14 | // 15 | // This library is distributed in the hope that it will be useful, 16 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | // General Public License for more details. 19 | // 20 | //////////////////////////////////////////////////////////////////////////////// 21 | 22 | #ifndef CU_TEX_IMAGE_H 23 | #define CU_TEX_IMAGE_H 24 | struct textureReference; 25 | 26 | class CuTexImage 27 | { 28 | protected: 29 | bool _owner; 30 | void* _cuData; 31 | unsigned int _numChannel; 32 | unsigned int _imgWidth; 33 | unsigned int _imgHeight; 34 | size_t _numBytes; 35 | public: 36 | bool InitTexture(unsigned int width, unsigned int height, unsigned int nchannel = 1); 37 | void SetTexture(void* data, unsigned int width, unsigned int nchannel = 1); 38 | void BindTexture(textureReference& texRef); 39 | void BindTexture(textureReference& texRef, int offset, size_t size); 40 | void BindTexture2(textureReference& texRef1, textureReference& texRef2); 41 | void BindTexture4(textureReference& texRef1, textureReference& texRef2, 42 | textureReference& texRef3, textureReference& texRef4); 43 | int BindTextureX(textureReference& texRef1, textureReference& texRef2, 44 | textureReference& texRef3, textureReference& texRef4, bool force4); 45 | void SwapData(CuTexImage & src); 46 | void CopyToHost(void* buf); 47 | void CopyFromDevice(const void* buf); 48 | void CopyFromHost(const void* buf); 49 | void SaveToFile(const char* name); 50 | void ReleaseData(); 51 | public: 52 | inline float* data() {return GetRequiredSize()? ((float*) _cuData) : NULL; } 53 | inline bool IsValid() {return _cuData!= NULL && GetDataSize() > 0 ; } 54 | inline unsigned int GetLength() {return _imgWidth * _imgHeight * _numChannel; } 55 | inline unsigned int GetImgWidth() {return _imgWidth;} 56 | inline unsigned int GetImgHeight() {return _imgHeight;} 57 | inline size_t GetReservedWidth() {return _numBytes == 0 ? 0 : (_numBytes / (_imgHeight * _numChannel * sizeof(float))); } 58 | inline size_t GetDataSize() {return _numBytes == 0? 0 : GetRequiredSize() ;} 59 | inline size_t GetRequiredSize() {return sizeof(float)* _imgWidth * _imgHeight * _numChannel ;} 60 | inline unsigned int IsHugeData() {return (GetLength() - 1) / (1 << 27);} 61 | public: 62 | CuTexImage(); 63 | virtual ~CuTexImage(); 64 | }; 65 | 66 | #endif // !defined(CU_TEX_IMAGE_H) 67 | 68 | -------------------------------------------------------------------------------- /pmvs-2/license/libgfx-license.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | libgfx: License 9 | 10 | 11 | 12 | 13 | 14 | 15 |

License

16 | 17 | 18 |

Copyright Notice 19 |

20 | Copyright © 1999–2001 Michael Garland. All rights reserved. 21 |
22 | 23 |

Terms and Conditions 24 | 25 |

Permission is hereby granted, free of charge, to any person obtaining a 26 | copy of this software and associated documentation files (the 27 | "Software"), to deal in the Software without restriction, including 28 | without limitation the rights to use, copy, modify, merge, publish, 29 | distribute, and/or sell copies of the Software, and to permit persons 30 | to whom the Software is furnished to do so, provided that the above 31 | copyright notice(s) and this permission notice appear in all copies of 32 | the Software and that both the above copyright notice(s) and this 33 | permission notice appear in supporting documentation. 34 | 35 |

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 36 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 37 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 38 | OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 39 | HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL 40 | INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING 41 | FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 42 | NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 43 | WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 44 | 45 |

Except as contained in this notice, the name of a copyright holder 46 | shall not be used in advertising or otherwise to promote the sale, use 47 | or other dealings in this Software without prior written authorization 48 | of the copyright holder. 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /pmvs-2/program/base/image/photo.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGE_PHOTO_H 2 | #define IMAGE_PHOTO_H 3 | 4 | #include "../numeric/vec4.h" 5 | #include "image.h" 6 | #include "camera.h" 7 | 8 | namespace Image { 9 | 10 | // Cphoto is an image with camera parameters 11 | class Cphoto : public Cimage, public Ccamera { 12 | public: 13 | Cphoto(void); 14 | virtual ~Cphoto(); 15 | 16 | virtual void init(const std::string name, const std::string mname, 17 | const std::string cname, const int maxLevel = 1); 18 | 19 | virtual void init(const std::string name, const std::string mname, 20 | const std::string ename, 21 | const std::string cname, const int maxLevel = 1); 22 | 23 | // grabTex given 2D sampling information 24 | void grabTex(const int level, const Vec2f& icoord, 25 | const Vec2f& xaxis, const Vec2f& yaxis, const int size, 26 | std::vector& tex, const int normalizef = 1) const; 27 | 28 | // grabTex given 3D sampling information 29 | void grabTex(const int level, const Vec4f& coord, 30 | const Vec4f& pxaxis, const Vec4f& pyaxis, const Vec4f& pzaxis, 31 | const int size, std::vector& tex, float& weight, 32 | const int normalizef = 1) const; 33 | 34 | 35 | inline Vec3f getColor(const float fx, const float fy, const int level) const; 36 | inline Vec3f getColor(const Vec4f& coord, const int level) const; 37 | inline int getMask(const Vec4f& coord, const int level) const; 38 | inline int getEdge(const Vec4f& coord, const int level) const; 39 | 40 | static float idot(const std::vector& tex0, 41 | const std::vector& tex1); 42 | 43 | static void idotC(const std::vector& tex0, 44 | const std::vector& tex1, double* idc); 45 | 46 | static void normalize(std::vector& tex); 47 | 48 | static float ssd(const std::vector& tex0, 49 | const std::vector& tex1); 50 | protected: 51 | }; 52 | 53 | Vec3f Cphoto::getColor(const float fx, const float fy, const int level) const { 54 | return Cimage::getColor(fx, fy, level); 55 | }; 56 | 57 | Vec3f Cphoto::getColor(const Vec4f& coord, const int level) const { 58 | const Vec3f icoord = project(coord, level); 59 | return Cimage::getColor(icoord[0], icoord[1], level); 60 | }; 61 | 62 | int Cphoto::getMask(const Vec4f& coord, const int level) const { 63 | if (m_masks[level].empty()) 64 | return 1; 65 | 66 | const Vec3f icoord = project(coord, level); 67 | return Cimage::getMask(icoord[0], icoord[1], level); 68 | }; 69 | 70 | int Cphoto::getEdge(const Vec4f& coord, const int level) const { 71 | if (m_edges[level].empty()) 72 | return 1; 73 | 74 | const Vec3f icoord = project(coord, level); 75 | 76 | if (icoord[0] < 0 || m_widths[level] - 1 <= icoord[0] || 77 | icoord[1] < 0 || m_heights[level] - 1 <= icoord[1]) 78 | return 0; 79 | 80 | return Cimage::getEdge(icoord[0], icoord[1], level); 81 | }; 82 | 83 | }; 84 | 85 | #endif // PHOTO_H 86 | -------------------------------------------------------------------------------- /pmvs-2/program/base/numeric/mylapack.h: -------------------------------------------------------------------------------- 1 | #ifndef NUMERIC_MYLAPACK_H 2 | #define NUMERIC_MYLAPACK_H 3 | 4 | #include 5 | 6 | class Cmylapack { 7 | public: 8 | 9 | 10 | // Solve Ax = 0. 11 | // Values contain singular values stored in an increasing order 12 | static void hlls(const std::vector >& A, 13 | std::vector& vec, 14 | std::vector& values); 15 | 16 | static void hlls(const std::vector >& A, 17 | std::vector& vec, 18 | std::vector& values); 19 | 20 | // Solve Ax = b 21 | static void lls(const std::vector >& A, 22 | const std::vector& b, 23 | std::vector& x); 24 | 25 | static void lls(const std::vector >& A, 26 | const std::vector& b, 27 | std::vector& x); 28 | 29 | static void lls(std::vector& A, 30 | std::vector& b, 31 | long int width, long int height); 32 | 33 | static void lls(std::vector& A, 34 | std::vector& b, 35 | long int width, long int height); 36 | 37 | // SVD 38 | // A = U Sigma V^T 39 | static void svd(const std::vector >& A, 40 | std::vector >& U, 41 | std::vector >& VT, 42 | std::vector& S); 43 | 44 | }; 45 | 46 | #endif // NUMERIC_MYLAPACK_H 47 | -------------------------------------------------------------------------------- /pmvs-2/program/base/pmvs/detectFeatures.h: -------------------------------------------------------------------------------- 1 | #ifndef PMVS3_DETECTFEATURES_H 2 | #define PMVS3_DETECTFEATURES_H 3 | 4 | /* 5 | * A main class to detect features 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include "../image/photoSetS.h" 12 | #include "point.h" 13 | 14 | namespace Image { 15 | class CphotoSetS; 16 | }; 17 | 18 | namespace PMVS3 { 19 | 20 | class CdetectFeatures { 21 | public: 22 | CdetectFeatures(void); 23 | virtual ~CdetectFeatures(); 24 | 25 | void run(const Image::CphotoSetS& pss, 26 | const int num, const int csize, const int level, 27 | const int CPU = 1); 28 | 29 | std::vector > m_points; 30 | 31 | protected: 32 | const Image::CphotoSetS* m_ppss; 33 | int m_csize; 34 | int m_level; 35 | 36 | //---------------------------------------------------------------------- 37 | // thread related 38 | //---------------------------------------------------------------------- 39 | pthread_rwlock_t m_rwlock; 40 | int m_CPU; 41 | 42 | std::list m_jobs; 43 | 44 | void runThread(void); 45 | static void* runThreadTmp(void*arg); 46 | }; 47 | }; 48 | 49 | #endif // PMVS3_DETECTFEATURES_H 50 | -------------------------------------------------------------------------------- /pmvs-2/program/base/pmvs/detector.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "point.h" 3 | #include "detector.h" 4 | 5 | using namespace PMVS3; 6 | using namespace std; 7 | 8 | void Cdetector::setGaussD(const float sigmaD, std::vector& gaussD) { 9 | //---------------------------------------------------------------------- 10 | const int marginD = (int)ceil(2 * sigmaD); 11 | const int sizeD = 2 * marginD + 1; 12 | 13 | gaussD.resize(sizeD); 14 | 15 | //---------------------------------------------------------------------- 16 | // set m_gaussD 17 | float denom = 0.0; 18 | for (int x = 0; x < sizeD; ++x) { 19 | int xtmp = x - marginD; 20 | const float dtmp = xtmp * exp(- (xtmp * xtmp) / (2 * sigmaD * sigmaD)); 21 | gaussD[x] = dtmp; 22 | if (0.0 < dtmp) 23 | denom += dtmp; 24 | } 25 | 26 | for (int x = 0; x < sizeD; ++x) 27 | gaussD[x] /= denom; 28 | } 29 | 30 | void Cdetector::setGaussI(const float sigmaI, std::vector& gaussI) { 31 | const int marginI = (int)ceil(2 * sigmaI); 32 | const int sizeI = 2 * marginI + 1; 33 | 34 | gaussI.resize(sizeI); 35 | 36 | //---------------------------------------------------------------------- 37 | // set m_gaussI 38 | float denom = 0.0; 39 | for (int x = 0; x < sizeI; ++x) { 40 | int xtmp = x - marginI; 41 | const float dtmp = exp(- (xtmp * xtmp) / (2 * sigmaI * sigmaI)); 42 | gaussI[x] = dtmp; 43 | denom += dtmp; 44 | } 45 | for (int x = 0; x < sizeI; ++x) 46 | gaussI[x] /= denom; 47 | } 48 | 49 | 50 | float Cdetector::setThreshold(std::multiset& grid) { 51 | float ave = 0.0; 52 | float ave2 = 0.0; 53 | multiset::iterator begin = grid.begin(); 54 | multiset::iterator end = grid.end(); 55 | int count = 0; 56 | while (begin != end) { 57 | count++; 58 | ave += begin->m_response; 59 | ave2 += begin->m_response * begin->m_response; 60 | begin++; 61 | } 62 | if (count == 0) 63 | count = 1; 64 | ave /= count; ave2 /= count; 65 | ave2 = sqrt(max(0.0f, ave2 - ave * ave)); 66 | const float threshold = ave + ave2; 67 | 68 | //cout << ave << ' ' << ave2 << endl; 69 | 70 | return threshold; 71 | } 72 | 73 | int Cdetector::isCloseBoundary(const int x, const int y, const int margin) const { 74 | if (m_mask.empty()) 75 | return 0; 76 | 77 | if (x - margin < 0 || m_width <= x + margin || 78 | y - margin < 0 || m_height <= y + margin) 79 | return 1; 80 | 81 | for (int j = -margin; j <= margin; ++j) { 82 | const int ytmp = y + j; 83 | for (int i = -margin; i <= margin; ++i) { 84 | const int xtmp = x + i; 85 | 86 | if (m_mask[ytmp][xtmp] == 0) 87 | return 1; 88 | } 89 | } 90 | return 0; 91 | } 92 | -------------------------------------------------------------------------------- /pmvs-2/program/base/pmvs/dog.h: -------------------------------------------------------------------------------- 1 | #ifndef PMVS3_DOG_H 2 | #define PMVS3_DOG_H 3 | 4 | #include 5 | #include 6 | #include "../numeric/vec3.h" 7 | #include "detector.h" 8 | #include "point.h" 9 | 10 | namespace PMVS3 { 11 | class Cdog: public Cdetector { 12 | public: 13 | void run (const std::vector& image, 14 | const std::vector& mask, 15 | const std::vector& edge, 16 | const int width, const int height, 17 | const int gspeedup, 18 | const float firstScale, // 1.4f 19 | const float lastScale, // 4.0f 20 | std::multiset & result); 21 | 22 | virtual ~Cdog() { 23 | } 24 | 25 | protected: 26 | float m_firstScale; 27 | float m_lastScale; 28 | 29 | void init(const std::vector& image, 30 | const std::vector& mask, 31 | const std::vector& edge); 32 | 33 | void setRes(const float sigma, 34 | std::vector >& res); 35 | 36 | static int isLocalMax(const std::vector >& pdog, 37 | const std::vector >& cdog, 38 | const std::vector >& ndog, 39 | const int x, const int y); 40 | 41 | static int isLocalMax(const std::vector >& dog, 42 | const int x, const int y); 43 | 44 | static int notOnEdge(const std::vector >& dog, int x, int y); 45 | 46 | static float getResponse(const std::vector >& pdog, 47 | const std::vector >& cdog, 48 | const std::vector >& ndog, 49 | const int x, const int y); 50 | 51 | static float getResponse(const std::vector >& dog, 52 | const int x, const int y); 53 | 54 | static void setDOG(const std::vector >& cres, 55 | const std::vector >& nres, 56 | std::vector >& dog); 57 | 58 | }; 59 | }; 60 | #endif // DOG_H 61 | -------------------------------------------------------------------------------- /pmvs-2/program/base/pmvs/expand.h: -------------------------------------------------------------------------------- 1 | #ifndef PMVS3_EXPAND_H 2 | #define PMVS3_EXPAND_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "patchOrganizerS.h" 8 | 9 | namespace PMVS3 { 10 | class CfindMatch; 11 | 12 | class Cexpand { 13 | public: 14 | Cexpand(CfindMatch& findMatch); 15 | ~Cexpand() {}; 16 | 17 | void init(void); 18 | void run(void); 19 | 20 | float computeRadius(const Patch::Cpatch& patch); 21 | 22 | protected: 23 | int expandSub(const Patch::Ppatch& orgppatch, const int id, 24 | const Vec4f& canCoord); 25 | 26 | int updateCounts(const Patch::Cpatch& patch); 27 | 28 | int checkCounts(Patch::Cpatch& patch); 29 | 30 | void findEmptyBlocks(const Patch::Ppatch& ppatch, 31 | std::vector >& canCoords); 32 | protected: 33 | 34 | std::priority_queue, P_compare> 35 | m_queue; 36 | 37 | CfindMatch& m_fm; 38 | 39 | //----------------------------------------------------------------- 40 | // thread related 41 | //----------------------------------------------------------------- 42 | void expandThread(void); 43 | static void* expandThreadTmp(void* arg); 44 | 45 | // Number of trials 46 | std::vector m_ecounts; 47 | // Number of failures in the prep 48 | std::vector m_fcounts0; 49 | // Number of failures in the post processing 50 | std::vector m_fcounts1; 51 | // Number passes 52 | std::vector m_pcounts; 53 | }; 54 | }; 55 | 56 | #endif // PMVS3_EXPAND_H 57 | -------------------------------------------------------------------------------- /pmvs-2/program/base/pmvs/filter.h: -------------------------------------------------------------------------------- 1 | #ifndef PMVS3_FILTER_H 2 | #define PMVS3_FILTER_H 3 | 4 | #include "patch.h" 5 | #include 6 | #include "../numeric/vec2.h" 7 | 8 | namespace PMVS3 { 9 | 10 | class CfindMatch; 11 | 12 | class Cfilter { 13 | public: 14 | Cfilter(CfindMatch& findMatch); 15 | 16 | void init(void); 17 | void run(void); 18 | 19 | float computeGain(const Patch::Cpatch& patch, const int lock); 20 | 21 | int filterQuad(const Patch::Cpatch& patch, 22 | const std::vector& neighbors) const; 23 | 24 | 25 | protected: 26 | void filterOutside(void); 27 | void filterOutsideThread(void); 28 | static void* filterOutsideThreadTmp(void* arg); 29 | 30 | void filterExact(void); 31 | void filterExactThread(void); 32 | static void* filterExactThreadTmp(void* arg); 33 | 34 | void filterNeighbor(const int time); 35 | void filterSmallGroups(void); 36 | void filterSmallGroupsSub(const int pid, const int id, 37 | std::vector& label, 38 | std::list& ltmp) const; 39 | void setDepthMaps(void); 40 | void setDepthMapsVGridsVPGridsAddPatchV(const int additive); 41 | 42 | void setConf(const int image); 43 | 44 | std::vector m_gains; 45 | 46 | std::vector > m_newimages, m_removeimages; 47 | std::vector > > m_newgrids, m_removegrids; 48 | 49 | int m_time; 50 | std::vector m_rejects; 51 | 52 | //---------------------------------------------------------------------- 53 | // Thread related 54 | //---------------------------------------------------------------------- 55 | void setDepthMapsThread(void); 56 | static void* setDepthMapsThreadTmp(void* arg); 57 | 58 | void addPatchVThread(void); 59 | static void* addPatchVThreadTmp(void* arg); 60 | 61 | void setVGridsVPGridsThread(void); 62 | static void* setVGridsVPGridsThreadTmp(void* arg); 63 | 64 | void filterNeighborThread(void); 65 | static void* filterNeighborThreadTmp(void* arg); 66 | 67 | CfindMatch& m_fm; 68 | 69 | }; 70 | }; 71 | 72 | #endif // PMVS3_FILTER_H 73 | -------------------------------------------------------------------------------- /pmvs-2/program/base/pmvs/harris.h: -------------------------------------------------------------------------------- 1 | #ifndef PMVS3_HARRIS_H 2 | #define PMVS3_HARRIS_H 3 | 4 | #include 5 | #include 6 | #include "../numeric/vec3.h" 7 | #include "detector.h" 8 | #include "point.h" 9 | 10 | namespace PMVS3 { 11 | 12 | class Charris: public Cdetector { 13 | public: 14 | void run(const std::vector& image, 15 | const std::vector& mask, 16 | const std::vector& edge, 17 | const int width, const int height, 18 | const int gspeedup, const float sigma, 19 | std::multiset & result); 20 | 21 | virtual ~Charris() { 22 | } 23 | 24 | protected: 25 | float m_sigmaD; 26 | float m_sigmaI; 27 | 28 | std::vector m_gaussD; 29 | std::vector m_gaussI; 30 | 31 | std::vector > m_dIdx; 32 | std::vector > m_dIdy; 33 | 34 | std::vector > m_dIdxdIdx; 35 | std::vector > m_dIdydIdy; 36 | std::vector > m_dIdxdIdy; 37 | 38 | std::vector > m_response; 39 | 40 | void init(const std::vector& image, 41 | const std::vector& mask, 42 | const std::vector& edge); 43 | 44 | void setDerivatives(void); 45 | void preprocess(void); 46 | void preprocess2(void); 47 | void setResponse(void); 48 | }; 49 | }; 50 | 51 | #endif // PMVS3_HARRIS_H 52 | -------------------------------------------------------------------------------- /pmvs-2/program/base/pmvs/option.h: -------------------------------------------------------------------------------- 1 | #ifndef PMVS3_OPTION_H 2 | #define PMVS3_OPTION_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace PMVS3 { 9 | 10 | struct Soption{ 11 | public: 12 | int m_level; 13 | int m_csize; 14 | float m_threshold; 15 | int m_wsize; 16 | int m_minImageNum; 17 | int m_CPU; 18 | float m_setEdge; 19 | int m_useBound; 20 | int m_useVisData; 21 | int m_sequence; 22 | 23 | float m_maxAngleThreshold; 24 | float m_quadThreshold; 25 | 26 | std::string m_prefix; 27 | std::string m_option; 28 | int m_tflag; 29 | std::vector m_timages; 30 | int m_oflag; 31 | std::vector m_oimages; 32 | 33 | std::map m_dict; 34 | 35 | std::vector m_bindexes; 36 | std::vector > m_visdata; 37 | std::vector > m_visdata2; 38 | 39 | Soption(void); 40 | 41 | void init(const std::string prefix, const std::string option); 42 | 43 | protected: 44 | void initOimages(void); 45 | void initBindexes(const std::string sbimages); 46 | void initVisdata(void); 47 | void initVisdata2(void); 48 | }; 49 | }; 50 | 51 | #endif // PMVS3_OPTION_H 52 | -------------------------------------------------------------------------------- /pmvs-2/program/base/pmvs/patch.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../numeric/vec4.h" 3 | #include "patch.h" 4 | 5 | using namespace std; 6 | 7 | std::istream& Patch::operator >>(std::istream& istr, Cpatch& rhs) { 8 | string header; 9 | int itmp; 10 | istr >> header >> rhs.m_coord >> rhs.m_normal >> rhs.m_ncc 11 | >> rhs.m_dscale >> rhs.m_ascale; 12 | 13 | if (header == "PATCHA") { 14 | int type; Vec4f dir; 15 | istr >> type >> dir; 16 | } 17 | 18 | istr >> itmp; 19 | rhs.m_images.resize(itmp); 20 | for (int i = 0; i < itmp; ++i) 21 | istr >> rhs.m_images[i]; 22 | 23 | istr >> itmp; 24 | rhs.m_vimages.resize(itmp); 25 | for (int i = 0; i < itmp; ++i) 26 | istr >> rhs.m_vimages[i]; 27 | 28 | return istr; 29 | } 30 | 31 | std::ostream& Patch::operator <<(std::ostream& ostr, const Cpatch& rhs) { 32 | ostr << "PATCHS" << endl 33 | << rhs.m_coord << endl 34 | << rhs.m_normal << endl 35 | << rhs.m_ncc << ' ' 36 | << rhs.m_dscale << ' ' 37 | << rhs.m_ascale << endl 38 | << (int)rhs.m_images.size() << endl; 39 | for (int i = 0; i < (int)rhs.m_images.size(); ++i) 40 | ostr << rhs.m_images[i] << ' '; 41 | ostr << endl; 42 | 43 | ostr << (int)rhs.m_vimages.size() << endl; 44 | for (int i = 0; i < (int)rhs.m_vimages.size(); ++i) 45 | ostr << rhs.m_vimages[i] << ' '; 46 | ostr << endl; 47 | 48 | return ostr; 49 | } 50 | -------------------------------------------------------------------------------- /pmvs-2/program/base/pmvs/patch.h: -------------------------------------------------------------------------------- 1 | #ifndef PMVS3_PATCH_H 2 | #define PMVS3_PATCH_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "../numeric/vec4.h" 8 | 9 | namespace Patch { 10 | 11 | class Cpatch { 12 | public: 13 | Cpatch(void) { 14 | m_ncc = -1.0; 15 | m_timages = 0; 16 | m_fix = 0; 17 | // dflag is initialized only once. if failed in one direction, we 18 | // never try that. 19 | m_dflag = 0; 20 | } 21 | 22 | //---------------------------------------------------------------------- 23 | // saved information 24 | // 3D coordinates of the center of the patch 25 | Vec4f m_coord; 26 | // patch outward normal vector 27 | Vec4f m_normal; 28 | 29 | // associated image ids. first image id is the reference one. images 30 | // can be non-targetting image. 31 | std::vector m_images; 32 | std::vector > m_grids; 33 | 34 | // visible images. m_vimages must be targetting images. 35 | std::vector m_vimages; 36 | std::vector > m_vgrids; 37 | 38 | //---------------------------------------------------------------------- 39 | inline float score(const float threshold) const{ 40 | return std::max(0.0f, m_ncc - threshold) * (int)m_images.size(); 41 | } 42 | inline float score2(const float threshold) const{ 43 | return std::max(0.0f, m_ncc - threshold) * m_timages; 44 | } 45 | 46 | // average ncc 47 | float m_ncc; 48 | // number of targetting images in m_images 49 | int m_timages; 50 | 51 | // flat for expansion 52 | // 0: not yet tested 53 | // 1: done 54 | int m_flag; 55 | 56 | // for directional flag 57 | unsigned char m_dflag; 58 | 59 | // fixed patch or not 60 | char m_fix; 61 | 62 | // id number in m_ppatches 63 | int m_id; 64 | 65 | // scaling factor corresponding to one pixel difference 66 | float m_dscale; 67 | float m_ascale; 68 | 69 | float m_tmp; 70 | }; 71 | 72 | typedef boost::shared_ptr Ppatch; 73 | 74 | struct Spatchcmp { 75 | bool operator()(const Ppatch& lhs, const Ppatch& rhs) { 76 | if (lhs.get() < rhs.get()) 77 | return true; 78 | else 79 | return false; 80 | } 81 | }; 82 | 83 | std::istream& operator >>(std::istream& istr, Patch::Cpatch& rhs); 84 | std::ostream& operator <<(std::ostream& ostr, const Patch::Cpatch& rhs); 85 | 86 | }; 87 | 88 | #endif // PMVS3_PATCH_H 89 | -------------------------------------------------------------------------------- /pmvs-2/program/base/pmvs/point.cc: -------------------------------------------------------------------------------- 1 | #include "point.h" 2 | 3 | using namespace PMVS3; 4 | using namespace std; 5 | 6 | Cpoint::Cpoint(void) { 7 | m_response = -1.0; 8 | m_type = -1; 9 | } 10 | 11 | Cpoint::~Cpoint() { 12 | } 13 | 14 | std::istream& PMVS3::operator >>(std::istream& istr, Cpoint& rhs) { 15 | string header; 16 | istr >> header; 17 | istr >> rhs.m_icoord[0] >> rhs.m_icoord[1] >> rhs.m_response >> rhs.m_type; 18 | rhs.m_icoord[2] = 1.0f; 19 | return istr; 20 | } 21 | 22 | std::ostream& PMVS3::operator <<(std::ostream& ostr, const Cpoint& rhs) { 23 | ostr << "POINT0" << endl 24 | << rhs.m_icoord[0] << ' ' << rhs.m_icoord[1] << ' ' << rhs.m_response << ' ' 25 | << rhs.m_type; 26 | return ostr; 27 | } 28 | -------------------------------------------------------------------------------- /pmvs-2/program/base/pmvs/point.h: -------------------------------------------------------------------------------- 1 | #ifndef PMVS3_POINT_H 2 | #define PMVS3_POINT_H 3 | 4 | #include "../numeric/vec4.h" 5 | #include "../numeric/mat3.h" 6 | 7 | namespace PMVS3 { 8 | class Cpoint { 9 | public: 10 | Cpoint(void); 11 | virtual ~Cpoint(); 12 | 13 | Vec3f m_icoord; 14 | float m_response; 15 | 16 | // 0: Harris 17 | // 1: DoG 18 | int m_type; 19 | 20 | // tempporary variable, used to store original imageid in initial match 21 | int m_itmp; 22 | 23 | // 3D coordinate 24 | Vec4f m_coord; 25 | 26 | bool operator < (const Cpoint& rhs) const { 27 | return m_response < rhs.m_response; 28 | } 29 | 30 | friend std::istream& operator >>(std::istream& istr, Cpoint& rhs); 31 | friend std::ostream& operator <<(std::ostream& ostr, const Cpoint& rhs); 32 | }; 33 | 34 | std::istream& operator >>(std::istream& istr, Cpoint& rhs); 35 | std::ostream& operator <<(std::ostream& ostr, const Cpoint& rhs); 36 | }; 37 | 38 | #endif //PMVS3_POINT_H 39 | -------------------------------------------------------------------------------- /pmvs-2/program/base/pmvs/seed.h: -------------------------------------------------------------------------------- 1 | #ifndef PMVS3_SEED_H 2 | #define PMVS3_SEED_H 3 | 4 | #include 5 | #include 6 | #include "patch.h" 7 | #include "point.h" 8 | 9 | #include 10 | 11 | namespace PMVS3 { 12 | class CfindMatch; 13 | typedef boost::shared_ptr Ppoint; 14 | 15 | class Cseed { 16 | public: 17 | Cseed(CfindMatch& findMatch); 18 | virtual ~Cseed() {}; 19 | 20 | void init(const std::vector >& points); 21 | void run(void); 22 | void clear(void); 23 | 24 | protected: 25 | void readPoints(const std::vector >& points); 26 | int canAdd(const int index, const int x, const int y); 27 | 28 | void initialMatch(const int index, const int id); 29 | void collectCells(const int index0, const int index1, 30 | const Cpoint& p0, std::vector& cells); 31 | 32 | void collectCandidates(const int index, const std::vector& indexes, 33 | const Cpoint& point, std::vector& vcp); 34 | 35 | int initialMatchSub(const int index0, const int index1, 36 | const int id, Patch::Cpatch& patch); 37 | 38 | void unproject(const int index0, const int index1, 39 | const Cpoint& p0, const Cpoint& p1, 40 | Vec4f& coord) const; 41 | 42 | //---------------------------------------------------------------------- 43 | CfindMatch& m_fm; 44 | // points in a grid. For each index, grid 45 | std::vector > > m_ppoints; 46 | 47 | //---------------------------------------------------------------------- 48 | // thread related 49 | //---------------------------------------------------------------------- 50 | void initialMatchThread(void); 51 | static void* initialMatchThreadTmp(void* arg); 52 | 53 | // Number of trials 54 | std::vector m_scounts; 55 | // Number of failures in the prep 56 | std::vector m_fcounts0; 57 | // Number of failures in the post processing 58 | std::vector m_fcounts1; 59 | // Number passes 60 | std::vector m_pcounts; 61 | }; 62 | }; 63 | 64 | #endif // PMVS3_SEED_H 65 | -------------------------------------------------------------------------------- /pmvs-2/program/main/Makefile: -------------------------------------------------------------------------------- 1 | ###################################################################### 2 | # 3 | # The following 2 commands to compile pmvs2. 4 | # > make depend 5 | # > make 6 | # 7 | ###################################################################### 8 | CXX = g++ 9 | 10 | 11 | # Your INCLUDE path (e.g., -I/usr/include) 12 | YOURINCLUDEPATH = 13 | 14 | # Your LDLIBRARY path (e.g., -L/usr/lib) 15 | YOURLDLIBPATH = 16 | 17 | CXXFLAGS = -O2 -Wall -Wno-deprecated ${YOURINCLUDEPATH} 18 | 19 | LDFLAGS = ${YOURLDLIBPATH} -lXext -lX11 -ljpeg -lm -lpthread \ 20 | -llapack -lgsl -lgslcblas 21 | 22 | ###################################################################### 23 | all: pmvs2 24 | 25 | pmvs2: pmvs2.o detectFeatures.o dog.o harris.o point.o detector.o \ 26 | findMatch.o detector.o expand.o filter.o optim.o \ 27 | patchOrganizerS.o seed.o point.o option.o \ 28 | image.o camera.o photoSetS.o patch.o photo.o \ 29 | mylapack.o 30 | ${CXX} ${LDFLAGS} -o $@ $^ ${LDFLAGS} 31 | 32 | %.o : ../base/pmvs/%.cc 33 | $(CXX) -c $(CXXFLAGS) $< 34 | 35 | %.o : ../base/image/%.cc 36 | $(CXX) -c $(CXXFLAGS) $< 37 | 38 | %.o : ../base/numeric/%.cc 39 | $(CXX) -c $(CXXFLAGS) $< 40 | 41 | ###################################################################### 42 | # general commands 43 | clean: 44 | /bin/rm -f core core.* *.o ${TARGET} 45 | 46 | depend: 47 | rm -f Dependencies 48 | for SOURCEFILE in `ls *.cc ../base/*/*.cc ../base/*/*.c ../base/*/*.C ../base/*/*.f`; do \ 49 | echo $$SOURCEFILE; \ 50 | $(CXX) -MM $(CXXFLAGS) $$SOURCEFILE >> Dependencies; \ 51 | done 52 | 53 | -include Dependencies 54 | -------------------------------------------------------------------------------- /pmvs-2/program/main/camera.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/pmvs-2/program/main/camera.o -------------------------------------------------------------------------------- /pmvs-2/program/main/detectFeatures.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/pmvs-2/program/main/detectFeatures.o -------------------------------------------------------------------------------- /pmvs-2/program/main/detector.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/pmvs-2/program/main/detector.o -------------------------------------------------------------------------------- /pmvs-2/program/main/dog.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/pmvs-2/program/main/dog.o -------------------------------------------------------------------------------- /pmvs-2/program/main/expand.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/pmvs-2/program/main/expand.o -------------------------------------------------------------------------------- /pmvs-2/program/main/filter.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/pmvs-2/program/main/filter.o -------------------------------------------------------------------------------- /pmvs-2/program/main/findMatch.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/pmvs-2/program/main/findMatch.o -------------------------------------------------------------------------------- /pmvs-2/program/main/harris.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/pmvs-2/program/main/harris.o -------------------------------------------------------------------------------- /pmvs-2/program/main/image.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/pmvs-2/program/main/image.o -------------------------------------------------------------------------------- /pmvs-2/program/main/libblas.so.3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/pmvs-2/program/main/libblas.so.3 -------------------------------------------------------------------------------- /pmvs-2/program/main/libgsl.so.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/pmvs-2/program/main/libgsl.so.0 -------------------------------------------------------------------------------- /pmvs-2/program/main/libgslcblas.so.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/pmvs-2/program/main/libgslcblas.so.0 -------------------------------------------------------------------------------- /pmvs-2/program/main/liblapack.so.3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/pmvs-2/program/main/liblapack.so.3 -------------------------------------------------------------------------------- /pmvs-2/program/main/mylapack.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/pmvs-2/program/main/mylapack.o -------------------------------------------------------------------------------- /pmvs-2/program/main/optim.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/pmvs-2/program/main/optim.o -------------------------------------------------------------------------------- /pmvs-2/program/main/option.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/pmvs-2/program/main/option.o -------------------------------------------------------------------------------- /pmvs-2/program/main/patch.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/pmvs-2/program/main/patch.o -------------------------------------------------------------------------------- /pmvs-2/program/main/patchOrganizerS.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/pmvs-2/program/main/patchOrganizerS.o -------------------------------------------------------------------------------- /pmvs-2/program/main/photo.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/pmvs-2/program/main/photo.o -------------------------------------------------------------------------------- /pmvs-2/program/main/photoSetS.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/pmvs-2/program/main/photoSetS.o -------------------------------------------------------------------------------- /pmvs-2/program/main/pmvs2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/pmvs-2/program/main/pmvs2 -------------------------------------------------------------------------------- /pmvs-2/program/main/pmvs2.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "../base/pmvs/findMatch.h" 4 | #include "../base/pmvs/option.h" 5 | 6 | using namespace PMVS3; 7 | using namespace std; 8 | 9 | int main(int argc, char* argv[]) { 10 | if (argc < 3) { 11 | cerr << "Usage: " << argv[0] << " prefix option_file" << endl 12 | << endl 13 | << "--------------------------------------------------" << endl 14 | << "level 1 csize 2" << endl 15 | << "threshold 0.7 wsize 7" << endl 16 | << "minImageNum 3 CPU 4" << endl 17 | << "useVisData 0 sequence -1" << endl 18 | << "quad 2.5 maxAngle 10.0" << endl 19 | << "--------------------------------------------------" << endl 20 | << "2 ways to specify targetting images" << endl 21 | << "timages 5 1 3 5 7 9 (enumeration)" << endl 22 | << " -1 0 24 (range specification)" << endl 23 | << "--------------------------------------------------" << endl 24 | << "4 ways to specify other images" << endl 25 | << "oimages 5 0 2 4 6 8 (enumeration)" << endl 26 | << " -1 24 48 (range specification)" << endl; 27 | exit (1); 28 | } 29 | 30 | PMVS3::Soption option; 31 | option.init(argv[1], argv[2]); 32 | 33 | PMVS3::CfindMatch findMatch; 34 | findMatch.init(option); 35 | findMatch.run(); 36 | 37 | char buffer[1024]; 38 | sprintf(buffer, "%smodels/%s", argv[1], argv[2]); 39 | findMatch.write(buffer); 40 | } 41 | -------------------------------------------------------------------------------- /pmvs-2/program/main/pmvs2.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/pmvs-2/program/main/pmvs2.o -------------------------------------------------------------------------------- /pmvs-2/program/main/point.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/pmvs-2/program/main/point.o -------------------------------------------------------------------------------- /pmvs-2/program/main/run0.sh: -------------------------------------------------------------------------------- 1 | ./matchp ../../data/hall/ option.txt 2 | -------------------------------------------------------------------------------- /pmvs-2/program/main/run1.sh: -------------------------------------------------------------------------------- 1 | ./matchp ../../data/hall/ option.txt-0000 2 | ./matchp ../../data/hall/ option.txt-0001 3 | -------------------------------------------------------------------------------- /pmvs-2/program/main/run2.sh: -------------------------------------------------------------------------------- 1 | ./matchp ../../data/hall/ option-highres.txt 2 | -------------------------------------------------------------------------------- /pmvs-2/program/main/seed.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/pmvs-2/program/main/seed.o -------------------------------------------------------------------------------- /scripts/dependencies.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Install CUDA from https://developer.nvidia.com/cuda-downloads" 4 | 5 | echo "Get VisualSFM from http://ccwu.me/vsfm/download/VisualSFM_linux_64bit.zip" 6 | 7 | VISUALSFM_DEPS="build-essential libsdl1.2debian libsdl1.2-dev libgl1-mesa-dev libglu1-mesa-dev libsdl-image1.2 libsdl-image1.2-dev freeglut3-dev libxmu-dev libdevil1c2 libdevil-dev libglew-dev libgtk2.0-dev" 8 | 9 | sudo apt-get install $VISUALSFM_DEPS 10 | 11 | echo "Get SIFTGPU from http://cs.unc.edu/~ccwu/siftgpu/download.html" 12 | SIFTGPU_DEPS="nvidia-cuda-dev nvidia-cuda-toolkit" 13 | 14 | sudo apt-get install $SIFTGPU_DEPS 15 | 16 | 17 | -------------------------------------------------------------------------------- /scripts/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd ../SiftGPU 4 | export CUDA_BIN_PATH=/usr/bin 5 | make 6 | -------------------------------------------------------------------------------- /vsfm/README: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # # 3 | # VisualSFM - A Visual Structure from Motion System # 4 | # Version 0.5 # 5 | # http://ccwu.me/vsfm/ # 6 | # # 7 | # Copyright 2006-2012 Changchang Wu # 8 | # # 9 | ############################################################################## 10 | 11 | 12 | License & disclaimer. 13 | 14 | Copyright 2006-2012 Changchang Wu 15 | 16 | VisualSFM is free for personal, non-profit, or academic use. You may 17 | redistrubute VisualSFM as long as you make no modifications. Commercial 18 | use of this tool is not permited, and please email Chanchang Wu 19 | at vsfm@ccwu.me if you are interested in commercial licensing. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | ------------------------------------------------------------------------------ 34 | 35 | IMPORTANT 36 | 37 | If you use VisualSFM for your publication, please cite either [1, 3] 38 | or [2, 3] in the following publication list. If you use the SiftGPU 39 | feature detection functionality, please consider also cite [4]. 40 | 41 | + Structure from Motion 42 | [1] Changchang Wu, "Towards Linear-time Incremental Structure From 43 | Motion", 3DV 2013 44 | [2] Changchang Wu, "VisualSFM: A Visual Structure from Motion System", 45 | http://ccwu.me/vsfm/, 2011 46 | 47 | + Bundle Adjustment 48 | [3] Changchang Wu, Sameer Agarwal, Brian Curless, and Steven M. Seitz, 49 | "Multicore Bundle Adjustment", CVPR 2011 50 | 51 | + Feature Detection 52 | [4] Changchang Wu, "SiftGPU: A GPU implementation of Scale Invaraint 53 | Feature Transform (SIFT)", http://cs.unc.edu/~ccwu/siftgpu, 2007 54 | -------------------------------------------------------------------------------- /vsfm/lib/VisualSFM.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/vsfm/lib/VisualSFM.a -------------------------------------------------------------------------------- /vsfm/lib/blas.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/vsfm/lib/blas.a -------------------------------------------------------------------------------- /vsfm/lib/lapack.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/vsfm/lib/lapack.a -------------------------------------------------------------------------------- /vsfm/lib/libf2c.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/vsfm/lib/libf2c.a -------------------------------------------------------------------------------- /vsfm/lib/libjpeg.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrquincle/visualsfm/0d9fef940ff54bbe01c93ea192d6e7147f43f2ff/vsfm/lib/libjpeg.a -------------------------------------------------------------------------------- /vsfm/makefile: -------------------------------------------------------------------------------- 1 | SHELL = /bin/sh 2 | CC = g++ -w 3 | 4 | BIN_DIR = bin 5 | OUT_DIR = build 6 | LIB_DIR = lib 7 | 8 | # detect OS 9 | OSUPPER = $(shell uname -s 2>/dev/null | tr [:lower:] [:upper:]) 10 | OSLOWER = $(shell uname -s 2>/dev/null | tr [:upper:] [:lower:]) 11 | DARWIN = $(strip $(findstring DARWIN, $(OSUPPER))) 12 | 13 | ifneq ($(DARWIN),) 14 | BUILD64 = 15 | ifneq ($(BUILD64),) 16 | #where to look for 64-bit libraries (I use homebrew for 64 bit) 17 | PKG_CONFIG = /usr/local/bin/pkg-config 18 | LIB_LIST = -L/usr/local/lib -L/usr/x11/lib 19 | else 20 | #where to look for 32-bit libraries (I use fink for 32 bit) 21 | PKG_CONFIG = /sw/bin/pkg-config 22 | #prefer mesa 3D (I had problem with OpenGL) 23 | LIB_LIST = -L/usr/lib -L/sw/lib/mesa -L/usr/X11/lib 24 | CC += -m32 25 | endif 26 | else 27 | PKG_CONFIG = pkg-config 28 | LIB_LIST = 29 | endif 30 | 31 | GTK_CFLAGS = $(shell $(PKG_CONFIG) --cflags gtk+-2.0) 32 | GTK_LIBS = $(shell $(PKG_CONFIG) --libs gtk+-2.0 gthread-2.0) 33 | 34 | LIB_LIST += -pthread -lGL -lGLU -lX11 -ldl $(GTK_LIBS) $(LIB_DIR)/lapack.a \ 35 | $(LIB_DIR)/blas.a $(LIB_DIR)/libf2c.a $(LIB_DIR)/libjpeg.a 36 | 37 | all: makepath VisualSFM 38 | 39 | #rules for the rest of the object files 40 | VisualSFM: makepath extract 41 | $(CC) -o $(BIN_DIR)/VisualSFM $(OUT_DIR)/*.* $(LIB_LIST) 42 | rm -f $(OUT_DIR)/*.* 43 | 44 | extract: $(LIB_DIR)/VisualSFM.a 45 | cd $(OUT_DIR); ar -x ../$(LIB_DIR)/VisualSFM.a; cd ..; 46 | 47 | makepath: 48 | mkdir -p $(OUT_DIR) 49 | mkdir -p $(BIN_DIR) 50 | 51 | clean: 52 | rm -f $(OUT_DIR)/*.* 53 | rm -f $(BIN_DIR)/VisualSFM 54 | 55 | 56 | --------------------------------------------------------------------------------