├── .gitignore ├── CMakeLists.txt ├── 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 ├── 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 ├── CMakeLists.txt ├── ServerSiftGPU ├── ServerSiftGPU.cpp ├── ServerSiftGPU.h └── server.cpp ├── SiftGPU ├── CLTexImage.cpp ├── CLTexImage.h ├── CMakeLists.txt ├── 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 ├── CMakeLists.txt ├── GLTestWnd.cpp ├── GLTestWnd.h ├── GLTransform.h ├── MultiThreadSIFT.cpp ├── SimpleSIFT.cpp ├── TestWinGlut.cpp ├── TestWinGlut.h └── speed.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | 3 | bin 4 | 5 | CMakeFiles 6 | CMakeCache.txt 7 | 8 | demos -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | CMAKE_MINIMUM_REQUIRED(VERSION 2.6) 2 | 3 | PROJECT(SIFTGPU C CXX) 4 | 5 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-write-strings -Wno-unused-result -Wno-deprecated -fPIC") 6 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-write-strings -Wno-unused-result -Wno-deprecated -fPIC") 7 | 8 | ADD_SUBDIRECTORY(src) 9 | 10 | -------------------------------------------------------------------------------- /OpenGL_and_CUDA.txt: -------------------------------------------------------------------------------- 1 | PART 1, OPENGL, 2 | 3 | Pay special attention if you have your own OpenGL code. 4 | The OpenGL-based implmentations of SiftGPU need valid OpenGL context to run properly. 5 | 6 | 1. If you use the same OpenGL context for SiftGPU and your own your visualization 7 | Make sure the OpenGL states are restored before calling SiftGPU. SiftGPU changes several 8 | OpenGL internal states, including texture binding to GL_TEXTURE_RECTANGLE_ARB and current 9 | ViewPort. You might need to restore them for your own OpenGL part. To avoid this problem, 10 | you can create a seperate GL context, and activate different context for different part. 11 | 12 | Note that GL_TEXTURE_RECTANGLE_ARB is always enabled in SiftGPU. When you have problem 13 | displaying textures, you can try first glDisable(GL_TEXTURE_RECTANGLE_ARB) before painting, 14 | but don't forget to call glEnable(GL_TEXTURE_RECTANGLE_ARB) after. (Thanks to Pilet) 15 | 16 | 2. How to create/setup an OpenGL context for SiftGPU 17 | 18 | If you choose to let SiftGPU to manage OpenGL context, you can simply do that by 19 | SiftGPU::CreateContextGL and SiftMatchGPU::CreateContextGL. When you mix your own OpenGL 20 | code with SiftGPU, you need to re-call CreateContextGL before calling SiftGPU functions, 21 | which will implicitly activate the internal OpenGL context. 22 | 23 | 24 | If you choose to create openGL contexts yourself when mixing SiftGPU with other openGL 25 | code, don't call SiftGPU::CreateContextGL or SiftMatchGPU::CreateContextGL; Instead you 26 | should first activate your OpenGL context (WglMakeCurrent in win32), and set GL_FILL 27 | for polygon mode, then call SiftGPU::VerifyContextGL or SiftMatchGPU::VerifyContextGL 28 | for initialization. You should also setup in the same way before calling SiftGPU functions. 29 | 30 | 31 | PART 2, CUDA 32 | --------------------------------------------------------------------------------- 33 | 1. How to enable CUDA 34 | 35 | The CUDA implementation in the package is not compiled by default. 36 | 37 | To enable it for visual stuio 2010, use msvc/SiftGPU_CUDA_Enabled.sln 38 | To enable it for other OS, you need to change siftgpu_enable_cuda to 1 in the makefile 39 | 40 | 41 | --------------------------------------------------------------------------------- 42 | 2. Change CUDA build parameters. 43 | For windows, you need to change the settings in the custom build command line of 44 | ProgramCU.cu. For example, add -use_fast_match for using fast match. 45 | 46 | For Other OS, you need to change the makefile. The top part of the makefile is 47 | the configuration section, which includes: 48 | siftgpu_enable_cuda = 0 (Set 1 to enable CUDA-based SiftGPU) 49 | CUDA_INSTALL_PATH = /usr/local/cuda (Where to find CUDA) 50 | siftgpu_cuda_options = -arch sm_10 (Additional CUDA Compiling options) 51 | 52 | 53 | ------------------------------------------------------------------------------------ 54 | 3. CUDA runtime parameters for SiftGPU::ParseParam 55 | First, you need to specify "-cuda" to use CUDA-based SiftGPU. More parameters can 56 | be chagned at runtime in CUDA-based SiftGPU than in OpenGL-based version. Check out 57 | the manual for details. 58 | 59 | NEW. You can choose GPU for CUDA computation by using "-cuda [device_index=0]" 60 | 61 | One parameter for CUDA is "-di", which controls whether dynamic indexing is used 62 | in descriptor generations. It is turned off by default. My experiments on 8800 63 | GTX show that unrolled loop of 8 if-assigns are faster than dynamic indexing, but 64 | it might be different on other GPUs. 65 | 66 | 67 | -------------------------------------------------------------------------------------- 68 | 4. Speed of CUDA-based SiftGPU 69 | If the size of the first octave (multiply the original size by 2 if upsample is used) 70 | is less than or around 1024x768, CUDA version will be faster than OpenGL versions, 71 | otherwise the OpenGL versions are still faster. 72 | 73 | ************************************************************************************** 74 | This is observed on nVidia 8800 GTX, it might be different on other GPUs. Recent 75 | experiments on GTX280 show that CUDA version is not as fast as OpenGL version. 76 | 77 | Note: the thread block settings are currently tuned on GPU nVidia GTX 8800, 78 | which may not be optimized for other GPUs. 79 | ************************************************************************************** 80 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /bin/DevIL.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pitzer/SiftGPU/90e9f4c1fcc8ebcc592b3c5b43d60bd4b4ba3560/bin/DevIL.dll -------------------------------------------------------------------------------- /bin/DevIL64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pitzer/SiftGPU/90e9f4c1fcc8ebcc592b3c5b43d60bd4b4ba3560/bin/DevIL64.dll -------------------------------------------------------------------------------- /bin/SiftGPU.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pitzer/SiftGPU/90e9f4c1fcc8ebcc592b3c5b43d60bd4b4ba3560/bin/SiftGPU.dll -------------------------------------------------------------------------------- /bin/SiftGPU64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pitzer/SiftGPU/90e9f4c1fcc8ebcc592b3c5b43d60bd4b4ba3560/bin/SiftGPU64.dll -------------------------------------------------------------------------------- /bin/SimpleSIFT.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pitzer/SiftGPU/90e9f4c1fcc8ebcc592b3c5b43d60bd4b4ba3560/bin/SimpleSIFT.exe -------------------------------------------------------------------------------- /bin/Speed.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pitzer/SiftGPU/90e9f4c1fcc8ebcc592b3c5b43d60bd4b4ba3560/bin/Speed.exe -------------------------------------------------------------------------------- /bin/TestWin.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pitzer/SiftGPU/90e9f4c1fcc8ebcc592b3c5b43d60bd4b4ba3560/bin/TestWin.exe -------------------------------------------------------------------------------- /bin/glew32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pitzer/SiftGPU/90e9f4c1fcc8ebcc592b3c5b43d60bd4b4ba3560/bin/glew32.dll -------------------------------------------------------------------------------- /bin/glew64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pitzer/SiftGPU/90e9f4c1fcc8ebcc592b3c5b43d60bd4b4ba3560/bin/glew64.dll -------------------------------------------------------------------------------- /data/1600.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pitzer/SiftGPU/90e9f4c1fcc8ebcc592b3c5b43d60bd4b4ba3560/data/1600.jpg -------------------------------------------------------------------------------- /data/640-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pitzer/SiftGPU/90e9f4c1fcc8ebcc592b3c5b43d60bd4b4ba3560/data/640-1.jpg -------------------------------------------------------------------------------- /data/640-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pitzer/SiftGPU/90e9f4c1fcc8ebcc592b3c5b43d60bd4b4ba3560/data/640-2.jpg -------------------------------------------------------------------------------- /data/640-3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pitzer/SiftGPU/90e9f4c1fcc8ebcc592b3c5b43d60bd4b4ba3560/data/640-3.jpg -------------------------------------------------------------------------------- /data/640-4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pitzer/SiftGPU/90e9f4c1fcc8ebcc592b3c5b43d60bd4b4ba3560/data/640-4.jpg -------------------------------------------------------------------------------- /data/640-5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pitzer/SiftGPU/90e9f4c1fcc8ebcc592b3c5b43d60bd4b4ba3560/data/640-5.jpg -------------------------------------------------------------------------------- /data/800-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pitzer/SiftGPU/90e9f4c1fcc8ebcc592b3c5b43d60bd4b4ba3560/data/800-1.jpg -------------------------------------------------------------------------------- /data/800-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pitzer/SiftGPU/90e9f4c1fcc8ebcc592b3c5b43d60bd4b4ba3560/data/800-2.jpg -------------------------------------------------------------------------------- /data/800-3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pitzer/SiftGPU/90e9f4c1fcc8ebcc592b3c5b43d60bd4b4ba3560/data/800-3.jpg -------------------------------------------------------------------------------- /data/800-4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pitzer/SiftGPU/90e9f4c1fcc8ebcc592b3c5b43d60bd4b4ba3560/data/800-4.jpg -------------------------------------------------------------------------------- /data/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pitzer/SiftGPU/90e9f4c1fcc8ebcc592b3c5b43d60bd4b4ba3560/data/Thumbs.db -------------------------------------------------------------------------------- /data/list640.txt: -------------------------------------------------------------------------------- 1 | 640-1.jpg 2 | 640-2.jpg 3 | 640-3.jpg 4 | 640-4.jpg 5 | 640-5.jpg -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /demos/demo1.bat: -------------------------------------------------------------------------------- 1 | ../bin/TestWinGlut.exe -i ../data/1600.jpg -------------------------------------------------------------------------------- /demos/demo2.bat: -------------------------------------------------------------------------------- 1 | ../bin/TestWinGlut.exe -il ../data/list640.txt -------------------------------------------------------------------------------- /demos/demo3.bat: -------------------------------------------------------------------------------- 1 | ../bin/TestWinGlut.exe -il ../data/listx.txt -------------------------------------------------------------------------------- /demos/evaluation-box.bat: -------------------------------------------------------------------------------- 1 | ../bin/TestWinGlut.exe -i ../doc/evaluation/box.pgm -o ../doc/evaluation/box.siftgpu -w 3 -fo -1 -loweo -exit -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /doc/evaluation/box.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pitzer/SiftGPU/90e9f4c1fcc8ebcc592b3c5b43d60bd4b4ba3560/doc/evaluation/box.pgm -------------------------------------------------------------------------------- /doc/evaluation/evaluation.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pitzer/SiftGPU/90e9f4c1fcc8ebcc592b3c5b43d60bd4b4ba3560/doc/evaluation/evaluation.jpg -------------------------------------------------------------------------------- /doc/manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pitzer/SiftGPU/90e9f4c1fcc8ebcc592b3c5b43d60bd4b4ba3560/doc/manual.pdf -------------------------------------------------------------------------------- /doc/speed_v311.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pitzer/SiftGPU/90e9f4c1fcc8ebcc592b3c5b43d60bd4b4ba3560/doc/speed_v311.jpg -------------------------------------------------------------------------------- /doc/speed_v340_v2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pitzer/SiftGPU/90e9f4c1fcc8ebcc592b3c5b43d60bd4b4ba3560/doc/speed_v340_v2.jpg -------------------------------------------------------------------------------- /doc/statistics.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pitzer/SiftGPU/90e9f4c1fcc8ebcc592b3c5b43d60bd4b4ba3560/doc/statistics.pdf -------------------------------------------------------------------------------- /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 | //////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | ################################################################# 2 | # SiftGPU congiruation: CUDA, SSE, TIMING 3 | ################################################################# 4 | #enable siftgpu server 5 | siftgpu_enable_server = 0 6 | #enable OpenCL-based SiftGPU? not finished yet; testing purpose 7 | siftgpu_enable_opencl = 0 8 | #------------------------------------------------------------------------------------------------ 9 | # enable CUDA-based SiftGPU? 10 | simple_find_cuda := $(shell type nvcc>/dev/null 2>&1; echo $$?) 11 | $(info ----- value $(simple_find_cuda) -----) 12 | ifeq ($(simple_find_cuda), 0) 13 | siftgpu_enable_cuda = 1 14 | else 15 | siftgpu_enable_cuda = 0 16 | endif 17 | 18 | CUDA_INSTALL_PATH = /usr/local/cuda 19 | #change additional settings, like SM version here if it is not 1.0 (eg. -arch sm_13 for GTX280) 20 | #siftgpu_cuda_options = -Xopencc -OPT:unroll_size=200000 21 | #siftgpu_cuda_options = -arch sm_10 22 | #-------------------------------------------------------------------------------------------------- 23 | # enable SSE optimization for GL-based implementations 24 | siftgpu_enable_sse = 1 25 | siftgpu_sse_options = -march=core2 -mfpmath=sse 26 | #-------------------------------------------------------------------------------------------------- 27 | # openGL context creation. 1 for glut, 0 for xlib 28 | siftgpu_prefer_glut = 1 29 | #whether remove dependency on DevIL (1 to remove, the output libsiftgpu.so still works for VisualSFM) 30 | siftgpu_disable_devil = 0 31 | #------------------------------------------------------------------------------------------------ 32 | #whether SimpleSIFT uses runtime loading of libsiftgpu.so or static linking of libsiftgpu.a 33 | simplesift_runtime_load = 1 34 | 35 | ################################################################# 36 | 37 | 38 | # cleanup trailing whitespaces for a few settings 39 | siftgpu_enable_cuda := $(strip $(siftgpu_enable_cuda)) 40 | siftgpu_disable_devil := $(strip $(siftgpu_disable_devil)) 41 | siftgpu_enable_server := $(strip $(siftgpu_enable_server)) 42 | siftgpu_enable_opencl := $(strip $(siftgpu_enable_opencl)) 43 | siftgpu_prefer_glut := $(strip $(siftgpu_prefer_glut)) 44 | simplesift_runtime_load := $(strip $(simplesift_runtime_load)) 45 | 46 | # detect OS 47 | OSUPPER = $(shell uname -s 2>/dev/null | tr [:lower:] [:upper:]) 48 | OSLOWER = $(shell uname -s 2>/dev/null | tr [:upper:] [:lower:]) 49 | DARWIN = $(strip $(findstring DARWIN, $(OSUPPER))) 50 | 51 | 52 | SHELL = /bin/sh 53 | INC_DIR = include 54 | BIN_DIR = bin 55 | SRC_SIFTGPU = src/SiftGPU 56 | SRC_DRIVER = src/TestWin 57 | SRC_SERVER = src/ServerSiftGPU 58 | CC = g++ 59 | CFLAGS = -I$(INC_DIR) -fPIC -L/usr/lib -L./bin -L./lib -Wall -Wno-deprecated -pthread 60 | 61 | #simple hack to repalce the native flat on OSX because gcc version is low 62 | ifneq ($(DARWIN),) 63 | siftgpu_sse_options = -march=core2 -mfpmath=sse 64 | endif 65 | 66 | ifneq ($(siftgpu_enable_sse), 0) 67 | CFLAGS += $(siftgpu_sse_options) 68 | endif 69 | 70 | ifneq ($(siftgpu_prefer_glut), 0) 71 | CFLAGS += -DWINDOW_PREFER_GLUT 72 | endif 73 | 74 | ifneq ($(siftgpu_enable_opencl), 0) 75 | CFLAGS += -DCL_SIFTGPU_ENABLED 76 | endif 77 | 78 | ODIR_SIFTGPU = build 79 | 80 | 81 | # external header files 82 | _HEADER_EXTERNAL = GL/glew.h GL/glut.h IL/il.h 83 | # siftgpu header files 84 | _HEADER_SIFTGPU = FrameBufferObject.h GlobalUtil.h GLTexImage.h ProgramGPU.h ShaderMan.h ProgramGLSL.h SiftGPU.h SiftPyramid.h SiftMatch.h PyramidGL.h LiteWindow.h 85 | # siftgpu library header files for drivers 86 | _HEADER_SIFTGPU_LIB = SiftGPU.h 87 | 88 | ifneq ($(DARWIN),) 89 | #librarys for SiftGPU 90 | LIBS_SIFTGPU = -lGLEW -framework GLUT -framework OpenGL 91 | CFLAGS += -L/Users/prb2pal/Development/Resources/lib 92 | else 93 | #librarys for SiftGPU 94 | LIBS_SIFTGPU = -lGLEW -lglut -lGL -lX11 95 | endif 96 | 97 | ifneq ($(siftgpu_disable_devil), 0) 98 | CFLAGS += -DSIFTGPU_NO_DEVIL 99 | else 100 | LIBS_SIFTGPU += -lIL 101 | endif 102 | 103 | #Obj files for SiftGPU 104 | _OBJ_SIFTGPU = FrameBufferObject.o GlobalUtil.o GLTexImage.o ProgramGLSL.o ProgramGPU.o ShaderMan.o SiftGPU.o SiftPyramid.o PyramidGL.o SiftMatch.o 105 | 106 | #add cuda options 107 | ifneq ($(siftgpu_enable_cuda), 0) 108 | ifdef CUDA_BIN_PATH 109 | NVCC = $(CUDA_BIN_PATH)/nvcc 110 | else 111 | NVCC = $(CUDA_INSTALL_PATH)/bin/nvcc 112 | endif 113 | 114 | ifndef CUDA_INC_PATH 115 | CUDA_INC_PATH = $(CUDA_INSTALL_PATH)/include 116 | endif 117 | 118 | ifndef CUDA_LIB_PATH 119 | CUDA_LIB_PATH = $(CUDA_INSTALL_PATH)/lib64 -L$(CUDA_INSTALL_PATH)/lib 120 | endif 121 | 122 | CFLAGS += -DCUDA_SIFTGPU_ENABLED -I$(CUDA_INC_PATH) -L$(CUDA_LIB_PATH) 123 | LIBS_SIFTGPU += -lcudart 124 | _OBJ_SIFTGPU += CuTexImage.o PyramidCU.o SiftMatchCU.o 125 | _HEADER_SIFTGPU += CuTexImage.h ProgramCU.h PyramidCU.h 126 | endif 127 | 128 | ifneq ($(siftgpu_enable_opencl), 0) 129 | CFLAGS += -lOpenCL 130 | endif 131 | 132 | all: makepath siftgpu server driver 133 | 134 | 135 | #the dependencies of SiftGPU library 136 | DEPS_SIFTGPU = $(patsubst %, $(SRC_SIFTGPU)/%, $(_HEADER_SIFTGPU)) 137 | 138 | 139 | #rules for the rest of the object files 140 | $(ODIR_SIFTGPU)/%.o: $(SRC_SIFTGPU)/%.cpp $(DEPS_SIFTGPU) 141 | $(CC) -o $@ $< $(CFLAGS) -c 142 | 143 | 144 | ifneq ($(siftgpu_enable_cuda), 0) 145 | NVCC_FLAGS = -I$(INC_DIR) -I$(CUDA_INC_PATH) -DCUDA_SIFTGPU_ENABLED -O2 -Xcompiler -fPIC 146 | ifdef siftgpu_cuda_options 147 | NVCC_FLAGS += $(siftgpu_cuda_options) 148 | endif 149 | #build rule for CUDA 150 | $(ODIR_SIFTGPU)/ProgramCU.o: $(SRC_SIFTGPU)/ProgramCU.cu $(DEPS_SIFTGPU) 151 | $(NVCC) $(NVCC_FLAGS) -o $@ $< -c 152 | _OBJ_SIFTGPU += ProgramCU.o 153 | endif 154 | 155 | 156 | ifneq ($(siftgpu_enable_server), 0) 157 | $(ODIR_SIFTGPU)/ServerSiftGPU.o: $(SRC_SERVER)/ServerSiftGPU.cpp $(DEPS_SIFTGPU) 158 | $(CC) -o $@ $< $(CFLAGS) -DSERVER_SIFTGPU_ENABLED -c 159 | _OBJ_SIFTGPU += ServerSiftGPU.o 160 | endif 161 | 162 | OBJ_SIFTGPU = $(patsubst %,$(ODIR_SIFTGPU)/%,$(_OBJ_SIFTGPU)) 163 | LIBS_DRIVER = $(BIN_DIR)/libsiftgpu.a $(LIBS_SIFTGPU) 164 | SRC_TESTWIN = $(SRC_DRIVER)/TestWinGlut.cpp $(SRC_DRIVER)/BasicTestWin.cpp 165 | DEP_TESTWIN = $(SRC_DRIVER)/TestWinGlut.h $(SRC_DRIVER)/BasicTestwin.h $(SRC_DRIVER)/GLTransform.h 166 | 167 | 168 | 169 | ifneq ($(simplesift_runtime_load), 0) 170 | LIBS_SIMPLESIFT = -ldl -DSIFTGPU_DLL_RUNTIME 171 | else 172 | LIBS_SIMPLESIFT = $(LIBS_DRIVER) -DSIFTGPU_STATIC 173 | endif 174 | 175 | siftgpu: makepath $(OBJ_SIFTGPU) 176 | ar rcs $(BIN_DIR)/libsiftgpu.a $(OBJ_SIFTGPU) 177 | $(CC) -o $(BIN_DIR)/libsiftgpu.so $(OBJ_SIFTGPU) $(LIBS_SIFTGPU) $(CFLAGS) -shared -fPIC 178 | 179 | driver: makepath 180 | $(CC) -o $(BIN_DIR)/TestWinGlut $(SRC_TESTWIN) $(LIBS_DRIVER) $(CFLAGS) 181 | $(CC) -o $(BIN_DIR)/SimpleSIFT $(SRC_DRIVER)/SimpleSIFT.cpp $(LIBS_SIMPLESIFT) $(CFLAGS) 182 | $(CC) -o $(BIN_DIR)/speed $(SRC_DRIVER)/speed.cpp $(LIBS_DRIVER) $(CFLAGS) 183 | $(CC) -o $(BIN_DIR)/MultiThreadSIFT $(SRC_DRIVER)/MultiThreadSIFT.cpp $(LIBS_DRIVER) $(CFLAGS) -pthread 184 | 185 | ifneq ($(siftgpu_enable_server), 0) 186 | server: makepath 187 | $(CC) -o $(BIN_DIR)/server_siftgpu $(SRC_SERVER)/server.cpp $(LIBS_DRIVER) $(CFLAGS) 188 | else 189 | server: 190 | 191 | endif 192 | 193 | makepath: 194 | mkdir -p $(ODIR_SIFTGPU) 195 | mkdir -p $(BIN_DIR) 196 | sed -i -e 's/\\/\//g' demos/*.bat 197 | 198 | clean: 199 | rm -f $(ODIR_SIFTGPU)/*.o 200 | rm -f $(BIN_DIR)/libsiftgpu.a 201 | rm -f $(BIN_DIR)/libsiftgpu.so 202 | rm -f $(BIN_DIR)/TestWinGlut 203 | rm -f $(BIN_DIR)/SimpleSIFT 204 | rm -f $(BIN_DIR)/speed 205 | rm -f $(BIN_DIR)/server_siftgpu 206 | rm -f $(BIN_DIR)/MultiThreadSIFT 207 | rm -f ProgramCU.linkinfo 208 | 209 | -------------------------------------------------------------------------------- /msvc/ServerSiftGPU/SiftGPU_Server.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="SiftGPU_Server" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Console Application" 0x0103 6 | 7 | CFG=SiftGPU_Server - 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 "SiftGPU_Server.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 "SiftGPU_Server.mak" CFG="SiftGPU_Server - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "SiftGPU_Server - Win32 Release" (based on "Win32 (x86) Console Application") 21 | !MESSAGE "SiftGPU_Server - Win32 Debug" (based on "Win32 (x86) Console Application") 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)" == "SiftGPU_Server - Win32 Release" 32 | 33 | # PROP BASE Use_MFC 0 34 | # PROP BASE Use_Debug_Libraries 0 35 | # PROP BASE Output_Dir "SiftGPU_Server___Win32_Release" 36 | # PROP BASE Intermediate_Dir "SiftGPU_Server___Win32_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 Ignore_Export_Lib 0 43 | # PROP Target_Dir "" 44 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c 45 | # ADD CPP /nologo /MT /W3 /GX /O2 /I "../../Include/" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c 46 | # ADD BASE RSC /l 0x409 /d "NDEBUG" 47 | # ADD RSC /l 0x409 /d "NDEBUG" 48 | BSC32=bscmake.exe 49 | # ADD BASE BSC32 /nologo 50 | # ADD BSC32 /nologo 51 | LINK32=link.exe 52 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 53 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib ws2_32.lib siftgpu.lib opengl32.lib /nologo /subsystem:console /machine:I386 /out:"../../bin/server_siftgpu.exe" /libpath:"../../lib" 54 | 55 | !ELSEIF "$(CFG)" == "SiftGPU_Server - Win32 Debug" 56 | 57 | # PROP BASE Use_MFC 0 58 | # PROP BASE Use_Debug_Libraries 1 59 | # PROP BASE Output_Dir "SiftGPU_Server___Win32_Debug" 60 | # PROP BASE Intermediate_Dir "SiftGPU_Server___Win32_Debug" 61 | # PROP BASE Target_Dir "" 62 | # PROP Use_MFC 0 63 | # PROP Use_Debug_Libraries 1 64 | # PROP Output_Dir "Debug" 65 | # PROP Intermediate_Dir "Debug" 66 | # PROP Ignore_Export_Lib 0 67 | # PROP Target_Dir "" 68 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c 69 | # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../Include/" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c 70 | # ADD BASE RSC /l 0x409 /d "_DEBUG" 71 | # ADD RSC /l 0x409 /d "_DEBUG" 72 | BSC32=bscmake.exe 73 | # ADD BASE BSC32 /nologo 74 | # ADD BSC32 /nologo 75 | LINK32=link.exe 76 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept 77 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib ws2_32.lib siftgpu_d.lib opengl32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../../bin/server_siftgpu.exe" /pdbtype:sept /libpath:"../../lib" 78 | 79 | !ENDIF 80 | 81 | # Begin Target 82 | 83 | # Name "SiftGPU_Server - Win32 Release" 84 | # Name "SiftGPU_Server - Win32 Debug" 85 | # Begin Group "Source Files" 86 | 87 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 88 | # Begin Source File 89 | 90 | SOURCE=..\..\src\ServerSiftGPU\server.cpp 91 | # End Source File 92 | # End Group 93 | # Begin Group "Header Files" 94 | 95 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 96 | # End Group 97 | # Begin Group "Resource Files" 98 | 99 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 100 | # End Group 101 | # End Target 102 | # End Project 103 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /msvc/SiftGPU.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SiftGPU", "SiftGPU\SiftGPU.vcxproj", "{594562D3-609A-47BC-B7E2-789C4E794CC3}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestBase", "TestWin\TestBase.vcxproj", "{57496D03-A005-4650-B041-8E70DDA4A591}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestWin", "TestWin\TestWin.vcxproj", "{E1C4EAB3-1677-46F7-92BC-1A1F309B2027}" 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestWinGlut", "TestWin\TestWinGlut.vcxproj", "{B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}" 11 | EndProject 12 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleSIFT", "TestWin\SimpleSIFT.vcxproj", "{D864A317-5A65-47B1-AA82-C04F99C4280F}" 13 | EndProject 14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Speed", "TestWin\Speed.vcxproj", "{7FF72B39-F50E-4ED5-9A50-DCD60EF03604}" 15 | EndProject 16 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SiftGPU_Server", "ServerSiftGPU\SiftGPU_Server.vcxproj", "{65C987E1-F62C-4461-9E2C-BE1E8A770C51}" 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 20 | Debug|Win32 = Debug|Win32 21 | Debug|x64 = Debug|x64 22 | Release|Win32 = Release|Win32 23 | Release|x64 = Release|x64 24 | EndGlobalSection 25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 26 | {594562D3-609A-47BC-B7E2-789C4E794CC3}.Debug|Win32.ActiveCfg = Debug|Win32 27 | {594562D3-609A-47BC-B7E2-789C4E794CC3}.Debug|Win32.Build.0 = Debug|Win32 28 | {594562D3-609A-47BC-B7E2-789C4E794CC3}.Debug|x64.ActiveCfg = Debug|x64 29 | {594562D3-609A-47BC-B7E2-789C4E794CC3}.Debug|x64.Build.0 = Debug|x64 30 | {594562D3-609A-47BC-B7E2-789C4E794CC3}.Release|Win32.ActiveCfg = Release|Win32 31 | {594562D3-609A-47BC-B7E2-789C4E794CC3}.Release|Win32.Build.0 = Release|Win32 32 | {594562D3-609A-47BC-B7E2-789C4E794CC3}.Release|x64.ActiveCfg = Release|x64 33 | {594562D3-609A-47BC-B7E2-789C4E794CC3}.Release|x64.Build.0 = Release|x64 34 | {57496D03-A005-4650-B041-8E70DDA4A591}.Debug|Win32.ActiveCfg = Debug|Win32 35 | {57496D03-A005-4650-B041-8E70DDA4A591}.Debug|Win32.Build.0 = Debug|Win32 36 | {57496D03-A005-4650-B041-8E70DDA4A591}.Debug|x64.ActiveCfg = Debug|x64 37 | {57496D03-A005-4650-B041-8E70DDA4A591}.Debug|x64.Build.0 = Debug|x64 38 | {57496D03-A005-4650-B041-8E70DDA4A591}.Release|Win32.ActiveCfg = Release|Win32 39 | {57496D03-A005-4650-B041-8E70DDA4A591}.Release|Win32.Build.0 = Release|Win32 40 | {57496D03-A005-4650-B041-8E70DDA4A591}.Release|x64.ActiveCfg = Release|x64 41 | {57496D03-A005-4650-B041-8E70DDA4A591}.Release|x64.Build.0 = Release|x64 42 | {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Debug|Win32.ActiveCfg = Debug|Win32 43 | {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Debug|Win32.Build.0 = Debug|Win32 44 | {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Debug|x64.ActiveCfg = Debug|x64 45 | {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Debug|x64.Build.0 = Debug|x64 46 | {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Release|Win32.ActiveCfg = Release|Win32 47 | {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Release|Win32.Build.0 = Release|Win32 48 | {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Release|x64.ActiveCfg = Release|x64 49 | {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Release|x64.Build.0 = Release|x64 50 | {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Debug|Win32.ActiveCfg = Debug|Win32 51 | {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Debug|Win32.Build.0 = Debug|Win32 52 | {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Debug|x64.ActiveCfg = Debug|x64 53 | {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Debug|x64.Build.0 = Debug|x64 54 | {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Release|Win32.ActiveCfg = Release|Win32 55 | {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Release|Win32.Build.0 = Release|Win32 56 | {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Release|x64.ActiveCfg = Release|x64 57 | {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Release|x64.Build.0 = Release|x64 58 | {D864A317-5A65-47B1-AA82-C04F99C4280F}.Debug|Win32.ActiveCfg = Debug|Win32 59 | {D864A317-5A65-47B1-AA82-C04F99C4280F}.Debug|Win32.Build.0 = Debug|Win32 60 | {D864A317-5A65-47B1-AA82-C04F99C4280F}.Debug|x64.ActiveCfg = Debug|x64 61 | {D864A317-5A65-47B1-AA82-C04F99C4280F}.Debug|x64.Build.0 = Debug|x64 62 | {D864A317-5A65-47B1-AA82-C04F99C4280F}.Release|Win32.ActiveCfg = Release|Win32 63 | {D864A317-5A65-47B1-AA82-C04F99C4280F}.Release|Win32.Build.0 = Release|Win32 64 | {D864A317-5A65-47B1-AA82-C04F99C4280F}.Release|x64.ActiveCfg = Release|x64 65 | {D864A317-5A65-47B1-AA82-C04F99C4280F}.Release|x64.Build.0 = Release|x64 66 | {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Debug|Win32.ActiveCfg = Debug|Win32 67 | {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Debug|Win32.Build.0 = Debug|Win32 68 | {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Debug|x64.ActiveCfg = Debug|x64 69 | {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Debug|x64.Build.0 = Debug|x64 70 | {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Release|Win32.ActiveCfg = Release|Win32 71 | {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Release|Win32.Build.0 = Release|Win32 72 | {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Release|x64.ActiveCfg = Release|x64 73 | {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Release|x64.Build.0 = Release|x64 74 | {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Debug|Win32.ActiveCfg = Debug|Win32 75 | {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Debug|Win32.Build.0 = Debug|Win32 76 | {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Debug|x64.ActiveCfg = Debug|x64 77 | {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Debug|x64.Build.0 = Debug|x64 78 | {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Release|Win32.ActiveCfg = Release|Win32 79 | {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Release|Win32.Build.0 = Release|Win32 80 | {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Release|x64.ActiveCfg = Release|x64 81 | {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Release|x64.Build.0 = Release|x64 82 | EndGlobalSection 83 | GlobalSection(SolutionProperties) = preSolution 84 | HideSolutionNode = FALSE 85 | EndGlobalSection 86 | EndGlobal 87 | -------------------------------------------------------------------------------- /msvc/SiftGPU/SiftGPU.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | CreateNewSiftGPU @1 3 | CreateNewSiftMatchGPU @2 4 | CreateLiteWindow @3 5 | CreateComboSiftGPU @4 6 | CreateRemoteSiftGPU @5 7 | -------------------------------------------------------------------------------- /msvc/SiftGPU/SiftGPU.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="SiftGPU" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 6 | 7 | CFG=SiftGPU - 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 "SiftGPU.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 "SiftGPU.mak" CFG="SiftGPU - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "SiftGPU - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") 21 | !MESSAGE "SiftGPU - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | MTL=midl.exe 30 | RSC=rc.exe 31 | 32 | !IF "$(CFG)" == "SiftGPU - Win32 Release" 33 | 34 | # PROP BASE Use_MFC 0 35 | # PROP BASE Use_Debug_Libraries 0 36 | # PROP BASE Output_Dir "Release" 37 | # PROP BASE Intermediate_Dir "Release" 38 | # PROP BASE Target_Dir "" 39 | # PROP Use_MFC 0 40 | # PROP Use_Debug_Libraries 0 41 | # PROP Output_Dir "Release" 42 | # PROP Intermediate_Dir "Release" 43 | # PROP Ignore_Export_Lib 0 44 | # PROP Target_Dir "" 45 | # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SIFTGPU_EXPORTS" /Yu"stdafx.h" /FD /c 46 | # ADD CPP /nologo /MT /W3 /GX /O2 /I "../../Include/" /D "NDEBUG" /D "SIFTGPU_EXPORTS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SIFTGPU_DLL" /D "DLL_EXPORT" /D "SERVER_SIFTGPU_ENABLED" /FD /c 47 | # SUBTRACT CPP /YX /Yc /Yu 48 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 49 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 50 | # ADD BASE RSC /l 0x409 /d "NDEBUG" 51 | # ADD RSC /l 0x409 /d "NDEBUG" 52 | BSC32=bscmake.exe 53 | # ADD BASE BSC32 /nologo 54 | # ADD BSC32 /nologo 55 | LINK32=link.exe 56 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 57 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib opengl32.lib glu32.lib winmm.lib glew32.lib glew32s.lib /nologo /dll /machine:I386 /def:".\SiftGPU.def" /out:"../../bin/SIFTGPU.dll" /implib:"../../lib/SIFTGPU.lib" /libpath:"../../lib/" 58 | # SUBTRACT LINK32 /pdb:none 59 | 60 | !ELSEIF "$(CFG)" == "SiftGPU - Win32 Debug" 61 | 62 | # PROP BASE Use_MFC 0 63 | # PROP BASE Use_Debug_Libraries 1 64 | # PROP BASE Output_Dir "Debug" 65 | # PROP BASE Intermediate_Dir "Debug" 66 | # PROP BASE Target_Dir "" 67 | # PROP Use_MFC 0 68 | # PROP Use_Debug_Libraries 1 69 | # PROP Output_Dir "Debug" 70 | # PROP Intermediate_Dir "Debug" 71 | # PROP Ignore_Export_Lib 0 72 | # PROP Target_Dir "" 73 | # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SIFTGPU_EXPORTS" /Yu"stdafx.h" /FD /GZ /c 74 | # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../Include/" /D "_DEBUG" /D "DLL_EXPORT" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SIFTGPU_DLL" /D "SERVER_SIFTGPU_ENABLED" /FD /GZ /c 75 | # SUBTRACT CPP /YX /Yc /Yu 76 | # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 77 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 78 | # ADD BASE RSC /l 0x409 /d "_DEBUG" 79 | # ADD RSC /l 0x409 /d "_DEBUG" 80 | BSC32=bscmake.exe 81 | # ADD BASE BSC32 /nologo 82 | # ADD BSC32 /nologo 83 | LINK32=link.exe 84 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept 85 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib opengl32.lib glu32.lib winmm.lib glew32.lib glew32s.lib /nologo /dll /debug /machine:I386 /def:".\SiftGPU.def" /out:"../../bin/SIFTGPU_d.dll" /implib:"../../lib/SIFTGPU_d.lib" /pdbtype:sept /libpath:"../../lib/" 86 | # SUBTRACT LINK32 /pdb:none 87 | 88 | !ENDIF 89 | 90 | # Begin Target 91 | 92 | # Name "SiftGPU - Win32 Release" 93 | # Name "SiftGPU - Win32 Debug" 94 | # Begin Group "Source Files" 95 | 96 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 97 | # Begin Source File 98 | 99 | SOURCE=..\..\src\SiftGPU\FrameBufferObject.cpp 100 | # End Source File 101 | # Begin Source File 102 | 103 | SOURCE=..\..\src\SiftGPU\GlobalUtil.cpp 104 | # End Source File 105 | # Begin Source File 106 | 107 | SOURCE=..\..\src\SiftGPU\GLTexImage.cpp 108 | # End Source File 109 | # Begin Source File 110 | 111 | SOURCE=..\..\src\SiftGPU\ProgramGLSL.cpp 112 | # End Source File 113 | # Begin Source File 114 | 115 | SOURCE=..\..\src\SiftGPU\ProgramGPU.cpp 116 | # End Source File 117 | # Begin Source File 118 | 119 | SOURCE=..\..\src\SiftGPU\PyramidGL.cpp 120 | # End Source File 121 | # Begin Source File 122 | 123 | SOURCE=..\..\src\ServerSiftGPU\ServerSiftGPU.cpp 124 | # End Source File 125 | # Begin Source File 126 | 127 | SOURCE=..\..\src\SiftGPU\ShaderMan.cpp 128 | # End Source File 129 | # Begin Source File 130 | 131 | SOURCE=..\..\src\SiftGPU\SiftGPU.cpp 132 | # End Source File 133 | # Begin Source File 134 | 135 | SOURCE=.\SiftGPU.def 136 | # PROP Exclude_From_Build 1 137 | # End Source File 138 | # Begin Source File 139 | 140 | SOURCE=..\..\src\SiftGPU\SiftMatch.cpp 141 | # End Source File 142 | # Begin Source File 143 | 144 | SOURCE=..\..\src\SiftGPU\SIFTPyramid.cpp 145 | # End Source File 146 | # End Group 147 | # Begin Group "Header Files" 148 | 149 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 150 | # Begin Source File 151 | 152 | SOURCE=..\..\src\SiftGPU\FrameBufferObject.h 153 | # End Source File 154 | # Begin Source File 155 | 156 | SOURCE=..\..\src\SiftGPU\GlobalUtil.h 157 | # End Source File 158 | # Begin Source File 159 | 160 | SOURCE=..\..\src\SiftGPU\GLTexImage.h 161 | # End Source File 162 | # Begin Source File 163 | 164 | SOURCE=..\..\src\SiftGPU\LiteWindow.h 165 | # End Source File 166 | # Begin Source File 167 | 168 | SOURCE=..\..\src\SiftGPU\ProgramGLSL.h 169 | # End Source File 170 | # Begin Source File 171 | 172 | SOURCE=..\..\src\SiftGPU\programGPU.h 173 | # End Source File 174 | # Begin Source File 175 | 176 | SOURCE=..\..\src\SiftGPU\PyramidGL.h 177 | # End Source File 178 | # Begin Source File 179 | 180 | SOURCE=..\..\src\ServerSiftGPU\ServerSiftGPU.h 181 | # End Source File 182 | # Begin Source File 183 | 184 | SOURCE=..\..\src\SiftGPU\ShaderMan.h 185 | # End Source File 186 | # Begin Source File 187 | 188 | SOURCE=..\..\src\SiftGPU\SiftGPU.h 189 | # End Source File 190 | # Begin Source File 191 | 192 | SOURCE=..\..\src\SiftGPU\SiftMatch.h 193 | # End Source File 194 | # Begin Source File 195 | 196 | SOURCE=..\..\src\SiftGPU\SIFTPyramid.h 197 | # End Source File 198 | # End Group 199 | # Begin Group "Resource Files" 200 | 201 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 202 | # End Group 203 | # End Target 204 | # End Project 205 | -------------------------------------------------------------------------------- /msvc/SiftGPU_CUDA_Enabled.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestBase", "TestWin\TestBase.vcxproj", "{57496D03-A005-4650-B041-8E70DDA4A591}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestWin", "TestWin\TestWin.vcxproj", "{E1C4EAB3-1677-46F7-92BC-1A1F309B2027}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {9252E247-4FE2-4929-BD5D-C2FA16EFD656} = {9252E247-4FE2-4929-BD5D-C2FA16EFD656} 9 | EndProjectSection 10 | EndProject 11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestWinGlut", "TestWin\TestWinGlut.vcxproj", "{B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}" 12 | ProjectSection(ProjectDependencies) = postProject 13 | {9252E247-4FE2-4929-BD5D-C2FA16EFD656} = {9252E247-4FE2-4929-BD5D-C2FA16EFD656} 14 | EndProjectSection 15 | EndProject 16 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleSIFT", "TestWin\SimpleSIFT.vcxproj", "{D864A317-5A65-47B1-AA82-C04F99C4280F}" 17 | ProjectSection(ProjectDependencies) = postProject 18 | {9252E247-4FE2-4929-BD5D-C2FA16EFD656} = {9252E247-4FE2-4929-BD5D-C2FA16EFD656} 19 | EndProjectSection 20 | EndProject 21 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Speed", "TestWin\Speed.vcxproj", "{7FF72B39-F50E-4ED5-9A50-DCD60EF03604}" 22 | EndProject 23 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SiftGPU_CUDA_Enabled", "SiftGPU\SiftGPU_CUDA_Enabled.vcxproj", "{9252E247-4FE2-4929-BD5D-C2FA16EFD656}" 24 | EndProject 25 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SiftGPU_Server", "ServerSiftGPU\SiftGPU_Server.vcxproj", "{65C987E1-F62C-4461-9E2C-BE1E8A770C51}" 26 | EndProject 27 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MultiThreadSIFT", "TestWin\MultiThreadSIFT.vcxproj", "{8F087E0E-0B77-4CF7-BCD7-F899DB361128}" 28 | EndProject 29 | Global 30 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 31 | Debug|Win32 = Debug|Win32 32 | Debug|x64 = Debug|x64 33 | Release|Win32 = Release|Win32 34 | Release|x64 = Release|x64 35 | EndGlobalSection 36 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 37 | {57496D03-A005-4650-B041-8E70DDA4A591}.Debug|Win32.ActiveCfg = Debug|Win32 38 | {57496D03-A005-4650-B041-8E70DDA4A591}.Debug|Win32.Build.0 = Debug|Win32 39 | {57496D03-A005-4650-B041-8E70DDA4A591}.Debug|x64.ActiveCfg = Debug|x64 40 | {57496D03-A005-4650-B041-8E70DDA4A591}.Debug|x64.Build.0 = Debug|x64 41 | {57496D03-A005-4650-B041-8E70DDA4A591}.Release|Win32.ActiveCfg = Release|Win32 42 | {57496D03-A005-4650-B041-8E70DDA4A591}.Release|Win32.Build.0 = Release|Win32 43 | {57496D03-A005-4650-B041-8E70DDA4A591}.Release|x64.ActiveCfg = Release|x64 44 | {57496D03-A005-4650-B041-8E70DDA4A591}.Release|x64.Build.0 = Release|x64 45 | {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Debug|Win32.ActiveCfg = Debug|Win32 46 | {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Debug|Win32.Build.0 = Debug|Win32 47 | {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Debug|x64.ActiveCfg = Debug|x64 48 | {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Debug|x64.Build.0 = Debug|x64 49 | {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Release|Win32.ActiveCfg = Release|Win32 50 | {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Release|Win32.Build.0 = Release|Win32 51 | {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Release|x64.ActiveCfg = Release|x64 52 | {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Release|x64.Build.0 = Release|x64 53 | {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Debug|Win32.ActiveCfg = Debug|Win32 54 | {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Debug|Win32.Build.0 = Debug|Win32 55 | {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Debug|x64.ActiveCfg = Debug|x64 56 | {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Debug|x64.Build.0 = Debug|x64 57 | {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Release|Win32.ActiveCfg = Release|Win32 58 | {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Release|Win32.Build.0 = Release|Win32 59 | {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Release|x64.ActiveCfg = Release|x64 60 | {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Release|x64.Build.0 = Release|x64 61 | {D864A317-5A65-47B1-AA82-C04F99C4280F}.Debug|Win32.ActiveCfg = Debug|Win32 62 | {D864A317-5A65-47B1-AA82-C04F99C4280F}.Debug|Win32.Build.0 = Debug|Win32 63 | {D864A317-5A65-47B1-AA82-C04F99C4280F}.Debug|x64.ActiveCfg = Debug|x64 64 | {D864A317-5A65-47B1-AA82-C04F99C4280F}.Debug|x64.Build.0 = Debug|x64 65 | {D864A317-5A65-47B1-AA82-C04F99C4280F}.Release|Win32.ActiveCfg = Release|Win32 66 | {D864A317-5A65-47B1-AA82-C04F99C4280F}.Release|Win32.Build.0 = Release|Win32 67 | {D864A317-5A65-47B1-AA82-C04F99C4280F}.Release|x64.ActiveCfg = Release|x64 68 | {D864A317-5A65-47B1-AA82-C04F99C4280F}.Release|x64.Build.0 = Release|x64 69 | {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Debug|Win32.ActiveCfg = Debug|Win32 70 | {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Debug|Win32.Build.0 = Debug|Win32 71 | {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Debug|x64.ActiveCfg = Debug|x64 72 | {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Debug|x64.Build.0 = Debug|x64 73 | {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Release|Win32.ActiveCfg = Release|Win32 74 | {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Release|Win32.Build.0 = Release|Win32 75 | {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Release|x64.ActiveCfg = Release|x64 76 | {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Release|x64.Build.0 = Release|x64 77 | {9252E247-4FE2-4929-BD5D-C2FA16EFD656}.Debug|Win32.ActiveCfg = Debug|Win32 78 | {9252E247-4FE2-4929-BD5D-C2FA16EFD656}.Debug|Win32.Build.0 = Debug|Win32 79 | {9252E247-4FE2-4929-BD5D-C2FA16EFD656}.Debug|x64.ActiveCfg = Debug|x64 80 | {9252E247-4FE2-4929-BD5D-C2FA16EFD656}.Debug|x64.Build.0 = Debug|x64 81 | {9252E247-4FE2-4929-BD5D-C2FA16EFD656}.Release|Win32.ActiveCfg = Release|Win32 82 | {9252E247-4FE2-4929-BD5D-C2FA16EFD656}.Release|Win32.Build.0 = Release|Win32 83 | {9252E247-4FE2-4929-BD5D-C2FA16EFD656}.Release|x64.ActiveCfg = Release|x64 84 | {9252E247-4FE2-4929-BD5D-C2FA16EFD656}.Release|x64.Build.0 = Release|x64 85 | {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Debug|Win32.ActiveCfg = Debug|Win32 86 | {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Debug|Win32.Build.0 = Debug|Win32 87 | {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Debug|x64.ActiveCfg = Debug|x64 88 | {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Debug|x64.Build.0 = Debug|x64 89 | {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Release|Win32.ActiveCfg = Release|Win32 90 | {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Release|Win32.Build.0 = Release|Win32 91 | {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Release|x64.ActiveCfg = Release|x64 92 | {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Release|x64.Build.0 = Release|x64 93 | {8F087E0E-0B77-4CF7-BCD7-F899DB361128}.Debug|Win32.ActiveCfg = Debug|Win32 94 | {8F087E0E-0B77-4CF7-BCD7-F899DB361128}.Debug|Win32.Build.0 = Debug|Win32 95 | {8F087E0E-0B77-4CF7-BCD7-F899DB361128}.Debug|x64.ActiveCfg = Debug|x64 96 | {8F087E0E-0B77-4CF7-BCD7-F899DB361128}.Debug|x64.Build.0 = Debug|x64 97 | {8F087E0E-0B77-4CF7-BCD7-F899DB361128}.Release|Win32.ActiveCfg = Release|Win32 98 | {8F087E0E-0B77-4CF7-BCD7-F899DB361128}.Release|Win32.Build.0 = Release|Win32 99 | {8F087E0E-0B77-4CF7-BCD7-F899DB361128}.Release|x64.ActiveCfg = Release|x64 100 | {8F087E0E-0B77-4CF7-BCD7-F899DB361128}.Release|x64.Build.0 = Release|x64 101 | EndGlobalSection 102 | GlobalSection(SolutionProperties) = preSolution 103 | HideSolutionNode = FALSE 104 | EndGlobalSection 105 | EndGlobal 106 | -------------------------------------------------------------------------------- /msvc/TestWin/MultiThreadSIFT.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="MultiThreadSIFT" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Console Application" 0x0103 6 | 7 | CFG=MultiThreadSIFT - 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 "MultiThreadSIFT.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 "MultiThreadSIFT.mak" CFG="MultiThreadSIFT - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "MultiThreadSIFT - Win32 Release" (based on "Win32 (x86) Console Application") 21 | !MESSAGE "MultiThreadSIFT - Win32 Debug" (based on "Win32 (x86) Console Application") 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)" == "MultiThreadSIFT - 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 Ignore_Export_Lib 0 43 | # PROP Target_Dir "" 44 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c 45 | # ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c 46 | # ADD BASE RSC /l 0x409 /d "NDEBUG" 47 | # ADD RSC /l 0x409 /d "NDEBUG" 48 | BSC32=bscmake.exe 49 | # ADD BASE BSC32 /nologo 50 | # ADD BSC32 /nologo 51 | LINK32=link.exe 52 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 53 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../../bin/MultiThreadSIFT.exe" 54 | 55 | !ELSEIF "$(CFG)" == "MultiThreadSIFT - Win32 Debug" 56 | 57 | # PROP BASE Use_MFC 0 58 | # PROP BASE Use_Debug_Libraries 1 59 | # PROP BASE Output_Dir "Debug" 60 | # PROP BASE Intermediate_Dir "Debug" 61 | # PROP BASE Target_Dir "" 62 | # PROP Use_MFC 0 63 | # PROP Use_Debug_Libraries 1 64 | # PROP Output_Dir "Debug" 65 | # PROP Intermediate_Dir "Debug" 66 | # PROP Ignore_Export_Lib 0 67 | # PROP Target_Dir "" 68 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c 69 | # ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c 70 | # ADD BASE RSC /l 0x409 /d "_DEBUG" 71 | # ADD RSC /l 0x409 /d "_DEBUG" 72 | BSC32=bscmake.exe 73 | # ADD BASE BSC32 /nologo 74 | # ADD BSC32 /nologo 75 | LINK32=link.exe 76 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept 77 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../../bin/MultiThreadSIFT_d.exe" /pdbtype:sept 78 | 79 | !ENDIF 80 | 81 | # Begin Target 82 | 83 | # Name "MultiThreadSIFT - Win32 Release" 84 | # Name "MultiThreadSIFT - Win32 Debug" 85 | # Begin Group "Source Files" 86 | 87 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 88 | # Begin Source File 89 | 90 | SOURCE=..\..\src\TestWin\MultiThreadSIFT.cpp 91 | # End Source File 92 | # End Group 93 | # Begin Group "Header Files" 94 | 95 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 96 | # End Group 97 | # Begin Group "Resource Files" 98 | 99 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 100 | # End Group 101 | # End Target 102 | # End Project 103 | -------------------------------------------------------------------------------- /msvc/TestWin/SimpleSIFT.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="SimpleSIFT" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Console Application" 0x0103 6 | 7 | CFG=SimpleSIFT - 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 "SimpleSIFT.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 "SimpleSIFT.mak" CFG="SimpleSIFT - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "SimpleSIFT - Win32 Release" (based on "Win32 (x86) Console Application") 21 | !MESSAGE "SimpleSIFT - Win32 Debug" (based on "Win32 (x86) Console Application") 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)" == "SimpleSIFT - 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 Ignore_Export_Lib 0 43 | # PROP Target_Dir "" 44 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c 45 | # ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c 46 | # ADD BASE RSC /l 0x409 /d "NDEBUG" 47 | # ADD RSC /l 0x409 /d "NDEBUG" 48 | BSC32=bscmake.exe 49 | # ADD BASE BSC32 /nologo 50 | # ADD BSC32 /nologo 51 | LINK32=link.exe 52 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 53 | # ADD LINK32 kernel32.lib /nologo /subsystem:console /machine:I386 /out:"../../bin/SimpleSIFT.exe" 54 | 55 | !ELSEIF "$(CFG)" == "SimpleSIFT - Win32 Debug" 56 | 57 | # PROP BASE Use_MFC 0 58 | # PROP BASE Use_Debug_Libraries 1 59 | # PROP BASE Output_Dir "Debug" 60 | # PROP BASE Intermediate_Dir "Debug" 61 | # PROP BASE Target_Dir "" 62 | # PROP Use_MFC 0 63 | # PROP Use_Debug_Libraries 1 64 | # PROP Output_Dir "Debug" 65 | # PROP Intermediate_Dir "Debug" 66 | # PROP Ignore_Export_Lib 0 67 | # PROP Target_Dir "" 68 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c 69 | # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c 70 | # ADD BASE RSC /l 0x409 /d "_DEBUG" 71 | # ADD RSC /l 0x409 /d "_DEBUG" 72 | BSC32=bscmake.exe 73 | # ADD BASE BSC32 /nologo 74 | # ADD BSC32 /nologo 75 | LINK32=link.exe 76 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept 77 | # ADD LINK32 kernel32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../../bin/SimpleSIFT_d.exe" /pdbtype:sept 78 | 79 | !ENDIF 80 | 81 | # Begin Target 82 | 83 | # Name "SimpleSIFT - Win32 Release" 84 | # Name "SimpleSIFT - Win32 Debug" 85 | # Begin Group "Source Files" 86 | 87 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 88 | # Begin Source File 89 | 90 | SOURCE=..\..\src\TestWin\SimpleSIFT.cpp 91 | # End Source File 92 | # End Group 93 | # Begin Group "Header Files" 94 | 95 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 96 | # End Group 97 | # Begin Group "Resource Files" 98 | 99 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 100 | # End Group 101 | # End Target 102 | # End Project 103 | -------------------------------------------------------------------------------- /msvc/TestWin/Speed.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="Speed" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Console Application" 0x0103 6 | 7 | CFG=Speed - 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 "Speed.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 "Speed.mak" CFG="Speed - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "Speed - Win32 Release" (based on "Win32 (x86) Console Application") 21 | !MESSAGE "Speed - Win32 Debug" (based on "Win32 (x86) Console Application") 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)" == "Speed - 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 Ignore_Export_Lib 0 43 | # PROP Target_Dir "" 44 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c 45 | # ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c 46 | # ADD BASE RSC /l 0x409 /d "NDEBUG" 47 | # ADD RSC /l 0x409 /d "NDEBUG" 48 | BSC32=bscmake.exe 49 | # ADD BASE BSC32 /nologo 50 | # ADD BSC32 /nologo 51 | LINK32=link.exe 52 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 53 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib siftgpu.lib /nologo /subsystem:console /machine:I386 /out:"../../bin/speed.exe" /libpath:"../../lib" 54 | 55 | !ELSEIF "$(CFG)" == "Speed - Win32 Debug" 56 | 57 | # PROP BASE Use_MFC 0 58 | # PROP BASE Use_Debug_Libraries 1 59 | # PROP BASE Output_Dir "Debug" 60 | # PROP BASE Intermediate_Dir "Debug" 61 | # PROP BASE Target_Dir "" 62 | # PROP Use_MFC 0 63 | # PROP Use_Debug_Libraries 1 64 | # PROP Output_Dir "Debug" 65 | # PROP Intermediate_Dir "Debug" 66 | # PROP Ignore_Export_Lib 0 67 | # PROP Target_Dir "" 68 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c 69 | # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c 70 | # ADD BASE RSC /l 0x409 /d "_DEBUG" 71 | # ADD RSC /l 0x409 /d "_DEBUG" 72 | BSC32=bscmake.exe 73 | # ADD BASE BSC32 /nologo 74 | # ADD BSC32 /nologo 75 | LINK32=link.exe 76 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept 77 | # ADD LINK32 kernel32.lib siftgpu_d.lib /nologo /subsystem:console /debug /machine:I386 /out:"../../bin/speed_d.exe" /pdbtype:sept /libpath:"../../lib" 78 | 79 | !ENDIF 80 | 81 | # Begin Target 82 | 83 | # Name "Speed - Win32 Release" 84 | # Name "Speed - Win32 Debug" 85 | # Begin Group "Source Files" 86 | 87 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 88 | # Begin Source File 89 | 90 | SOURCE=..\..\src\TestWin\speed.cpp 91 | # End Source File 92 | # End Group 93 | # Begin Group "Header Files" 94 | 95 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 96 | # End Group 97 | # Begin Group "Resource Files" 98 | 99 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 100 | # End Group 101 | # End Target 102 | # End Project 103 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /msvc/TestWin/TestWin.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="TestWin" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Application" 0x0101 6 | 7 | CFG=TestWin - 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 "TestWin.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 "TestWin.mak" CFG="TestWin - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "TestWin - Win32 Release" (based on "Win32 (x86) Application") 21 | !MESSAGE "TestWin - Win32 Debug" (based on "Win32 (x86) Application") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | MTL=midl.exe 30 | RSC=rc.exe 31 | 32 | !IF "$(CFG)" == "TestWin - Win32 Release" 33 | 34 | # PROP BASE Use_MFC 0 35 | # PROP BASE Use_Debug_Libraries 0 36 | # PROP BASE Output_Dir "Release" 37 | # PROP BASE Intermediate_Dir "Release" 38 | # PROP BASE Target_Dir "" 39 | # PROP Use_MFC 0 40 | # PROP Use_Debug_Libraries 0 41 | # PROP Output_Dir "Release" 42 | # PROP Intermediate_Dir "Release" 43 | # PROP Ignore_Export_Lib 0 44 | # PROP Target_Dir "" 45 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c 46 | # ADD CPP /nologo /W3 /GX /O2 /I "../../Include/" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c 47 | # SUBTRACT CPP /YX /Yc /Yu 48 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 49 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 50 | # ADD BASE RSC /l 0x409 /d "NDEBUG" 51 | # ADD RSC /l 0x409 /d "NDEBUG" 52 | BSC32=bscmake.exe 53 | # ADD BASE BSC32 /nologo 54 | # ADD BSC32 /nologo 55 | LINK32=link.exe 56 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 57 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib opengl32.lib siftgpu.lib testbase.lib /nologo /subsystem:console /machine:I386 /out:"../../bin/TestWin.exe" /libpath:"../../lib/" 58 | # SUBTRACT LINK32 /pdb:none 59 | 60 | !ELSEIF "$(CFG)" == "TestWin - Win32 Debug" 61 | 62 | # PROP BASE Use_MFC 0 63 | # PROP BASE Use_Debug_Libraries 1 64 | # PROP BASE Output_Dir "Debug" 65 | # PROP BASE Intermediate_Dir "Debug" 66 | # PROP BASE Target_Dir "" 67 | # PROP Use_MFC 0 68 | # PROP Use_Debug_Libraries 1 69 | # PROP Output_Dir "Debug" 70 | # PROP Intermediate_Dir "Debug" 71 | # PROP Ignore_Export_Lib 0 72 | # PROP Target_Dir "" 73 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c 74 | # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../Include/" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c 75 | # SUBTRACT CPP /YX /Yc /Yu 76 | # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 77 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 78 | # ADD BASE RSC /l 0x409 /d "_DEBUG" 79 | # ADD RSC /l 0x409 /d "_DEBUG" 80 | BSC32=bscmake.exe 81 | # ADD BASE BSC32 /nologo 82 | # ADD BSC32 /nologo 83 | LINK32=link.exe 84 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept 85 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib opengl32.lib siftgpu_d.lib testbase_d.lib /nologo /subsystem:console /debug /machine:I386 /out:"../../bin/TestWin_d.exe" /pdbtype:sept /libpath:"../../lib/" 86 | # SUBTRACT LINK32 /pdb:none 87 | 88 | !ENDIF 89 | 90 | # Begin Target 91 | 92 | # Name "TestWin - Win32 Release" 93 | # Name "TestWin - Win32 Debug" 94 | # Begin Group "Source Files" 95 | 96 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 97 | # Begin Source File 98 | 99 | SOURCE=..\..\src\TestWin\GLTestWnd.cpp 100 | # End Source File 101 | # End Group 102 | # Begin Group "Header Files" 103 | 104 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 105 | # Begin Source File 106 | 107 | SOURCE=..\..\src\TestWin\GLTestWnd.h 108 | # End Source File 109 | # End Group 110 | # Begin Group "Resource Files" 111 | 112 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 113 | # End Group 114 | # End Target 115 | # End Project 116 | -------------------------------------------------------------------------------- /msvc/TestWin/TestWinGlut.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="TestWinGlut" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Console Application" 0x0103 6 | 7 | CFG=TestWinGlut - 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 "TestWinGlut.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 "TestWinGlut.mak" CFG="TestWinGlut - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "TestWinGlut - Win32 Release" (based on "Win32 (x86) Console Application") 21 | !MESSAGE "TestWinGlut - Win32 Debug" (based on "Win32 (x86) Console Application") 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)" == "TestWinGlut - 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 Ignore_Export_Lib 0 43 | # PROP Target_Dir "" 44 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c 45 | # ADD CPP /nologo /W3 /GX /O2 /I "../../Include/" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c 46 | # ADD BASE RSC /l 0x409 /d "NDEBUG" 47 | # ADD RSC /l 0x409 /d "NDEBUG" 48 | BSC32=bscmake.exe 49 | # ADD BASE BSC32 /nologo 50 | # ADD BSC32 /nologo 51 | LINK32=link.exe 52 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 53 | # ADD LINK32 kernel32.lib user32.lib siftgpu.lib testbase.lib /nologo /subsystem:console /machine:I386 /out:"../../bin/TestWinGlut.exe" /libpath:"../../lib/" 54 | 55 | !ELSEIF "$(CFG)" == "TestWinGlut - Win32 Debug" 56 | 57 | # PROP BASE Use_MFC 0 58 | # PROP BASE Use_Debug_Libraries 1 59 | # PROP BASE Output_Dir "Debug" 60 | # PROP BASE Intermediate_Dir "Debug" 61 | # PROP BASE Target_Dir "" 62 | # PROP Use_MFC 0 63 | # PROP Use_Debug_Libraries 1 64 | # PROP Output_Dir "Debug" 65 | # PROP Intermediate_Dir "Debug" 66 | # PROP Ignore_Export_Lib 0 67 | # PROP Target_Dir "" 68 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c 69 | # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../Include/" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c 70 | # ADD BASE RSC /l 0x409 /d "_DEBUG" 71 | # ADD RSC /l 0x409 /d "_DEBUG" 72 | BSC32=bscmake.exe 73 | # ADD BASE BSC32 /nologo 74 | # ADD BSC32 /nologo 75 | LINK32=link.exe 76 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept 77 | # ADD LINK32 kernel32.lib siftgpu_d.lib testbase_d.lib /nologo /subsystem:console /debug /machine:I386 /out:"../../bin/TestWinGlut_d.exe" /pdbtype:sept /libpath:"../../lib/" 78 | 79 | !ENDIF 80 | 81 | # Begin Target 82 | 83 | # Name "TestWinGlut - Win32 Release" 84 | # Name "TestWinGlut - Win32 Debug" 85 | # Begin Group "Source Files" 86 | 87 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 88 | # Begin Source File 89 | 90 | SOURCE=..\..\src\TestWin\TestWinGlut.cpp 91 | # End Source File 92 | # End Group 93 | # Begin Group "Header Files" 94 | 95 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 96 | # Begin Source File 97 | 98 | SOURCE=..\..\src\TestWin\TestWinGlut.h 99 | # End Source File 100 | # End Group 101 | # Begin Group "Resource Files" 102 | 103 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 104 | # End Group 105 | # End Target 106 | # End Project 107 | -------------------------------------------------------------------------------- /speed_and_accuracy.txt: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------ 2 | SPEED 3 | ------------------------------------------------------------------------ 4 | 1. The first several rounds of SiftGPU might be slow, don't worry. If it 5 | is always slow, the reason might be either the graphic card is old or the 6 | graphic memory is small. 7 | 8 | 2. Texture reallocation happens when a new image does not fit in the already 9 | allocated storage. To get less reallocations, you can pre-allocate storage 10 | to fit the largest image size, or just use images with the same size. 11 | 12 | 3. Loading some compressed images (.e.g jpg) may take a lot of time on 13 | decompressing. Using binary pgm files or directly specifying data in memory 14 | can achive better performance. Writing ASCII SIFT files is also slow. 15 | 16 | 4. The packd version saves GPU memory but also run faster than the unpacked, 17 | which is default now. 18 | 19 | 5. SiftGPU might be faster with older grpahic card drivers than with newer ones. 20 | 21 | 6. The descriptor normalization in the OpenGL-based implementation is running 22 | on CPU. New versions are now using SSE, which improves the speed for this part 23 | a lot. 24 | 25 | 7. The orientation computation in unpacked implementation is occasionally slow 26 | under single orientation mode (-m 1) or packed orientation mode (-m2p). By 27 | default, siftgpu uses 2 orientations (-m 2), which should be fine. This issue 28 | is still unresolved. 29 | 30 | 8. The thread block settings in the CUDA-based SiftGPU are currently tuned 31 | for my GPU nVidia GTX 8800, which may not be optimized for other GPUs. 32 | 33 | ---------------------------------------------------------------------------- 34 | ACCURACY 35 | ---------------------------------------------------------------------------- 36 | 1. The latest version of SiftGPU now has comparable accuracy with CPU 37 | implementatins. Evaluation on box.pgm of Lowe's package now gives around 600 38 | matches, which is close to SIFT++. 39 | 40 | 2. In orientation computation, SiftGPU uses a factor 2.0 * sigma as the sample 41 | window size, which is smaller than the typical value 3.0. Changing it from 2.0 42 | to 3.0 reduces the speed of this step by %40, but gives only a very small 43 | improvements in matching. You can change it by specifying parameter "-w 3". 44 | 45 | 3. In keypoint localization, SiftGPU refines the location only once by default, 46 | and SiftGPU does not move the level of keypoints in the refinement. 47 | 48 | 4. The feature locations are having a (0.5,0.5) offset compared with CPU 49 | implementations by default. (0, 0) in texture is at the top-left coorner 50 | (instead of center) of the top-left pixel. You can use the center as (0, 0) 51 | by specifying "-loweo" 52 | 53 | 5. By default, SiftGPU does not do Upsampling(-fo -1), To match it with Lowe's 54 | implementation you need to use "-fo -1 -loweo". 55 | 56 | 6. SiftGPU may get slightly different results on different GPUs due to different 57 | floating point precision. SiftGPU is tested on limited types of graphic cards/OS, 58 | working on your graphic card is not guaranteed. 59 | 60 | IF it returns different number of features at different run on the same card, 61 | then something is going wrong, and probably some special tricks need to be used. 62 | Please email me if that happens. 63 | 64 | 7. When getting wrong matches, please look at the saved SIFT file to make sure 65 | there are no weired descriptors( for example, all of the numbers of a descriptor 66 | are 45, or any number in a descriptor is larger than 255) 67 | 68 | ------------------------------------------------------------------------------ 69 | KWOWN ISSUES. 70 | ------------------------------------------------------------------------------ 71 | 1. SiftGPU may have problem with dual monitor. 72 | 2. Slow on 7950. Changing GlobalParam::_iTexFormat to GL_RGBA16F_ARB can make 73 | it work. Unknown reason. 74 | 3. Experiments on 8600 show problems. It works fine for the first image, but 75 | gets wrong keypoints after. 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_SUBDIRECTORY(SiftGPU) 2 | -------------------------------------------------------------------------------- /src/ServerSiftGPU/ServerSiftGPU.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: ServerSiftGPu.h 3 | // Author: Changchang Wu 4 | // Description : interface for the ServerSiftGPU class. 5 | // It starts a SiftGPU server in a new process 6 | // or connects to an existing server. 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 | #ifndef GPU_SIFT_SERVER_H 25 | #define GPU_SIFT_SERVER_H 26 | 27 | 28 | class ComboSiftGPU; 29 | class LiteWindow; 30 | 31 | ///////////////////////////////////////////////////////////////////////////// 32 | //ServerSiftGPU::ServerSiftGPU(int port, char* remote_server) 33 | //Run SiftGPU/SiftMatchGPU computation on a remote computer/process 34 | //if( remote_server == NULL) 35 | // a local server is created in a different process and connects to it 36 | // multiple-GPU can be used by creating multiple instances 37 | // GPU selection done through ParseParam function 38 | //otherwise, 39 | // Assumes the existenc of a remote server and connects to it 40 | // GPU selection is done on the server-end when create the server by running 41 | // server_siftgpu -server port [siftgpu_param] 42 | ///////////////////////////////////////////////////////////////////////////// 43 | 44 | 45 | class ServerSiftGPU: public ComboSiftGPU 46 | { 47 | enum 48 | { 49 | COMMAND_NONE= 0, 50 | COMMAND_EXIT= 1, 51 | COMMAND_DISCONNECT, 52 | /////////////////////////////// 53 | COMMAND_INITIALIZE, 54 | COMMAND_ALLOCATE_PYRAMID, 55 | COMMAND_RUNSIFT, 56 | COMMAND_RUNSIFT_FILE, 57 | COMMAND_RUNSIFT_KEY, 58 | COMMAND_RUNSIFT_DATA, 59 | COMMAND_SAVE_SIFT, 60 | COMMAND_SET_MAX_DIMENSION, 61 | COMMAND_SET_KEYPOINT, 62 | COMMAND_GET_FEATURE_COUNT, 63 | COMMAND_SET_TIGHTPYRAMID, 64 | COMMAND_GET_KEY_VECTOR, 65 | COMMAND_GET_DES_VECTOR, 66 | COMMAND_PARSE_PARAM, 67 | 68 | ///////////////////////////////// 69 | COMMAND_MATCH_INITIALIZE, 70 | COMMAND_MATCH_SET_LANGUAGE, 71 | COMMAND_MATCH_SET_DES_FLOAT, 72 | COMMAND_MATCH_SET_DES_BYTE, 73 | COMMAND_MATCH_SET_MAXSIFT, 74 | COMMAND_MATCH_GET_MATCH, 75 | /////////////////////////////// 76 | DEFAULT_PORT = 7777 77 | }; 78 | private: 79 | #ifdef _WIN64 80 | unsigned __int64 _socketfd; 81 | #else 82 | int _socketfd; 83 | #endif 84 | int _port; 85 | int _connected; 86 | char _server_name[1024]; 87 | private: 88 | void SetParamSiftGPU(int argc, char** argv); 89 | int InitializeConnection(int argc, char** argv); 90 | int StartServerProcess(int argc, char** argv); 91 | int ConnectServer(const char* server_name, int port); 92 | void Disconnect(); 93 | static int InitSocket(); 94 | static int GetPixelSizeGL(unsigned int gl_format, unsigned int gl_type); 95 | static void ServerLoop(int port, int argc, char** argv); 96 | public: 97 | //two options : multi-threading or multi-processing 98 | SIFTGPU_EXPORT ServerSiftGPU(int port = DEFAULT_PORT, char* remote_server = NULL); 99 | virtual ~ServerSiftGPU(); 100 | //////////////////////////////////////// 101 | virtual void ParseParam(int argc, char **argv); 102 | virtual int VerifyContextGL(); 103 | //////////////////////////////////////////////////////////////////////// 104 | //available SiftGPU functions are the following: 105 | virtual int RunSIFT(const char * imgpath); 106 | virtual int RunSIFT(); 107 | //note the difference with class SiftGPU for the function below, 108 | //you have to provide the number of bytes of the data. 109 | virtual int RunSIFT(int width, int height, const void * data, unsigned int gl_format, unsigned int gl_type); 110 | virtual int RunSIFT(int num, const SiftGPU::SiftKeypoint * keys, int keys_have_orientation = 1); 111 | virtual int AllocatePyramid(int width, int height); 112 | ///////////////////////////////////////////////////////////////////// 113 | virtual int GetFeatureNum(); 114 | virtual void SetTightPyramid(int tight = 1); 115 | virtual void SetMaxDimension(int sz); 116 | virtual void GetFeatureVector(SiftGPU::SiftKeypoint * keys, float * descriptors); 117 | virtual void SetKeypointList(int num, const SiftGPU::SiftKeypoint * keys, int keys_have_orientation = 1); 118 | ///////////////////////////////////////////////////////////////////////////// 119 | //the following functions do not block in multi-process mode 120 | //for example, SaveSIFT will return before the file is written 121 | virtual void SaveSIFT(const char * szFileName); 122 | 123 | //simplified functions 124 | int GetImageCount(){return 1;} 125 | int CreateContextGL(){return VerifyContextGL();} 126 | int IsFullSupported(){return VerifyContextGL() == SiftGPU::SIFTGPU_FULL_SUPPORTED;} 127 | int RunSIFT(int index) {return RunSIFT();} 128 | 129 | //////////////////////// 130 | public: 131 | virtual int _CreateContextGL() {return _VerifyContextGL();} 132 | virtual int _VerifyContextGL(); 133 | virtual void SetLanguage(int gpu_language); 134 | virtual void SetDeviceParam(int argc, char**argv); 135 | virtual void SetMaxSift(int max_sift); 136 | virtual void SetDescriptors(int index, int num, const float* descriptors, int id = -1); 137 | virtual void SetDescriptors(int index, int num, const unsigned char * descriptors, int id = -1); 138 | virtual int GetSiftMatch(int max_match, int match_buffer[][2], //buffeture indices 139 | float distmax, float ratiomax, int mutual_best_match); // 140 | public: 141 | ////////////////////////////////////////////////////// 142 | //Some SiftGPU functions are not supported 143 | void SetImageList(int nimage, const char** filelist) {} 144 | void SetVerbose(){} 145 | 146 | ///Guided matching is not supported here, not hard to implement yourself 147 | virtual void SetFeautreLocation(int index, const float* locations, int gap) {return ;} 148 | virtual int GetGuidedSiftMatch(int max_match, int match_buffer[][2], float H[3][3],float F[3][3], 149 | float distmax, float ratiomax, float hdistmax, float fdistmax, int mutual_best_match) {return 0; } 150 | 151 | friend void RunServerLoop(int port, int argc, char** argv); 152 | 153 | }; 154 | 155 | 156 | 157 | #endif 158 | 159 | 160 | -------------------------------------------------------------------------------- /src/ServerSiftGPU/server.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: server.cpp 3 | // Author: Changchang Wu 4 | // Description : driver of a SiftGPU Server. 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 | #include 22 | #include 23 | #include 24 | using std::cout; 25 | 26 | #include "../SiftGPU/SiftGPU.h" 27 | 28 | //if you included ServerSiftGPU.h here. 29 | //CreateRemoteSiftGPU can be replaced by new ServerSiftGPU(); 30 | 31 | int main(int argc, char** argv) 32 | { 33 | 34 | if(argc >= 2 && strcmp(argv[1], "-server") == 0) 35 | { 36 | //run siftgpu server 37 | std::cout << "Starting server process...\n"; 38 | int port = 7777; 39 | if(argc >= 3) sscanf(argv[2], "%d", &port); 40 | ////////////////////////////////////// 41 | RunServerLoop(port, argc - 3, argv + 3); 42 | }else if(argc >=2 && strcmp(argv[1], "-test") == 0) 43 | { 44 | //start server on same computer and connect... 45 | //note we are using a SiftGPU pointer.. 46 | SiftGPU* siftgpu = CreateRemoteSiftGPU(); 47 | siftgpu->ParseParam(argc - 2, argv + 2); 48 | if(siftgpu->VerifyContextGL()) 49 | { 50 | //files on the matchines where the server runs 51 | siftgpu->RunSIFT("../data/800-1.jpg"); 52 | siftgpu->RunSIFT("../data/800-2.jpg"); 53 | } 54 | delete siftgpu; //this will terminate the server 55 | }else if(argc >=4 && strcmp(argv[1], "-test_remote") == 0) 56 | { 57 | ////test client that connects to remote server... 58 | char server_name[1024]; int port = 7777; 59 | strcpy(server_name, argv[2]); 60 | sscanf(argv[3], "%d", &port); 61 | SiftGPU* siftgpu = CreateRemoteSiftGPU(port, server_name);//new ServerSiftGPU(port, server_name); 62 | siftgpu->ParseParam(argc - 4, argv + 4); 63 | if(siftgpu->VerifyContextGL()) 64 | { 65 | //files on the matchines where the server runs 66 | siftgpu->RunSIFT("../data/800-1.jpg"); 67 | siftgpu->RunSIFT("../data/800-2.jpg"); 68 | } 69 | delete siftgpu; 70 | }else if(argc >=2 && strcmp(argv[1], "-test2") == 0) 71 | { 72 | //test using two siftgpu servers...usage: 73 | //server_siftgpu -test2 [server1_params] [-server2 [server2_params]] 74 | 75 | //////////////////////////////////////////// 76 | //they need to use different ports. 77 | SiftGPU* siftgpu1 = CreateRemoteSiftGPU(7777);//new ServerSiftGPU(7777); 78 | SiftGPU* siftgpu2 = CreateRemoteSiftGPU(8888);//new ServerSiftGPU(8888); 79 | 80 | //split the parameters for the two servers 81 | int argc1 = 0, argc2 = 0; 82 | char** argv1 = argv + 2, **argv2 = 0; 83 | while(argc1 + 2 < argc && strcmp(argv[argc1 + 2], "-server2")) 84 | { 85 | argc1++; 86 | } 87 | if(argc1 + 3 < argc && strcmp(argv[argc1 + 2], "-server2") == 0) 88 | { 89 | argv2 = argv + argc1 + 3; 90 | argc2 = argc - argc1 - 3; 91 | } 92 | 93 | //initialize the two servers with their siftgpu parameters 94 | siftgpu1->ParseParam(argc1, argv1); 95 | siftgpu2->ParseParam(argc2, argv2); 96 | if(siftgpu1->VerifyContextGL() && siftgpu2->VerifyContextGL()) 97 | { 98 | siftgpu1->RunSIFT("../data/800-1.jpg"); 99 | siftgpu2->RunSIFT("../data/800-1.jpg"); 100 | siftgpu1->RunSIFT("../data/800-2.jpg"); 101 | siftgpu2->RunSIFT("../data/800-2.jpg"); 102 | } 103 | delete siftgpu1; 104 | delete siftgpu2; 105 | }else 106 | { 107 | std::cout 108 | <<"try -test [siftgpu_param] to create a local server and a client\n" 109 | <<"try -test2 [siftgpu_param1] [-server2 [siftgpu_param2]]\n" 110 | <<" to create two servers and two clients\n" 111 | <<"try -test_remote remote_sever_name remote_server_port\n" 112 | <<" to create a client and connect to remote server\n" 113 | <<"use -server port [siftgpu_param] to start a server\n" 114 | <<"Note [siftgpu_param] allows you to select GPU from multi-GPUs\n" 115 | <<"\n"; 116 | } 117 | return 1; 118 | } 119 | 120 | -------------------------------------------------------------------------------- /src/SiftGPU/CLTexImage.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: CLTexImage.cpp 3 | // Author: Changchang Wu 4 | // Description : implementation of the CLTexImage class. 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 | #if defined(CL_SIFTGPU_ENABLED) 23 | 24 | #include "GL/glew.h" 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | using namespace std; 31 | 32 | 33 | #include 34 | #include "CLTexImage.h" 35 | #include "ProgramCL.h" 36 | #include "GlobalUtil.h" 37 | 38 | 39 | CLTexImage::CLTexImage() 40 | { 41 | _context = NULL; 42 | _queue = NULL; 43 | _clData = NULL; 44 | _numChannel = _bufferLen = _fromGL = 0; 45 | _imgWidth = _imgHeight = _texWidth = _texHeight = 0; 46 | } 47 | 48 | CLTexImage::CLTexImage(cl_context context, cl_command_queue queue) 49 | { 50 | _context = context; 51 | _queue = queue; 52 | _clData = NULL; 53 | _numChannel = _bufferLen = _fromGL = 0; 54 | _imgWidth = _imgHeight = _texWidth = _texHeight = 0; 55 | } 56 | 57 | void CLTexImage::SetContext(cl_context context, cl_command_queue queue) 58 | { 59 | _context = context; 60 | _queue = queue; 61 | } 62 | 63 | 64 | CLTexImage::~CLTexImage() 65 | { 66 | ReleaseTexture(); 67 | } 68 | 69 | void CLTexImage::ReleaseTexture() 70 | { 71 | if(_fromGL) clEnqueueReleaseGLObjects(_queue, 1, &_clData, 0, NULL, NULL); 72 | if(_clData) clReleaseMemObject(_clData); 73 | } 74 | 75 | void CLTexImage::SetImageSize(int width, int height) 76 | { 77 | _imgWidth = width; 78 | _imgHeight = height; 79 | } 80 | 81 | void CLTexImage::InitBufferTex(int width, int height, int nchannel) 82 | { 83 | if(width == 0 || height == 0 || nchannel <= 0 || _fromGL) return; 84 | 85 | _imgWidth = width; _imgHeight = height; 86 | _texWidth = _texHeight = _fromGL = 0; 87 | _numChannel = min(nchannel, 4); 88 | 89 | int size = width * height * _numChannel * sizeof(float); 90 | if (size <= _bufferLen) return; 91 | 92 | //allocate the buffer data 93 | cl_int status; 94 | if(_clData) status = clReleaseMemObject(_clData); 95 | 96 | _clData = clCreateBuffer(_context, CL_MEM_READ_WRITE, 97 | _bufferLen = size, NULL, &status); 98 | 99 | ProgramBagCL::CheckErrorCL(status, "CLTexImage::InitBufferTex"); 100 | 101 | } 102 | 103 | void CLTexImage::InitTexture(int width, int height, int nchannel) 104 | { 105 | if(width == 0 || height == 0 || nchannel <= 0 || _fromGL) return; 106 | if(_clData && width == _texWidth && height == _texHeight && _numChannel == nchannel) return; 107 | if(_clData) clReleaseMemObject(_clData); 108 | 109 | _texWidth = _imgWidth = width; 110 | _texHeight = _imgHeight = height; 111 | _numChannel = nchannel; 112 | _bufferLen = _fromGL = 0; 113 | 114 | cl_int status; cl_image_format format; 115 | 116 | if(nchannel == 1) format.image_channel_order = CL_R; 117 | else if(nchannel == 2) format.image_channel_order = CL_RG; 118 | else if(nchannel == 3) format.image_channel_order = CL_RGB; 119 | else format.image_channel_order = CL_RGBA; 120 | 121 | format.image_channel_data_type = CL_FLOAT; 122 | _clData = clCreateImage2D(_context, CL_MEM_READ_WRITE, & format, 123 | _texWidth, _texHeight, 0, 0, &status); 124 | ProgramBagCL::CheckErrorCL(status, "CLTexImage::InitTexture"); 125 | } 126 | 127 | void CLTexImage::InitPackedTex(int width, int height, int packed) 128 | { 129 | if(packed) InitTexture((width + 1) >> 1, (height + 1) >> 1, 4); 130 | else InitTexture(width, height, 1); 131 | } 132 | 133 | void CLTexImage::SetPackedSize(int width, int height, int packed) 134 | { 135 | if(packed) SetImageSize((width + 1) >> 1, (height + 1) >> 1); 136 | else SetImageSize(width, height); 137 | } 138 | 139 | void CLTexImage::InitTextureGL(GLuint tex, int width, int height, int nchannel) 140 | { 141 | if(tex == 0) return; 142 | if(_clData) clReleaseMemObject(_clData); 143 | 144 | ////create the memory object 145 | cl_int status; 146 | _clData = clCreateFromGLTexture2D(_context, CL_MEM_WRITE_ONLY, 147 | GlobalUtil::_texTarget, 0 , tex, &status); 148 | ProgramBagCL::CheckErrorCL(status, "CLTexImage::InitTextureGL->clCreateFromGLTexture2D"); 149 | if(status != CL_SUCCESS) return; 150 | 151 | _texWidth = _imgWidth = width; 152 | _texHeight = _imgHeight = height; 153 | _numChannel = nchannel; 154 | _bufferLen = 0; _fromGL = 1; 155 | 156 | ////acquire object 157 | status = clEnqueueAcquireGLObjects(_queue, 1, &_clData, 0, NULL, NULL); 158 | ProgramBagCL::CheckErrorCL(status, "CLTexImage::InitTextureGL->clEnqueueAcquireGLObjects"); 159 | 160 | } 161 | 162 | void CLTexImage::CopyFromHost(const void * buf) 163 | { 164 | if(_clData == NULL) return; 165 | cl_int status; 166 | if(_bufferLen) 167 | { 168 | status = clEnqueueWriteBuffer(_queue, _clData, false, 0, 169 | _imgWidth * _imgHeight * _numChannel * sizeof(float), buf, 0, NULL, NULL); 170 | }else 171 | { 172 | size_t origin[3] = {0, 0, 0}, region[3] = {_imgWidth, _imgHeight, 1}; 173 | size_t row_pitch = _imgWidth * _numChannel * sizeof(float); 174 | status = clEnqueueWriteImage(_queue, _clData, false, origin, 175 | region, row_pitch, 0, buf, 0, 0, 0); 176 | } 177 | ProgramBagCL::CheckErrorCL(status, "CLTexImage::CopyFromHost"); 178 | } 179 | 180 | int CLTexImage::GetImageDataSize() 181 | { 182 | return _imgWidth * _imgHeight * _numChannel * sizeof(float); 183 | } 184 | 185 | int CLTexImage::CopyToPBO(GLuint pbo) 186 | { 187 | glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbo); 188 | 189 | int esize = GetImageDataSize(), bsize; 190 | glGetBufferParameteriv(GL_PIXEL_UNPACK_BUFFER_ARB, GL_BUFFER_SIZE, &bsize); 191 | if(bsize < esize) 192 | { 193 | glBufferData(GL_PIXEL_UNPACK_BUFFER_ARB, esize, NULL, GL_STATIC_DRAW_ARB); 194 | glGetBufferParameteriv(GL_PIXEL_UNPACK_BUFFER_ARB, GL_BUFFER_SIZE, &bsize); 195 | } 196 | if(bsize >= esize) 197 | { 198 | // map the buffer object into client's memory 199 | void* ptr = glMapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY_ARB); 200 | CopyToHost(ptr); 201 | clFinish(_queue); 202 | glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB); 203 | } 204 | glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0); 205 | GlobalUtil::CheckErrorsGL("CLTexImage::CopyToPBO"); 206 | return esize >= bsize; 207 | } 208 | 209 | void CLTexImage::CopyToHost(void * buf) 210 | { 211 | if(_clData == NULL) return; 212 | cl_int status; 213 | if(_bufferLen) 214 | { 215 | status = clEnqueueReadBuffer(_queue, _clData, true, 0, 216 | _imgWidth * _imgHeight * _numChannel * sizeof(float), buf, 0, NULL, NULL); 217 | }else 218 | { 219 | size_t origin[3] = {0, 0, 0}, region[3] = {_imgWidth, _imgHeight, 1}; 220 | size_t row_pitch = _imgWidth * _numChannel * sizeof(float); 221 | status = clEnqueueReadImage(_queue, _clData, true, origin, 222 | region, row_pitch, 0, buf, 0, 0, 0); 223 | } 224 | 225 | ProgramBagCL::CheckErrorCL(status, "CLTexImage::CopyToHost"); 226 | } 227 | 228 | #endif 229 | 230 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/SiftGPU/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(OpenGL REQUIRED) 2 | find_package(GLUT REQUIRED) 3 | find_package(GLEW REQUIRED) 4 | 5 | SET(SIFTGPU_ENABLE_SERVER FALSE) 6 | SET(SIFTGPU_ENABLE_OPENCL FALSE) 7 | SET(SIFTGPU_ENABLE_CUDA FALSE) 8 | SET(SIFTGPU_ENABLE_SSE TRUE) 9 | SET(SIFTGPU_SSE_OPTIONS -march=core2 -mfpmath=sse) 10 | SET(SIFTGPU_PREFER_GLUT TRUE) 11 | SET(SIFTGPU_DISABLE_DEVIL TRUE) 12 | 13 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -Wno-deprecated" ) 14 | 15 | IF(SIFTGPU_ENABLE_SSE) 16 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=core2 -mfpmath=sse" ) 17 | ENDIF(SIFTGPU_ENABLE_SSE) 18 | 19 | IF(SIFTGPU_PREFER_GLUT) 20 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWINDOW_PREFER_GLUT" ) 21 | ENDIF(SIFTGPU_PREFER_GLUT) 22 | 23 | IF(SIFTGPU_ENABLE_OPENCL) 24 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCL_SIFTGPU_ENABLED" ) 25 | ENDIF(SIFTGPU_ENABLE_OPENCL) 26 | 27 | IF(APPLE) 28 | SET(LIBS_SIFTGPU ) 29 | ELSE(APPLE) 30 | SET(LIBS_SIFTGPU glut GL X11 ) 31 | ENDIF(APPLE) 32 | 33 | IF(SIFTGPU_DISABLE_DEVIL) 34 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSIFTGPU_NO_DEVIL" ) 35 | ELSE(SIFTGPU_DISABLE_DEVIL) 36 | SET(LIBS_SIFTGPU ${LIBS_SIFTGPU} IL ) 37 | ENDIF(SIFTGPU_DISABLE_DEVIL) 38 | 39 | if (GLEW_FOUND) 40 | include_directories( ${GLEW_INCLUDE_DIRS} ) 41 | SET (GLEW_LIBRARIES GLEW) 42 | endif (GLEW_FOUND) 43 | 44 | ADD_LIBRARY(siftgpu STATIC FrameBufferObject.cpp GlobalUtil.cpp GLTexImage.cpp ProgramGLSL.cpp 45 | ProgramGPU.cpp ShaderMan.cpp SiftGPU.cpp SiftPyramid.cpp PyramidGL.cpp SiftMatch.cpp) 46 | 47 | TARGET_LINK_LIBRARIES(siftgpu ${LIBS_SIFTGPU} ${GLEW_LIBRARIES} ${GLUT_LIBRARIES} ${OPENGL_LIBRARIES} ) 48 | 49 | INSTALL(FILES SiftGPU.h DESTINATION include) 50 | INSTALL(TARGETS siftgpu DESTINATION lib ) 51 | -------------------------------------------------------------------------------- /src/SiftGPU/CuTexImage.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: CuTexImage.cpp 3 | // Author: Changchang Wu 4 | // Description : implementation of the CuTexImage class. 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 | #if defined(CUDA_SIFTGPU_ENABLED) 23 | 24 | #include "GL/glew.h" 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | using namespace std; 31 | 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | #include "GlobalUtil.h" 38 | #include "GLTexImage.h" 39 | #include "CuTexImage.h" 40 | #include "ProgramCU.h" 41 | 42 | #if CUDA_VERSION <= 2010 && defined(SIFTGPU_ENABLE_LINEAR_TEX2D) 43 | #error "Require CUDA 2.2 or higher" 44 | #endif 45 | 46 | 47 | CuTexImage::CuTexImage() 48 | { 49 | _cuData = NULL; 50 | _cuData2D = NULL; 51 | _fromPBO = 0; 52 | _numChannel = _numBytes = 0; 53 | _imgWidth = _imgHeight = _texWidth = _texHeight = 0; 54 | } 55 | 56 | CuTexImage::CuTexImage(int width, int height, int nchannel, GLuint pbo) 57 | { 58 | _cuData = NULL; 59 | 60 | //check size of pbo 61 | GLint bsize, esize = width * height * nchannel * sizeof(float); 62 | glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, pbo); 63 | glGetBufferParameteriv(GL_PIXEL_PACK_BUFFER_ARB, GL_BUFFER_SIZE, &bsize); 64 | if(bsize < esize) 65 | { 66 | glBufferData(GL_PIXEL_PACK_BUFFER_ARB, esize, NULL, GL_STATIC_DRAW_ARB); 67 | glGetBufferParameteriv(GL_PIXEL_PACK_BUFFER_ARB, GL_BUFFER_SIZE, &bsize); 68 | } 69 | glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0); 70 | if(bsize >=esize) 71 | { 72 | 73 | cudaGLRegisterBufferObject(pbo); 74 | cudaGLMapBufferObject(&_cuData, pbo); 75 | ProgramCU::CheckErrorCUDA("cudaGLMapBufferObject"); 76 | _fromPBO = pbo; 77 | }else 78 | { 79 | _cuData = NULL; 80 | _fromPBO = 0; 81 | } 82 | if(_cuData) 83 | { 84 | _numBytes = bsize; 85 | _imgWidth = width; 86 | _imgHeight = height; 87 | _numChannel = nchannel; 88 | }else 89 | { 90 | _numBytes = 0; 91 | _imgWidth = 0; 92 | _imgHeight = 0; 93 | _numChannel = 0; 94 | } 95 | 96 | _texWidth = _texHeight =0; 97 | 98 | _cuData2D = NULL; 99 | } 100 | 101 | CuTexImage::~CuTexImage() 102 | { 103 | 104 | 105 | if(_fromPBO) 106 | { 107 | cudaGLUnmapBufferObject(_fromPBO); 108 | cudaGLUnregisterBufferObject(_fromPBO); 109 | }else if(_cuData) 110 | { 111 | cudaFree(_cuData); 112 | } 113 | if(_cuData2D) cudaFreeArray(_cuData2D); 114 | } 115 | 116 | void CuTexImage::SetImageSize(int width, int height) 117 | { 118 | _imgWidth = width; 119 | _imgHeight = height; 120 | } 121 | 122 | void CuTexImage::InitTexture(int width, int height, int nchannel) 123 | { 124 | int size; 125 | _imgWidth = width; 126 | _imgHeight = height; 127 | _numChannel = min(max(nchannel, 1), 4); 128 | 129 | size = width * height * _numChannel * sizeof(float); 130 | 131 | if(size <= _numBytes) return; 132 | 133 | if(_cuData) cudaFree(_cuData); 134 | 135 | //allocate the array data 136 | cudaMalloc(&_cuData, _numBytes = size); 137 | 138 | #ifdef _DEBUG 139 | ProgramCU::CheckErrorCUDA("CuTexImage::InitTexture"); 140 | #endif 141 | } 142 | 143 | void CuTexImage::CopyFromHost(const void * buf) 144 | { 145 | if(_cuData == NULL) return; 146 | cudaMemcpy( _cuData, buf, _imgWidth * _imgHeight * _numChannel * sizeof(float), cudaMemcpyHostToDevice); 147 | } 148 | 149 | void CuTexImage::CopyToHost(void * buf) 150 | { 151 | if(_cuData == NULL) return; 152 | cudaMemcpy(buf, _cuData, _imgWidth * _imgHeight * _numChannel * sizeof(float), cudaMemcpyDeviceToHost); 153 | } 154 | 155 | void CuTexImage::CopyToHost(void * buf, int stream) 156 | { 157 | if(_cuData == NULL) return; 158 | cudaMemcpyAsync(buf, _cuData, _imgWidth * _imgHeight * _numChannel * sizeof(float), cudaMemcpyDeviceToHost, (cudaStream_t)stream); 159 | } 160 | 161 | void CuTexImage::InitTexture2D() 162 | { 163 | #if !defined(SIFTGPU_ENABLE_LINEAR_TEX2D) 164 | if(_cuData2D && (_texWidth < _imgWidth || _texHeight < _imgHeight)) 165 | { 166 | cudaFreeArray(_cuData2D); 167 | _cuData2D = NULL; 168 | } 169 | 170 | if(_cuData2D == NULL) 171 | { 172 | _texWidth = max(_texWidth, _imgWidth); 173 | _texHeight = max(_texHeight, _imgHeight); 174 | cudaChannelFormatDesc desc; 175 | desc.f = cudaChannelFormatKindFloat; 176 | desc.x = sizeof(float) * 8; 177 | desc.y = _numChannel >=2 ? sizeof(float) * 8 : 0; 178 | desc.z = _numChannel >=3 ? sizeof(float) * 8 : 0; 179 | desc.w = _numChannel >=4 ? sizeof(float) * 8 : 0; 180 | cudaMallocArray(&_cuData2D, &desc, _texWidth, _texHeight); 181 | ProgramCU::CheckErrorCUDA("cudaMallocArray"); 182 | } 183 | #endif 184 | } 185 | 186 | void CuTexImage::CopyToTexture2D() 187 | { 188 | #if !defined(SIFTGPU_ENABLE_LINEAR_TEX2D) 189 | InitTexture2D(); 190 | 191 | if(_cuData2D) 192 | { 193 | cudaMemcpy2DToArray(_cuData2D, 0, 0, _cuData, _imgWidth* _numChannel* sizeof(float) , 194 | _imgWidth * _numChannel*sizeof(float), _imgHeight, cudaMemcpyDeviceToDevice); 195 | ProgramCU::CheckErrorCUDA("cudaMemcpy2DToArray"); 196 | } 197 | #endif 198 | 199 | } 200 | 201 | int CuTexImage::DebugCopyToTexture2D() 202 | { 203 | 204 | /* CuTexImage tex; 205 | float data1[2][3] = {{1, 2, 5}, {3, 4, 5}}, data2[2][5]; 206 | tex.InitTexture(3, 2, 1); 207 | cudaMemcpy(tex._cuData, data1[0], 6 * sizeof(float), cudaMemcpyHostToDevice); 208 | cudaMemcpy(data1, tex._cuData, 4 * sizeof(float) , cudaMemcpyDeviceToHost); 209 | tex._texWidth =5; tex._texHeight = 2; 210 | tex.CopyToTexture2D(); 211 | cudaMemcpyFromArray(data2[0], tex._cuData2D, 0, 0, 10 * sizeof(float), cudaMemcpyDeviceToHost);*/ 212 | 213 | return 1; 214 | } 215 | 216 | 217 | 218 | void CuTexImage::CopyFromPBO(int width, int height, GLuint pbo) 219 | { 220 | void* pbuf =NULL; 221 | GLint esize = width * height * sizeof(float); 222 | cudaGLRegisterBufferObject(pbo); 223 | cudaGLMapBufferObject(&pbuf, pbo); 224 | 225 | cudaMemcpy(_cuData, pbuf, esize, cudaMemcpyDeviceToDevice); 226 | 227 | cudaGLUnmapBufferObject(pbo); 228 | cudaGLUnregisterBufferObject(pbo); 229 | } 230 | 231 | int CuTexImage::CopyToPBO(GLuint pbo) 232 | { 233 | void* pbuf =NULL; 234 | GLint bsize, esize = _imgWidth * _imgHeight * sizeof(float) * _numChannel; 235 | glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, pbo); 236 | glGetBufferParameteriv(GL_PIXEL_PACK_BUFFER_ARB, GL_BUFFER_SIZE, &bsize); 237 | if(bsize < esize) 238 | { 239 | glBufferData(GL_PIXEL_PACK_BUFFER_ARB, esize*3/2, NULL, GL_STATIC_DRAW_ARB); 240 | glGetBufferParameteriv(GL_PIXEL_PACK_BUFFER_ARB, GL_BUFFER_SIZE, &bsize); 241 | } 242 | glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0); 243 | 244 | if(bsize >= esize) 245 | { 246 | cudaGLRegisterBufferObject(pbo); 247 | cudaGLMapBufferObject(&pbuf, pbo); 248 | cudaMemcpy(pbuf, _cuData, esize, cudaMemcpyDeviceToDevice); 249 | cudaGLUnmapBufferObject(pbo); 250 | cudaGLUnregisterBufferObject(pbo); 251 | return 1; 252 | }else 253 | { 254 | return 0; 255 | } 256 | } 257 | 258 | #endif 259 | 260 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/SiftGPU/GLTexImage.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: GLTexImage.h 3 | // Author: Changchang Wu 4 | // Description : interface for the GLTexImage class. 5 | // GLTexImage: naive texture class. 6 | // sevral different quad drawing functions are provied 7 | // GLTexPacked: packed version (four value packed as four channels of a pixel) 8 | // GLTexInput: GLTexImage + some input information 9 | // 10 | // Copyright (c) 2007 University of North Carolina at Chapel Hill 11 | // All Rights Reserved 12 | // 13 | // Permission to use, copy, modify and distribute this software and its 14 | // documentation for educational, research and non-profit purposes, without 15 | // fee, and without a written agreement is hereby granted, provided that the 16 | // above copyright notice and the following paragraph appear in all copies. 17 | // 18 | // The University of North Carolina at Chapel Hill make no representations 19 | // about the suitability of this software for any purpose. It is provided 20 | // 'as is' without express or implied warranty. 21 | // 22 | // Please send BUG REPORTS to ccwu@cs.unc.edu 23 | // 24 | //////////////////////////////////////////////////////////////////////////// 25 | 26 | 27 | #ifndef GL_TEX_IMAGE_H 28 | #define GL_TEX_IMAGE_H 29 | 30 | class GlobalUtil; 31 | class GLTexImage :public GlobalUtil 32 | { 33 | protected: 34 | GLuint _texID; 35 | int _imgWidth; 36 | int _imgHeight; 37 | int _texWidth; 38 | int _texHeight; 39 | int _drawWidth; 40 | int _drawHeight; 41 | public: 42 | static void DetachFBO(int i); 43 | static void UnbindTex(); 44 | static void UnbindMultiTex(int n); 45 | static void DrawQuad(float x1, float x2, float y1, float y2); 46 | 47 | public: 48 | virtual void DrawQuadUS(int scale); 49 | virtual void DrawQuadDS(int scale); 50 | virtual void DrawImage(); 51 | virtual void TexConvertRGB(); 52 | virtual void ZeroHistoMargin(); 53 | virtual void SetImageSize(int width, int height); 54 | virtual void InitTexture(int width, int height, int clamp_to_edge =1 ); 55 | void InitTexture(int width, int height, int clamp_to_edge, GLuint format); 56 | virtual void FillMargin(int marginx, int marginy); 57 | public: 58 | void DrawScaledQuad(float scale); 59 | int CopyToPBO(GLuint pbo, int width, int height, GLenum format = GL_RGBA); 60 | void CopyFromPBO(GLuint pbo, int width, int height, GLenum format = GL_RGBA); 61 | void FitRealTexViewPort(); 62 | void DrawQuadMT8(); 63 | void DrawQuadMT4(); 64 | void DrawQuadReduction(); 65 | void DrawQuadReduction(int w, int h); 66 | void DrawMargin(int right, int bottom); 67 | void DrawQuad(); 68 | void FitTexViewPort(); 69 | void ZeroHistoMargin(int hw, int hh); 70 | int CheckTexture(); 71 | void SaveToASCII(const char* path); 72 | public: 73 | void AttachToFBO(int i ); 74 | void BindTex(); 75 | operator GLuint (){return _texID;} 76 | GLuint GetTexID(){return _texID;} 77 | int GetImgPixelCount(){return _imgWidth*_imgHeight;} 78 | int GetTexPixelCount(){return _texWidth*_texHeight;} 79 | int GetImgWidth(){return _imgWidth;} 80 | int GetImgHeight(){return _imgHeight;} 81 | int GetTexWidth(){return _texWidth;} 82 | int GetTexHeight(){return _texHeight;} 83 | int GetDrawWidth(){return _drawWidth;} 84 | int GetDrawHeight(){return _drawHeight;} 85 | //int IsTexTight(){return _texWidth == _drawWidth && _texHeight == _drawHeight;} 86 | int IsTexPacked(){return _drawWidth != _imgWidth;} 87 | GLTexImage(); 88 | virtual ~GLTexImage(); 89 | friend class SiftGPU; 90 | }; 91 | 92 | //class for handle data input, to support all openGL-supported data format, 93 | //data are first uploaded to an openGL texture then converted, and optionally 94 | //when the datatype is simple, we downsample/convert on cpu 95 | class GLTexInput:public GLTexImage 96 | { 97 | public: 98 | int _down_sampled; 99 | int _rgb_converted; 100 | int _data_modified; 101 | 102 | ////////////////////////// 103 | float * _converted_data; 104 | const void* _pixel_data; 105 | public: 106 | static int IsSimpleGlFormat(unsigned int gl_format, unsigned int gl_type) 107 | { 108 | //the formats there is a cpu code to conver rgb and downsample 109 | return (gl_format ==GL_LUMINANCE ||gl_format == GL_LUMINANCE_ALPHA|| 110 | gl_format == GL_RGB|| gl_format == GL_RGBA|| 111 | gl_format == GL_BGR || gl_format == GL_BGRA) && 112 | (gl_type == GL_UNSIGNED_BYTE || gl_type == GL_FLOAT || gl_type == GL_UNSIGNED_SHORT); 113 | } 114 | //in vc6, template member function doesn't work 115 | #if !defined(_MSC_VER) || _MSC_VER > 1200 116 | template 117 | static int DownSamplePixelDataI(unsigned int gl_format, int width, int height, 118 | int ds, const Uint * pin, Uint * pout); 119 | template 120 | static int DownSamplePixelDataI2F(unsigned int gl_format, int width, int height, 121 | int ds, const Uint * pin, float * pout, int skip = 0); 122 | #endif 123 | static int DownSamplePixelDataF(unsigned int gl_format, int width, int height, 124 | int ds, const float * pin, float * pout, int skip = 0); 125 | static int TruncateWidthCU(int w) {return w & 0xfffffffc; } 126 | public: 127 | GLTexInput() : _down_sampled(0), _rgb_converted(0), _data_modified(0), 128 | _converted_data(0), _pixel_data(0){} 129 | int SetImageData(int width, int height, const void * data, 130 | unsigned int gl_format, unsigned int gl_type); 131 | int LoadImageFile(char * imagepath, int & w, int &h); 132 | void VerifyTexture(); 133 | virtual ~GLTexInput(); 134 | }; 135 | 136 | //GLTexPacked doesn't have any data 137 | //so that we can use the GLTexImage* pointer to index a GLTexPacked Vector 138 | 139 | class GLTexPacked:public GLTexImage 140 | { 141 | public: 142 | virtual void DrawImage(); 143 | virtual void DrawQuadUS(int scale); 144 | virtual void DrawQuadDS(int scale); 145 | virtual void FillMargin(int marginx, int marginy); 146 | virtual void InitTexture(int width, int height, int clamp_to_edge =1); 147 | virtual void TexConvertRGB(); 148 | virtual void SetImageSize(int width, int height); 149 | virtual void ZeroHistoMargin(); 150 | //virtual void GetHistWH(int& w, int& h){return w = (3 + sz)>>1;} 151 | public: 152 | void DrawMargin(int right, int bottom, int mx, int my); 153 | GLTexPacked():GLTexImage(){} 154 | }; 155 | 156 | 157 | #endif // !defined(GL_TEX_IMAGE_H) 158 | 159 | -------------------------------------------------------------------------------- /src/SiftGPU/GlobalUtil.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: GlobalUtil.h 3 | // Author: Changchang Wu 4 | // Description : 5 | // GlobalParam: Global parameters 6 | // ClockTimer: Timer 7 | // GlobalUtil: Global Function wrapper 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 | #ifndef _GLOBAL_UTILITY_H 27 | #define _GLOBAL_UTILITY_H 28 | 29 | 30 | //wrapper for some shader function 31 | //class ProgramGPU; 32 | class LiteWindow; 33 | 34 | class GlobalParam 35 | { 36 | public: 37 | static GLuint _texTarget; 38 | static GLuint _iTexFormat; 39 | static int _texMaxDim; 40 | static int _texMaxDimGL; 41 | static int _texMinDim; 42 | static int _MemCapGPU; 43 | static int _FitMemoryCap; 44 | static int _verbose; 45 | static int _timingS; 46 | static int _timingO; 47 | static int _timingL; 48 | static int _usePackedTex; 49 | static int _IsNvidia; 50 | static int _KeepShaderLoop; 51 | static int _UseCUDA; 52 | static int _UseOpenCL; 53 | static int _UseDynamicIndexing; 54 | static int _debug; 55 | static int _MaxFilterWidth; 56 | static float _FilterWidthFactor; 57 | static float _OrientationWindowFactor; 58 | static float _DescriptorWindowFactor; 59 | static int _MaxOrientation; 60 | static int _OrientationPack2; 61 | static int _ListGenGPU; 62 | static int _ListGenSkipGPU; 63 | static int _SupportNVFloat; 64 | static int _SupportTextureRG; 65 | static int _FullSupported; 66 | static float _MaxFeaturePercent; 67 | static int _MaxLevelFeatureNum; 68 | static int _DescriptorPPR; 69 | static int _DescriptorPPT; //pixel per texture for one descriptor 70 | static int _FeatureTexBlock; 71 | static int _NarrowFeatureTex; //implemented but no performance improvement 72 | static int _SubpixelLocalization; 73 | static int _ProcessOBO; //not implemented yet 74 | static int _TruncateMethod; 75 | static int _PreciseBorder; //implemented 76 | static int _UseSiftGPUEX; 77 | static int _ForceTightPyramid; 78 | static int _octave_min_default; 79 | static int _octave_num_default; 80 | static int _InitPyramidWidth; 81 | static int _InitPyramidHeight; 82 | static int _PreProcessOnCPU; 83 | static int _GoodOpenGL; 84 | static int _FixedOrientation; 85 | static int _LoweOrigin; 86 | static int _ExitAfterSIFT; 87 | static int _NormalizedSIFT; 88 | static int _BinarySIFT; 89 | static int _KeepExtremumSign; 90 | static int _FeatureCountThreshold; 91 | static int _KeyPointListForceLevel0; 92 | static int _DarknessAdaption; 93 | 94 | //for compatability with old version: 95 | static float _OrientationExtraFactor; 96 | static float _OrientationGaussianFactor; 97 | static float _MulitiOrientationThreshold; 98 | 99 | //////////////////////////////////////// 100 | static int _WindowInitX; 101 | static int _WindowInitY; 102 | static const char* _WindowDisplay; 103 | static int _DeviceIndex; 104 | }; 105 | 106 | 107 | class ClockTimer 108 | { 109 | private: 110 | char _current_event[256]; 111 | int _time_start; 112 | int _time_stop; 113 | public: 114 | static int ClockMS(); 115 | static double CLOCK(); 116 | static void InitHighResolution(); 117 | void StopTimer(int verb = 1); 118 | void StartTimer(const char * event, int verb=0); 119 | float GetElapsedTime(); 120 | }; 121 | 122 | class GlobalUtil:public GlobalParam 123 | { 124 | static ClockTimer _globalTimer; 125 | public: 126 | inline static double CLOCK() { return ClockTimer::CLOCK(); } 127 | inline static void StopTimer() { _globalTimer.StopTimer(_timingS); } 128 | inline static void StartTimer(const char * event) { _globalTimer.StartTimer(event, _timingO); } 129 | inline static float GetElapsedTime() { return _globalTimer.GetElapsedTime(); } 130 | 131 | static void FitViewPort(int width, int height); 132 | static void SetTextureParameter(); 133 | static void SetTextureParameterUS(); 134 | #ifdef _DEBUG 135 | static void CheckErrorsGL(const char* location = NULL); 136 | #else 137 | static void inline CheckErrorsGL(const char* location = NULL){}; 138 | #endif 139 | static bool CheckFramebufferStatus(); 140 | //initialize Opengl parameters 141 | static void SelectDisplay(); 142 | static void InitGLParam(int NotTargetGL = 0); 143 | static void SetGLParam(); 144 | static int CreateWindowEZ(); 145 | static void CleanupOpenGL(); 146 | static void SetDeviceParam(int argc, char** argv); 147 | static int CreateWindowEZ(LiteWindow* window); 148 | }; 149 | 150 | 151 | #if defined(_MSC_VER) && _MSC_VER == 1200 152 | #define max(a,b) (((a) > (b)) ? (a) : (b)) 153 | #define min(a,b) (((a) < (b)) ? (a) : (b)) 154 | #endif 155 | 156 | #endif 157 | 158 | -------------------------------------------------------------------------------- /src/SiftGPU/LiteWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef LITE_WINDOW_H 2 | #define LITE_WINDOW_H 3 | 4 | //#define WINDOW_PREFER_GLUT 5 | 6 | #if defined(WINDOW_PREFER_GLUT) 7 | 8 | #ifdef __APPLE__ 9 | #include "GLUT/glut.h" 10 | #else 11 | #include "GL/glut.h" 12 | #endif 13 | //for apple, use GLUT to create the window.. 14 | class LiteWindow 15 | { 16 | int glut_id; 17 | public: 18 | LiteWindow() { glut_id = 0; } 19 | int IsValid() { return glut_id > 0; } 20 | virtual ~LiteWindow() { if(glut_id > 0) glutDestroyWindow(glut_id); } 21 | void MakeCurrent() { glutSetWindow(glut_id); } 22 | void Create(int x = -1, int y = -1, const char* display = NULL) 23 | { 24 | static int _glut_init_called = 0; 25 | if(glut_id != 0) return; 26 | 27 | //see if there is an existing window 28 | if(_glut_init_called) glut_id = glutGetWindow(); 29 | 30 | //create one if no glut window exists 31 | if(glut_id != 0) return; 32 | 33 | if(_glut_init_called == 0) 34 | { 35 | int argc = 1; 36 | char * argv[4] = { "-iconic", 0 , 0, 0}; 37 | if(display) 38 | { 39 | argc = 3; 40 | argv[1] = "-display"; 41 | argv[2] = (char*) display; 42 | } 43 | glutInit(&argc, argv); 44 | glutInitDisplayMode (GLUT_RGBA ); 45 | _glut_init_called = 1; 46 | } 47 | if(x != -1) glutInitWindowPosition(x, y); 48 | if(display || x != -1) std::cout << "Using display [" 49 | << (display? display : "\0" )<< "] at (" << x << "," << y << ")\n"; 50 | glut_id = glutCreateWindow ("SIFT_GPU_GLUT"); 51 | glutHideWindow(); 52 | } 53 | }; 54 | #elif defined( _WIN32) 55 | 56 | #ifndef _INC_WINDOWS 57 | #ifndef WIN32_LEAN_AND_MEAN 58 | #define WIN32_LEAN_AND_MEAN 59 | #endif 60 | #include 61 | #endif 62 | 63 | class LiteWindow 64 | { 65 | HWND hWnd; 66 | HGLRC hContext; 67 | HDC hdc; 68 | public: 69 | LiteWindow() 70 | { 71 | hWnd = NULL; 72 | hContext = NULL; 73 | hdc = NULL; 74 | } 75 | virtual ~LiteWindow() 76 | { 77 | if(hContext)wglDeleteContext(hContext); 78 | if(hdc)ReleaseDC(hWnd, hdc); 79 | if(hWnd)DestroyWindow(hWnd); 80 | } 81 | int IsValid() 82 | { 83 | return hContext != NULL; 84 | } 85 | 86 | //display is ignored under Win32 87 | void Create(int x = -1, int y = -1, const char* display = NULL) 88 | { 89 | if(hContext) return; 90 | WNDCLASSEX wcex = { sizeof(WNDCLASSEX), CS_HREDRAW | CS_VREDRAW, 91 | (WNDPROC)DefWindowProc, 0, 4, 0, 0, 0, 0, 0, 92 | ("SIFT_GPU_LITE"), 0}; 93 | RegisterClassEx(&wcex); 94 | hWnd = CreateWindow("SIFT_GPU_LITE", "SIFT_GPU", 0, 95 | CW_USEDEFAULT, CW_USEDEFAULT, 96 | 100, 100, NULL, NULL, 0, 0); 97 | 98 | //move the window so that it can be on the second monitor 99 | if(x !=-1) 100 | { 101 | MoveWindow(hWnd, x, y, 100, 100, 0); 102 | std::cout << "CreateWindow at (" << x << "," << y<<")\n"; 103 | } 104 | 105 | /////////////////////////////////////////////////// 106 | PIXELFORMATDESCRIPTOR pfd = 107 | { 108 | sizeof(PIXELFORMATDESCRIPTOR), 1, 109 | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL , 110 | PFD_TYPE_RGBA,16,0, 0, 0, 0, 0, 0, 0, 0, 111 | 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0 112 | }; 113 | hdc=GetDC(hWnd); 114 | //////////////////////////////////// 115 | int pixelformat = ChoosePixelFormat(hdc, &pfd); 116 | DescribePixelFormat(hdc, pixelformat, sizeof(pfd), &pfd); 117 | SetPixelFormat(hdc, pixelformat, &pfd); 118 | hContext = wglCreateContext(hdc); 119 | 120 | } 121 | void MakeCurrent() 122 | { 123 | wglMakeCurrent(hdc, hContext); 124 | } 125 | }; 126 | 127 | #else 128 | 129 | #include 130 | #include 131 | #include 132 | 133 | class LiteWindow 134 | { 135 | Display* xDisplay; 136 | XVisualInfo* xVisual; 137 | Window xWin; 138 | GLXContext xContext; 139 | Colormap xColormap; 140 | public: 141 | LiteWindow() 142 | { 143 | xDisplay = NULL; 144 | xVisual = NULL; 145 | xWin = 0; 146 | xColormap = 0; 147 | xContext = NULL; 148 | } 149 | int IsValid () 150 | { 151 | return xContext != NULL && glXIsDirect(xDisplay, xContext); 152 | } 153 | virtual ~LiteWindow() 154 | { 155 | if(xWin) XDestroyWindow(xDisplay, xWin); 156 | if(xContext) glXDestroyContext(xDisplay, xContext); 157 | if(xColormap) XFreeColormap(xDisplay, xColormap); 158 | if(xDisplay) XCloseDisplay(xDisplay); 159 | } 160 | void Create(int x = 0, int y = 0, const char * display = NULL) 161 | { 162 | if(xDisplay) return; 163 | if(display) std::cout << "Using display ["<screen), 173 | xVisual->visual, AllocNone); 174 | 175 | XSetWindowAttributes wa; 176 | wa.event_mask = 0; 177 | wa.border_pixel = 0; 178 | wa.colormap = xColormap; 179 | 180 | xWin = XCreateWindow( xDisplay, RootWindow(xDisplay, xVisual->screen) , 181 | x, y, 100, 100, 0, xVisual->depth, 182 | InputOutput, xVisual->visual, 183 | CWBorderPixel |CWColormap | CWEventMask, &wa); 184 | 185 | xContext = glXCreateContext(xDisplay, xVisual, 0, GL_TRUE); 186 | } 187 | void MakeCurrent() 188 | { 189 | if(xContext) glXMakeCurrent(xDisplay, xWin, xContext); 190 | } 191 | }; 192 | 193 | #endif 194 | 195 | 196 | #endif 197 | 198 | -------------------------------------------------------------------------------- /src/SiftGPU/ProgramCG.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: ProgramCG.h 3 | // Author: Changchang Wu 4 | // Description : interface for the ProgramCG classes. 5 | // ProgramCG: Cg programs 6 | // ShaderBagCG: All Cg shaders for Sift in a bag 7 | // FilterGLCG: Cg Gaussian Filters 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(CG_SIFTGPU_ENABLED) 27 | 28 | #ifndef _PROGRAM_CG_H 29 | #define _PROGRAM_CG_H 30 | 31 | #include "ProgramGPU.h" 32 | class FragmentProgram; 33 | #include "Cg/cgGL.h" 34 | 35 | class ProgramCG:public ProgramGPU 36 | { 37 | CGprogram _programID; 38 | CGprofile _profile; 39 | int _valid; 40 | public: 41 | static CGcontext _Context; 42 | static CGprofile _FProfile; 43 | public: 44 | operator CGprogram (){return _programID;} 45 | CGprogram GetProgramID(){return _programID;} 46 | int UseProgram(); 47 | int IsValidProgram(){return _programID && _valid;} 48 | static void ErrorCallback(); 49 | static void InitContext(); 50 | static void DestroyContext(); 51 | ProgramCG(const char * code, const char** cg_compile_args= NULL, CGprofile profile = ProgramCG::_FProfile); 52 | ProgramCG(); 53 | virtual ~ProgramCG(); 54 | 55 | }; 56 | 57 | class ShaderBagCG:public ShaderBag 58 | { 59 | CGparameter _param_dog_texu; 60 | CGparameter _param_dog_texd; 61 | CGparameter _param_genlist_start_tex0; 62 | CGparameter _param_ftex_width; 63 | CGparameter _param_genlist_step_tex; 64 | CGparameter _param_genlist_step_tex0; 65 | CGparameter _param_genvbo_size; 66 | CGparameter _param_orientation_gtex; 67 | CGparameter _param_orientation_stex; 68 | CGparameter _param_orientation_size; 69 | CGparameter _param_descriptor_gtex; 70 | CGparameter _param_descriptor_size; 71 | CGparameter _param_descriptor_dsize; 72 | CGparameter _param_margin_copy_truncate; 73 | CGparameter _param_genlist_init_bbox; 74 | public: 75 | virtual void LoadDescriptorShader(); 76 | void LoadDescriptorShaderF2(); 77 | static void WriteOrientationCodeToStream(ostream& out); 78 | virtual void SetGenListInitParam(int w, int h); 79 | virtual void SetMarginCopyParam(int xmax, int ymax); 80 | virtual void SetFeatureOrientationParam(int gtex, int width, int height, float sigma, int stex = 0, float step = 1.0f); 81 | virtual void SetFeatureDescirptorParam(int gtex, int otex, float dwidth, float fwidth, float width, float height, float sigma); 82 | virtual void SetSimpleOrientationInput(int oTex, float sigma, float sigma_step); 83 | void LoadOrientationShader(); 84 | virtual void SetGenListStartParam(float width, int tex0); 85 | static ProgramCG* LoadGenListStepShader(int start, int step); 86 | static ProgramCG* LoadGenListStepShaderV2(int start, int step); 87 | void LoadGenListShader(int ndoglev, int nlev); 88 | virtual void UnloadProgram(); 89 | virtual void SetDogTexParam(int texU, int texD); 90 | virtual void SetGenListStepParam(int tex, int tex0); 91 | virtual void SetGenVBOParam( float width, float fwidth, float size); 92 | virtual void LoadFixedShaders(); 93 | virtual void LoadDisplayShaders(); 94 | virtual void LoadKeypointShader(float threshold, float edgeThreshold); 95 | virtual int LoadKeypointShaderMR(float threshold, float edgeThreshold); 96 | ShaderBagCG(); 97 | virtual ~ShaderBagCG(){} 98 | }; 99 | 100 | 101 | class FilterGLCG : public FilterProgram 102 | { 103 | private: 104 | ProgramGPU* CreateFilterH(float kernel[], float offset[], int width); 105 | ProgramGPU* CreateFilterV(float kernel[], float offset[], int height); 106 | //packed version 107 | ProgramGPU* CreateFilterHPK(float kernel[], float offset[], int width); 108 | ProgramGPU* CreateFilterVPK(float kernel[], float offset[], int height); 109 | }; 110 | 111 | class ShaderBagPKCG:public ShaderBag 112 | { 113 | private: 114 | CGparameter _param_dog_texu; 115 | CGparameter _param_dog_texd; 116 | CGparameter _param_margin_copy_truncate; 117 | CGparameter _param_grad_pass_texp; 118 | CGparameter _param_genlist_init_bbox; 119 | CGparameter _param_genlist_start_tex0; 120 | CGparameter _param_ftex_width; 121 | CGparameter _param_genlist_step_tex; 122 | CGparameter _param_genlist_step_tex0; 123 | CGparameter _param_genlist_end_ktex; 124 | CGparameter _param_genvbo_size; 125 | CGparameter _param_orientation_gtex; 126 | CGparameter _param_orientation_otex; 127 | CGparameter _param_orientation_size; 128 | CGparameter _param_descriptor_gtex; 129 | CGparameter _param_descriptor_otex; 130 | CGparameter _param_descriptor_size; 131 | CGparameter _param_descriptor_dsize; 132 | 133 | public: 134 | ShaderBagPKCG(); 135 | virtual ~ShaderBagPKCG(){} 136 | virtual void LoadDescriptorShader(); 137 | virtual void LoadDescriptorShaderF2(); 138 | virtual void LoadOrientationShader(); 139 | virtual void LoadGenListShader(int ndoglev, int nlev); 140 | virtual void LoadGenListShaderV2(int ndoglev, int nlev); 141 | virtual void UnloadProgram() ; 142 | virtual void LoadKeypointShader(float threshold, float edgeTrheshold); 143 | virtual void LoadFixedShaders(); 144 | virtual void LoadDisplayShaders(); 145 | virtual void SetGradPassParam(int texP); 146 | virtual void SetGenListEndParam(int ktex); 147 | public: 148 | //parameters 149 | virtual void SetGenListStartParam(float width, int tex0); 150 | virtual void SetGenListInitParam(int w, int h); 151 | virtual void SetMarginCopyParam(int xmax, int ymax); 152 | virtual void SetDogTexParam(int texU, int texD); 153 | virtual void SetGenListStepParam(int tex, int tex0); 154 | virtual void SetGenVBOParam( float width, float fwidth, float size); 155 | virtual void SetFeatureDescirptorParam(int gtex, int otex, float dwidth, float fwidth, float width, float height, float sigma); 156 | virtual void SetFeatureOrientationParam(int gtex, int width, int height, float sigma, int stex, float step); 157 | virtual void SetSimpleOrientationInput(int oTex, float sigma, float sigma_step); 158 | }; 159 | #endif 160 | #endif 161 | 162 | -------------------------------------------------------------------------------- /src/SiftGPU/ProgramCL.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: ProgramCL.h 3 | // Author: Changchang Wu 4 | // Description : interface for the ProgramCL classes. 5 | // ProgramCL: Cg programs 6 | // ShaderBagCG: All Cg shaders for Sift in a bag 7 | // FilterCL: Cg Gaussian Filters 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(CL_SIFTGPU_ENABLED) 27 | 28 | #ifndef _PROGRAM_CL_H 29 | #define _PROGRAM_CL_H 30 | 31 | #include "ProgramGPU.h" 32 | 33 | class ProgramCL: public ProgramGPU 34 | { 35 | cl_program _program; 36 | cl_kernel _kernel; 37 | int _valid; 38 | public: 39 | int IsValidProgram(){return _program && _valid;} 40 | ProgramCL(const char* name, const char * code, cl_context contex, cl_device_id device); 41 | ProgramCL(); 42 | void PrintBuildLog(cl_device_id device, int all); 43 | virtual ~ProgramCL(); 44 | virtual int UseProgram(){return 1;} 45 | virtual void * GetProgramID() {return _kernel;} 46 | friend class ProgramBagCL; 47 | friend class ProgramBagCLN; 48 | }; 49 | 50 | class CLTexImage; 51 | class FilterCL 52 | { 53 | public: 54 | ProgramCL* s_shader_h; 55 | ProgramCL* s_shader_v; 56 | int _size; 57 | int _id; 58 | CLTexImage * _weight; 59 | public: 60 | FilterCL() : s_shader_h(NULL), s_shader_v(NULL), _size(0), _id(0), _weight(NULL) {} 61 | ~FilterCL() {if(s_shader_h) delete s_shader_h; if(s_shader_v) delete s_shader_v; if(_weight) delete _weight; } 62 | }; 63 | 64 | class SiftParam; 65 | 66 | class ProgramBagCL 67 | { 68 | protected: 69 | cl_platform_id _platform; 70 | cl_device_id _device; 71 | cl_context _context; 72 | cl_command_queue _queue; 73 | protected: 74 | ProgramCL * s_gray; 75 | ProgramCL * s_sampling; 76 | ProgramCL * s_sampling_k; 77 | ProgramCL * s_sampling_u; 78 | ProgramCL * s_zero_pass; 79 | ProgramCL * s_packup; 80 | ProgramCL * s_unpack; 81 | ProgramCL * s_unpack_dog; 82 | ProgramCL * s_unpack_grd; 83 | ProgramCL * s_unpack_key; 84 | ProgramCL * s_dog_pass; 85 | ProgramCL * s_grad_pass; 86 | ProgramCL * s_grad_pass2; 87 | ProgramCL * s_gray_pack; 88 | ProgramCL * s_keypoint; 89 | public: 90 | FilterCL * f_gaussian_skip0; 91 | vector f_gaussian_skip0_v; 92 | FilterCL * f_gaussian_skip1; 93 | FilterCL ** f_gaussian_step; 94 | int _gaussian_step_num; 95 | public: 96 | ProgramBagCL(); 97 | bool InitializeContext(); 98 | virtual ~ProgramBagCL(); 99 | void FinishCL(); 100 | cl_context GetContextCL() {return _context;} 101 | cl_command_queue GetCommandQueue() {return _queue;} 102 | static const char* GetErrorString(cl_int error); 103 | static bool CheckErrorCL(cl_int error, const char* location = NULL); 104 | public: 105 | FilterCL * CreateGaussianFilter(float sigma); 106 | void CreateGaussianFilters(SiftParam¶m); 107 | void SelectInitialSmoothingFilter(int octave_min, SiftParam¶m); 108 | void FilterInitialImage(CLTexImage* tex, CLTexImage* buf); 109 | void FilterSampledImage(CLTexImage* tex, CLTexImage* buf); 110 | void UnpackImage(CLTexImage*src, CLTexImage* dst); 111 | void UnpackImageDOG(CLTexImage*src, CLTexImage* dst); 112 | void UnpackImageGRD(CLTexImage*src, CLTexImage* dst); 113 | void UnpackImageKEY(CLTexImage*src, CLTexImage* dog, CLTexImage* dst); 114 | void ComputeDOG(CLTexImage*tex, CLTexImage* texp, CLTexImage* dog, CLTexImage* grad, CLTexImage* rot); 115 | void ComputeKEY(CLTexImage*dog, CLTexImage* key, float Tdog, float Tedge); 116 | public: 117 | virtual void SampleImageU(CLTexImage *dst, CLTexImage *src, int log_scale); 118 | virtual void SampleImageD(CLTexImage *dst, CLTexImage *src, int log_scale = 1); 119 | virtual void FilterImage(FilterCL* filter, CLTexImage *dst, CLTexImage *src, CLTexImage*tmp); 120 | virtual ProgramCL* CreateFilterH(float kernel[], int width); 121 | virtual ProgramCL* CreateFilterV(float kernel[], int width); 122 | virtual FilterCL* CreateFilter(float kernel[], int width); 123 | public: 124 | virtual void InitProgramBag(SiftParam¶m); 125 | virtual void LoadDescriptorShader(); 126 | virtual void LoadDescriptorShaderF2(); 127 | virtual void LoadOrientationShader(); 128 | virtual void LoadGenListShader(int ndoglev, int nlev); 129 | virtual void UnloadProgram() ; 130 | virtual void LoadKeypointShader(); 131 | virtual void LoadFixedShaders(); 132 | virtual void LoadDisplayShaders(); 133 | virtual void LoadDynamicShaders(SiftParam& param); 134 | public: 135 | //parameters 136 | virtual void SetGradPassParam(int texP); 137 | virtual void SetGenListEndParam(int ktex); 138 | virtual void SetGenListStartParam(float width, int tex0); 139 | virtual void SetGenListInitParam(int w, int h); 140 | virtual void SetMarginCopyParam(int xmax, int ymax); 141 | virtual void SetDogTexParam(int texU, int texD); 142 | virtual void SetGenListStepParam(int tex, int tex0); 143 | virtual void SetGenVBOParam( float width, float fwidth, float size); 144 | virtual void SetFeatureDescirptorParam(int gtex, int otex, float dwidth, float fwidth, float width, float height, float sigma); 145 | virtual void SetFeatureOrientationParam(int gtex, int width, int height, float sigma, int stex, float step); 146 | virtual void SetSimpleOrientationInput(int oTex, float sigma, float sigma_step); 147 | 148 | }; 149 | 150 | class CLTexImage ; 151 | class ProgramBagCLN: public ProgramBagCL 152 | { 153 | public: 154 | virtual void SampleImageD(CLTexImage *dst, CLTexImage *src, int log_scale = 1); 155 | virtual FilterCL* CreateFilter(float kernel[], int width); 156 | virtual ProgramCL* CreateFilterH(float kernel[], int width); 157 | virtual ProgramCL* CreateFilterV(float kernel[], int width); 158 | virtual void FilterImage(FilterCL* filter, CLTexImage *dst, CLTexImage *src, CLTexImage*tmp); 159 | virtual void LoadFixedShaders(); 160 | virtual void LoadDisplayShaders(); 161 | }; 162 | #endif 163 | #endif 164 | 165 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/SiftGPU/PyramidGL.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: PyramidGL.h 3 | // Author: Changchang Wu 4 | // Description : interface for the PyramdGL 5 | // class PyramidNaive and PyramidPacked are derived from PyramidGL 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 | 25 | #ifndef _PYRAMID_GL_H 26 | #define _PYRAMID_GL_H 27 | 28 | class GLTexImage; 29 | class SiftParam; 30 | class ProgramGPU; 31 | class ShaderMan; 32 | class GlobalUtil; 33 | class SiftPyramid; 34 | 35 | class PyramidGL:public SiftPyramid 36 | { 37 | protected: 38 | GLTexImage* _histoPyramidTex; 39 | GLTexImage* _featureTex; 40 | GLTexImage* _descriptorTex; 41 | GLTexImage* _orientationTex; 42 | public: 43 | void InitializeContext(); 44 | void SetLevelFeatureNum(int idx, int num); 45 | void GetTextureStorageSize(int num, int &fw, int& fh); 46 | void GetAlignedStorageSize(int num, int align, int &fw, int &fh); 47 | static void InterlaceDescriptorF2(int w, int h, float* buf, float* pd, int step); 48 | static void NormalizeDescriptor(int num, float*pd); 49 | virtual void DownloadKeypoints(); 50 | virtual int ResizeFeatureStorage(); 51 | //////////////////////////// 52 | virtual void DestroyPerLevelData(); 53 | virtual void DestroySharedData(); 54 | virtual void GetFeatureDescriptors(); 55 | virtual void GenerateFeatureListTex(); 56 | virtual void ReshapeFeatureListCPU(); 57 | virtual void GenerateFeatureDisplayVBO(); 58 | virtual void CleanUpAfterSIFT(); 59 | virtual GLTexImage* GetBaseLevel(int octave, int dataName = DATA_GAUSSIAN)=0; 60 | public: 61 | PyramidGL(SiftParam&sp); 62 | virtual ~PyramidGL(); 63 | }; 64 | 65 | class PyramidNaive:public PyramidGL, public ShaderMan 66 | { 67 | protected: 68 | GLTexImage * _texPyramid; 69 | GLTexImage * _auxPyramid; 70 | public: 71 | void DestroyPyramidData(); 72 | void GetSimplifiedOrientation(); 73 | void GenerateFeatureListCPU(); 74 | virtual void GetFeatureOrientations(); 75 | virtual void GenerateFeatureList(); 76 | void DetectKeypointsEX(); 77 | void ComputeGradient(); 78 | GLTexImage* GetLevelTexture(int octave, int level); 79 | GLTexImage* GetBaseLevel(int octave, int dataName = DATA_GAUSSIAN); 80 | GLTexImage* GetLevelTexture(int octave, int level, int dataName); 81 | void BuildPyramid(GLTexInput * input); 82 | void InitPyramid(int w, int h, int ds); 83 | void FitPyramid(int w, int h); 84 | void ResizePyramid(int w, int h); 85 | void FitHistogramPyramid(); 86 | PyramidNaive(SiftParam & sp); 87 | ~PyramidNaive(); 88 | private: 89 | void GenerateFeatureList(int i, int j); 90 | }; 91 | 92 | 93 | class PyramidPacked:public PyramidGL, public ShaderMan 94 | { 95 | GLTexPacked * _allPyramid; 96 | public: 97 | PyramidPacked(SiftParam& sp); 98 | ~PyramidPacked(); 99 | void DestroyPyramidData(); 100 | void DetectKeypointsEX(); 101 | void ComputeGradient(); 102 | void BuildPyramid(GLTexInput * input); 103 | void InitPyramid(int w, int h, int ds); 104 | void FitPyramid(int w, int h); 105 | void ResizePyramid(int w, int h); 106 | void FitHistogramPyramid(); 107 | void GenerateFeatureListCPU(); 108 | void GenerateFeatureList(); 109 | void GetSimplifiedOrientation(); 110 | void GetFeatureOrientations(); 111 | GLTexImage* GetBaseLevel(int octave, int dataName = DATA_GAUSSIAN); 112 | GLTexImage* GetLevelTexture(int octave, int level); 113 | GLTexImage* GetLevelTexture(int octave, int level, int dataName); 114 | virtual int IsUsingRectDescription(){return _existing_keypoints & SIFT_RECT_DESCRIPTION; } 115 | private: 116 | void GenerateFeatureList(int i, int j); 117 | }; 118 | 119 | #endif 120 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/SiftGPU/SiftMatchCU.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: SiftMatchCU.cpp 3 | // Author: Changchang Wu 4 | // Description : implementation of the SiftMatchCU class. 5 | // CUDA-based implementation of SiftMatch 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 | #if defined(CUDA_SIFTGPU_ENABLED) 24 | 25 | #include "GL/glew.h" 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | using namespace std; 32 | 33 | 34 | #include "GlobalUtil.h" 35 | #include "CuTexImage.h" 36 | #include "SiftGPU.h" 37 | #include "ProgramCU.h" 38 | #include "SiftMatchCU.h" 39 | 40 | 41 | SiftMatchCU::SiftMatchCU(int max_sift):SiftMatchGPU() 42 | { 43 | _num_sift[0] = _num_sift[1] = 0; 44 | _id_sift[0] = _id_sift[1] = 0; 45 | _have_loc[0] = _have_loc[1] = 0; 46 | _max_sift = max_sift <=0 ? 4096 : ((max_sift + 31)/ 32 * 32) ; 47 | _initialized = 0; 48 | } 49 | 50 | void SiftMatchCU::SetMaxSift(int max_sift) 51 | { 52 | max_sift = ((max_sift + 31)/32)*32; 53 | if(max_sift > GlobalUtil::_texMaxDimGL) max_sift = GlobalUtil::_texMaxDimGL; 54 | _max_sift = max_sift; 55 | } 56 | 57 | 58 | int SiftMatchCU::CheckCudaDevice(int device) 59 | { 60 | return ProgramCU::CheckCudaDevice(device); 61 | } 62 | 63 | void SiftMatchCU::InitSiftMatch() 64 | { 65 | if(_initialized) return; 66 | GlobalUtil::_GoodOpenGL = max(GlobalUtil::_GoodOpenGL, 1); 67 | _initialized = 1; 68 | } 69 | 70 | 71 | void SiftMatchCU::SetDescriptors(int index, int num, const unsigned char* descriptors, int id) 72 | { 73 | if(_initialized == 0) return; 74 | if (index > 1) index = 1; 75 | if (index < 0) index = 0; 76 | _have_loc[index] = 0; 77 | //the same feature is already set 78 | if(id !=-1 && id == _id_sift[index]) return ; 79 | _id_sift[index] = id; 80 | if(num > _max_sift) num = _max_sift; 81 | _num_sift[index] = num; 82 | _texDes[index].InitTexture(8 * num, 1, 4); 83 | _texDes[index].CopyFromHost((void*)descriptors); 84 | } 85 | 86 | 87 | void SiftMatchCU::SetDescriptors(int index, int num, const float* descriptors, int id) 88 | { 89 | if(_initialized == 0) return; 90 | if (index > 1) index = 1; 91 | if (index < 0) index = 0; 92 | if(num > _max_sift) num = _max_sift; 93 | 94 | sift_buffer.resize(num * 128 /4); 95 | unsigned char * pub = (unsigned char*) &sift_buffer[0]; 96 | for(int i = 0; i < 128 * num; ++i) 97 | { 98 | pub[i] = int(512 * descriptors[i] + 0.5); 99 | } 100 | SetDescriptors(index, num, pub, id); 101 | } 102 | 103 | 104 | void SiftMatchCU::SetFeautreLocation(int index, const float* locations, int gap) 105 | { 106 | if(_num_sift[index] <=0) return; 107 | _texLoc[index].InitTexture(_num_sift[index], 1, 2); 108 | if(gap == 0) 109 | { 110 | _texLoc[index].CopyFromHost(locations); 111 | }else 112 | { 113 | sift_buffer.resize(_num_sift[index] * 2); 114 | float* pbuf = (float*) (&sift_buffer[0]); 115 | for(int i = 0; i < _num_sift[index]; ++i) 116 | { 117 | pbuf[i*2] = *locations++; 118 | pbuf[i*2+1]= *locations ++; 119 | locations += gap; 120 | } 121 | _texLoc[index].CopyFromHost(pbuf); 122 | } 123 | _have_loc[index] = 1; 124 | } 125 | 126 | int SiftMatchCU::GetGuidedSiftMatch(int max_match, int match_buffer[][2], float H[3][3], float F[3][3], 127 | float distmax, float ratiomax, float hdistmax, float fdistmax, int mbm) 128 | { 129 | 130 | if(_initialized ==0) return 0; 131 | if(_num_sift[0] <= 0 || _num_sift[1] <=0) return 0; 132 | if(_have_loc[0] == 0 || _have_loc[1] == 0) return 0; 133 | ProgramCU::MultiplyDescriptorG(_texDes, _texDes+1, _texLoc, _texLoc + 1, 134 | &_texDot, (mbm? &_texCRT: NULL), H, hdistmax, F, fdistmax); 135 | return GetBestMatch(max_match, match_buffer, distmax, ratiomax, mbm); 136 | } 137 | 138 | 139 | int SiftMatchCU::GetSiftMatch(int max_match, int match_buffer[][2], float distmax, float ratiomax, int mbm) 140 | { 141 | if(_initialized ==0) return 0; 142 | if(_num_sift[0] <= 0 || _num_sift[1] <=0) return 0; 143 | ProgramCU::MultiplyDescriptor(_texDes, _texDes + 1, &_texDot, (mbm? &_texCRT: NULL)); 144 | return GetBestMatch(max_match, match_buffer, distmax, ratiomax, mbm); 145 | } 146 | 147 | 148 | int SiftMatchCU::GetBestMatch(int max_match, int match_buffer[][2], float distmax, float ratiomax, int mbm) 149 | { 150 | sift_buffer.resize(_num_sift[0] + _num_sift[1]); 151 | int * buffer1 = (int*) &sift_buffer[0], * buffer2 = (int*) &sift_buffer[_num_sift[0]]; 152 | _texMatch[0].InitTexture(_num_sift[0], 1); 153 | ProgramCU::GetRowMatch(&_texDot, _texMatch, distmax, ratiomax); 154 | _texMatch[0].CopyToHost(buffer1); 155 | if(mbm) 156 | { 157 | _texMatch[1].InitTexture(_num_sift[1], 1); 158 | ProgramCU::GetColMatch(&_texCRT, _texMatch + 1, distmax, ratiomax); 159 | _texMatch[1].CopyToHost(buffer2); 160 | } 161 | int nmatch = 0, j ; 162 | for(int i = 0; i < _num_sift[0] && nmatch < max_match; ++i) 163 | { 164 | j = int(buffer1[i]); 165 | if( j>= 0 && (!mbm ||int(buffer2[j]) == i)) 166 | { 167 | match_buffer[nmatch][0] = i; 168 | match_buffer[nmatch][1] = j; 169 | nmatch++; 170 | } 171 | } 172 | return nmatch; 173 | } 174 | 175 | #endif 176 | 177 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/SiftGPU/SiftPyramid.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: SiftPyramid.h 3 | // Author: Changchang Wu 4 | // Description : interface for the SiftPyramid class. 5 | // SiftPyramid: data storage for SIFT 6 | // |---PyramidGL: OpenGL based implementation 7 | // | |--PyramidNaive: Unpacked version 8 | // | |--PyramidPacked: packed version 9 | // |--PyramidCU: CUDA-based implementation 10 | // 11 | // Copyright (c) 2007 University of North Carolina at Chapel Hill 12 | // All Rights Reserved 13 | // 14 | // Permission to use, copy, modify and distribute this software and its 15 | // documentation for educational, research and non-profit purposes, without 16 | // fee, and without a written agreement is hereby granted, provided that the 17 | // above copyright notice and the following paragraph appear in all copies. 18 | // 19 | // The University of North Carolina at Chapel Hill make no representations 20 | // about the suitability of this software for any purpose. It is provided 21 | // 'as is' without express or implied warranty. 22 | // 23 | // Please send BUG REPORTS to ccwu@cs.unc.edu 24 | // 25 | //////////////////////////////////////////////////////////////////////////// 26 | 27 | 28 | 29 | #ifndef _SIFT_PYRAMID_H 30 | #define _SIFT_PYRAMID_H 31 | 32 | 33 | class GLTexImage; 34 | class GLTexInput; 35 | class SiftParam; 36 | class GlobalUtil; 37 | 38 | ///////////////////////////////////////////////////////////////////////////// 39 | //class SiftPyramid 40 | //description: virutal class of SIFT data pyramid 41 | // provides functions for SiftPU to run steps of GPU SIFT 42 | // class PyramidNaive is the first implementation 43 | // class PyramidPacked is a better OpenGL implementation 44 | // class PyramidCU is a CUDA based implementation 45 | ///////////////////////////////////////////////////////////////////////////// 46 | 47 | #define NO_DUPLICATE_DOWNLOAD 48 | 49 | class SiftPyramid : public GlobalUtil 50 | { 51 | public: 52 | enum{ 53 | DATA_GAUSSIAN = 0, 54 | DATA_DOG = 1, 55 | DATA_KEYPOINT = 2, 56 | DATA_GRAD = 3, 57 | DATA_ROT = 4, 58 | DATA_NUM = 5 59 | }; 60 | enum{ 61 | SIFT_SKIP_FILTERING = 0x01, 62 | SIFT_SKIP_DETECTION = 0x02, 63 | SIFT_SKIP_ORIENTATION = 0x04, 64 | SIFT_RECT_DESCRIPTION = 0x08 65 | }; 66 | protected: 67 | SiftParam& param; 68 | int _hpLevelNum; 69 | int* _levelFeatureNum; 70 | int _featureNum; 71 | float* _histo_buffer; 72 | //keypoint list 73 | int _existing_keypoints; 74 | vector _keypoint_index; 75 | //display vbo 76 | GLuint* _featureDisplayVBO; 77 | GLuint* _featurePointVBO; 78 | public: 79 | // 80 | float _timing[8]; 81 | //image size related 82 | //first octave 83 | int _octave_min; 84 | //how many octaves 85 | int _octave_num; 86 | //pyramid storage 87 | int _pyramid_octave_num; 88 | int _pyramid_octave_first; 89 | int _pyramid_width; 90 | int _pyramid_height; 91 | int _down_sample_factor; 92 | int _allocated; 93 | int _alignment; 94 | int _siftgpu_failed; 95 | public: 96 | vector _keypoint_buffer; 97 | vector _descriptor_buffer; 98 | private: 99 | inline void PrepareBuffer(); 100 | inline void LimitFeatureCount(int have_keylist = 0); 101 | public: 102 | //shared by all implementations 103 | virtual void RunSIFT(GLTexInput*input); 104 | virtual void SaveSIFT(const char * szFileName); 105 | virtual void CopyFeatureVector(float*keys, float *descriptors); 106 | virtual void SetKeypointList(int num, const float * keys, int run_on_current, int skip_orientation); 107 | //implementation-dependent functions 108 | virtual void GetFeatureDescriptors() = 0; 109 | virtual void GenerateFeatureListTex() =0; 110 | virtual void ReshapeFeatureListCPU() =0; 111 | virtual void GenerateFeatureDisplayVBO() =0; 112 | virtual void DownloadKeypoints() = 0; 113 | virtual void GenerateFeatureListCPU()=0; 114 | virtual void GenerateFeatureList()=0; 115 | virtual GLTexImage* GetLevelTexture(int octave, int level)=0; 116 | virtual GLTexImage* GetLevelTexture(int octave, int level, int dataName) = 0; 117 | virtual void BuildPyramid(GLTexInput * input)=0; 118 | virtual void ResizePyramid(int w, int h) = 0; 119 | virtual void InitPyramid(int w, int h, int ds = 0)=0; 120 | virtual void DetectKeypointsEX() = 0; 121 | virtual void ComputeGradient() = 0; 122 | virtual void GetFeatureOrientations() = 0; 123 | virtual void GetSimplifiedOrientation() = 0; 124 | 125 | //////////////////////////////// 126 | virtual void CleanUpAfterSIFT() {} 127 | virtual int IsUsingRectDescription() {return 0; } 128 | static int GetRequiredOctaveNum(int inputsz); 129 | 130 | ///inline functions, shared by all implementations 131 | inline void SetFailStatus() {_siftgpu_failed = 1; } 132 | inline int GetSucessStatus() {return _siftgpu_failed == 0; } 133 | inline int GetFeatureNum(){return _featureNum;} 134 | inline int GetHistLevelNum(){return _hpLevelNum;} 135 | inline const GLuint * GetFeatureDipslayVBO(){return _featureDisplayVBO;} 136 | inline const GLuint * GetPointDisplayVBO(){return _featurePointVBO;} 137 | inline const int * GetLevelFeatureNum(){return _levelFeatureNum;} 138 | inline void GetPyramidTiming(float * timing){ for(int i = 0; i < 8; i++) timing[i] = _timing[i]; } 139 | inline void CleanupBeforeSIFT() 140 | { 141 | _siftgpu_failed = 0; 142 | for(int i = 0; i < 8; ++i) _timing[i] = 0; 143 | } 144 | SiftPyramid(SiftParam&sp):param(sp) 145 | { 146 | _featureNum = 0; 147 | _featureDisplayVBO = 0; 148 | _featurePointVBO = 0; 149 | _levelFeatureNum = NULL; 150 | _histo_buffer = NULL; 151 | _hpLevelNum = 0; 152 | 153 | //image size 154 | _octave_num = 0; 155 | _octave_min = 0; 156 | _alignment = 1; 157 | _pyramid_octave_num = _pyramid_octave_first = 0; 158 | _pyramid_width = _pyramid_height = 0; 159 | _allocated = 0; 160 | _down_sample_factor = 0; 161 | 162 | ///// 163 | _existing_keypoints = 0; 164 | } 165 | virtual ~SiftPyramid() {}; 166 | 167 | #ifdef DEBUG_SIFTGPU 168 | private: 169 | void StopDEBUG(); 170 | void BeginDEBUG(const char* imagepath); 171 | void WriteTextureForDEBUG(GLTexImage * tex, const char * namet, ...); 172 | #endif 173 | }; 174 | 175 | #define SIFTGPU_ENABLE_REVERSE_ORDER 176 | #ifdef SIFTGPU_ENABLE_REVERSE_ORDER 177 | #define FIRST_OCTAVE(R) (R? _octave_num - 1 : 0) 178 | #define NOT_LAST_OCTAVE(i, R) (R? (i >= 0) : (i < _octave_num)) 179 | #define GOTO_NEXT_OCTAVE(i, R) (R? (--i) : (++i)) 180 | #define FIRST_LEVEL(R) (R? param._dog_level_num - 1 : 0) 181 | #define GOTO_NEXT_LEVEL(j, R) (R? (--j) : (++j)) 182 | #define NOT_LAST_LEVEL(j, R) (R? (j >= 0) : (j < param._dog_level_num)) 183 | #define FOR_EACH_OCTAVE(i, R) for(int i = FIRST_OCTAVE(R); NOT_LAST_OCTAVE(i, R); GOTO_NEXT_OCTAVE(i, R)) 184 | #define FOR_EACH_LEVEL(j, R) for(int j = FIRST_LEVEL(R); NOT_LAST_LEVEL(j, R); GOTO_NEXT_LEVEL(j, R)) 185 | #else 186 | #define FOR_EACH_OCTAVE(i, R) for(int i = 0; i < _octave_num; ++i) 187 | #define FOR_EACH_LEVEL(j, R) for(int j = 0; j < param._dog_level_num; ++j) 188 | #endif 189 | 190 | #endif 191 | -------------------------------------------------------------------------------- /src/TestWin/BasicTestWin.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: BasicTestWin.cpp 3 | // Author: Changchang Wu 4 | // Description : implementation of the BasicTestWin 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 | #ifdef _WIN32 24 | #define WIN32_LEAN_AND_MEAN 25 | #include 26 | #define SIFTGPU_DLL 27 | #include 28 | #else 29 | #include 30 | #endif 31 | 32 | #include "stdlib.h" 33 | #include 34 | using std::iostream; 35 | 36 | #ifdef __APPLE__ 37 | #include "OpenGL/OpenGL.h" 38 | #else 39 | #include "GL/gl.h" 40 | #endif 41 | 42 | #include "../SiftGPU/SiftGPU.h" 43 | #include "BasicTestWin.h" 44 | 45 | ////////////////////////////////////////////////////////////////////// 46 | // Construction/Destruction 47 | ////////////////////////////////////////////////////////////////////// 48 | 49 | BasicTestWin::BasicTestWin() 50 | { 51 | _view = 0; 52 | _sub_view = 0; 53 | _motion = 0; 54 | _looping = 0; 55 | _current = 0; 56 | 57 | 58 | // 59 | _win_w = _win_h = 0; 60 | _imgWidth = _imgHeight = 0; 61 | _displayScale = 1.0f; 62 | _sift = new SiftGPUEX(); 63 | } 64 | 65 | BasicTestWin::~BasicTestWin() 66 | { 67 | _motion = 0; 68 | _looping = 0; 69 | } 70 | 71 | 72 | 73 | void BasicTestWin::Display() 74 | { 75 | glMatrixMode(GL_MODELVIEW); 76 | glLoadIdentity(); 77 | glClear(GL_COLOR_BUFFER_BIT); 78 | _transform.transform(_displayScale); 79 | if(_sift) _sift->DisplaySIFT(); 80 | glFlush(); 81 | glFinish(); 82 | 83 | } 84 | 85 | void BasicTestWin::OnIdle() 86 | { 87 | if(_looping && ! _motion) 88 | { 89 | KeyInput('r'); 90 | UpdateDisplay(); 91 | } 92 | 93 | } 94 | void BasicTestWin::KeyInput(int key) 95 | { 96 | switch(key) 97 | { 98 | case '+': 99 | case '=': 100 | _transform.scaleup(); 101 | break; 102 | case '-': 103 | _transform.scaledown(); 104 | break; 105 | case '\r': 106 | _view++; 107 | _sub_view =0; 108 | SetView(); 109 | break; 110 | case '\b': 111 | _view--; 112 | _sub_view = 0; 113 | SetView(); 114 | break; 115 | case ' ': 116 | case '.': 117 | _sub_view++; 118 | SetView(); 119 | break; 120 | case ',': 121 | _sub_view--; 122 | SetView(); 123 | break; 124 | case 'o': 125 | case 'O': 126 | _transform.reset(); 127 | break; 128 | case 'd': 129 | case 'D': 130 | if(_sift) _sift->ToggleDisplayDebug(); 131 | break; 132 | case 'r': 133 | case 'R': 134 | if(_sift) 135 | { 136 | _sift->RunSIFT(++_current); 137 | _stat_frames++; 138 | FitWindow(); 139 | } 140 | break; 141 | case 'c': 142 | case 'C': 143 | if(_sift) _sift->RandomizeColor(); 144 | break; 145 | case 'q': 146 | case 'Q': 147 | if(_sift) _sift->SetVerbose(-1); 148 | break; 149 | case 'v': 150 | if(_sift) _sift->SetVerbose(4); 151 | break; 152 | case 'x': 153 | case 'X': 154 | case 27: 155 | exit(0); 156 | break; 157 | case 'l': 158 | case 'L': 159 | _looping = ! _looping; 160 | if(_looping) 161 | { 162 | _stat_tstart = myclock(); 163 | _stat_frames = 0; 164 | }else 165 | { 166 | float t = (myclock() - _stat_tstart); 167 | float fps = _stat_frames/t; 168 | std::cout<<"************************************\n" 169 | <RunSIFT()) 203 | { 204 | _sift->SetVerbose(2); 205 | FitWindow(); 206 | }else 207 | { 208 | exit(0); 209 | } 210 | } 211 | 212 | void BasicTestWin::ParseSiftParam(int argc, char** argv) 213 | { 214 | _sift->ParseParam(argc, argv); 215 | _sift->SetVerbose(5); 216 | _win_x = _win_y = -1; 217 | _sift->GetInitWindowPotition(_win_x, _win_y); 218 | } 219 | 220 | 221 | 222 | 223 | void BasicTestWin::FitWindow() 224 | { 225 | int w, h , dw, dh; 226 | _sift->GetImageDimension(w, h); 227 | 228 | 229 | if(w <=0 || h <=0 ) return; 230 | 231 | 232 | if( w == _imgWidth || h == _imgHeight) 233 | { 234 | ReShape(_win_w, _win_h); 235 | return; 236 | } 237 | 238 | 239 | _transform.setcenter(w*0.5, h*0.5); 240 | 241 | /// 242 | 243 | dw =_imgWidth = w; 244 | dh =_imgHeight = h; 245 | 246 | _displayScale = 1.0; 247 | 248 | while(dw>1024 || dh >1024) 249 | { 250 | dw>>=1; 251 | dh>>=1; 252 | _displayScale *= 0.5; 253 | } 254 | 255 | while(dw < 512 && dh < 512) 256 | { 257 | dw <<= 1; 258 | dh <<= 1; 259 | _displayScale*= 2.0; 260 | } 261 | 262 | if ( dw > _win_w || dh > _win_h) 263 | { 264 | _win_w = dw; 265 | _win_h = dh; 266 | SetDisplaySize(dw, dh); 267 | }else 268 | { 269 | ReShape(_win_w, _win_h); 270 | } 271 | } 272 | 273 | 274 | 275 | 276 | void BasicTestWin::SetView() 277 | { 278 | if(_sift) 279 | { 280 | _sift->SetView(_view, _sub_view, _title); 281 | SetWindowTitle(_title); 282 | } 283 | } 284 | 285 | void BasicTestWin::StartMotion(int x, int y) 286 | { 287 | _motion = 1; 288 | _motion_x = x; 289 | _motion_y = y; 290 | } 291 | 292 | void BasicTestWin::EndMotion() 293 | { 294 | _motion = 0; 295 | } 296 | 297 | 298 | void BasicTestWin::SetVerbose() 299 | { 300 | _sift->SetVerbose(); 301 | } 302 | 303 | float BasicTestWin::myclock() 304 | { 305 | #if defined(_WIN32) 306 | return clock() * 1.0 / CLOCKS_PER_SEC; 307 | #else 308 | static int started = 0; 309 | static struct timeval tstart; 310 | if(started == 0) 311 | { 312 | gettimeofday(&tstart, NULL); 313 | started = 1; 314 | return 0; 315 | }else 316 | { 317 | struct timeval now; 318 | gettimeofday(&now, NULL) ; 319 | return (now.tv_usec - tstart.tv_usec + (now.tv_sec - tstart.tv_sec) * 1000000)/1000000.f; 320 | } 321 | #endif 322 | } 323 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/TestWin/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(OpenGL REQUIRED) 2 | find_package(GLUT REQUIRED) 3 | find_package(Glew REQUIRED) 4 | 5 | include_directories( ${GLEW_INCLUDE_DIRS} ) 6 | 7 | ADD_EXECUTABLE(SimpleSIFT SimpleSIFT.cpp) 8 | TARGET_LINK_LIBRARIES(SimpleSIFT siftgpu) 9 | 10 | ADD_EXECUTABLE(TestWinGlut TestWinGlut.cpp BasicTestWin.cpp ) 11 | TARGET_LINK_LIBRARIES(TestWinGlut siftgpu) 12 | 13 | set(CMAKE_VERBOSE_MAKEFILE ON) 14 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/TestWin/TestWinGlut.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: TestWinGlut.cpp 3 | // Author: Changchang Wu 4 | // Description : Implementation of TestWinGlut 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 | #include 25 | #ifdef __APPLE__ 26 | #include "GLUT/glut.h" 27 | #else 28 | #include "GL/glut.h" 29 | #endif 30 | #include "BasicTestWin.h" 31 | #include "TestWinGlut.h" 32 | 33 | ///main etry 34 | 35 | int main(int argc, char**argv) 36 | { 37 | // 38 | ////uncomment this if you want to parse glut parameters 39 | glutInit(&argc, argv); 40 | 41 | 42 | //create the glut window 43 | TestWinGlut twg(argc, argv); 44 | // TestWinGlut twg2(0, NULL); 45 | 46 | 47 | //run the glut main loop to display all the TestWinGlut Windows 48 | TestWinGlut::Run(); 49 | 50 | return 0; 51 | } 52 | 53 | ////////////////////////////////////////////////////////////////////// 54 | // TestWinGlut Class 55 | ////////////////////////////////////////////////////////////////////// 56 | 57 | 58 | 59 | ///////////////////////////////////////////////////////////////////// 60 | ///Global Variables 61 | ////////////////////////////////////////////////////////////////////// 62 | TestWinGlut* TestWinGlut::_win[TestWinGlut::MAX_TEST_WIN_GLUT]; 63 | 64 | ////////////////////////////////////////////////////////////////////// 65 | // Construction/Destruction 66 | ////////////////////////////////////////////////////////////////////// 67 | 68 | 69 | 70 | TestWinGlut::TestWinGlut(int argc, char**argv) 71 | 72 | { 73 | //enable console output 74 | SetVerbose(); 75 | ParseSiftParam(argc, argv); 76 | 77 | //create glut window 78 | CreateGLUT(); 79 | 80 | //parse parameters and run sift 81 | RunSiftGPU(); 82 | 83 | 84 | } 85 | 86 | TestWinGlut::~TestWinGlut() 87 | { 88 | 89 | } 90 | 91 | 92 | 93 | void TestWinGlut::CreateGLUT() 94 | { 95 | int id; 96 | glutInitDisplayMode (GLUT_RGBA | GLUT_DOUBLE); 97 | glutInitWindowSize (600,450); 98 | if(_win_x != -1) glutInitWindowPosition(_win_x, _win_y); 99 | id = glutCreateWindow ("SIFT_GPU"); 100 | if(id>0) 101 | { 102 | if(id >=MAX_TEST_WIN_GLUT) exit(0);//should not happen... 103 | 104 | // 105 | glutDisplayFunc (display); 106 | glutKeyboardFunc(keyboard); 107 | glutReshapeFunc (reshape); 108 | glutIdleFunc(idle); 109 | glutMotionFunc(motion); 110 | glutMouseFunc(button); 111 | //save a pointer to the stucture 112 | _win[id] = this; 113 | } 114 | 115 | } 116 | 117 | void TestWinGlut::idle() 118 | { 119 | int id = glutGetWindow(); 120 | _win[id]->OnIdle(); 121 | } 122 | 123 | void TestWinGlut::keyboard(unsigned char key, int x, int y) 124 | { 125 | int id = glutGetWindow(); 126 | 127 | _win[id]->KeyInput(key); 128 | glutPostRedisplay(); 129 | } 130 | void TestWinGlut::reshape(int w, int h) 131 | { 132 | int id = glutGetWindow(); 133 | _win[id]->ReShape(w, h); 134 | glutPostRedisplay(); 135 | } 136 | void TestWinGlut::display() 137 | { 138 | static int firstcall=1; 139 | int id = glutGetWindow(); 140 | _win[id]->Display(); 141 | glutSwapBuffers(); 142 | if(firstcall ==0) 143 | { 144 | }else 145 | { 146 | //if it is the first display call, redraw 147 | firstcall = 0; 148 | glutPostRedisplay(); 149 | } 150 | } 151 | 152 | void TestWinGlut::Run() 153 | { 154 | glutMainLoop(); 155 | } 156 | 157 | void TestWinGlut::motion(int x, int y) 158 | { 159 | int id = glutGetWindow(); 160 | _win[id]->MoveMouse(x, y); 161 | } 162 | 163 | void TestWinGlut::SetWindowTitle(char *title) 164 | { 165 | glutSetWindowTitle(title); 166 | } 167 | 168 | void TestWinGlut::button(int button, int state,int x, int y) 169 | { 170 | int id = glutGetWindow(); 171 | if (button == GLUT_LEFT_BUTTON) 172 | { 173 | if(state == GLUT_DOWN) 174 | _win[id]->StartMotion(x, y); 175 | else if (state == GLUT_UP) 176 | _win[id]->EndMotion(); 177 | } 178 | } 179 | 180 | void TestWinGlut::UpdateDisplay() 181 | { 182 | glutPostRedisplay(); 183 | } 184 | 185 | void TestWinGlut::SetDisplaySize(int w, int h) 186 | { 187 | glutReshapeWindow(w, h); 188 | } 189 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/TestWin/speed.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // File: Speed.cpp 3 | // Author: Changchang Wu 4 | // Description : Evaluate the speed of SiftGPU 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 26 | #include 27 | #include 28 | using std::cout; 29 | 30 | #ifdef _WIN32 31 | //dll import definition for win32 32 | #define SIFTGPU_DLL 33 | #endif 34 | 35 | #if defined(_WIN32) 36 | //for windows, the default timing uses timeGetTime, you can define TIMING_BY_CLOCK to use clock() 37 | #if defined(TIMING_BY_CLOCK) 38 | #include 39 | #else 40 | #define WIN32_LEAN_AND_MEAN 41 | #include 42 | #include 43 | #pragma comment(lib, "winmm.lib") 44 | #endif 45 | #else 46 | #include 47 | #endif 48 | 49 | 50 | #include "../SiftGPU/SiftGPU.h" 51 | 52 | //define the marcro bellow to reload image file everytime 53 | //#define INCLUDE_DISK_READING_TIME 54 | 55 | //define the macro below to test speed of multi-process mode 56 | //#define TEST_MULTI_PROCESS_SIFTGPU 57 | 58 | 59 | 60 | #define SIFTGPU_REPEAT 30 61 | 62 | // you should specify the input image and the sift parameter to speed.exe 63 | // for example: speed.exe -i 600.pgm -fo -1 64 | // to test CUDA, you first need to recompile SiftGPU with CUDA capability 65 | 66 | int GetMilliSecond(); 67 | 68 | int main(int argc, char * argv[]) 69 | { 70 | #ifndef TEST_MULTI_PROCESS_SIFTGPU 71 | SiftGPU sift; 72 | #else 73 | ComboSiftGPU* combo = CreateRemoteSiftGPU(); 74 | SiftGPU& sift = (*combo); 75 | #endif 76 | int num; 77 | float timing[10], time_all =0, time_start; 78 | 79 | //Parse parameters 80 | sift.ParseParam(argc - 1, argv + 1); 81 | sift.SetVerbose(0); 82 | 83 | std::cout<<"Initialize and warm up...\n"; 84 | //create an OpenGL context for computation 85 | if(sift.CreateContextGL() ==0) return 0; 86 | 87 | if(sift.RunSIFT()==0) return 0; 88 | 89 | //image is loaded for only once for this experiment 90 | #ifndef TEST_MULTI_PROCESS_SIFTGPU 91 | std::cout<<"Loading image: " << sift._timing[0]*1000 << "ms, " 92 | <<"Tex initialization: "<