diff --git a/.gitignore b/.gitignore
index c390e7f9..016afb65 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,4 @@
.idea/
build/
debug/
-3rdparty/svmlight/
*~
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 00000000..de9d9399
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,9 @@
+[submodule "3rdparty/pugixml"]
+ path = 3rdparty/pugixml
+ url = https://github.com/zeux/pugixml.git
+[submodule "3rdparty/SiftGPU"]
+ path = 3rdparty/SiftGPU
+ url = https://github.com/pitzer/SiftGPU.git
+[submodule "3rdparty/svmlight"]
+ path = 3rdparty/svmlight
+ url = https://github.com/giacomodabisias/svmlightlib.git
diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt
index ef76da1c..8e740eb2 100644
--- a/3rdparty/CMakeLists.txt
+++ b/3rdparty/CMakeLists.txt
@@ -1,9 +1,9 @@
-#add mandatory 3rd party builds
-add_subdirectory(pugixml-1.6)
+#add mandatory 3rdparty libraries
+add_subdirectory(pugixml_build)
if(WITH_SVMLIGHT)
- add_subdirectory(svmlight)
-endif(WITH_SVMLIGHT)
+ add_subdirectory(svmlight)
+endif()
if(WITH_GPU)
add_subdirectory(SiftGPU)
diff --git a/3rdparty/SiftGPU b/3rdparty/SiftGPU
new file mode 160000
index 00000000..b46bd5b8
--- /dev/null
+++ b/3rdparty/SiftGPU
@@ -0,0 +1 @@
+Subproject commit b46bd5b8cc5cfdc1dc163444b72c705569800b6d
diff --git a/3rdparty/SiftGPU/CMakeLists.txt b/3rdparty/SiftGPU/CMakeLists.txt
deleted file mode 100644
index 10bab6ff..00000000
--- a/3rdparty/SiftGPU/CMakeLists.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-PROJECT(OD_SIFTGPU C CXX)
-
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-write-strings -Wno-unused-result -Wno-deprecated -fPIC")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-write-strings -Wno-unused-result -Wno-deprecated -fPIC")
-
-ADD_SUBDIRECTORY(src)
-
diff --git a/3rdparty/SiftGPU/History.txt b/3rdparty/SiftGPU/History.txt
deleted file mode 100644
index 1f8e9154..00000000
--- a/3rdparty/SiftGPU/History.txt
+++ /dev/null
@@ -1,190 +0,0 @@
-0.5.400
- Fixes some platform issues to make SiftGPU work with Intel integrated GPUs.
- Tested on window 7 and Ubuntu.
- Note that Linux+Intel card works only on Mesa 9 for now.
- Replaced the deprecated ostrstream by ostringstream
- Fixed a few memory leaks (delete[]/delete mistakes);
-0.5.382
- Fixed a bug with CUDA-based SiftMatchGPU (can match up to only 4096)
- * The maximu texture dimension is not updated from hardware since V370
-0.5.381
- Really fixed the bug in CUDA-implementation of Guided SIFT matching...
-
-0.5.380
- Fixed a bug in CUDA-implementation of Guided SIFT matching. (Thanks to Oliver Whyte)
- Added auto-downsampling to try fit the GPU memory cap.
- Fixed minor GLSL code issue on Intel Integrated Cards.. not fully functional on Intel
- Fixed bug with a rarely used parameter -tc for limiting feature counts
- Updated Devil 64 bit lib to let it search for Devil64.dll (to keep both in the same folder)
- Fixed an issue on the new nVidia driver with one GLSL shader.
- Fixed a glReadPixels issue on ATI when the feature count is too big.
- Modified the descriptor code to make it work correctly for ATI
- Finally made GPU selection for Windows working (e.g. -display \\.\DISPLAY4)
- MSVC Only: Converted the visual studio solution to v2010
-0.5.370
- Automatic switch from OpenGL to CUDA when OpenGL is not supported (Useful for X)
- Dropped indirect data transfer path CPU->GL->CUDA
- (CUDA part not requiring OpenGL at all, but restrictive on input type)
- New parameter -mind (mininum working dimension) for performance tweak
- (By default it is 16; Gaussian octaves smaller than this will be skipped)
- (Small dimensions are ineffecient for GPU because many processes are on idle)
- Added a function to compute SIFT for any rectangle (not only square!)
- (Email me if you are interested in using it)
-
- Dropped all CG implementation to simplify maintance
- Added a partial OpenCL implementation (half speed of CUDA/GLSL)
- Added macro SIFTGPU_NO_DEVIL to allow droping DevIL depencency
- Fixed minor bug in makefile
- Removed reference to MAX_PATH in SiftGPU.h. It is dangerrous..since they can be redefined.
-
-0.5.360
- Added demo MultiThreadSIFT to demonstrate using Multi-GPU with Multi-Threading.
- Improved CUDA performance on frequent image size changes
- Skipped unacessary gradient/dog computation when using keypoint list on a same image
- Added x64 projects to VisualStudio solution
- Provided three different ways to limit the number of feautres -tc1 -tc2 -tc3
- (to keep either the highest levels or the lowest levels)
- Fixed a bug with -tc introduced in V360Beta (2/26/10)
- Fixed a bug in CUDA-implementation when the first several octaves are skipped (2/28/10)
- Let RunSIFT return 0 when errors are found in CUDA (previously ignored)
- Added option -display to select GPU according to Display
- Modified option -cuda [device_index] to select GPU device.
- Added Wrapper ServerSiftGPU to allow run multiple SiftGPU on multiple GPUs
- Added option -tc to set a soft limit for the number of returned features.
- Changed OpenGL context creation. The core library no longer requires GLUT.
- Removed calles to std in file ProgramCU.cu to avoid possible compiling errors.
- Reorganized the file structure of the code package.
- Fixed some linux makefile issue and linux compilation issue.
- Fixed linux name mangling problem for dynamic library loading.
-0.5.345
- New Linux makefile. CG, CUDA and sse parameters can now be changed easily in makefile.
- CG-based SiftGPU is now disabled by default to reduce dependencies.
- Made more parameters changable after initizlization (check manual for details)
- Changed the way of handling out-of-boundary user-specified keypoints.
- Changed the timing function from clock to gettimeofday for Linux (Thanks to Pilet)
- Fixed a bug in saving binary format(Thanks to Dekker)
- Fixed linux makefile for CUDA-SIFTGPU (Thanks to Planna)
- Fixed a conversion bug for 64-bit system introduced in V340 (Thanks to Plana and Wang)
-0.5.340
- Added (-glsl -pack -m -s) to default setting. (You can change back to CG by -cg)
- Updated libraries (CG 2.1, GLEW 1.5, DEVIL 1.77)
- Used SSE to speed up descriptor normalization
- Improved speed of the OpenGL-based SiftMatchGPU. (1.5x)
- Added GLSL and CUDA implementation of SiftMatchGPU
- Added the packed glsl implementation. It might be slightly faster than cg.
- Added a CUDA-based SiftGPU implementation(use -cuda to turn it on)
- Cleaned up the GLSL code to follow the GLSL standard more strictly.
- Tested many of the GLSL shaders in GPU ShaderAnalyzer 1.5.
- Added option -fastmath to specify -fastmath to cg compiler(yet no big difference).
- Increased the threshold to fix the bug in guided matching when F is NULL
- Fixed a bug in orientation for -m2p (missing a ";" in shader code)
- Changed interface to handle all OpenGL pixel data (Previous only float and unsigned char).
- Kept only the fastest verion of descriptor generation code, and dropped others.
-0.5.320
- Fixed a bug (Wrong texture size may be assigned when image size changes)
- Fixed a bug (Descriptor storage size may be not updated when image size changes)
-0.5.319
- Fixed a bug (Setkeypoint before specifying image was not working in previous versoins)
-0.5.318
- Changed interface to process keypoints WITHOUT known orientations
- Added interface to specifiy float image data
- Overloaded new operator of SiftGPU and SiftMatchGPU to fix a possible heap corruption on deallocation
-0.5.317
- Fixed a bug in processing user-specified keypoints
- Updated the .def file for the released package
-0.5.316
- Fixed a bug of insufficient buffer allocation in very rare cases. (Thanks to Zheng)
- Added guided SIFT putative matching using homography or/and fundamental matrix
- Added function to change the feature number limitation for sift matching
-0.5.315
- Added a cg-based sift matching implementation (Thanks to Zach)(see SimpleSIFT.cpp for example).
- Added optional output of the extremum type (maximum or minimum) of feature
- Added function to compute descriptors for user-specified keypoints
- Included xcode project and makefile(Thanks to Perfanov and Wittenhagen)
-0.5.313
- Finished the GLSL implementation of SIFT (use -glsl to turn it on).
- Fixed a bug of crashing after many iterations on newer graphic card like GTX 280. (Thanks to Zheng)
-0.5.312
- Fixed a bug introduced in V311(One texture size not updated for image size chaning with -pack)
- Fixed a bug introduced in V311(feature readback function is empty for -pack). (Thanks to Palomo)
-0.5.311
- Fixed a bug in descriptor computation (it may cause error in descriptors of 10% of features)
- Implemented a packed SIFT implementation (use -pack to use it. 3x pyramid construction speed)
- Used GPU/CPU mixed list generation (2X compared with old method)
- Used only CPU for multi-orientation list generation (much faster than GPU)
- Changed parameter to avoid using dyamic array indexing by default.
- Implemented a new descriptor computation method(30% faster than the old one
- Evaluated the speed on GTX 280. (obtained 1.5x the speed of 8800 GTX)
- Dropped many unreferenced functions and also some old shaders.
- Changed some definition for better compiliation on Mac (Thanks to Wittenhagen)
- Changed SaveSIFT function to keep a little bit less fractional digits
- Combined the horizontal gradient and vertical gradient visualization to one.
-0.5.302
- Updated cg, glew and glut libraries
- Added speed evaluation code
- Added some debug code to write out floating point tiff images
- Refactorized code a little bit, now it is having much less warnings
-0.5.293
- Changed gaussian weighting factor in orientation computation, now closer to Lowe's
- Minor bug fix on texture reallocation for too many features
- Added new feature to automatically down-sample images that are larger than user-defined size.
-0.5.288
- Added comparision with Lowe's SIFT on box.pgm(check /doc/evaluation for results)
- Fixed two bugs related to feature scale
- Fixed a bug related to up-sampling
- Added a missing dog threshold test after subpixel localization.
- Added new parameter for fixing the feature orientations
- Added export function to check how SiftGPU is supported by current OpenGL context
- Changed some default parameter ( now it downloades result, and use verbose level 2 by default)
-0.5.280
- Added an example of dyanmic loading of siftgpu library
- Fixed a serious bug of GetFeatureVector (orientation and scale are misordered previously)
- Fixed a bug in def file
- Fixed a bug in calling RunSIFT with pixel data.
- Fixed some GLSL shader bugs
-0.5.276
- Removed file "gs_types.h" and put the export definition in "siftgpu.h"
- Added high resolution timing for windows by using funciton timeGetTime
- Fixed some problems on arbfp1. Now it can run a limited demo again.
- Added parameter for changing the maximum allowed feature number of a level
-0.5.267
- Corrected a neglected stricmp to _stricmp for linux compiliation
- Fixed a bug in function ResizePyramid which happens when image size changes in some way
- Added key input function to change verbose level for GUI mode
-
-0.5.265
- Added display of fps information in console for sequential processing
- Added an optional step that converts RGB to Luminance before uploading to GPU
- Added a parameter "-p WxH" to specify the size for initializing the pyramids
-0.5.261
- Added a new feature for using existing memories for processing smaller images
- Added new functions to let user control the allocation pyramid momory
- Fixed a bug with sub-pixel localization
-
-0.5.256
- Added linux makefile
- Added a new feature for allocating seperate processing memories for multiple images.
-0.5.250
- New keypoint detection code capable of sub-pixel/sub-scale localization
- Changed code for easy Linux porting. Thank Martin Schneider for his help on this
- Changed some default values of the parameters.
- Improved SIFT visualization.
-0.5.236
- Fixed an important bug in orientation computation
- Successfully tested on many image matching experiments
- Changed the command line -m to default 2 orientations
-0.5.232
- Fixed a sift output bug
- Fixed a NaN bug in descriptor generation
- Fixed a bug that some images are flipped
-0.5.224
- Fixed a memory leak bug on FBO
- Added one more demo for processing 640*480 image sequence
- Smalled change to interface, so that image data can be specified like OpenGL textures
-0.5.220
- Added more examples to manual.
- Added more comments about the siftgpu interface
- Added one more input interface
- Fixed bug of crash on image size change
-0.5.208
- First release
\ No newline at end of file
diff --git a/3rdparty/SiftGPU/OpenGL_and_CUDA.txt b/3rdparty/SiftGPU/OpenGL_and_CUDA.txt
deleted file mode 100644
index 6f6307ea..00000000
--- a/3rdparty/SiftGPU/OpenGL_and_CUDA.txt
+++ /dev/null
@@ -1,79 +0,0 @@
-PART 1, OPENGL,
-
-Pay special attention if you have your own OpenGL code.
-The OpenGL-based implmentations of SiftGPU need valid OpenGL context to run properly.
-
-1. If you use the same OpenGL context for SiftGPU and your own your visualization
- Make sure the OpenGL states are restored before calling SiftGPU. SiftGPU changes several
- OpenGL internal states, including texture binding to GL_TEXTURE_RECTANGLE_ARB and current
- ViewPort. You might need to restore them for your own OpenGL part. To avoid this problem,
- you can create a seperate GL context, and activate different context for different part.
-
- Note that GL_TEXTURE_RECTANGLE_ARB is always enabled in SiftGPU. When you have problem
- displaying textures, you can try first glDisable(GL_TEXTURE_RECTANGLE_ARB) before painting,
- but don't forget to call glEnable(GL_TEXTURE_RECTANGLE_ARB) after. (Thanks to Pilet)
-
-2. How to create/setup an OpenGL context for SiftGPU
-
- If you choose to let SiftGPU to manage OpenGL context, you can simply do that by
- SiftGPU::CreateContextGL and SiftMatchGPU::CreateContextGL. When you mix your own OpenGL
- code with SiftGPU, you need to re-call CreateContextGL before calling SiftGPU functions,
- which will implicitly activate the internal OpenGL context.
-
-
- If you choose to create openGL contexts yourself when mixing SiftGPU with other openGL
- code, don't call SiftGPU::CreateContextGL or SiftMatchGPU::CreateContextGL; Instead you
- should first activate your OpenGL context (WglMakeCurrent in win32), and set GL_FILL
- for polygon mode, then call SiftGPU::VerifyContextGL or SiftMatchGPU::VerifyContextGL
- for initialization. You should also setup in the same way before calling SiftGPU functions.
-
-
-PART 2, CUDA
----------------------------------------------------------------------------------
-1. How to enable CUDA
-
-The CUDA implementation in the package is not compiled by default.
-
-To enable it for visual stuio 2010, use msvc/SiftGPU_CUDA_Enabled.sln
-To enable it for other OS, you need to change siftgpu_enable_cuda to 1 in the makefile
-
-
----------------------------------------------------------------------------------
-2. Change CUDA build parameters.
-For windows, you need to change the settings in the custom build command line of
-ProgramCU.cu. For example, add -use_fast_match for using fast match.
-
-For Other OS, you need to change the makefile. The top part of the makefile is
-the configuration section, which includes:
- siftgpu_enable_cuda = 0 (Set 1 to enable CUDA-based SiftGPU)
- CUDA_INSTALL_PATH = /usr/local/cuda (Where to find CUDA)
- siftgpu_cuda_options = -arch sm_10 (Additional CUDA Compiling options)
-
-
-------------------------------------------------------------------------------------
-3. CUDA runtime parameters for SiftGPU::ParseParam
-First, you need to specify "-cuda" to use CUDA-based SiftGPU. More parameters can
-be chagned at runtime in CUDA-based SiftGPU than in OpenGL-based version. Check out
-the manual for details.
-
-NEW. You can choose GPU for CUDA computation by using "-cuda [device_index=0]"
-
-One parameter for CUDA is "-di", which controls whether dynamic indexing is used
-in descriptor generations. It is turned off by default. My experiments on 8800
-GTX show that unrolled loop of 8 if-assigns are faster than dynamic indexing, but
-it might be different on other GPUs.
-
-
---------------------------------------------------------------------------------------
-4. Speed of CUDA-based SiftGPU
-If the size of the first octave (multiply the original size by 2 if upsample is used)
-is less than or around 1024x768, CUDA version will be faster than OpenGL versions,
-otherwise the OpenGL versions are still faster.
-
-**************************************************************************************
-This is observed on nVidia 8800 GTX, it might be different on other GPUs. Recent
-experiments on GTX280 show that CUDA version is not as fast as OpenGL version.
-
-Note: the thread block settings are currently tuned on GPU nVidia GTX 8800,
- which may not be optimized for other GPUs.
-**************************************************************************************
diff --git a/3rdparty/SiftGPU/README.txt b/3rdparty/SiftGPU/README.txt
deleted file mode 100644
index f84381e5..00000000
--- a/3rdparty/SiftGPU/README.txt
+++ /dev/null
@@ -1,58 +0,0 @@
-A GPU implementation of David Lowe's Scale Invariant Feature Transform
-
-Changchang wu
-
-http://cs.unc.edu/~ccwu
-
-University of North Carolina at Chapel Hill
-
-
-
-
-1. SIFT
-
- SIFTGPU is an implementation of SIFT for GPU. SiftGPU uses GPU to process pixels and features
- parallely in Gaussian pyramid construction, DoG keypoint detection and descriptor generation
- for SIFT. Compact feature list is efficiently build through a GPU/CPU mixed reduction.
-
- SIFTGPU is inspired by Andrea Vedaldi's sift++ and Sudipta N Sinha et al's GPU-SIFT. Many
- parameters of sift++ ( for example, number of octaves,number of DOG levels, edge threshold,
- etc) are available in SiftGPU.
-
-
- SIFTGPU also includes a GPU exhaustive/guided sift matcher SiftMatchGPU. It basically multiplies
- the descriptor matrix on GPU and find closest feature matches on GPU. GLSL/CUDA/CG implementations
- are all provided.
-
- NEW: The latest SIFTGPU also enables you to use Multi-GPUs and GPUS on different computers.
- Check doc/manual.pdf for more information. You can modify some marcros definition in
- SimpleSIFT.cpp and speed.cpp to enable the testing of the new functions.
-
-
-2. Requirements
-
- The default implemntation uses GLSL, and it requires a GPU that has large memory and supports
- dynamic branching. For nVidia graphic cards, you can optionally use CG(require fp40) or
- CUDA implementation. You can try different implementations and to find out the fastest one
- for different image sizes and parameters.
-
- The GLSL version may not work on ATI now. They did compile sucessfully with ATI Catalyst 8.9,
- but not any more with 9.x versions.
-
- SiftGPU uses DevIl Image library, GLEW and GLUT. You'll need to make sure your system has
- all the dependening libraries. SiftGPU should be able to run on any operation system that supports
- the above libraries
-
- For windows system visual studio solution are provided as msvc/SiftGPU.dsw, msvc/SiftGPU.sln and
- msvc/SiftGPU_CUDA_Enabled.sln. Linux/Mac makefile is in folder Linux of the package.
-
-
-3. Helps
-
- Use -help to get parameter information. Check /doc/manual.pdf for samples and explanations.
- In the vc workspace, there is a project called SimpleSIF that gives an example of simple
- SiftGPU usage. There are more examples of different ways of using SiftGPU in manual.pdf
-
-
- Check /doc/manual.pdf for help on the viewer.
-
diff --git a/3rdparty/SiftGPU/bin/DevIL.dll b/3rdparty/SiftGPU/bin/DevIL.dll
deleted file mode 100644
index 7cc8553d..00000000
Binary files a/3rdparty/SiftGPU/bin/DevIL.dll and /dev/null differ
diff --git a/3rdparty/SiftGPU/bin/DevIL64.dll b/3rdparty/SiftGPU/bin/DevIL64.dll
deleted file mode 100644
index 082f6965..00000000
Binary files a/3rdparty/SiftGPU/bin/DevIL64.dll and /dev/null differ
diff --git a/3rdparty/SiftGPU/bin/SiftGPU.dll b/3rdparty/SiftGPU/bin/SiftGPU.dll
deleted file mode 100644
index 2f2fdf64..00000000
Binary files a/3rdparty/SiftGPU/bin/SiftGPU.dll and /dev/null differ
diff --git a/3rdparty/SiftGPU/bin/SiftGPU64.dll b/3rdparty/SiftGPU/bin/SiftGPU64.dll
deleted file mode 100644
index 06a4cc60..00000000
Binary files a/3rdparty/SiftGPU/bin/SiftGPU64.dll and /dev/null differ
diff --git a/3rdparty/SiftGPU/bin/SimpleSIFT.exe b/3rdparty/SiftGPU/bin/SimpleSIFT.exe
deleted file mode 100644
index 2607c8f0..00000000
Binary files a/3rdparty/SiftGPU/bin/SimpleSIFT.exe and /dev/null differ
diff --git a/3rdparty/SiftGPU/bin/Speed.exe b/3rdparty/SiftGPU/bin/Speed.exe
deleted file mode 100644
index 8c72462f..00000000
Binary files a/3rdparty/SiftGPU/bin/Speed.exe and /dev/null differ
diff --git a/3rdparty/SiftGPU/bin/TestWin.exe b/3rdparty/SiftGPU/bin/TestWin.exe
deleted file mode 100644
index 6b3774c9..00000000
Binary files a/3rdparty/SiftGPU/bin/TestWin.exe and /dev/null differ
diff --git a/3rdparty/SiftGPU/bin/glew32.dll b/3rdparty/SiftGPU/bin/glew32.dll
deleted file mode 100644
index 8857ba67..00000000
Binary files a/3rdparty/SiftGPU/bin/glew32.dll and /dev/null differ
diff --git a/3rdparty/SiftGPU/bin/glew64.dll b/3rdparty/SiftGPU/bin/glew64.dll
deleted file mode 100644
index e1dda868..00000000
Binary files a/3rdparty/SiftGPU/bin/glew64.dll and /dev/null differ
diff --git a/3rdparty/SiftGPU/license.txt b/3rdparty/SiftGPU/license.txt
deleted file mode 100644
index c4c35d9b..00000000
--- a/3rdparty/SiftGPU/license.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-////////////////////////////////////////////////////////////////////////////
-//
-// Copyright (c) 2007 University of North Carolina at Chapel Hill
-// All Rights Reserved
-//
-// Permission to use, copy, modify and distribute this software and its
-// documentation for educational, research and non-profit purposes, without
-// fee, and without a written agreement is hereby granted, provided that the
-// above copyright notice and the following paragraph appear in all copies.
-//
-// The University of North Carolina at Chapel Hill make no representations
-// about the suitability of this software for any purpose. It is provided
-// 'as is' without express or implied warranty.
-//
-// Please send BUG REPORTS to ccwu@cs.unc.edu
-//
-////////////////////////////////////////////////////////////////////////////
\ No newline at end of file
diff --git a/3rdparty/SiftGPU/makefile b/3rdparty/SiftGPU/makefile
deleted file mode 100644
index 2059b927..00000000
--- a/3rdparty/SiftGPU/makefile
+++ /dev/null
@@ -1,207 +0,0 @@
-#################################################################
-# SiftGPU congiruation: CUDA, SSE, TIMING
-#################################################################
-#enable siftgpu server
-siftgpu_enable_server = 0
-#enable OpenCL-based SiftGPU? not finished yet; testing purpose
-siftgpu_enable_opencl = 0
-#------------------------------------------------------------------------------------------------
-# enable CUDA-based SiftGPU?
-simple_find_cuda = $(shell locate libcudart.so)
-ifneq ($(simple_find_cuda), )
- siftgpu_enable_cuda = 0
-else
- siftgpu_enable_cuda = 0
-endif
-
-CUDA_INSTALL_PATH = /usr/local/cuda
-#change additional settings, like SM version here if it is not 1.0 (eg. -arch sm_13 for GTX280)
-#siftgpu_cuda_options = -Xopencc -OPT:unroll_size=200000
-#siftgpu_cuda_options = -arch sm_10
-#--------------------------------------------------------------------------------------------------
-# enable SSE optimization for GL-based implementations
-siftgpu_enable_sse = 1
-siftgpu_sse_options = -march=core2 -mfpmath=sse
-#--------------------------------------------------------------------------------------------------
-# openGL context creation. 1 for glut, 0 for xlib
-siftgpu_prefer_glut = 1
-#whether remove dependency on DevIL (1 to remove, the output libsiftgpu.so still works for VisualSFM)
-siftgpu_disable_devil = 0
-#------------------------------------------------------------------------------------------------
-#whether SimpleSIFT uses runtime loading of libsiftgpu.so or static linking of libsiftgpu.a
-simplesift_runtime_load = 1
-
-#################################################################
-
-
-# cleanup trailing whitespaces for a few settings
-siftgpu_enable_cuda := $(strip $(siftgpu_enable_cuda))
-siftgpu_disable_devil := $(strip $(siftgpu_disable_devil))
-siftgpu_enable_server := $(strip $(siftgpu_enable_server))
-siftgpu_enable_opencl := $(strip $(siftgpu_enable_opencl))
-siftgpu_prefer_glut := $(strip $(siftgpu_prefer_glut))
-simplesift_runtime_load := $(strip $(simplesift_runtime_load))
-
-# detect OS
-OSUPPER = $(shell uname -s 2>/dev/null | tr [:lower:] [:upper:])
-OSLOWER = $(shell uname -s 2>/dev/null | tr [:upper:] [:lower:])
-DARWIN = $(strip $(findstring DARWIN, $(OSUPPER)))
-
-
-SHELL = /bin/sh
-INC_DIR = include
-BIN_DIR = bin
-SRC_SIFTGPU = src/SiftGPU
-SRC_DRIVER = src/TestWin
-SRC_SERVER = src/ServerSiftGPU
-CC = g++
-CFLAGS = -I$(INC_DIR) -fPIC -L/usr/lib -L./bin -L./lib -Wall -Wno-deprecated -pthread
-
-#simple hack to repalce the native flat on OSX because gcc version is low
-ifneq ($(DARWIN),)
- siftgpu_sse_options = -march=core2 -mfpmath=sse
-endif
-
-ifneq ($(siftgpu_enable_sse), 0)
- CFLAGS += $(siftgpu_sse_options)
-endif
-
-ifneq ($(siftgpu_prefer_glut), 0)
- CFLAGS += -DWINDOW_PREFER_GLUT
-endif
-
-ifneq ($(siftgpu_enable_opencl), 0)
- CFLAGS += -DCL_SIFTGPU_ENABLED
-endif
-
-ODIR_SIFTGPU = build
-
-
-# external header files
-_HEADER_EXTERNAL = GL/glew.h GL/glut.h IL/il.h
-# siftgpu header files
-_HEADER_SIFTGPU = FrameBufferObject.h GlobalUtil.h GLTexImage.h ProgramGPU.h ShaderMan.h ProgramGLSL.h SiftGPU.h SiftPyramid.h SiftMatch.h PyramidGL.h LiteWindow.h
-# siftgpu library header files for drivers
-_HEADER_SIFTGPU_LIB = SiftGPU.h
-
-ifneq ($(DARWIN),)
-#librarys for SiftGPU
-LIBS_SIFTGPU = -lGLEW -framework GLUT -framework OpenGL
-CFLAGS += -L/Users/prb2pal/Development/Resources/lib
-else
-#librarys for SiftGPU
-LIBS_SIFTGPU = -lGLEW -lglut -lGL -lX11
-endif
-
-ifneq ($(siftgpu_disable_devil), 0)
- CFLAGS += -DSIFTGPU_NO_DEVIL
-else
- LIBS_SIFTGPU += -lIL
-endif
-
-#Obj files for SiftGPU
-_OBJ_SIFTGPU = FrameBufferObject.o GlobalUtil.o GLTexImage.o ProgramGLSL.o ProgramGPU.o ShaderMan.o SiftGPU.o SiftPyramid.o PyramidGL.o SiftMatch.o
-
-#add cuda options
-ifneq ($(siftgpu_enable_cuda), 0)
- ifdef CUDA_BIN_PATH
- NVCC = $(CUDA_BIN_PATH)/nvcc
- else
- NVCC = $(CUDA_INSTALL_PATH)/bin/nvcc
- endif
-
- ifndef CUDA_INC_PATH
- CUDA_INC_PATH = $(CUDA_INSTALL_PATH)/include
- endif
-
- ifndef CUDA_LIB_PATH
- CUDA_LIB_PATH = $(CUDA_INSTALL_PATH)/lib64 -L$(CUDA_INSTALL_PATH)/lib
- endif
-
- CFLAGS += -DCUDA_SIFTGPU_ENABLED -I$(CUDA_INC_PATH) -L$(CUDA_LIB_PATH)
- LIBS_SIFTGPU += -lcudart
- _OBJ_SIFTGPU += CuTexImage.o PyramidCU.o SiftMatchCU.o
- _HEADER_SIFTGPU += CuTexImage.h ProgramCU.h PyramidCU.h
-endif
-
-ifneq ($(siftgpu_enable_opencl), 0)
- CFLAGS += -lOpenCL
-endif
-
-all: makepath siftgpu server driver
-
-
-#the dependencies of SiftGPU library
-DEPS_SIFTGPU = $(patsubst %, $(SRC_SIFTGPU)/%, $(_HEADER_SIFTGPU))
-
-
-#rules for the rest of the object files
-$(ODIR_SIFTGPU)/%.o: $(SRC_SIFTGPU)/%.cpp $(DEPS_SIFTGPU)
- $(CC) -o $@ $< $(CFLAGS) -c
-
-
-ifneq ($(siftgpu_enable_cuda), 0)
-NVCC_FLAGS = -I$(INC_DIR) -I$(CUDA_INC_PATH) -DCUDA_SIFTGPU_ENABLED -O2 -Xcompiler -fPIC
-ifdef siftgpu_cuda_options
- NVCC_FLAGS += $(siftgpu_cuda_options)
-endif
-#build rule for CUDA
-$(ODIR_SIFTGPU)/ProgramCU.o: $(SRC_SIFTGPU)/ProgramCU.cu $(DEPS_SIFTGPU)
- $(NVCC) $(NVCC_FLAGS) -o $@ $< -c
-_OBJ_SIFTGPU += ProgramCU.o
-endif
-
-
-ifneq ($(siftgpu_enable_server), 0)
-$(ODIR_SIFTGPU)/ServerSiftGPU.o: $(SRC_SERVER)/ServerSiftGPU.cpp $(DEPS_SIFTGPU)
- $(CC) -o $@ $< $(CFLAGS) -DSERVER_SIFTGPU_ENABLED -c
-_OBJ_SIFTGPU += ServerSiftGPU.o
-endif
-
-OBJ_SIFTGPU = $(patsubst %,$(ODIR_SIFTGPU)/%,$(_OBJ_SIFTGPU))
-LIBS_DRIVER = $(BIN_DIR)/libsiftgpu.a $(LIBS_SIFTGPU)
-SRC_TESTWIN = $(SRC_DRIVER)/TestWinGlut.cpp $(SRC_DRIVER)/BasicTestWin.cpp
-DEP_TESTWIN = $(SRC_DRIVER)/TestWinGlut.h $(SRC_DRIVER)/BasicTestwin.h $(SRC_DRIVER)/GLTransform.h
-
-
-
-ifneq ($(simplesift_runtime_load), 0)
-LIBS_SIMPLESIFT = -ldl -DSIFTGPU_DLL_RUNTIME
-else
-LIBS_SIMPLESIFT = $(LIBS_DRIVER) -DSIFTGPU_STATIC
-endif
-
-siftgpu: makepath $(OBJ_SIFTGPU)
- ar rcs $(BIN_DIR)/libsiftgpu.a $(OBJ_SIFTGPU)
- $(CC) -o $(BIN_DIR)/libsiftgpu.so $(OBJ_SIFTGPU) $(LIBS_SIFTGPU) $(CFLAGS) -shared -fPIC
-
-driver: makepath
- $(CC) -o $(BIN_DIR)/TestWinGlut $(SRC_TESTWIN) $(LIBS_DRIVER) $(CFLAGS)
- $(CC) -o $(BIN_DIR)/SimpleSIFT $(SRC_DRIVER)/SimpleSIFT.cpp $(LIBS_SIMPLESIFT) $(CFLAGS)
- $(CC) -o $(BIN_DIR)/speed $(SRC_DRIVER)/speed.cpp $(LIBS_DRIVER) $(CFLAGS)
- $(CC) -o $(BIN_DIR)/MultiThreadSIFT $(SRC_DRIVER)/MultiThreadSIFT.cpp $(LIBS_DRIVER) $(CFLAGS) -pthread
-
-ifneq ($(siftgpu_enable_server), 0)
-server: makepath
- $(CC) -o $(BIN_DIR)/server_siftgpu $(SRC_SERVER)/server.cpp $(LIBS_DRIVER) $(CFLAGS)
-else
-server:
-
-endif
-
-makepath:
- mkdir -p $(ODIR_SIFTGPU)
- mkdir -p $(BIN_DIR)
- sed -i -e 's/\\/\//g' demos/*.bat
-
-clean:
- rm -f $(ODIR_SIFTGPU)/*.o
- rm -f $(BIN_DIR)/libsiftgpu.a
- rm -f $(BIN_DIR)/libsiftgpu.so
- rm -f $(BIN_DIR)/TestWinGlut
- rm -f $(BIN_DIR)/SimpleSIFT
- rm -f $(BIN_DIR)/speed
- rm -f $(BIN_DIR)/server_siftgpu
- rm -f $(BIN_DIR)/MultiThreadSIFT
- rm -f ProgramCU.linkinfo
-
diff --git a/3rdparty/SiftGPU/msvc/ServerSiftGPU/SiftGPU_Server.dsp b/3rdparty/SiftGPU/msvc/ServerSiftGPU/SiftGPU_Server.dsp
deleted file mode 100644
index 46978894..00000000
--- a/3rdparty/SiftGPU/msvc/ServerSiftGPU/SiftGPU_Server.dsp
+++ /dev/null
@@ -1,102 +0,0 @@
-# Microsoft Developer Studio Project File - Name="SiftGPU_Server" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=SiftGPU_Server - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "SiftGPU_Server.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "SiftGPU_Server.mak" CFG="SiftGPU_Server - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "SiftGPU_Server - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "SiftGPU_Server - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "SiftGPU_Server - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "SiftGPU_Server___Win32_Release"
-# PROP BASE Intermediate_Dir "SiftGPU_Server___Win32_Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../Include/" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# 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
-# 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"
-
-!ELSEIF "$(CFG)" == "SiftGPU_Server - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "SiftGPU_Server___Win32_Debug"
-# PROP BASE Intermediate_Dir "SiftGPU_Server___Win32_Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../Include/" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# 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
-# 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"
-
-!ENDIF
-
-# Begin Target
-
-# Name "SiftGPU_Server - Win32 Release"
-# Name "SiftGPU_Server - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=..\..\src\ServerSiftGPU\server.cpp
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/3rdparty/SiftGPU/msvc/ServerSiftGPU/SiftGPU_Server.vcxproj b/3rdparty/SiftGPU/msvc/ServerSiftGPU/SiftGPU_Server.vcxproj
deleted file mode 100644
index 5ab88619..00000000
--- a/3rdparty/SiftGPU/msvc/ServerSiftGPU/SiftGPU_Server.vcxproj
+++ /dev/null
@@ -1,204 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {65C987E1-F62C-4461-9E2C-BE1E8A770C51}
- SiftGPU_Server
- Win32Proj
-
-
-
- Application
- MultiByte
- true
-
-
- Application
- MultiByte
-
-
- Application
- MultiByte
- true
-
-
- Application
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <_ProjectFileVersion>10.0.30319.1
- ..\..\bin\
- $(Configuration)\
- true
- ..\..\bin\
- $(Configuration)_$(Platform)\
- true
- ..\..\bin\
- $(Configuration)\
- false
- ..\..\bin\
- $(Configuration)_$(Platform)\
- false
- server_siftgpu
- server_siftgpu
- server_siftgpu
- server_siftgpu
-
-
-
- Disabled
- ../../Include/;%(AdditionalIncludeDirectories)
- WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
- true
- EnableFastChecks
- MultiThreadedDebug
-
-
- $(IntDir)
- Level3
- EditAndContinue
-
-
- siftgpu_d.lib;%(AdditionalDependencies)
- $(OutDir)$(TargetName)$(TargetExt)
- ../../lib;%(AdditionalLibraryDirectories)
- true
- Console
- MachineX86
-
-
- false
-
-
-
-
- X64
-
-
- Disabled
- ../../Include/;%(AdditionalIncludeDirectories)
- WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
- true
- EnableFastChecks
- MultiThreadedDebug
-
-
- $(IntDir)
- Level3
- ProgramDatabase
-
-
- siftgpu_d.lib;%(AdditionalDependencies)
- $(OutDir)$(TargetName)$(TargetExt)
- ../../lib;%(AdditionalLibraryDirectories)
- true
- Console
- MachineX64
-
-
- false
-
-
-
-
- ../../Include/;%(AdditionalIncludeDirectories)
- WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
- MultiThreaded
-
-
- $(IntDir)
- Level3
- ProgramDatabase
-
-
- siftgpu.lib;%(AdditionalDependencies)
- $(OutDir)$(TargetName)$(TargetExt)
- ../../lib;%(AdditionalLibraryDirectories)
- true
- Console
- true
- true
- MachineX86
-
-
- false
-
-
-
-
- X64
-
-
- ../../Include/;%(AdditionalIncludeDirectories)
- WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
- MultiThreaded
-
-
- $(IntDir)
- Level3
- ProgramDatabase
-
-
- siftgpu.lib;%(AdditionalDependencies)
- $(OutDir)$(TargetName)$(TargetExt)
- ../../lib;%(AdditionalLibraryDirectories)
- true
- Console
- true
- true
- MachineX64
-
-
- false
-
-
-
-
-
-
-
- {594562d3-609a-47bc-b7e2-789c4e794cc3}
- false
-
-
- {9252e247-4fe2-4929-bd5d-c2fa16efd656}
- false
-
-
-
-
-
-
\ No newline at end of file
diff --git a/3rdparty/SiftGPU/msvc/SiftGPU.dsw b/3rdparty/SiftGPU/msvc/SiftGPU.dsw
deleted file mode 100644
index 8af0f428..00000000
--- a/3rdparty/SiftGPU/msvc/SiftGPU.dsw
+++ /dev/null
@@ -1,119 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "SiftGPU"=.\SiftGPU\SiftGPU.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Project: "SiftGPU_Server"=.\ServerSiftGPU\SiftGPU_Server.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
- Begin Project Dependency
- Project_Dep_Name SiftGPU
- End Project Dependency
-}}}
-
-###############################################################################
-
-Project: "SimpleSIFT"=.\TestWin\SimpleSIFT.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
- Begin Project Dependency
- Project_Dep_Name SiftGPU
- End Project Dependency
-}}}
-
-###############################################################################
-
-Project: "Speed"=.\TestWin\Speed.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
- Begin Project Dependency
- Project_Dep_Name SiftGPU
- End Project Dependency
-}}}
-
-###############################################################################
-
-Project: "TestBase"=.\TestWin\TestBase.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
- Begin Project Dependency
- Project_Dep_Name SiftGPU
- End Project Dependency
-}}}
-
-###############################################################################
-
-Project: "TestWin"=.\TestWin\TestWin.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
- Begin Project Dependency
- Project_Dep_Name TestBase
- End Project Dependency
-}}}
-
-###############################################################################
-
-Project: "TestWinGlut"=.\TestWin\TestWinGlut.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
- Begin Project Dependency
- Project_Dep_Name TestBase
- End Project Dependency
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/3rdparty/SiftGPU/msvc/SiftGPU.sln b/3rdparty/SiftGPU/msvc/SiftGPU.sln
deleted file mode 100644
index e4f56a40..00000000
--- a/3rdparty/SiftGPU/msvc/SiftGPU.sln
+++ /dev/null
@@ -1,86 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SiftGPU", "SiftGPU\SiftGPU.vcxproj", "{594562D3-609A-47BC-B7E2-789C4E794CC3}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestBase", "TestWin\TestBase.vcxproj", "{57496D03-A005-4650-B041-8E70DDA4A591}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestWin", "TestWin\TestWin.vcxproj", "{E1C4EAB3-1677-46F7-92BC-1A1F309B2027}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestWinGlut", "TestWin\TestWinGlut.vcxproj", "{B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleSIFT", "TestWin\SimpleSIFT.vcxproj", "{D864A317-5A65-47B1-AA82-C04F99C4280F}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Speed", "TestWin\Speed.vcxproj", "{7FF72B39-F50E-4ED5-9A50-DCD60EF03604}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SiftGPU_Server", "ServerSiftGPU\SiftGPU_Server.vcxproj", "{65C987E1-F62C-4461-9E2C-BE1E8A770C51}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Debug|x64 = Debug|x64
- Release|Win32 = Release|Win32
- Release|x64 = Release|x64
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {594562D3-609A-47BC-B7E2-789C4E794CC3}.Debug|Win32.ActiveCfg = Debug|Win32
- {594562D3-609A-47BC-B7E2-789C4E794CC3}.Debug|Win32.Build.0 = Debug|Win32
- {594562D3-609A-47BC-B7E2-789C4E794CC3}.Debug|x64.ActiveCfg = Debug|x64
- {594562D3-609A-47BC-B7E2-789C4E794CC3}.Debug|x64.Build.0 = Debug|x64
- {594562D3-609A-47BC-B7E2-789C4E794CC3}.Release|Win32.ActiveCfg = Release|Win32
- {594562D3-609A-47BC-B7E2-789C4E794CC3}.Release|Win32.Build.0 = Release|Win32
- {594562D3-609A-47BC-B7E2-789C4E794CC3}.Release|x64.ActiveCfg = Release|x64
- {594562D3-609A-47BC-B7E2-789C4E794CC3}.Release|x64.Build.0 = Release|x64
- {57496D03-A005-4650-B041-8E70DDA4A591}.Debug|Win32.ActiveCfg = Debug|Win32
- {57496D03-A005-4650-B041-8E70DDA4A591}.Debug|Win32.Build.0 = Debug|Win32
- {57496D03-A005-4650-B041-8E70DDA4A591}.Debug|x64.ActiveCfg = Debug|x64
- {57496D03-A005-4650-B041-8E70DDA4A591}.Debug|x64.Build.0 = Debug|x64
- {57496D03-A005-4650-B041-8E70DDA4A591}.Release|Win32.ActiveCfg = Release|Win32
- {57496D03-A005-4650-B041-8E70DDA4A591}.Release|Win32.Build.0 = Release|Win32
- {57496D03-A005-4650-B041-8E70DDA4A591}.Release|x64.ActiveCfg = Release|x64
- {57496D03-A005-4650-B041-8E70DDA4A591}.Release|x64.Build.0 = Release|x64
- {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Debug|Win32.ActiveCfg = Debug|Win32
- {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Debug|Win32.Build.0 = Debug|Win32
- {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Debug|x64.ActiveCfg = Debug|x64
- {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Debug|x64.Build.0 = Debug|x64
- {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Release|Win32.ActiveCfg = Release|Win32
- {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Release|Win32.Build.0 = Release|Win32
- {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Release|x64.ActiveCfg = Release|x64
- {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Release|x64.Build.0 = Release|x64
- {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Debug|Win32.ActiveCfg = Debug|Win32
- {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Debug|Win32.Build.0 = Debug|Win32
- {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Debug|x64.ActiveCfg = Debug|x64
- {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Debug|x64.Build.0 = Debug|x64
- {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Release|Win32.ActiveCfg = Release|Win32
- {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Release|Win32.Build.0 = Release|Win32
- {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Release|x64.ActiveCfg = Release|x64
- {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Release|x64.Build.0 = Release|x64
- {D864A317-5A65-47B1-AA82-C04F99C4280F}.Debug|Win32.ActiveCfg = Debug|Win32
- {D864A317-5A65-47B1-AA82-C04F99C4280F}.Debug|Win32.Build.0 = Debug|Win32
- {D864A317-5A65-47B1-AA82-C04F99C4280F}.Debug|x64.ActiveCfg = Debug|x64
- {D864A317-5A65-47B1-AA82-C04F99C4280F}.Debug|x64.Build.0 = Debug|x64
- {D864A317-5A65-47B1-AA82-C04F99C4280F}.Release|Win32.ActiveCfg = Release|Win32
- {D864A317-5A65-47B1-AA82-C04F99C4280F}.Release|Win32.Build.0 = Release|Win32
- {D864A317-5A65-47B1-AA82-C04F99C4280F}.Release|x64.ActiveCfg = Release|x64
- {D864A317-5A65-47B1-AA82-C04F99C4280F}.Release|x64.Build.0 = Release|x64
- {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Debug|Win32.ActiveCfg = Debug|Win32
- {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Debug|Win32.Build.0 = Debug|Win32
- {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Debug|x64.ActiveCfg = Debug|x64
- {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Debug|x64.Build.0 = Debug|x64
- {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Release|Win32.ActiveCfg = Release|Win32
- {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Release|Win32.Build.0 = Release|Win32
- {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Release|x64.ActiveCfg = Release|x64
- {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Release|x64.Build.0 = Release|x64
- {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Debug|Win32.ActiveCfg = Debug|Win32
- {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Debug|Win32.Build.0 = Debug|Win32
- {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Debug|x64.ActiveCfg = Debug|x64
- {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Debug|x64.Build.0 = Debug|x64
- {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Release|Win32.ActiveCfg = Release|Win32
- {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Release|Win32.Build.0 = Release|Win32
- {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Release|x64.ActiveCfg = Release|x64
- {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Release|x64.Build.0 = Release|x64
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/3rdparty/SiftGPU/msvc/SiftGPU/SiftGPU.def b/3rdparty/SiftGPU/msvc/SiftGPU/SiftGPU.def
deleted file mode 100644
index 5512ab90..00000000
--- a/3rdparty/SiftGPU/msvc/SiftGPU/SiftGPU.def
+++ /dev/null
@@ -1,6 +0,0 @@
-EXPORTS
- CreateNewSiftGPU @1
- CreateNewSiftMatchGPU @2
- CreateLiteWindow @3
- CreateComboSiftGPU @4
- CreateRemoteSiftGPU @5
diff --git a/3rdparty/SiftGPU/msvc/SiftGPU/SiftGPU.dsp b/3rdparty/SiftGPU/msvc/SiftGPU/SiftGPU.dsp
deleted file mode 100644
index 1bfcd0a4..00000000
--- a/3rdparty/SiftGPU/msvc/SiftGPU/SiftGPU.dsp
+++ /dev/null
@@ -1,204 +0,0 @@
-# Microsoft Developer Studio Project File - Name="SiftGPU" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=SiftGPU - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "SiftGPU.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "SiftGPU.mak" CFG="SiftGPU - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "SiftGPU - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "SiftGPU - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "SiftGPU - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# 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
-# 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
-# SUBTRACT CPP /YX /Yc /Yu
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# 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
-# 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/"
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF "$(CFG)" == "SiftGPU - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# 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
-# 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
-# SUBTRACT CPP /YX /Yc /Yu
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# 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
-# 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/"
-# SUBTRACT LINK32 /pdb:none
-
-!ENDIF
-
-# Begin Target
-
-# Name "SiftGPU - Win32 Release"
-# Name "SiftGPU - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=..\..\src\SiftGPU\FrameBufferObject.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\src\SiftGPU\GlobalUtil.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\src\SiftGPU\GLTexImage.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\src\SiftGPU\ProgramGLSL.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\src\SiftGPU\ProgramGPU.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\src\SiftGPU\PyramidGL.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\src\ServerSiftGPU\ServerSiftGPU.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\src\SiftGPU\ShaderMan.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\src\SiftGPU\SiftGPU.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\SiftGPU.def
-# PROP Exclude_From_Build 1
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\src\SiftGPU\SiftMatch.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\src\SiftGPU\SIFTPyramid.cpp
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=..\..\src\SiftGPU\FrameBufferObject.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\src\SiftGPU\GlobalUtil.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\src\SiftGPU\GLTexImage.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\src\SiftGPU\LiteWindow.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\src\SiftGPU\ProgramGLSL.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\src\SiftGPU\programGPU.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\src\SiftGPU\PyramidGL.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\src\ServerSiftGPU\ServerSiftGPU.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\src\SiftGPU\ShaderMan.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\src\SiftGPU\SiftGPU.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\src\SiftGPU\SiftMatch.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\src\SiftGPU\SIFTPyramid.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/3rdparty/SiftGPU/msvc/SiftGPU/SiftGPU.vcxproj b/3rdparty/SiftGPU/msvc/SiftGPU/SiftGPU.vcxproj
deleted file mode 100644
index 6d3542d5..00000000
--- a/3rdparty/SiftGPU/msvc/SiftGPU/SiftGPU.vcxproj
+++ /dev/null
@@ -1,375 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {594562D3-609A-47BC-B7E2-789C4E794CC3}
- SiftGPU
-
-
-
- DynamicLibrary
- false
- MultiByte
-
-
- DynamicLibrary
- false
- MultiByte
-
-
- DynamicLibrary
- false
- MultiByte
-
-
- DynamicLibrary
- false
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <_ProjectFileVersion>10.0.30319.1
- ..\..\bin\
- $(Configuration)\
- false
- ..\..\bin\
- $(Configuration)\
- true
- ..\..\bin\
- $(Configuration)_$(Platform)\
- false
- ..\..\bin\
- $(Configuration)_$(Platform)\
- true
- $(ProjectName)_d
- $(ProjectName)_d
-
-
-
- NDEBUG;%(PreprocessorDefinitions)
- true
- true
- Win32
- .\Release/SiftGPU.tlb
-
-
-
-
- MaxSpeed
- OnlyExplicitInline
- false
- Speed
- ../../Include/;%(AdditionalIncludeDirectories)
- NDEBUG;SIFTGPU_EXPORTS;WIN32;_WINDOWS;_USRDLL;SIFTGPU_DLL;DLL_EXPORT;_CRT_SECURE_NO_DEPRECATE;SERVER_SIFTGPU_ENABLED;%(PreprocessorDefinitions)
- false
- true
- MultiThreaded
- true
-
-
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
-
-
- NDEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- opengl32.lib;glu32.lib;winmm.lib;glew32.lib;glew32s.lib;%(AdditionalDependencies)
- $(OutDir)$(TargetName)$(TargetExt)
- true
- ../../lib/;%(AdditionalLibraryDirectories)
- SiftGPU.def
- $(IntDir)/SIFTGPU.pdb
- ../../lib/SIFTGPU.lib
- MachineX86
-
-
- true
- .\Release/SiftGPU.bsc
-
-
-
-
- _DEBUG;%(PreprocessorDefinitions)
- true
- true
- Win32
- .\Debug/SiftGPU.tlb
-
-
-
-
- Disabled
- ../../Include/;%(AdditionalIncludeDirectories)
- _DEBUG;DLL_EXPORT;WIN32;_WINDOWS;_USRDLL;SIFTGPU_DLL;_CRT_SECURE_NO_DEPRECATE;SERVER_SIFTGPU_ENABLED;%(PreprocessorDefinitions)
- false
- true
- EnableFastChecks
- MultiThreadedDebug
-
-
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
- EditAndContinue
-
-
- _DEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- opengl32.lib;glu32.lib;winmm.lib;glew32.lib;glew32s.lib;%(AdditionalDependencies)
- $(OutDir)$(TargetName)$(TargetExt)
- true
- ../../lib/;%(AdditionalLibraryDirectories)
- SiftGPU.def
- true
- $(IntDir)/SIFTGPU.pdb
- ../../lib/SIFTGPU_d.lib
- MachineX86
-
-
- true
- .\Debug/SiftGPU.bsc
-
-
-
-
- NDEBUG;%(PreprocessorDefinitions)
- true
- true
- X64
- .\Release/SiftGPU.tlb
-
-
-
-
- MaxSpeed
- OnlyExplicitInline
- false
- Speed
- ../../Include/;%(AdditionalIncludeDirectories)
- NDEBUG;SIFTGPU_EXPORTS;WIN32;_WINDOWS;_USRDLL;SIFTGPU_DLL;DLL_EXPORT;_CRT_SECURE_NO_DEPRECATE;SERVER_SIFTGPU_ENABLED;%(PreprocessorDefinitions)
- false
- true
- MultiThreaded
- true
-
-
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
-
-
- NDEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- opengl32.lib;glu32.lib;winmm.lib;glew64.lib;glew64s.lib;%(AdditionalDependencies)
- $(OutDir)$(TargetName)$(TargetExt)
- true
- ../../lib/;%(AdditionalLibraryDirectories)
- SiftGPU.def
- $(IntDir)/SIFTGPU.pdb
- ../../lib/SIFTGPU.lib
- MachineX64
-
-
- true
- .\Release/SiftGPU.bsc
-
-
-
-
- _DEBUG;%(PreprocessorDefinitions)
- true
- true
- X64
- .\Debug/SiftGPU.tlb
-
-
-
-
- Disabled
- ../../Include/;%(AdditionalIncludeDirectories)
- _DEBUG;DLL_EXPORT;WIN32;_WINDOWS;_USRDLL;SIFTGPU_DLL;_CRT_SECURE_NO_DEPRECATE;SERVER_SIFTGPU_ENABLED;%(PreprocessorDefinitions)
- false
- true
- EnableFastChecks
- MultiThreadedDebug
-
-
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
- ProgramDatabase
-
-
- _DEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- opengl32.lib;glu32.lib;winmm.lib;glew64.lib;glew64s.lib;%(AdditionalDependencies)
- $(OutDir)$(TargetName)$(TargetExt)
- true
- ../../lib/;%(AdditionalLibraryDirectories)
- SiftGPU.def
- true
- $(IntDir)/SIFTGPU.pdb
- ../../lib/SIFTGPU_d.lib
- MachineX64
-
-
- true
- .\Debug/SiftGPU.bsc
-
-
-
-
-
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
-
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
-
-
-
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/3rdparty/SiftGPU/msvc/SiftGPU/SiftGPU_CUDA_Enabled.vcxproj b/3rdparty/SiftGPU/msvc/SiftGPU/SiftGPU_CUDA_Enabled.vcxproj
deleted file mode 100644
index c9b216a4..00000000
--- a/3rdparty/SiftGPU/msvc/SiftGPU/SiftGPU_CUDA_Enabled.vcxproj
+++ /dev/null
@@ -1,390 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {9252E247-4FE2-4929-BD5D-C2FA16EFD656}
- SiftGPU_CUDA_Enabled
-
-
-
- DynamicLibrary
- false
- MultiByte
-
-
- DynamicLibrary
- false
- MultiByte
-
-
- DynamicLibrary
- false
- MultiByte
-
-
- DynamicLibrary
- false
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <_ProjectFileVersion>10.0.30319.1
- ..\..\bin\
- .\Release_CUDA\
- false
- ..\..\bin\
- .\Debug_CUDA\
- true
- ..\..\bin\
- $(Configuration)_CUDA_$(Platform)\
- false
- ..\..\bin\
- $(Configuration)_CUDA_$(Platform)\
- true
- SiftGPU_d
- SiftGPU_d
- SiftGPU
- SiftGPU
-
-
-
- NDEBUG;%(PreprocessorDefinitions)
- true
- true
- Win32
- .\Release/SiftGPU.tlb
-
-
-
-
- MaxSpeed
- OnlyExplicitInline
- ../../Include/;%(AdditionalIncludeDirectories)
- NDEBUG;SIFTGPU_EXPORTS;WIN32;_WINDOWS;_USRDLL;SIFTGPU_DLL;DLL_EXPORT;_CRT_SECURE_NO_DEPRECATE;CUDA_SIFTGPU_ENABLED;SERVER_SIFTGPU_ENABLED;%(PreprocessorDefinitions)
- false
- true
- MultiThreaded
- true
- $(IntDir)/SIFTGPU.pch
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
-
-
- NDEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- opengl32.lib;glu32.lib;winmm.lib;cuda.lib;cudart.lib;glew32.lib;glew32s.lib;%(AdditionalDependencies)
- $(OutDir)$(TargetName)$(TargetExt)
- true
- ../../lib/;$(CUDA_LIB_PATH)/../Win32;%(AdditionalLibraryDirectories)
- SiftGPU.def
- $(IntDir)/SIFTGPU.pdb
- ../../lib/SIFTGPU.lib
- MachineX86
-
-
- true
- .\Release/SiftGPU.bsc
-
-
-
-
- _DEBUG;%(PreprocessorDefinitions)
- true
- true
- Win32
- .\Debug/SiftGPU.tlb
-
-
-
-
- Disabled
- ../../Include/;%(AdditionalIncludeDirectories)
- _DEBUG;DLL_EXPORT;WIN32;_WINDOWS;_USRDLL;SIFTGPU_DLL;_CRT_SECURE_NO_DEPRECATE;CUDA_SIFTGPU_ENABLED;SERVER_SIFTGPU_ENABLED;%(PreprocessorDefinitions)
- false
- true
- EnableFastChecks
- MultiThreadedDebug
- $(IntDir)/SIFTGPU.pch
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
- EditAndContinue
-
-
- _DEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- opengl32.lib;glu32.lib;winmm.lib;cuda.lib;cudart.lib;glew32.lib;glew32s.lib;%(AdditionalDependencies)
- $(OutDir)$(TargetName)$(TargetExt)
- true
- ../../lib/;$(CUDA_LIB_PATH)/../Win32;%(AdditionalLibraryDirectories)
- SiftGPU.def
- true
- $(IntDir)/SIFTGPU.pdb
- ../../lib/SIFTGPU_d.lib
- MachineX86
-
-
- true
- .\Debug/SiftGPU.bsc
-
-
-
-
- NDEBUG;%(PreprocessorDefinitions)
- true
- true
- X64
- .\Release/SiftGPU.tlb
-
-
-
-
- MaxSpeed
- OnlyExplicitInline
- ../../Include/;%(AdditionalIncludeDirectories)
- NDEBUG;SIFTGPU_EXPORTS;WIN32;_WINDOWS;_USRDLL;SIFTGPU_DLL;DLL_EXPORT;_CRT_SECURE_NO_DEPRECATE;CUDA_SIFTGPU_ENABLED;SERVER_SIFTGPU_ENABLED;%(PreprocessorDefinitions)
- false
- true
- MultiThreaded
- true
- $(IntDir)/SIFTGPU.pch
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
-
-
- NDEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- opengl32.lib;glu32.lib;winmm.lib;cuda.lib;cudart.lib;glew64.lib;glew64s.lib;%(AdditionalDependencies)
- $(OutDir)$(TargetName)$(TargetExt)
- true
- ../../lib/;$(CUDA_LIB_PATH)/../x64;%(AdditionalLibraryDirectories)
- SiftGPU.def
- $(IntDir)/SIFTGPU.pdb
- ../../lib/SIFTGPU.lib
- MachineX64
-
-
- true
- .\Release/SiftGPU.bsc
-
-
-
-
- _DEBUG;%(PreprocessorDefinitions)
- true
- true
- X64
- .\Debug/SiftGPU.tlb
-
-
-
-
- Disabled
- ../../Include/;%(AdditionalIncludeDirectories)
- _DEBUG;DLL_EXPORT;WIN32;_WINDOWS;_USRDLL;SIFTGPU_DLL;_CRT_SECURE_NO_DEPRECATE;CUDA_SIFTGPU_ENABLED;SERVER_SIFTGPU_ENABLED;%(PreprocessorDefinitions)
- false
- true
- EnableFastChecks
- MultiThreadedDebug
- $(IntDir)/SIFTGPU.pch
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
- ProgramDatabase
-
-
- _DEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- opengl32.lib;glu32.lib;winmm.lib;cuda.lib;cudart.lib;glew64.lib;glew64s.lib;%(AdditionalDependencies)
- $(OutDir)$(TargetName)$(TargetExt)
- true
- ../../lib/;$(CUDA_LIB_PATH)/../x64;%(AdditionalLibraryDirectories)
- SiftGPU.def
- true
- $(IntDir)/SIFTGPU.pdb
- ../../lib/SIFTGPU_d.lib
- MachineX64
-
-
- true
- .\Debug/SiftGPU.bsc
-
-
-
-
- $(CUDA_INC_PATH)\;%(AdditionalIncludeDirectories)
- $(CUDA_INC_PATH)\;%(AdditionalIncludeDirectories)
- $(CUDA_INC_PATH)\;%(AdditionalIncludeDirectories)
- $(CUDA_INC_PATH)\;%(AdditionalIncludeDirectories)
-
-
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
- $(CUDA_INC_PATH)\;%(AdditionalIncludeDirectories)
- $(CUDA_INC_PATH)\;%(AdditionalIncludeDirectories)
- $(CUDA_INC_PATH)\;%(AdditionalIncludeDirectories)
- $(CUDA_INC_PATH)\;%(AdditionalIncludeDirectories)
-
-
-
-
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
-
-
-
-
-
- Document
- "$(CUDA_BIN_PATH)\nvcc.exe" -ccbin "$(VCInstallDir)\bin" -c -DWIN32 -D_CONSOLE -D_MBCS -DCUDA_SIFTGPU_ENABLED -Xcompiler /EHsc,/W3,/nologo,/O2,/Zi,/MTd -m 64 -I "$(CUDA_INC_PATH)" -I./ -I../../Include -o $(IntDir)\$(InputName).obj %(FullPath)
- $(IntDir)\$(InputName).obj
- "$(CUDA_BIN_PATH)\nvcc.exe" -ccbin "$(VCInstallDir)\bin" -c -DWIN32 -D_CONSOLE -D_MBCS -DCUDA_SIFTGPU_ENABLED -Xcompiler /EHsc,/W3,/nologo,/O2,/MT -m 64 -I "$(CUDA_INC_PATH)" -I./ -I../../Include -o $(IntDir)\$(InputName).obj %(FullPath)
- $(IntDir)\$(InputName).obj
- "$(CUDA_BIN_PATH)\nvcc.exe" -ccbin "$(VCInstallDir)\bin" -c -DWIN32 -D_CONSOLE -D_MBCS -DCUDA_SIFTGPU_ENABLED -Xcompiler /EHsc,/W3,/nologo,/O2,/Zi,/MT -m 32 -I "$(CUDA_INC_PATH)" -I./ -I../../Include -o $(IntDir)\$(InputName).obj %(FullPath)
- $(IntDir)\$(InputName).obj
- "$(CUDA_BIN_PATH)\nvcc.exe" -ccbin "$(VCInstallDir)\bin" -c -DWIN32 -D_CONSOLE -D_MBCS -DCUDA_SIFTGPU_ENABLED -Xcompiler /EHsc,/W3,/nologo,/O2,/Zi,/MTd -m 32 -I "$(CUDA_INC_PATH)" -I./ -I../../Include -o $(IntDir)\$(InputName).obj %(FullPath)
- $(IntDir)\$(InputName).obj
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/3rdparty/SiftGPU/msvc/SiftGPU_CUDA_Enabled.sln b/3rdparty/SiftGPU/msvc/SiftGPU_CUDA_Enabled.sln
deleted file mode 100644
index febda092..00000000
--- a/3rdparty/SiftGPU/msvc/SiftGPU_CUDA_Enabled.sln
+++ /dev/null
@@ -1,105 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestBase", "TestWin\TestBase.vcxproj", "{57496D03-A005-4650-B041-8E70DDA4A591}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestWin", "TestWin\TestWin.vcxproj", "{E1C4EAB3-1677-46F7-92BC-1A1F309B2027}"
- ProjectSection(ProjectDependencies) = postProject
- {9252E247-4FE2-4929-BD5D-C2FA16EFD656} = {9252E247-4FE2-4929-BD5D-C2FA16EFD656}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestWinGlut", "TestWin\TestWinGlut.vcxproj", "{B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}"
- ProjectSection(ProjectDependencies) = postProject
- {9252E247-4FE2-4929-BD5D-C2FA16EFD656} = {9252E247-4FE2-4929-BD5D-C2FA16EFD656}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleSIFT", "TestWin\SimpleSIFT.vcxproj", "{D864A317-5A65-47B1-AA82-C04F99C4280F}"
- ProjectSection(ProjectDependencies) = postProject
- {9252E247-4FE2-4929-BD5D-C2FA16EFD656} = {9252E247-4FE2-4929-BD5D-C2FA16EFD656}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Speed", "TestWin\Speed.vcxproj", "{7FF72B39-F50E-4ED5-9A50-DCD60EF03604}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SiftGPU_CUDA_Enabled", "SiftGPU\SiftGPU_CUDA_Enabled.vcxproj", "{9252E247-4FE2-4929-BD5D-C2FA16EFD656}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SiftGPU_Server", "ServerSiftGPU\SiftGPU_Server.vcxproj", "{65C987E1-F62C-4461-9E2C-BE1E8A770C51}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MultiThreadSIFT", "TestWin\MultiThreadSIFT.vcxproj", "{8F087E0E-0B77-4CF7-BCD7-F899DB361128}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Debug|x64 = Debug|x64
- Release|Win32 = Release|Win32
- Release|x64 = Release|x64
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {57496D03-A005-4650-B041-8E70DDA4A591}.Debug|Win32.ActiveCfg = Debug|Win32
- {57496D03-A005-4650-B041-8E70DDA4A591}.Debug|Win32.Build.0 = Debug|Win32
- {57496D03-A005-4650-B041-8E70DDA4A591}.Debug|x64.ActiveCfg = Debug|x64
- {57496D03-A005-4650-B041-8E70DDA4A591}.Debug|x64.Build.0 = Debug|x64
- {57496D03-A005-4650-B041-8E70DDA4A591}.Release|Win32.ActiveCfg = Release|Win32
- {57496D03-A005-4650-B041-8E70DDA4A591}.Release|Win32.Build.0 = Release|Win32
- {57496D03-A005-4650-B041-8E70DDA4A591}.Release|x64.ActiveCfg = Release|x64
- {57496D03-A005-4650-B041-8E70DDA4A591}.Release|x64.Build.0 = Release|x64
- {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Debug|Win32.ActiveCfg = Debug|Win32
- {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Debug|Win32.Build.0 = Debug|Win32
- {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Debug|x64.ActiveCfg = Debug|x64
- {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Debug|x64.Build.0 = Debug|x64
- {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Release|Win32.ActiveCfg = Release|Win32
- {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Release|Win32.Build.0 = Release|Win32
- {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Release|x64.ActiveCfg = Release|x64
- {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}.Release|x64.Build.0 = Release|x64
- {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Debug|Win32.ActiveCfg = Debug|Win32
- {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Debug|Win32.Build.0 = Debug|Win32
- {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Debug|x64.ActiveCfg = Debug|x64
- {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Debug|x64.Build.0 = Debug|x64
- {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Release|Win32.ActiveCfg = Release|Win32
- {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Release|Win32.Build.0 = Release|Win32
- {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Release|x64.ActiveCfg = Release|x64
- {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}.Release|x64.Build.0 = Release|x64
- {D864A317-5A65-47B1-AA82-C04F99C4280F}.Debug|Win32.ActiveCfg = Debug|Win32
- {D864A317-5A65-47B1-AA82-C04F99C4280F}.Debug|Win32.Build.0 = Debug|Win32
- {D864A317-5A65-47B1-AA82-C04F99C4280F}.Debug|x64.ActiveCfg = Debug|x64
- {D864A317-5A65-47B1-AA82-C04F99C4280F}.Debug|x64.Build.0 = Debug|x64
- {D864A317-5A65-47B1-AA82-C04F99C4280F}.Release|Win32.ActiveCfg = Release|Win32
- {D864A317-5A65-47B1-AA82-C04F99C4280F}.Release|Win32.Build.0 = Release|Win32
- {D864A317-5A65-47B1-AA82-C04F99C4280F}.Release|x64.ActiveCfg = Release|x64
- {D864A317-5A65-47B1-AA82-C04F99C4280F}.Release|x64.Build.0 = Release|x64
- {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Debug|Win32.ActiveCfg = Debug|Win32
- {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Debug|Win32.Build.0 = Debug|Win32
- {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Debug|x64.ActiveCfg = Debug|x64
- {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Debug|x64.Build.0 = Debug|x64
- {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Release|Win32.ActiveCfg = Release|Win32
- {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Release|Win32.Build.0 = Release|Win32
- {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Release|x64.ActiveCfg = Release|x64
- {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}.Release|x64.Build.0 = Release|x64
- {9252E247-4FE2-4929-BD5D-C2FA16EFD656}.Debug|Win32.ActiveCfg = Debug|Win32
- {9252E247-4FE2-4929-BD5D-C2FA16EFD656}.Debug|Win32.Build.0 = Debug|Win32
- {9252E247-4FE2-4929-BD5D-C2FA16EFD656}.Debug|x64.ActiveCfg = Debug|x64
- {9252E247-4FE2-4929-BD5D-C2FA16EFD656}.Debug|x64.Build.0 = Debug|x64
- {9252E247-4FE2-4929-BD5D-C2FA16EFD656}.Release|Win32.ActiveCfg = Release|Win32
- {9252E247-4FE2-4929-BD5D-C2FA16EFD656}.Release|Win32.Build.0 = Release|Win32
- {9252E247-4FE2-4929-BD5D-C2FA16EFD656}.Release|x64.ActiveCfg = Release|x64
- {9252E247-4FE2-4929-BD5D-C2FA16EFD656}.Release|x64.Build.0 = Release|x64
- {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Debug|Win32.ActiveCfg = Debug|Win32
- {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Debug|Win32.Build.0 = Debug|Win32
- {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Debug|x64.ActiveCfg = Debug|x64
- {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Debug|x64.Build.0 = Debug|x64
- {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Release|Win32.ActiveCfg = Release|Win32
- {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Release|Win32.Build.0 = Release|Win32
- {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Release|x64.ActiveCfg = Release|x64
- {65C987E1-F62C-4461-9E2C-BE1E8A770C51}.Release|x64.Build.0 = Release|x64
- {8F087E0E-0B77-4CF7-BCD7-F899DB361128}.Debug|Win32.ActiveCfg = Debug|Win32
- {8F087E0E-0B77-4CF7-BCD7-F899DB361128}.Debug|Win32.Build.0 = Debug|Win32
- {8F087E0E-0B77-4CF7-BCD7-F899DB361128}.Debug|x64.ActiveCfg = Debug|x64
- {8F087E0E-0B77-4CF7-BCD7-F899DB361128}.Debug|x64.Build.0 = Debug|x64
- {8F087E0E-0B77-4CF7-BCD7-F899DB361128}.Release|Win32.ActiveCfg = Release|Win32
- {8F087E0E-0B77-4CF7-BCD7-F899DB361128}.Release|Win32.Build.0 = Release|Win32
- {8F087E0E-0B77-4CF7-BCD7-F899DB361128}.Release|x64.ActiveCfg = Release|x64
- {8F087E0E-0B77-4CF7-BCD7-F899DB361128}.Release|x64.Build.0 = Release|x64
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/3rdparty/SiftGPU/msvc/TestWin/MultiThreadSIFT.dsp b/3rdparty/SiftGPU/msvc/TestWin/MultiThreadSIFT.dsp
deleted file mode 100644
index 0070f726..00000000
--- a/3rdparty/SiftGPU/msvc/TestWin/MultiThreadSIFT.dsp
+++ /dev/null
@@ -1,102 +0,0 @@
-# Microsoft Developer Studio Project File - Name="MultiThreadSIFT" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=MultiThreadSIFT - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "MultiThreadSIFT.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "MultiThreadSIFT.mak" CFG="MultiThreadSIFT - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "MultiThreadSIFT - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "MultiThreadSIFT - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "MultiThreadSIFT - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# 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
-# 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"
-
-!ELSEIF "$(CFG)" == "MultiThreadSIFT - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# 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
-# 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
-
-!ENDIF
-
-# Begin Target
-
-# Name "MultiThreadSIFT - Win32 Release"
-# Name "MultiThreadSIFT - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=..\..\src\TestWin\MultiThreadSIFT.cpp
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/3rdparty/SiftGPU/msvc/TestWin/MultiThreadSIFT.vcxproj b/3rdparty/SiftGPU/msvc/TestWin/MultiThreadSIFT.vcxproj
deleted file mode 100644
index fe0c1b20..00000000
--- a/3rdparty/SiftGPU/msvc/TestWin/MultiThreadSIFT.vcxproj
+++ /dev/null
@@ -1,259 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {8F087E0E-0B77-4CF7-BCD7-F899DB361128}
-
-
-
- Application
- false
- MultiByte
-
-
- Application
- false
- MultiByte
-
-
- Application
- false
- MultiByte
-
-
- Application
- false
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <_ProjectFileVersion>10.0.30319.1
- ..\..\bin\
- $(ProjectName)_$(Configuration)\
- true
- ..\..\bin\
- $(ProjectName)_$(Configuration)\
- false
- ..\..\bin\
- $(ProjectName)_$(Configuration)_$(Platform)\
- true
- ..\..\bin\
- $(ProjectName)_$(Configuration)_$(Platform)\
- false
- $(ProjectName)_d
- $(ProjectName)_d
-
-
-
- .\Debug/MultiThreadSIFT.tlb
-
-
-
-
- Disabled
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- EnableFastChecks
- MultiThreadedDebugDLL
- .\Debug/MultiThreadSIFT.pch
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
- EditAndContinue
-
-
- _DEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- $(OutDir)$(TargetName)$(TargetExt)
- true
- true
- .\Debug/MultiThreadSIFT_d.pdb
- Console
- MachineX86
-
-
- true
- .\Debug/MultiThreadSIFT.bsc
-
-
- false
-
-
-
-
- .\Release/MultiThreadSIFT.tlb
-
-
-
-
- MaxSpeed
- OnlyExplicitInline
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- MultiThreadedDLL
- true
- .\Release/MultiThreadSIFT.pch
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
-
-
- NDEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- $(OutDir)$(TargetName)$(TargetExt)
- true
- .\Release/MultiThreadSIFT.pdb
- Console
- MachineX86
-
-
- true
- .\Release/MultiThreadSIFT.bsc
-
-
- false
-
-
-
-
- X64
- .\Debug/MultiThreadSIFT.tlb
-
-
-
-
- Disabled
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- EnableFastChecks
- MultiThreadedDebugDLL
- .\Debug/MultiThreadSIFT.pch
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
- ProgramDatabase
-
-
- _DEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- $(OutDir)$(TargetName)$(TargetExt)
- true
- true
- .\Debug/MultiThreadSIFT_d.pdb
- Console
- MachineX64
-
-
- true
- .\Debug/MultiThreadSIFT.bsc
-
-
- false
-
-
-
-
- X64
- .\Release/MultiThreadSIFT.tlb
-
-
-
-
- MaxSpeed
- OnlyExplicitInline
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- MultiThreadedDLL
- true
- .\Release/MultiThreadSIFT.pch
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
-
-
- NDEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- $(OutDir)$(TargetName)$(TargetExt)
- true
- .\Release/MultiThreadSIFT.pdb
- Console
- MachineX64
-
-
- true
- .\Release/MultiThreadSIFT.bsc
-
-
- false
-
-
-
-
- %(PreprocessorDefinitions)
- %(PreprocessorDefinitions)
- %(PreprocessorDefinitions)
- %(PreprocessorDefinitions)
-
-
-
-
- {9252e247-4fe2-4929-bd5d-c2fa16efd656}
- false
-
-
-
-
-
-
\ No newline at end of file
diff --git a/3rdparty/SiftGPU/msvc/TestWin/SimpleSIFT.dsp b/3rdparty/SiftGPU/msvc/TestWin/SimpleSIFT.dsp
deleted file mode 100644
index 512e9ff3..00000000
--- a/3rdparty/SiftGPU/msvc/TestWin/SimpleSIFT.dsp
+++ /dev/null
@@ -1,102 +0,0 @@
-# Microsoft Developer Studio Project File - Name="SimpleSIFT" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=SimpleSIFT - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "SimpleSIFT.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "SimpleSIFT.mak" CFG="SimpleSIFT - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "SimpleSIFT - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "SimpleSIFT - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "SimpleSIFT - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# 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
-# ADD LINK32 kernel32.lib /nologo /subsystem:console /machine:I386 /out:"../../bin/SimpleSIFT.exe"
-
-!ELSEIF "$(CFG)" == "SimpleSIFT - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# 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
-# ADD LINK32 kernel32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../../bin/SimpleSIFT_d.exe" /pdbtype:sept
-
-!ENDIF
-
-# Begin Target
-
-# Name "SimpleSIFT - Win32 Release"
-# Name "SimpleSIFT - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=..\..\src\TestWin\SimpleSIFT.cpp
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/3rdparty/SiftGPU/msvc/TestWin/SimpleSIFT.vcxproj b/3rdparty/SiftGPU/msvc/TestWin/SimpleSIFT.vcxproj
deleted file mode 100644
index 5648fa6f..00000000
--- a/3rdparty/SiftGPU/msvc/TestWin/SimpleSIFT.vcxproj
+++ /dev/null
@@ -1,259 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {D864A317-5A65-47B1-AA82-C04F99C4280F}
-
-
-
- Application
- false
- MultiByte
-
-
- Application
- false
- MultiByte
-
-
- Application
- false
- MultiByte
-
-
- Application
- false
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <_ProjectFileVersion>10.0.30319.1
- ..\..\bin\
- $(ProjectName)_$(Configuration)\
- true
- ..\..\bin\
- $(ProjectName)_$(Configuration)_$(Platform)\
- true
- ..\..\bin\
- $(ProjectName)_$(Configuration)\
- false
- ..\..\bin\
- $(ProjectName)_$(Configuration)_$(Platform)\
- false
- $(ProjectName)_d
- $(ProjectName)_d
-
-
-
- .\Debug/SimpleSIFT.tlb
-
-
-
-
- Disabled
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- EnableFastChecks
- MultiThreadedDebug
- .\Debug/SimpleSIFT.pch
- .\Debug/
- .\Debug/
- .\Debug/
- Level3
- true
- EditAndContinue
-
-
- _DEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- $(OutDir)$(TargetName)$(TargetExt)
- true
- true
- .\Debug/SimpleSIFT_d.pdb
- Console
- MachineX86
-
-
- true
- .\Debug/SimpleSIFT.bsc
-
-
- false
-
-
-
-
- X64
- .\Debug/SimpleSIFT.tlb
-
-
-
-
- Disabled
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- EnableFastChecks
- MultiThreadedDebug
- .\Debug/SimpleSIFT.pch
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
- ProgramDatabase
-
-
- _DEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- $(OutDir)$(TargetName)$(TargetExt)
- true
- true
- .\Debug/SimpleSIFT_d.pdb
- Console
- MachineX64
-
-
- true
- .\Debug/SimpleSIFT.bsc
-
-
- false
-
-
-
-
- .\Release/SimpleSIFT.tlb
-
-
-
-
- MaxSpeed
- OnlyExplicitInline
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- MultiThreaded
- true
- .\Release/SimpleSIFT.pch
- .\Release/
- .\Release/
- .\Release/
- Level3
- true
-
-
- NDEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- $(OutDir)$(TargetName)$(TargetExt)
- true
- .\Release/SimpleSIFT.pdb
- Console
- MachineX86
-
-
- true
- .\Release/SimpleSIFT.bsc
-
-
- false
-
-
-
-
- X64
- .\Release/SimpleSIFT.tlb
-
-
-
-
- MaxSpeed
- OnlyExplicitInline
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- MultiThreaded
- true
- .\Release/SimpleSIFT.pch
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
-
-
- NDEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- $(OutDir)$(TargetName)$(TargetExt)
- true
- .\Release/SimpleSIFT.pdb
- Console
- MachineX64
-
-
- true
- .\Release/SimpleSIFT.bsc
-
-
- false
-
-
-
-
- %(PreprocessorDefinitions)
- %(PreprocessorDefinitions)
- %(PreprocessorDefinitions)
- %(PreprocessorDefinitions)
-
-
-
-
- {594562d3-609a-47bc-b7e2-789c4e794cc3}
- false
-
-
-
-
-
-
\ No newline at end of file
diff --git a/3rdparty/SiftGPU/msvc/TestWin/Speed.dsp b/3rdparty/SiftGPU/msvc/TestWin/Speed.dsp
deleted file mode 100644
index 001d7f41..00000000
--- a/3rdparty/SiftGPU/msvc/TestWin/Speed.dsp
+++ /dev/null
@@ -1,102 +0,0 @@
-# Microsoft Developer Studio Project File - Name="Speed" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=Speed - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "Speed.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "Speed.mak" CFG="Speed - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "Speed - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "Speed - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "Speed - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# 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
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib siftgpu.lib /nologo /subsystem:console /machine:I386 /out:"../../bin/speed.exe" /libpath:"../../lib"
-
-!ELSEIF "$(CFG)" == "Speed - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# 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
-# ADD LINK32 kernel32.lib siftgpu_d.lib /nologo /subsystem:console /debug /machine:I386 /out:"../../bin/speed_d.exe" /pdbtype:sept /libpath:"../../lib"
-
-!ENDIF
-
-# Begin Target
-
-# Name "Speed - Win32 Release"
-# Name "Speed - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=..\..\src\TestWin\speed.cpp
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/3rdparty/SiftGPU/msvc/TestWin/Speed.vcxproj b/3rdparty/SiftGPU/msvc/TestWin/Speed.vcxproj
deleted file mode 100644
index 725c3709..00000000
--- a/3rdparty/SiftGPU/msvc/TestWin/Speed.vcxproj
+++ /dev/null
@@ -1,272 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {7FF72B39-F50E-4ED5-9A50-DCD60EF03604}
- Speed
-
-
-
- Application
- false
- MultiByte
-
-
- Application
- false
- MultiByte
-
-
- Application
- false
- MultiByte
-
-
- Application
- false
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <_ProjectFileVersion>10.0.30319.1
- ..\..\bin\
- $(ProjectName)_$(Configuration)\
- false
- ..\..\bin\
- $(ProjectName)_$(Configuration)_$(Platform)\
- false
- ..\..\bin\
- $(ProjectName)_$(Configuration)\
- true
- ..\..\bin\
- $(ProjectName)_$(Configuration)_$(Platform)\
- true
- $(ProjectName)_d
- $(ProjectName)_d
-
-
-
- .\Release/Speed.tlb
-
-
-
-
- MaxSpeed
- OnlyExplicitInline
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- MultiThreaded
- true
- .\Release/Speed.pch
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
-
-
- NDEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- siftgpu.lib;%(AdditionalDependencies)
- $(OutDir)$(TargetName)$(TargetExt)
- true
- ../../lib;%(AdditionalLibraryDirectories)
- .\Release/speed.pdb
- Console
- MachineX86
-
-
- true
- .\Release/Speed.bsc
-
-
- false
-
-
-
-
- X64
- .\Release/Speed.tlb
-
-
-
-
- MaxSpeed
- OnlyExplicitInline
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- MultiThreaded
- true
- .\Release/Speed.pch
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
-
-
- NDEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- siftgpu.lib;%(AdditionalDependencies)
- $(OutDir)$(TargetName)$(TargetExt)
- true
- ../../lib;%(AdditionalLibraryDirectories)
- .\Release/speed.pdb
- Console
- MachineX64
-
-
- true
- .\Release/Speed.bsc
-
-
- false
-
-
-
-
- .\Debug/Speed.tlb
-
-
-
-
- Disabled
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- EnableFastChecks
- MultiThreadedDebug
- .\Debug/Speed.pch
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
- EditAndContinue
-
-
- _DEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- siftgpu_d.lib;%(AdditionalDependencies)
- $(OutDir)$(TargetName)$(TargetExt)
- true
- ../../lib;%(AdditionalLibraryDirectories)
- true
- .\Debug/speed_d.pdb
- Console
- MachineX86
-
-
- true
- .\Debug/Speed.bsc
-
-
- false
-
-
-
-
- X64
- .\Debug/Speed.tlb
-
-
-
-
- Disabled
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- EnableFastChecks
- MultiThreadedDebug
- .\Debug/Speed.pch
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
- ProgramDatabase
-
-
- _DEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- siftgpu_d.lib;%(AdditionalDependencies)
- $(OutDir)$(TargetName)$(TargetExt)
- true
- ../../lib;%(AdditionalLibraryDirectories)
- true
- .\Debug/speed_d.pdb
- Console
- MachineX64
-
-
- true
- .\Debug/Speed.bsc
-
-
- false
-
-
-
-
- %(PreprocessorDefinitions)
- %(PreprocessorDefinitions)
- %(PreprocessorDefinitions)
- %(PreprocessorDefinitions)
-
-
-
-
- {594562d3-609a-47bc-b7e2-789c4e794cc3}
- false
-
-
- {9252e247-4fe2-4929-bd5d-c2fa16efd656}
- false
-
-
-
-
-
-
\ No newline at end of file
diff --git a/3rdparty/SiftGPU/msvc/TestWin/TestBase.dsp b/3rdparty/SiftGPU/msvc/TestWin/TestBase.dsp
deleted file mode 100644
index 80d004e0..00000000
--- a/3rdparty/SiftGPU/msvc/TestWin/TestBase.dsp
+++ /dev/null
@@ -1,104 +0,0 @@
-# Microsoft Developer Studio Project File - Name="TestBase" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Static Library" 0x0104
-
-CFG=TestBase - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "TestBase.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "TestBase.mak" CFG="TestBase - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "TestBase - Win32 Release" (based on "Win32 (x86) Static Library")
-!MESSAGE "TestBase - Win32 Debug" (based on "Win32 (x86) Static Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "TestBase - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /I "../../Include/" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"..\..\lib\TestBase.lib"
-
-!ELSEIF "$(CFG)" == "TestBase - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../Include/" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"..\..\lib\TestBase_d.lib"
-
-!ENDIF
-
-# Begin Target
-
-# Name "TestBase - Win32 Release"
-# Name "TestBase - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=..\..\src\TestWin\BasicTestWin.cpp
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=..\..\src\TestWin\BasicTestWin.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\src\TestWin\GLTransform.h
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/3rdparty/SiftGPU/msvc/TestWin/TestBase.vcxproj b/3rdparty/SiftGPU/msvc/TestWin/TestBase.vcxproj
deleted file mode 100644
index d8ca6db5..00000000
--- a/3rdparty/SiftGPU/msvc/TestWin/TestBase.vcxproj
+++ /dev/null
@@ -1,230 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {57496D03-A005-4650-B041-8E70DDA4A591}
-
-
-
- StaticLibrary
- false
- MultiByte
-
-
- StaticLibrary
- false
- MultiByte
-
-
- StaticLibrary
- false
- MultiByte
-
-
- StaticLibrary
- false
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <_ProjectFileVersion>10.0.30319.1
- ..\..\lib\
- $(ProjectName)_$(Configuration)\
- ..\..\lib\
- $(ProjectName)_$(Configuration)_$(Platform)\
- ..\..\lib\
- $(ProjectName)_$(Configuration)\
- ..\..\lib\
- $(ProjectName)_$(Configuration)_$(Platform)\
- $(ProjectName)_d
- $(ProjectName)_$(Platform)_d
- $(ProjectName)_$(Platform)
-
-
-
- Disabled
- ../../Include/;%(AdditionalIncludeDirectories)
- WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)
- true
- EnableFastChecks
- MultiThreadedDebug
- .\Debug/TestBase.pch
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
- EditAndContinue
-
-
- _DEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- $(OutDir)$(TargetName)$(TargetExt)
- true
-
-
- true
- .\Debug/TestBase.bsc
-
-
-
-
- X64
-
-
- Disabled
- ../../Include/;%(AdditionalIncludeDirectories)
- WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)
- true
- EnableFastChecks
- MultiThreadedDebug
- .\Debug/TestBase.pch
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
- ProgramDatabase
-
-
- _DEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- $(OutDir)$(TargetName)$(TargetExt)
- true
-
-
- true
- .\Debug/TestBase.bsc
-
-
-
-
- MaxSpeed
- OnlyExplicitInline
- ../../Include/;%(AdditionalIncludeDirectories)
- WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)
- true
- MultiThreaded
- true
- .\Release/TestBase.pch
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
-
-
- NDEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- $(OutDir)$(TargetName)$(TargetExt)
- true
-
-
- true
- .\Release/TestBase.bsc
-
-
-
-
- X64
-
-
- MaxSpeed
- OnlyExplicitInline
- ../../Include/;%(AdditionalIncludeDirectories)
- WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)
- true
- MultiThreaded
- true
- .\Release/TestBase.pch
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
-
-
- NDEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- $(OutDir)$(TargetName)$(TargetExt)
- true
-
-
- true
- .\Release/TestBase.bsc
-
-
-
-
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
-
-
-
-
-
-
- {594562d3-609a-47bc-b7e2-789c4e794cc3}
- false
-
-
- {9252e247-4fe2-4929-bd5d-c2fa16efd656}
- false
-
-
-
-
-
-
\ No newline at end of file
diff --git a/3rdparty/SiftGPU/msvc/TestWin/TestWin.dsp b/3rdparty/SiftGPU/msvc/TestWin/TestWin.dsp
deleted file mode 100644
index 0aa9998f..00000000
--- a/3rdparty/SiftGPU/msvc/TestWin/TestWin.dsp
+++ /dev/null
@@ -1,115 +0,0 @@
-# Microsoft Developer Studio Project File - Name="TestWin" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Application" 0x0101
-
-CFG=TestWin - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "TestWin.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "TestWin.mak" CFG="TestWin - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "TestWin - Win32 Release" (based on "Win32 (x86) Application")
-!MESSAGE "TestWin - Win32 Debug" (based on "Win32 (x86) Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "TestWin - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /I "../../Include/" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
-# SUBTRACT CPP /YX /Yc /Yu
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# 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
-# 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/"
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF "$(CFG)" == "TestWin - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../Include/" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
-# SUBTRACT CPP /YX /Yc /Yu
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# 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
-# 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/"
-# SUBTRACT LINK32 /pdb:none
-
-!ENDIF
-
-# Begin Target
-
-# Name "TestWin - Win32 Release"
-# Name "TestWin - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=..\..\src\TestWin\GLTestWnd.cpp
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=..\..\src\TestWin\GLTestWnd.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/3rdparty/SiftGPU/msvc/TestWin/TestWin.vcxproj b/3rdparty/SiftGPU/msvc/TestWin/TestWin.vcxproj
deleted file mode 100644
index c901972d..00000000
--- a/3rdparty/SiftGPU/msvc/TestWin/TestWin.vcxproj
+++ /dev/null
@@ -1,292 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {E1C4EAB3-1677-46F7-92BC-1A1F309B2027}
-
-
-
- Application
- false
- MultiByte
-
-
- Application
- false
- MultiByte
-
-
- Application
- false
- MultiByte
-
-
- Application
- false
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <_ProjectFileVersion>10.0.30319.1
- ..\..\bin\
- $(ProjectName)_$(Configuration)\
- false
- ..\..\bin\
- $(ProjectName)_$(Configuration)_$(Platform)\
- false
- ..\..\bin\
- $(ProjectName)_$(Configuration)\
- true
- ..\..\bin\
- $(ProjectName)_$(Configuration)_$(Platform)\
- true
- $(ProjectName)_d
- $(ProjectName)_d
-
-
-
- NDEBUG;%(PreprocessorDefinitions)
- true
- true
- Win32
- .\Release/TestWin.tlb
-
-
-
-
- MaxSpeed
- OnlyExplicitInline
- ../../Include/;%(AdditionalIncludeDirectories)
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- MultiThreaded
- true
- .\Release/TestWin.pch
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
-
-
- NDEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- opengl32.lib;glu32.lib;testbase.lib;siftgpu.lib;%(AdditionalDependencies)
- $(OutDir)$(TargetName)$(TargetExt)
- true
- ../../lib/;%(AdditionalLibraryDirectories)
- .\Release/TestWin.pdb
- Console
- MachineX86
-
-
- true
- .\Release/TestWin.bsc
-
-
- false
-
-
-
-
- NDEBUG;%(PreprocessorDefinitions)
- true
- true
- X64
- .\Release/TestWin.tlb
-
-
-
-
- MaxSpeed
- OnlyExplicitInline
- ../../Include/;%(AdditionalIncludeDirectories)
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- MultiThreaded
- true
- .\Release/TestWin.pch
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
-
-
- NDEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- opengl32.lib;glu32.lib;testbase_x64.lib;siftgpu.lib;%(AdditionalDependencies)
- $(OutDir)$(TargetName)$(TargetExt)
- true
- ../../lib/;%(AdditionalLibraryDirectories)
- .\Release/TestWin.pdb
- Console
- MachineX64
-
-
- true
- .\Release/TestWin.bsc
-
-
- false
-
-
-
-
- _DEBUG;%(PreprocessorDefinitions)
- true
- true
- Win32
- .\Debug/TestWin.tlb
-
-
-
-
- Disabled
- ../../Include/;%(AdditionalIncludeDirectories)
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- EnableFastChecks
- MultiThreadedDebug
- .\Debug/TestWin.pch
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
- EditAndContinue
-
-
- _DEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- opengl32.lib;glu32.lib;testbase_d.lib;siftgpu_d.lib;%(AdditionalDependencies)
- $(OutDir)$(TargetName)$(TargetExt)
- true
- ../../lib/;%(AdditionalLibraryDirectories)
- true
- .\Debug/TestWin_d.pdb
- Console
- MachineX86
-
-
- true
- .\Debug/TestWin.bsc
-
-
- false
-
-
-
-
- _DEBUG;%(PreprocessorDefinitions)
- true
- true
- X64
- .\Debug/TestWin.tlb
-
-
-
-
- Disabled
- ../../Include/;%(AdditionalIncludeDirectories)
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- EnableFastChecks
- MultiThreadedDebug
- .\Debug/TestWin.pch
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
- ProgramDatabase
-
-
- _DEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- opengl32.lib;glu32.lib;testbase_x64_d.lib;siftgpu_d.lib;%(AdditionalDependencies)
- $(OutDir)$(TargetName)$(TargetExt)
- true
- ../../lib/;%(AdditionalLibraryDirectories)
- true
- .\Debug/TestWin_d.pdb
- Console
- MachineX64
-
-
- true
- .\Debug/TestWin.bsc
-
-
- false
-
-
-
-
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
-
-
-
-
-
- {57496d03-a005-4650-b041-8e70dda4a591}
- false
-
-
-
-
-
-
\ No newline at end of file
diff --git a/3rdparty/SiftGPU/msvc/TestWin/TestWinGlut.dsp b/3rdparty/SiftGPU/msvc/TestWin/TestWinGlut.dsp
deleted file mode 100644
index 0d069123..00000000
--- a/3rdparty/SiftGPU/msvc/TestWin/TestWinGlut.dsp
+++ /dev/null
@@ -1,106 +0,0 @@
-# Microsoft Developer Studio Project File - Name="TestWinGlut" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=TestWinGlut - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "TestWinGlut.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "TestWinGlut.mak" CFG="TestWinGlut - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "TestWinGlut - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "TestWinGlut - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "TestWinGlut - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /I "../../Include/" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# 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
-# ADD LINK32 kernel32.lib user32.lib siftgpu.lib testbase.lib /nologo /subsystem:console /machine:I386 /out:"../../bin/TestWinGlut.exe" /libpath:"../../lib/"
-
-!ELSEIF "$(CFG)" == "TestWinGlut - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../Include/" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# 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
-# 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/"
-
-!ENDIF
-
-# Begin Target
-
-# Name "TestWinGlut - Win32 Release"
-# Name "TestWinGlut - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=..\..\src\TestWin\TestWinGlut.cpp
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=..\..\src\TestWin\TestWinGlut.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/3rdparty/SiftGPU/msvc/TestWin/TestWinGlut.vcxproj b/3rdparty/SiftGPU/msvc/TestWin/TestWinGlut.vcxproj
deleted file mode 100644
index 937f2cc0..00000000
--- a/3rdparty/SiftGPU/msvc/TestWin/TestWinGlut.vcxproj
+++ /dev/null
@@ -1,280 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {B33F9B4E-BF99-442B-BDC5-3DAA4BCCA395}
-
-
-
- Application
- false
- MultiByte
-
-
- Application
- false
- MultiByte
-
-
- Application
- false
- MultiByte
-
-
- Application
- false
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <_ProjectFileVersion>10.0.30319.1
- ..\..\bin\
- $(ProjectName)_$(Configuration)\
- true
- ..\..\bin\
- $(ProjectName)_$(Configuration)_$(Platform)\
- true
- ..\..\bin\
- $(ProjectName)_$(Configuration)\
- false
- ..\..\bin\
- $(ProjectName)_$(Configuration)_$(Platform)\
- false
- $(ProjectName)_d
- $(ProjectName)_d
-
-
-
- .\Debug/TestWinGlut.tlb
-
-
-
-
- Disabled
- ../../Include/;%(AdditionalIncludeDirectories)
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- EnableFastChecks
- MultiThreadedDebug
- .\Debug/TestWinGlut.pch
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
- EditAndContinue
-
-
- _DEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- siftgpu_d.lib;testbase_d.lib;%(AdditionalDependencies)
- $(OutDir)$(TargetName)$(TargetExt)
- true
- ../../lib/;%(AdditionalLibraryDirectories)
- true
- .\Debug/TestWinGlut_d.pdb
- Console
- MachineX86
-
-
- true
- .\Debug/TestWinGlut.bsc
-
-
- false
-
-
-
-
- X64
- .\Debug/TestWinGlut.tlb
-
-
-
-
- Disabled
- ../../Include/;%(AdditionalIncludeDirectories)
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- EnableFastChecks
- MultiThreadedDebug
- .\Debug/TestWinGlut.pch
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
- ProgramDatabase
-
-
- _DEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- siftgpu_d.lib;testbase_x64_d.lib;glut64.lib;%(AdditionalDependencies)
- $(OutDir)$(TargetName)$(TargetExt)
- true
- ../../lib/;%(AdditionalLibraryDirectories)
- glut32.lib;%(IgnoreSpecificDefaultLibraries)
- true
- .\Debug/TestWinGlut_d.pdb
- Console
- MachineX64
-
-
- true
- .\Debug/TestWinGlut.bsc
-
-
- false
-
-
-
-
- .\Release/TestWinGlut.tlb
-
-
-
-
- MaxSpeed
- OnlyExplicitInline
- ../../Include/;%(AdditionalIncludeDirectories)
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- MultiThreaded
- true
- .\Release/TestWinGlut.pch
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
-
-
- NDEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- siftgpu.lib;testbase.lib;%(AdditionalDependencies)
- $(OutDir)$(TargetName)$(TargetExt)
- true
- ../../lib/;%(AdditionalLibraryDirectories)
- .\Release/TestWinGlut.pdb
- Console
- MachineX86
-
-
- true
- .\Release/TestWinGlut.bsc
-
-
- false
-
-
-
-
- X64
- .\Release/TestWinGlut.tlb
-
-
-
-
- MaxSpeed
- OnlyExplicitInline
- ../../Include/;%(AdditionalIncludeDirectories)
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- MultiThreaded
- true
- .\Release/TestWinGlut.pch
- $(IntDir)
- $(IntDir)
- $(IntDir)
- Level3
- true
-
-
- NDEBUG;%(PreprocessorDefinitions)
- 0x0409
-
-
- siftgpu.lib;testbase_x64.lib;glut64.lib;%(AdditionalDependencies)
- $(OutDir)$(TargetName)$(TargetExt)
- true
- ../../lib/;%(AdditionalLibraryDirectories)
- glut32.lib;%(IgnoreSpecificDefaultLibraries)
- .\Release/TestWinGlut.pdb
- Console
- MachineX64
-
-
- true
- .\Release/TestWinGlut.bsc
-
-
- false
-
-
-
-
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
-
-
-
-
-
- {57496d03-a005-4650-b041-8e70dda4a591}
- false
-
-
-
-
-
-
\ No newline at end of file
diff --git a/3rdparty/SiftGPU/speed_and_accuracy.txt b/3rdparty/SiftGPU/speed_and_accuracy.txt
deleted file mode 100644
index ca68166c..00000000
--- a/3rdparty/SiftGPU/speed_and_accuracy.txt
+++ /dev/null
@@ -1,87 +0,0 @@
-------------------------------------------------------------------------
-SPEED
-------------------------------------------------------------------------
-1. The first several rounds of SiftGPU might be slow, don't worry. If it
-is always slow, the reason might be either the graphic card is old or the
-graphic memory is small.
-
-2. Texture reallocation happens when a new image does not fit in the already
-allocated storage. To get less reallocations, you can pre-allocate storage
-to fit the largest image size, or just use images with the same size.
-
-3. Loading some compressed images (.e.g jpg) may take a lot of time on
-decompressing. Using binary pgm files or directly specifying data in memory
-can achive better performance. Writing ASCII SIFT files is also slow.
-
-4. The packd version saves GPU memory but also run faster than the unpacked,
-which is default now.
-
-5. SiftGPU might be faster with older grpahic card drivers than with newer ones.
-
-6. The descriptor normalization in the OpenGL-based implementation is running
-on CPU. New versions are now using SSE, which improves the speed for this part
-a lot.
-
-7. The orientation computation in unpacked implementation is occasionally slow
-under single orientation mode (-m 1) or packed orientation mode (-m2p). By
-default, siftgpu uses 2 orientations (-m 2), which should be fine. This issue
-is still unresolved.
-
-8. The thread block settings in the CUDA-based SiftGPU are currently tuned
-for my GPU nVidia GTX 8800, which may not be optimized for other GPUs.
-
-----------------------------------------------------------------------------
-ACCURACY
-----------------------------------------------------------------------------
-1. The latest version of SiftGPU now has comparable accuracy with CPU
-implementatins. Evaluation on box.pgm of Lowe's package now gives around 600
-matches, which is close to SIFT++.
-
-2. In orientation computation, SiftGPU uses a factor 2.0 * sigma as the sample
-window size, which is smaller than the typical value 3.0. Changing it from 2.0
-to 3.0 reduces the speed of this step by %40, but gives only a very small
-improvements in matching. You can change it by specifying parameter "-w 3".
-
-3. In keypoint localization, SiftGPU refines the location only once by default,
-and SiftGPU does not move the level of keypoints in the refinement.
-
-4. The feature locations are having a (0.5,0.5) offset compared with CPU
-implementations by default. (0, 0) in texture is at the top-left coorner
-(instead of center) of the top-left pixel. You can use the center as (0, 0)
-by specifying "-loweo"
-
-5. By default, SiftGPU does not do Upsampling(-fo -1), To match it with Lowe's
-implementation you need to use "-fo -1 -loweo".
-
-6. SiftGPU may get slightly different results on different GPUs due to different
-floating point precision. SiftGPU is tested on limited types of graphic cards/OS,
-working on your graphic card is not guaranteed.
-
-IF it returns different number of features at different run on the same card,
-then something is going wrong, and probably some special tricks need to be used.
-Please email me if that happens.
-
-7. When getting wrong matches, please look at the saved SIFT file to make sure
-there are no weired descriptors( for example, all of the numbers of a descriptor
-are 45, or any number in a descriptor is larger than 255)
-
-------------------------------------------------------------------------------
-KWOWN ISSUES.
-------------------------------------------------------------------------------
-1. SiftGPU may have problem with dual monitor.
-2. Slow on 7950. Changing GlobalParam::_iTexFormat to GL_RGBA16F_ARB can make
- it work. Unknown reason.
-3. Experiments on 8600 show problems. It works fine for the first image, but
- gets wrong keypoints after.
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/3rdparty/SiftGPU/src/CMakeLists.txt b/3rdparty/SiftGPU/src/CMakeLists.txt
deleted file mode 100644
index d72205fe..00000000
--- a/3rdparty/SiftGPU/src/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-ADD_SUBDIRECTORY(SiftGPU)
diff --git a/3rdparty/SiftGPU/src/ServerSiftGPU/ServerSiftGPU.cpp b/3rdparty/SiftGPU/src/ServerSiftGPU/ServerSiftGPU.cpp
deleted file mode 100644
index 894aa75f..00000000
--- a/3rdparty/SiftGPU/src/ServerSiftGPU/ServerSiftGPU.cpp
+++ /dev/null
@@ -1,902 +0,0 @@
-////////////////////////////////////////////////////////////////////////////
-// File: ServerSiftGPU.cpp
-// Author: Changchang Wu
-// Description : implementation for the ServerSiftGPU class.
-//
-// Copyright (c) 2007 University of North Carolina at Chapel Hill
-// All Rights Reserved
-//
-// Permission to use, copy, modify and distribute this software and its
-// documentation for educational, research and non-profit purposes, without
-// fee, and without a written agreement is hereby granted, provided that the
-// above copyright notice and the following paragraph appear in all copies.
-//
-// The University of North Carolina at Chapel Hill make no representations
-// about the suitability of this software for any purpose. It is provided
-// 'as is' without express or implied warranty.
-//
-// Please send BUG REPORTS to ccwu@cs.unc.edu
-//
-////////////////////////////////////////////////////////////////////////////
-
-#include
-#include
-
-using std::cout;
-using std::vector;
-
-
-#if defined(SERVER_SIFTGPU_ENABLED)
-
-#include "GL/glew.h"
-
-#ifdef _WIN32
- #include
- #include
- #define socklen_t int
- #pragma comment(lib, "ws2_32.lib")
-#else
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- //conversion from Win32
- typedef int SOCKET;
- #define INVALID_SOCKET -1
- #define closesocket close
-#endif
-
-#include "../SiftGPU/SiftGPU.h"
-#include "ServerSiftGPU.h"
-
-
-
-
-
-
-class SocketUtil
-{
-public:
- static int readline(SOCKET s, char *buf, int nread)
- {
- char c;
- int num,n=0;
- for(n=1; n 0 && count_read_sum < count);
- return count_read_sum == count;
- }
- static int init()
- {
-
-#ifdef _WIN32
- WSADATA WsaData;
- if(WSAStartup(0x0202, &WsaData))
- {
- std::cout << "server: can't startup socket\n";
- return 0;
- }else
- {
- return 1;
- }
-#else
- return 1;
-#endif
-
- }
-};
-
-
-ServerSiftGPU::ServerSiftGPU(int port, char* remote_server)
-{
- _port = port;
- _socketfd = INVALID_SOCKET;
- _connected = 0;
- strcpy(_server_name, remote_server? remote_server : "\0");
-}
-
-int ServerSiftGPU::InitSocket()
-{
- return SocketUtil::init();
-}
-
-
-int ServerSiftGPU::StartServerProcess(int argc, char** argv)
-{
- vector args(argc + 4); char ports[16];
-
- args[0] = "server_siftgpu";
- args[1] = "-server";
- sprintf(ports, "%d", _port);
- args[2] = ports;
- ///////////////////////////////////////////////
- for(int i = 0; i < argc; ++i) args[i + 3] = argv[i];
- args[argc + 3] = 0;
- ///////////////////////////////////////////////////////
- //make a new process
-#ifdef _WIN32
- int result = (int) _spawnv(_P_NOWAIT, "server_siftgpu.exe", &args[0]);
- if(result == -1) std::cerr<< "spawn returns -1 with error = " << errno << "\n";
- return result != -1;
-#else
- #ifdef __APPLE__
- #define LIBPATH_NAME "DYLD_LIBRARY_PATH"
- #else
- #define LIBPATH_NAME "LD_LIBRARY_PATH"
- #endif
- int result; pid_t pid;
- char* oldpath = getenv(LIBPATH_NAME);
- if(oldpath == NULL)
- {
- result = posix_spawn(&pid, "server_siftgpu", NULL, NULL, &args[0], NULL);
- }else
- {
- char newpath[1024]= LIBPATH_NAME "=";
- strcat(newpath, oldpath);
- char* envp [] = {newpath, 0};
- result = posix_spawn(&pid, "server_siftgpu", NULL, NULL, &args[0], envp);
- }
- if(result) std::cerr << "failed to use poxis_spawn to create the server.\n";
- return result == 0;
-#endif
-}
-
-int ServerSiftGPU::ConnectServer(const char* server_name, int port)
-{
- struct hostent* hh;
-
- if((hh = gethostbyname(server_name)) == NULL)return 0;
-
- ////////////////////////////////////////
- struct sockaddr_in servaddr;
- memset(&servaddr, 0, sizeof(servaddr));
- servaddr.sin_family = AF_INET;
- servaddr.sin_port = htons(port);
- servaddr.sin_addr.s_addr=((struct in_addr*)(hh->h_addr))->s_addr;
-
- ((SOCKET&)_socketfd) = socket(AF_INET, SOCK_STREAM, 0);
- if(_socketfd==INVALID_SOCKET) return 0;
-
- //if can not connect to server, start again
- if(connect(_socketfd, (struct sockaddr *)&servaddr, sizeof(servaddr)))
- {
- closesocket(_socketfd);
- _socketfd = INVALID_SOCKET;
- return 0;
- }else
- {
- std::cout<<"Connected to server " << server_name << "\n";
- return 1;
- }
-}
-
-void ServerSiftGPU::Disconnect()
-{
- SocketUtil::writeint(_socketfd, _server_name[0]? COMMAND_DISCONNECT : COMMAND_EXIT);
- closesocket(_socketfd);
- _socketfd = INVALID_SOCKET;
- _connected = 0;
-}
-
-ServerSiftGPU::~ServerSiftGPU()
-{
- if(_connected) Disconnect();
-}
-
-
-inline void ServerSiftGPU::ServerLoop(int port, int argc, char** argv)
-{
- SOCKET sockfd, newsockfd;
- struct sockaddr_in serv_addr, cli_addr;
- socklen_t addr_len = sizeof(sockaddr_in);
- //////////////////////////////////////////////////
- memset((char*)&serv_addr, 0, sizeof(serv_addr));
- serv_addr.sin_family = AF_INET;
- serv_addr.sin_port = htons(port);
- serv_addr.sin_addr.s_addr = INADDR_ANY;
- /////////////////////////////////////////////
-
- if(ServerSiftGPU::InitSocket() == 0)
- {
- return;
- }
- //////////////////////////////////////////////////////////////
- sockfd=socket(AF_INET,SOCK_STREAM,0);
- if(sockfd==INVALID_SOCKET)
- {
- std::cout << "server: can't open stream socket\n";
- return;
- }else if(bind(sockfd,(struct sockaddr*)&serv_addr, sizeof(serv_addr)))
- {
- std::cout << "server: can't bind to port " << port <<"\n";
- return;
- }else if(listen(sockfd, 1))
- {
- std::cout << "server: failed to listen\n";
- return;
- }else
- {
- std::cout << "server: listent to port "<< port << "\n";
- }
-
- newsockfd = accept(sockfd, (struct sockaddr*) &cli_addr, &addr_len);
- if(newsockfd == INVALID_SOCKET)
- {
- std::cout << "error: accept failed\n";
- closesocket(sockfd);
- return;
- }
- ////////////////////////////////////////////////////////////////
- char buf[1024];
- int command, result;
- int sift_feature_count = 0;;
- vector keys;
- vector descriptors;
- vector databuf;
-
- /////////////////////////////////////////////////////////////////
- SiftGPU siftgpu;
- SiftMatchGPU matcher;
-
- if(argc > 0) siftgpu.ParseParam(argc, argv);
-
- /////////////////////
- siftgpu.SetVerbose(0);
- /////////////////////////////////////////////////////////////////
-
- do
- {
- while(SocketUtil::readint(newsockfd, &command) && command != COMMAND_DISCONNECT)
- {
- switch(command)
- {
- case COMMAND_INITIALIZE:
- {
- result = (siftgpu.CreateContextGL() == SiftGPU::SIFTGPU_FULL_SUPPORTED);
- SocketUtil::writeint(newsockfd, result);
- if(result) break;
- }
- case COMMAND_EXIT:
- closesocket(newsockfd);
- closesocket(sockfd);
- return;
- case COMMAND_ALLOCATE_PYRAMID:
- {
- int size[2];
- SocketUtil::readint(newsockfd, size, 2);
- if(size[0] > 0 && size[1] > 0) siftgpu.AllocatePyramid(size[0], size[1]);
- break;
- }
- case COMMAND_GET_KEY_VECTOR:
- {
- int size = sift_feature_count * sizeof(SiftGPU::SiftKeypoint);
- SocketUtil::writedata(newsockfd, &keys[0], size);
- break;
- }
- case COMMAND_GET_DES_VECTOR:
- {
- int size = sift_feature_count * sizeof(float) * 128;
- SocketUtil::writedata(newsockfd, &descriptors[0], size);
- break;
- }
- case COMMAND_RUNSIFT:
- {
- result = siftgpu.RunSIFT();
- if((sift_feature_count = siftgpu.GetFeatureNum()) > 0)
- {
- keys.resize(sift_feature_count);
- descriptors.resize(sift_feature_count * 128);
- siftgpu.GetFeatureVector(&keys[0], &descriptors[0]);
- std::cout << "RunSIFT: [-] [" << sift_feature_count << "]\n";
- }
- SocketUtil::writeint(newsockfd, result);
- break;
- }
- case COMMAND_RUNSIFT_FILE:
- {
- SocketUtil::readline(newsockfd, buf, 1024);
-
- result = siftgpu.RunSIFT(buf);
- if((sift_feature_count = siftgpu.GetFeatureNum()) > 0)
- {
- keys.resize(sift_feature_count);
- descriptors.resize(sift_feature_count * 128);
- siftgpu.GetFeatureVector(&keys[0], &descriptors[0]);
- }
- std::cout << "RunSIFT: "<< buf <<" " << sift_feature_count << "\n" ;
- SocketUtil::writeint(newsockfd, result);
- break;
- }
- case COMMAND_SET_KEYPOINT:
- {
- int keys_have_orientation;
- SocketUtil::readint(newsockfd, &sift_feature_count);
- SocketUtil::readint(newsockfd, &keys_have_orientation);
- if(sift_feature_count > 0)
- {
- keys.resize(sift_feature_count);
- descriptors.resize(sift_feature_count * 128);
- SocketUtil::readdata(newsockfd, &keys[0], int(keys.size() * sizeof(SiftGPU::SiftKeypoint)));
- siftgpu.SetKeypointList(sift_feature_count, &keys[0], keys_have_orientation);
- }
- break;
- }
- case COMMAND_RUNSIFT_KEY:
- {
- int keys_have_orientation;
- SocketUtil::readint(newsockfd, &sift_feature_count);
- SocketUtil::readint(newsockfd, &keys_have_orientation);
- if(sift_feature_count > 0)
- {
- std::cout << "RunSIFT: "<< sift_feature_count << " KEYPOINTS\n" ;
- int key_data_size = sift_feature_count * sizeof(SiftGPU::SiftKeypoint);
- keys.resize(sift_feature_count);
- descriptors.resize(sift_feature_count * 128);
- SocketUtil::readdata(newsockfd, &keys[0], key_data_size);
- result = siftgpu.RunSIFT(sift_feature_count, &keys[0], keys_have_orientation);
- siftgpu.GetFeatureVector(NULL, &descriptors[0]);
- }else
- {
- result = 0;
- }
- SocketUtil::writeint(newsockfd, result);
- break;
- }
- case COMMAND_RUNSIFT_DATA:
- {
- int data_des[4], size = 0;
- SocketUtil::readint(newsockfd, data_des, 4);
- SocketUtil::readint(newsockfd, &size, 1);
- std::cout << "RunSIFT: [" << data_des[0] << "x" << data_des[1] << "]";
-
- databuf.resize(size);
- void* data_ptr = &databuf[0];
- SocketUtil::readdata(newsockfd, data_ptr, size);
-
-
- result = siftgpu.RunSIFT(data_des[0], data_des[1], data_ptr, data_des[2], data_des[3]);
- if((sift_feature_count = siftgpu.GetFeatureNum()) > 0)
- {
- keys.resize(sift_feature_count);
- descriptors.resize(sift_feature_count * 128);
- siftgpu.GetFeatureVector(&keys[0], &descriptors[0]);
- }
- std::cout << "[" << sift_feature_count << "]\n";
- SocketUtil::writeint(newsockfd, result);
- break;
- }
- case COMMAND_SAVE_SIFT:
- {
- SocketUtil::readline(newsockfd, buf, 1024);
- siftgpu.SaveSIFT(buf);
- break;
- }
- case COMMAND_SET_MAX_DIMENSION:
- {
- int maxd;
- if(SocketUtil::readint(newsockfd, &maxd) && maxd > 0) siftgpu.SetMaxDimension(maxd);
- break;
- }
- case COMMAND_SET_TIGHTPYRAMID:
- {
- int tight;
- if(SocketUtil::readint(newsockfd, &tight)) siftgpu.SetTightPyramid(tight);
- break;
- }
- case COMMAND_GET_FEATURE_COUNT:
- {
- SocketUtil::writeint(newsockfd, sift_feature_count);
- break;
- }
- case COMMAND_PARSE_PARAM:
- {
- SocketUtil::readline(newsockfd, buf, 1024);
- std::cout << "ParseParam [" << buf << "]\n";
- vector params;
- char* p = buf;
- while(*p)
- {
- while(*p == ' ' || *p == '\t')*p++ = 0;
- params.push_back(p);
- while(*p && *p != ' ' && *p != '\t') p++;
- }
- siftgpu.ParseParam(params.size(), ¶ms[0]);
- break;
- }
- case COMMAND_MATCH_INITIALIZE:
- {
- result = matcher.CreateContextGL();
- SocketUtil::writeint(newsockfd, result);
- break;
- }
- case COMMAND_MATCH_SET_LANGUAGE:
- {
- int language;
- if(SocketUtil::readint(newsockfd, &language)) matcher.SetLanguage(language);
- break;
- }
- case COMMAND_MATCH_SET_DES_FLOAT:
- {
- int command[3] = {0, 0, 0};
- if(SocketUtil::readdata(newsockfd, command, sizeof(command)))
- {
- databuf.resize(sizeof(float) * 128 * command[1]);
- if(SocketUtil::readdata(newsockfd, &databuf[0], databuf.size()))
- {
- matcher.SetDescriptors(command[0], command[1], (float*) (&databuf[0]), command[2]);
- }
- }
- break;
- }
- case COMMAND_MATCH_SET_DES_BYTE:
- {
- int command[3] = {0, 0, 0};
- if(SocketUtil::readdata(newsockfd, command, sizeof(command)))
- {
- databuf.resize(sizeof(unsigned char) * 128 * command[1]);
- if(SocketUtil::readdata(newsockfd, &databuf[0], databuf.size()))
- {
- matcher.SetDescriptors(command[0], command[1], (unsigned char*) (&databuf[0]), command[2]);
- }
- }
- break;
- }
- case COMMAND_MATCH_GET_MATCH:
- {
- int command[2]; float fcommand[2];
- result = 0;
- if( SocketUtil::readdata(newsockfd, command, sizeof(command)) &&
- SocketUtil::readdata(newsockfd, fcommand, sizeof(fcommand)))
- {
- int max_match = command[0], mbm = command[1];
- float distmax = fcommand[0], ratiomax = fcommand[1];
- databuf.resize(max_match * 2 * sizeof(int));
- result = matcher.GetSiftMatch(max_match, ( int(*)[2]) (&databuf[0]), distmax, ratiomax, mbm);
-
- }
- SocketUtil::writeint(newsockfd, result);
- if(result > 0) SocketUtil::writedata(newsockfd, &databuf[0], sizeof(int) * 2 * result);
- std::cout << "SiftMatch: " << result << "\n";
- break;
- }
- case COMMAND_MATCH_SET_MAXSIFT:
- {
- int max_sift;
- if(SocketUtil::readint(newsockfd, &max_sift)) matcher.SetMaxSift(max_sift);
- break;
- }
- break;
- default:
- std::cout << "unrecognized command: " << command << "\n";
- break;
- }
- }
-
- //client disconneted
- closesocket(newsockfd);
- //wait for the next client.
- std::cout << "wait for new client...";
- newsockfd = accept(sockfd, (struct sockaddr*) &cli_addr, &addr_len);
- if(newsockfd == INVALID_SOCKET)
- {
- std::cout << "error: accept failed";
- closesocket(sockfd);
- return;
- }else
- {
- std::cout << "connected\n\n";
- }
- }while(1);
-}
-
-void ServerSiftGPU::SetParamSiftGPU(int argc, char** argv)
-{
- if(!_connected || argc <= 0) return;
-
- char buf[1025], *p = buf, cret = '\n';
- for(int i = 0; i < argc; ++i)
- {
- if(argv[i])
- {
- strcpy(p, argv[i]);
- p += strlen(argv[i]);
- }
- *p++= ((i +1 < argc)? ' ' : '\0');
- }
- SocketUtil::writeint(_socketfd, COMMAND_PARSE_PARAM);
- SocketUtil::writedata(_socketfd, buf, (p - buf));
- SocketUtil::writedata(_socketfd, &cret, 1);
-
-}
-
-int ServerSiftGPU:: InitializeConnection(int argc, char** argv)
-{
- char server_name[1024];
- if(!InitSocket()) return 0 ;
- if(_server_name[0] == 0)
- {
- if(StartServerProcess(argc, argv) == 0)
- {
- std::cout<<"Unable to start local siftgpu server\n";
- return 0 ;
- }
- strcpy(server_name, "127.0.0.1");
- }else
- {
- strcpy(server_name, _server_name);
- }
-
- ///////////////////////////////////////////////
- if(ConnectServer(server_name, _port) == 0)
- {
- //wait for one second
-#ifdef _WIN32
- Sleep(1000);
-#else
- sleep(1);
-#endif
- if(ConnectServer(server_name, _port) == 0)
- {
- std::cout<<"Unable to connect siftgpu sever\n";
- return 0 ;
- }
- }
- return 1;
-}
-
-void ServerSiftGPU::ParseParam(int argc, char **argv)
-{
- if(_connected == 1)
- {
- SetParamSiftGPU(argc, argv);
- }else
- {
- _connected = InitializeConnection(argc, argv);
- if(_server_name[0] && argc > 0) SetParamSiftGPU(argc, argv);
- }
-}
-
-int ServerSiftGPU::VerifyContextGL()
-{
- ////////////////////////////////////////////////////
- if(!_connected) return 0;
-
- int result = 0;
-
- if(SocketUtil::writeint(_socketfd, COMMAND_INITIALIZE) &&
- SocketUtil::readint(_socketfd, &result) && result)
- {
- return SiftGPU::SIFTGPU_FULL_SUPPORTED;
- }else
- {
- std::cout<<"SifGPU failed to initialize\n";
- Disconnect();
- return 0;
- }
-}
-
-int ServerSiftGPU::GetFeatureNum()
-{
- if(!_connected) return 0;
- int result = 0;
- SocketUtil::writeint(_socketfd, COMMAND_GET_FEATURE_COUNT);
- SocketUtil::readint(_socketfd, &result);
- return result;
-}
-
-int ServerSiftGPU::AllocatePyramid(int width, int height)
-{
- if(!_connected) return 0;
- int command[3] = {COMMAND_ALLOCATE_PYRAMID, width, height};
- return SocketUtil::writedata(_socketfd, command, sizeof(int) * 3);
-}
-
-////////////////////////////////////////////////////////////
-void ServerSiftGPU::SaveSIFT(const char * szFileName)
-{
- if(!_connected) return;
-
- char cret = '\n';
- SocketUtil::writeint(_socketfd, COMMAND_SAVE_SIFT);
- SocketUtil::writedata(_socketfd, szFileName, (int)strlen(szFileName));
- SocketUtil::writedata(_socketfd, &cret, 1);
-
-}
-
-void ServerSiftGPU::GetFeatureVector(SiftGPU::SiftKeypoint * keys, float * descriptors)
-{
- if(!_connected) return;
-
- int num = GetFeatureNum(), result = 1;
- if(keys && num > 0)
- {
- result&= SocketUtil::writeint(_socketfd, COMMAND_GET_KEY_VECTOR);
- result &= SocketUtil::readdata(_socketfd, keys, num * sizeof(SiftGPU::SiftKeypoint));
- }
- if(descriptors && num > 0)
- {
- result&= SocketUtil::writeint(_socketfd, COMMAND_GET_DES_VECTOR);
- result&= SocketUtil::readdata(_socketfd, descriptors, num * 128 * sizeof(float));
- }
-}
-
-void ServerSiftGPU::SetKeypointList(int num, const SiftGPU::SiftKeypoint * keys, int keys_have_orientation)
-{
- if(!_connected) return;
-
- SocketUtil::writeint(_socketfd, COMMAND_SET_KEYPOINT);
- SocketUtil::writeint(_socketfd, num);
- SocketUtil::writeint(_socketfd, keys_have_orientation);
- SocketUtil::writedata(_socketfd, keys, sizeof(SiftGPU::SiftKeypoint) * num);
-
-}
-
-void ServerSiftGPU::SetTightPyramid(int tight)
-{
- if(!_connected) return ;
- SocketUtil::writeint(_socketfd, COMMAND_SET_TIGHTPYRAMID);
- SocketUtil::writeint(_socketfd, tight);
-
-}
-
-void ServerSiftGPU::SetMaxDimension(int sz)
-{
- if(!_connected) return ;
- SocketUtil::writeint(_socketfd, COMMAND_SET_MAX_DIMENSION);
- SocketUtil::writeint(_socketfd, sz);
-
-}
-
-int ServerSiftGPU::GetPixelSizeGL(unsigned int gl_format, unsigned int gl_type)
-{
- int num_channel_byte = 0;
- int num_channels = 0;
- switch(gl_type)
- {
- case GL_BITMAP:
- case GL_UNSIGNED_BYTE:
- case GL_BYTE:
- num_channel_byte = 1;
- break;
- case GL_UNSIGNED_SHORT:
- case GL_SHORT:
- num_channel_byte = 2;
- break;
- case GL_UNSIGNED_INT:
- case GL_INT:
- case GL_FLOAT:
- num_channel_byte = 4;
- break;
- default:
- num_channel_byte = 0;
- break;
- }
-
- switch(gl_format)
- {
- case GL_RED:
- case GL_GREEN:
- case GL_BLUE:
- case GL_ALPHA:
- case GL_LUMINANCE:
- num_channels = 1;
- break;
- case GL_RGB:
- case GL_BGR_EXT:
- num_channels = 3;
- break;
- case GL_RGBA:
- case GL_BGRA_EXT:
-#ifdef GL_ARGB_I3D
- case GL_ARGB_I3D:
-#endif
- num_channels = 4;
- break;
- case GL_LUMINANCE_ALPHA:
-#ifdef GL_422_EXT
- case GL_422_EXT:
- case GL_422_REV_EXT:
- case GL_422_AVERAGE_EXT:
- case GL_422_REV_AVERAGE_EXT:
-#endif
- num_channels = 2;
- default:
- num_channels = 0;
- break;
- }
- return num_channels * num_channel_byte;
-}
-
-int ServerSiftGPU::RunSIFT(int width, int height, const void * data, unsigned int gl_format, unsigned int gl_type)
-{
- if(width <=0 || height <= 0 || data == NULL || !_connected) return 0;
- int num_bytes = GetPixelSizeGL(gl_format , gl_type) * width * height;
- if(num_bytes == 0) return 0;
- SocketUtil::writeint(_socketfd, COMMAND_RUNSIFT_DATA);
- unsigned int data_des[5] = {width, height, gl_format, gl_type, num_bytes};
- SocketUtil::writedata(_socketfd, data_des, 5 * sizeof(unsigned int));
- SocketUtil::writedata(_socketfd, data, num_bytes);
- int result = 0;
- return SocketUtil::readint(_socketfd, &result) && result;
-}
-
-int ServerSiftGPU::RunSIFT(int num, const SiftGPU::SiftKeypoint * keys, int keys_have_orientation)
-{
- if(num <= 0 || keys == NULL) return 0;
- if(!_connected) return 0;
- SocketUtil::writeint(_socketfd, COMMAND_RUNSIFT_KEY);
- SocketUtil::writeint(_socketfd, num);
- SocketUtil::writeint(_socketfd, keys_have_orientation);
- SocketUtil::writedata(_socketfd, keys, sizeof(SiftGPU::SiftKeypoint) * num);
- int result = 0;
- return SocketUtil::readint(_socketfd, &result) && result;
-}
-
-int ServerSiftGPU::RunSIFT()
-{
- if(!_connected) return 0;
- int result = 0;
- SocketUtil::writeint(_socketfd, COMMAND_RUNSIFT);
- return SocketUtil::readint(_socketfd, &result) && result;
-}
-
-int ServerSiftGPU::RunSIFT(const char *imgpath)
-{
- if(!_connected) return 0;
- int result = 0; char cret = '\n';
- SocketUtil::writeint(_socketfd, COMMAND_RUNSIFT_FILE);
- SocketUtil::writedata(_socketfd, imgpath, (int)strlen(imgpath));
- SocketUtil::writedata(_socketfd, &cret, 1);
- return SocketUtil::readint(_socketfd, &result) && result;
-}
-
-
-////////////////////////////////////////////////
-int ServerSiftGPU::_VerifyContextGL()
-{
- if(!_connected) return 0;
- int result;
- if( SocketUtil::writeint(_socketfd, COMMAND_MATCH_INITIALIZE) &&
- SocketUtil::readint(_socketfd, &result) && result)
- {
- return 1;
- }else
- {
- Disconnect();
- return 0;
- }
-}
-
-void ServerSiftGPU::SetLanguage(int gpu_language)
-{
- if(!_connected) return ;
- SocketUtil::writeint(_socketfd, COMMAND_MATCH_SET_LANGUAGE);
- SocketUtil::writeint(_socketfd, gpu_language);
-}
-
-void ServerSiftGPU::SetDeviceParam(int argc, char**argv)
-{
- ServerSiftGPU::ParseParam(argc, argv);
-}
-
-
-void ServerSiftGPU::SetMaxSift(int max_sift)
-{
- if(!_connected) return;
- SocketUtil::writeint(_socketfd, COMMAND_MATCH_SET_MAXSIFT);
- SocketUtil::writeint(_socketfd, max_sift);
-}
-
-void ServerSiftGPU::SetDescriptors(int index, int num, const float* descriptors, int id)
-{
- if(!_connected) return ;
- int command[4] = {COMMAND_MATCH_SET_DES_FLOAT, index, num, id};
- SocketUtil::writedata(_socketfd, command, sizeof(command));
- SocketUtil::writedata(_socketfd, descriptors, sizeof(float) * 128 * num);
-}
-
-
-void ServerSiftGPU::SetDescriptors(int index, int num, const unsigned char * descriptors, int id)
-{
- if(!_connected) return ;
- int command[4] = {COMMAND_MATCH_SET_DES_BYTE, index, num, id};
- SocketUtil::writedata(_socketfd, command, sizeof(command));
- SocketUtil::writedata(_socketfd, descriptors, sizeof(unsigned char) * 128 * num);
-}
-
-int ServerSiftGPU::GetSiftMatch(int max_match, int match_buffer[][2],
- float distmax, float ratiomax, int mutual_best_match)
-{
- if(!_connected) return 0;
- int command[3] = {COMMAND_MATCH_GET_MATCH, max_match, mutual_best_match};
- float fcommand[2] = {distmax, ratiomax};
- SocketUtil::writedata(_socketfd, command, sizeof(command));
- SocketUtil::writedata(_socketfd, fcommand, sizeof(fcommand));
- int nm; SocketUtil::readint(_socketfd, &nm);
- if(nm > 0) SocketUtil::readint(_socketfd, match_buffer[0], 2 * nm);
- return nm;
-}
-
-void RunServerLoop(int port, int argc, char** argv)
-{
- ServerSiftGPU::ServerLoop(port, argc, argv);
-}
-
-
-ComboSiftGPU* CreateRemoteSiftGPU(int port, char* remote_server)
-{
- return new ServerSiftGPU(port, remote_server);
-}
-
-
-#else
-
-#include "../SiftGPU/LiteWindow.h"
-#include "../SiftGPU/SiftGPU.h"
-
-ComboSiftGPU* CreateRemoteSiftGPU(int port, char* remote_server)
-{
- std::cout << "ServerSiftGPU need marcro SERVER_SIFTGPU_EANBLED.\n"
- << "Use local SiftGPU/SiftMatchGPU instead. \n";
- return new ComboSiftGPU;
-}
-
-void RunServerLoop(int port, int argc, char** argv)
-{
- std::cout << "ServerSiftGPU need marcro SERVER_SIFTGPU_EANBLED.\n"
- }
-
-#endif
-
diff --git a/3rdparty/SiftGPU/src/ServerSiftGPU/ServerSiftGPU.h b/3rdparty/SiftGPU/src/ServerSiftGPU/ServerSiftGPU.h
deleted file mode 100644
index b0a28b22..00000000
--- a/3rdparty/SiftGPU/src/ServerSiftGPU/ServerSiftGPU.h
+++ /dev/null
@@ -1,159 +0,0 @@
-////////////////////////////////////////////////////////////////////////////
-// File: ServerSiftGPu.h
-// Author: Changchang Wu
-// Description : interface for the ServerSiftGPU class.
-// It starts a SiftGPU server in a new process
-// or connects to an existing server.
-//
-// Copyright (c) 2007 University of North Carolina at Chapel Hill
-// All Rights Reserved
-//
-// Permission to use, copy, modify and distribute this software and its
-// documentation for educational, research and non-profit purposes, without
-// fee, and without a written agreement is hereby granted, provided that the
-// above copyright notice and the following paragraph appear in all copies.
-//
-// The University of North Carolina at Chapel Hill make no representations
-// about the suitability of this software for any purpose. It is provided
-// 'as is' without express or implied warranty.
-//
-// Please send BUG REPORTS to ccwu@cs.unc.edu
-//
-////////////////////////////////////////////////////////////////////////////
-
-#ifndef GPU_SIFT_SERVER_H
-#define GPU_SIFT_SERVER_H
-
-
-class ComboSiftGPU;
-class LiteWindow;
-
-/////////////////////////////////////////////////////////////////////////////
-//ServerSiftGPU::ServerSiftGPU(int port, char* remote_server)
-//Run SiftGPU/SiftMatchGPU computation on a remote computer/process
-//if( remote_server == NULL)
-// a local server is created in a different process and connects to it
-// multiple-GPU can be used by creating multiple instances
-// GPU selection done through ParseParam function
-//otherwise,
-// Assumes the existenc of a remote server and connects to it
-// GPU selection is done on the server-end when create the server by running
-// server_siftgpu -server port [siftgpu_param]
-/////////////////////////////////////////////////////////////////////////////
-
-
-class ServerSiftGPU: public ComboSiftGPU
-{
- enum
- {
- COMMAND_NONE= 0,
- COMMAND_EXIT= 1,
- COMMAND_DISCONNECT,
- ///////////////////////////////
- COMMAND_INITIALIZE,
- COMMAND_ALLOCATE_PYRAMID,
- COMMAND_RUNSIFT,
- COMMAND_RUNSIFT_FILE,
- COMMAND_RUNSIFT_KEY,
- COMMAND_RUNSIFT_DATA,
- COMMAND_SAVE_SIFT,
- COMMAND_SET_MAX_DIMENSION,
- COMMAND_SET_KEYPOINT,
- COMMAND_GET_FEATURE_COUNT,
- COMMAND_SET_TIGHTPYRAMID,
- COMMAND_GET_KEY_VECTOR,
- COMMAND_GET_DES_VECTOR,
- COMMAND_PARSE_PARAM,
-
- /////////////////////////////////
- COMMAND_MATCH_INITIALIZE,
- COMMAND_MATCH_SET_LANGUAGE,
- COMMAND_MATCH_SET_DES_FLOAT,
- COMMAND_MATCH_SET_DES_BYTE,
- COMMAND_MATCH_SET_MAXSIFT,
- COMMAND_MATCH_GET_MATCH,
- ///////////////////////////////
- DEFAULT_PORT = 7777
- };
-private:
-#ifdef _WIN64
- unsigned __int64 _socketfd;
-#else
- int _socketfd;
-#endif
- int _port;
- int _connected;
- char _server_name[1024];
-private:
- void SetParamSiftGPU(int argc, char** argv);
- int InitializeConnection(int argc, char** argv);
- int StartServerProcess(int argc, char** argv);
- int ConnectServer(const char* server_name, int port);
- void Disconnect();
- static int InitSocket();
- static int GetPixelSizeGL(unsigned int gl_format, unsigned int gl_type);
- static void ServerLoop(int port, int argc, char** argv);
-public:
- //two options : multi-threading or multi-processing
- SIFTGPU_EXPORT ServerSiftGPU(int port = DEFAULT_PORT, char* remote_server = NULL);
- virtual ~ServerSiftGPU();
- ////////////////////////////////////////
- virtual void ParseParam(int argc, char **argv);
- virtual int VerifyContextGL();
- ////////////////////////////////////////////////////////////////////////
- //available SiftGPU functions are the following:
- virtual int RunSIFT(const char * imgpath);
- virtual int RunSIFT();
- //note the difference with class SiftGPU for the function below,
- //you have to provide the number of bytes of the data.
- virtual int RunSIFT(int width, int height, const void * data, unsigned int gl_format, unsigned int gl_type);
- virtual int RunSIFT(int num, const SiftGPU::SiftKeypoint * keys, int keys_have_orientation = 1);
- virtual int AllocatePyramid(int width, int height);
- /////////////////////////////////////////////////////////////////////
- virtual int GetFeatureNum();
- virtual void SetTightPyramid(int tight = 1);
- virtual void SetMaxDimension(int sz);
- virtual void GetFeatureVector(SiftGPU::SiftKeypoint * keys, float * descriptors);
- virtual void SetKeypointList(int num, const SiftGPU::SiftKeypoint * keys, int keys_have_orientation = 1);
- /////////////////////////////////////////////////////////////////////////////
- //the following functions do not block in multi-process mode
- //for example, SaveSIFT will return before the file is written
- virtual void SaveSIFT(const char * szFileName);
-
- //simplified functions
- int GetImageCount(){return 1;}
- int CreateContextGL(){return VerifyContextGL();}
- int IsFullSupported(){return VerifyContextGL() == SiftGPU::SIFTGPU_FULL_SUPPORTED;}
- int RunSIFT(int index) {return RunSIFT();}
-
-////////////////////////
-public:
- virtual int _CreateContextGL() {return _VerifyContextGL();}
- virtual int _VerifyContextGL();
- virtual void SetLanguage(int gpu_language);
- virtual void SetDeviceParam(int argc, char**argv);
- virtual void SetMaxSift(int max_sift);
- virtual void SetDescriptors(int index, int num, const float* descriptors, int id = -1);
- virtual void SetDescriptors(int index, int num, const unsigned char * descriptors, int id = -1);
- virtual int GetSiftMatch(int max_match, int match_buffer[][2], //buffeture indices
- float distmax, float ratiomax, int mutual_best_match); //
-public:
- //////////////////////////////////////////////////////
- //Some SiftGPU functions are not supported
- void SetImageList(int nimage, const char** filelist) {}
- void SetVerbose(){}
-
- ///Guided matching is not supported here, not hard to implement yourself
- virtual void SetFeautreLocation(int index, const float* locations, int gap) {return ;}
- virtual int GetGuidedSiftMatch(int max_match, int match_buffer[][2], float H[3][3],float F[3][3],
- float distmax, float ratiomax, float hdistmax, float fdistmax, int mutual_best_match) {return 0; }
-
- friend void RunServerLoop(int port, int argc, char** argv);
-
-};
-
-
-
-#endif
-
-
diff --git a/3rdparty/SiftGPU/src/ServerSiftGPU/server.cpp b/3rdparty/SiftGPU/src/ServerSiftGPU/server.cpp
deleted file mode 100644
index c0f0e240..00000000
--- a/3rdparty/SiftGPU/src/ServerSiftGPU/server.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-////////////////////////////////////////////////////////////////////////////
-// File: server.cpp
-// Author: Changchang Wu
-// Description : driver of a SiftGPU Server.
-//
-// Copyright (c) 2007 University of North Carolina at Chapel Hill
-// All Rights Reserved
-//
-// Permission to use, copy, modify and distribute this software and its
-// documentation for educational, research and non-profit purposes, without
-// fee, and without a written agreement is hereby granted, provided that the
-// above copyright notice and the following paragraph appear in all copies.
-//
-// The University of North Carolina at Chapel Hill make no representations
-// about the suitability of this software for any purpose. It is provided
-// 'as is' without express or implied warranty.
-//
-// Please send BUG REPORTS to ccwu@cs.unc.edu
-//
-////////////////////////////////////////////////////////////////////////////
-#include
-#include
-#include
-using std::cout;
-
-#include "../SiftGPU/SiftGPU.h"
-
-//if you included ServerSiftGPU.h here.
-//CreateRemoteSiftGPU can be replaced by new ServerSiftGPU();
-
-int main(int argc, char** argv)
-{
-
- if(argc >= 2 && strcmp(argv[1], "-server") == 0)
- {
- //run siftgpu server
- std::cout << "Starting server process...\n";
- int port = 7777;
- if(argc >= 3) sscanf(argv[2], "%d", &port);
- //////////////////////////////////////
- RunServerLoop(port, argc - 3, argv + 3);
- }else if(argc >=2 && strcmp(argv[1], "-test") == 0)
- {
- //start server on same computer and connect...
- //note we are using a SiftGPU pointer..
- SiftGPU* siftgpu = CreateRemoteSiftGPU();
- siftgpu->ParseParam(argc - 2, argv + 2);
- if(siftgpu->VerifyContextGL())
- {
- //files on the matchines where the server runs
- siftgpu->RunSIFT("../data/800-1.jpg");
- siftgpu->RunSIFT("../data/800-2.jpg");
- }
- delete siftgpu; //this will terminate the server
- }else if(argc >=4 && strcmp(argv[1], "-test_remote") == 0)
- {
- ////test client that connects to remote server...
- char server_name[1024]; int port = 7777;
- strcpy(server_name, argv[2]);
- sscanf(argv[3], "%d", &port);
- SiftGPU* siftgpu = CreateRemoteSiftGPU(port, server_name);//new ServerSiftGPU(port, server_name);
- siftgpu->ParseParam(argc - 4, argv + 4);
- if(siftgpu->VerifyContextGL())
- {
- //files on the matchines where the server runs
- siftgpu->RunSIFT("../data/800-1.jpg");
- siftgpu->RunSIFT("../data/800-2.jpg");
- }
- delete siftgpu;
- }else if(argc >=2 && strcmp(argv[1], "-test2") == 0)
- {
- //test using two siftgpu servers...usage:
- //server_siftgpu -test2 [server1_params] [-server2 [server2_params]]
-
- ////////////////////////////////////////////
- //they need to use different ports.
- SiftGPU* siftgpu1 = CreateRemoteSiftGPU(7777);//new ServerSiftGPU(7777);
- SiftGPU* siftgpu2 = CreateRemoteSiftGPU(8888);//new ServerSiftGPU(8888);
-
- //split the parameters for the two servers
- int argc1 = 0, argc2 = 0;
- char** argv1 = argv + 2, **argv2 = 0;
- while(argc1 + 2 < argc && strcmp(argv[argc1 + 2], "-server2"))
- {
- argc1++;
- }
- if(argc1 + 3 < argc && strcmp(argv[argc1 + 2], "-server2") == 0)
- {
- argv2 = argv + argc1 + 3;
- argc2 = argc - argc1 - 3;
- }
-
- //initialize the two servers with their siftgpu parameters
- siftgpu1->ParseParam(argc1, argv1);
- siftgpu2->ParseParam(argc2, argv2);
- if(siftgpu1->VerifyContextGL() && siftgpu2->VerifyContextGL())
- {
- siftgpu1->RunSIFT("../data/800-1.jpg");
- siftgpu2->RunSIFT("../data/800-1.jpg");
- siftgpu1->RunSIFT("../data/800-2.jpg");
- siftgpu2->RunSIFT("../data/800-2.jpg");
- }
- delete siftgpu1;
- delete siftgpu2;
- }else
- {
- std::cout
- <<"try -test [siftgpu_param] to create a local server and a client\n"
- <<"try -test2 [siftgpu_param1] [-server2 [siftgpu_param2]]\n"
- <<" to create two servers and two clients\n"
- <<"try -test_remote remote_sever_name remote_server_port\n"
- <<" to create a client and connect to remote server\n"
- <<"use -server port [siftgpu_param] to start a server\n"
- <<"Note [siftgpu_param] allows you to select GPU from multi-GPUs\n"
- <<"\n";
- }
- return 1;
-}
-
diff --git a/3rdparty/SiftGPU/src/SiftGPU/CLTexImage.cpp b/3rdparty/SiftGPU/src/SiftGPU/CLTexImage.cpp
deleted file mode 100644
index a796721f..00000000
--- a/3rdparty/SiftGPU/src/SiftGPU/CLTexImage.cpp
+++ /dev/null
@@ -1,229 +0,0 @@
-////////////////////////////////////////////////////////////////////////////
-// File: CLTexImage.cpp
-// Author: Changchang Wu
-// Description : implementation of the CLTexImage class.
-//
-// Copyright (c) 2007 University of North Carolina at Chapel Hill
-// All Rights Reserved
-//
-// Permission to use, copy, modify and distribute this software and its
-// documentation for educational, research and non-profit purposes, without
-// fee, and without a written agreement is hereby granted, provided that the
-// above copyright notice and the following paragraph appear in all copies.
-//
-// The University of North Carolina at Chapel Hill make no representations
-// about the suitability of this software for any purpose. It is provided
-// 'as is' without express or implied warranty.
-//
-// Please send BUG REPORTS to ccwu@cs.unc.edu
-//
-////////////////////////////////////////////////////////////////////////////
-
-#if defined(CL_SIFTGPU_ENABLED)
-
-#include "GL/glew.h"
-#include
-#include
-#include
-#include
-#include
-using namespace std;
-
-
-#include
-#include "CLTexImage.h"
-#include "ProgramCL.h"
-#include "GlobalUtil.h"
-
-
-CLTexImage::CLTexImage()
-{
- _context = NULL;
- _queue = NULL;
- _clData = NULL;
- _numChannel = _bufferLen = _fromGL = 0;
- _imgWidth = _imgHeight = _texWidth = _texHeight = 0;
-}
-
-CLTexImage::CLTexImage(cl_context context, cl_command_queue queue)
-{
- _context = context;
- _queue = queue;
- _clData = NULL;
- _numChannel = _bufferLen = _fromGL = 0;
- _imgWidth = _imgHeight = _texWidth = _texHeight = 0;
-}
-
-void CLTexImage::SetContext(cl_context context, cl_command_queue queue)
-{
- _context = context;
- _queue = queue;
-}
-
-
-CLTexImage::~CLTexImage()
-{
- ReleaseTexture();
-}
-
-void CLTexImage::ReleaseTexture()
-{
- if(_fromGL) clEnqueueReleaseGLObjects(_queue, 1, &_clData, 0, NULL, NULL);
- if(_clData) clReleaseMemObject(_clData);
-}
-
-void CLTexImage::SetImageSize(int width, int height)
-{
- _imgWidth = width;
- _imgHeight = height;
-}
-
-void CLTexImage::InitBufferTex(int width, int height, int nchannel)
-{
- if(width == 0 || height == 0 || nchannel <= 0 || _fromGL) return;
-
- _imgWidth = width; _imgHeight = height;
- _texWidth = _texHeight = _fromGL = 0;
- _numChannel = min(nchannel, 4);
-
- int size = width * height * _numChannel * sizeof(float);
- if (size <= _bufferLen) return;
-
- //allocate the buffer data
- cl_int status;
- if(_clData) status = clReleaseMemObject(_clData);
-
- _clData = clCreateBuffer(_context, CL_MEM_READ_WRITE,
- _bufferLen = size, NULL, &status);
-
- ProgramBagCL::CheckErrorCL(status, "CLTexImage::InitBufferTex");
-
-}
-
-void CLTexImage::InitTexture(int width, int height, int nchannel)
-{
- if(width == 0 || height == 0 || nchannel <= 0 || _fromGL) return;
- if(_clData && width == _texWidth && height == _texHeight && _numChannel == nchannel) return;
- if(_clData) clReleaseMemObject(_clData);
-
- _texWidth = _imgWidth = width;
- _texHeight = _imgHeight = height;
- _numChannel = nchannel;
- _bufferLen = _fromGL = 0;
-
- cl_int status; cl_image_format format;
-
- if(nchannel == 1) format.image_channel_order = CL_R;
- else if(nchannel == 2) format.image_channel_order = CL_RG;
- else if(nchannel == 3) format.image_channel_order = CL_RGB;
- else format.image_channel_order = CL_RGBA;
-
- format.image_channel_data_type = CL_FLOAT;
- _clData = clCreateImage2D(_context, CL_MEM_READ_WRITE, & format,
- _texWidth, _texHeight, 0, 0, &status);
- ProgramBagCL::CheckErrorCL(status, "CLTexImage::InitTexture");
-}
-
-void CLTexImage::InitPackedTex(int width, int height, int packed)
-{
- if(packed) InitTexture((width + 1) >> 1, (height + 1) >> 1, 4);
- else InitTexture(width, height, 1);
-}
-
-void CLTexImage::SetPackedSize(int width, int height, int packed)
-{
- if(packed) SetImageSize((width + 1) >> 1, (height + 1) >> 1);
- else SetImageSize(width, height);
-}
-
-void CLTexImage::InitTextureGL(GLuint tex, int width, int height, int nchannel)
-{
- if(tex == 0) return;
- if(_clData) clReleaseMemObject(_clData);
-
- ////create the memory object
- cl_int status;
- _clData = clCreateFromGLTexture2D(_context, CL_MEM_WRITE_ONLY,
- GlobalUtil::_texTarget, 0 , tex, &status);
- ProgramBagCL::CheckErrorCL(status, "CLTexImage::InitTextureGL->clCreateFromGLTexture2D");
- if(status != CL_SUCCESS) return;
-
- _texWidth = _imgWidth = width;
- _texHeight = _imgHeight = height;
- _numChannel = nchannel;
- _bufferLen = 0; _fromGL = 1;
-
- ////acquire object
- status = clEnqueueAcquireGLObjects(_queue, 1, &_clData, 0, NULL, NULL);
- ProgramBagCL::CheckErrorCL(status, "CLTexImage::InitTextureGL->clEnqueueAcquireGLObjects");
-
-}
-
-void CLTexImage::CopyFromHost(const void * buf)
-{
- if(_clData == NULL) return;
- cl_int status;
- if(_bufferLen)
- {
- status = clEnqueueWriteBuffer(_queue, _clData, false, 0,
- _imgWidth * _imgHeight * _numChannel * sizeof(float), buf, 0, NULL, NULL);
- }else
- {
- size_t origin[3] = {0, 0, 0}, region[3] = {_imgWidth, _imgHeight, 1};
- size_t row_pitch = _imgWidth * _numChannel * sizeof(float);
- status = clEnqueueWriteImage(_queue, _clData, false, origin,
- region, row_pitch, 0, buf, 0, 0, 0);
- }
- ProgramBagCL::CheckErrorCL(status, "CLTexImage::CopyFromHost");
-}
-
-int CLTexImage::GetImageDataSize()
-{
- return _imgWidth * _imgHeight * _numChannel * sizeof(float);
-}
-
-int CLTexImage::CopyToPBO(GLuint pbo)
-{
- glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbo);
-
- int esize = GetImageDataSize(), bsize;
- glGetBufferParameteriv(GL_PIXEL_UNPACK_BUFFER_ARB, GL_BUFFER_SIZE, &bsize);
- if(bsize < esize)
- {
- glBufferData(GL_PIXEL_UNPACK_BUFFER_ARB, esize, NULL, GL_STATIC_DRAW_ARB);
- glGetBufferParameteriv(GL_PIXEL_UNPACK_BUFFER_ARB, GL_BUFFER_SIZE, &bsize);
- }
- if(bsize >= esize)
- {
- // map the buffer object into client's memory
- void* ptr = glMapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY_ARB);
- CopyToHost(ptr);
- clFinish(_queue);
- glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB);
- }
- glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
- GlobalUtil::CheckErrorsGL("CLTexImage::CopyToPBO");
- return esize >= bsize;
-}
-
-void CLTexImage::CopyToHost(void * buf)
-{
- if(_clData == NULL) return;
- cl_int status;
- if(_bufferLen)
- {
- status = clEnqueueReadBuffer(_queue, _clData, true, 0,
- _imgWidth * _imgHeight * _numChannel * sizeof(float), buf, 0, NULL, NULL);
- }else
- {
- size_t origin[3] = {0, 0, 0}, region[3] = {_imgWidth, _imgHeight, 1};
- size_t row_pitch = _imgWidth * _numChannel * sizeof(float);
- status = clEnqueueReadImage(_queue, _clData, true, origin,
- region, row_pitch, 0, buf, 0, 0, 0);
- }
-
- ProgramBagCL::CheckErrorCL(status, "CLTexImage::CopyToHost");
-}
-
-#endif
-
diff --git a/3rdparty/SiftGPU/src/SiftGPU/CLTexImage.h b/3rdparty/SiftGPU/src/SiftGPU/CLTexImage.h
deleted file mode 100644
index 2897cbc8..00000000
--- a/3rdparty/SiftGPU/src/SiftGPU/CLTexImage.h
+++ /dev/null
@@ -1,83 +0,0 @@
-////////////////////////////////////////////////////////////////////////////
-// File: CLTexImage.h
-// Author: Changchang Wu
-// Description : interface for the CLTexImage class.
-// class for storing data in CUDA.
-//
-// Copyright (c) 2007 University of North Carolina at Chapel Hill
-// All Rights Reserved
-//
-// Permission to use, copy, modify and distribute this software and its
-// documentation for educational, research and non-profit purposes, without
-// fee, and without a written agreement is hereby granted, provided that the
-// above copyright notice and the following paragraph appear in all copies.
-//
-// The University of North Carolina at Chapel Hill make no representations
-// about the suitability of this software for any purpose. It is provided
-// 'as is' without express or implied warranty.
-//
-// Please send BUG REPORTS to ccwu@cs.unc.edu
-//
-////////////////////////////////////////////////////////////////////////////
-#if defined(CL_SIFTGPU_ENABLED)
-
-#ifndef CL_TEX_IMAGE_H
-#define CL_TEX_IMAGE_H
-
-class GLTexImage;
-
-class CLTexImage
-{
-protected:
- cl_context _context;
- cl_command_queue _queue;
- cl_mem _clData;
- int _numChannel;
- int _imgWidth;
- int _imgHeight;
- int _texWidth;
- int _texHeight;
- int _bufferLen;
- int _fromGL;
-private:
- void ReleaseTexture();
-public:
- void SetImageSize(int width, int height);
- void SetPackedSize(int width, int height, int packed);
- void InitBufferTex(int width, int height, int nchannel);
- void InitTexture(int width, int height, int nchannel);
- void InitPackedTex(int width, int height, int packed);
- void InitTextureGL(GLuint tex, int width, int height, int nchannel);
- void CopyToHost(void* buf);
- void CopyFromHost(const void* buf);
-public:
- int CopyToPBO(GLuint pbo);
- int GetImageDataSize();
-public:
- inline operator cl_mem(){return _clData; }
- inline int GetImgWidth(){return _imgWidth;}
- inline int GetImgHeight(){return _imgHeight;}
- inline int GetTexWidth(){return _texWidth;}
- inline int GetTexHeight(){return _texHeight;}
- inline int GetDataSize(){return _bufferLen;}
- inline bool IsImage2D() {return _bufferLen == 0;}
- inline int GetImgPixelCount(){return _imgWidth*_imgHeight;}
- inline int GetTexPixelCount(){return _texWidth*_texHeight;}
-public:
- CLTexImage();
- CLTexImage(cl_context context, cl_command_queue queue);
- void SetContext(cl_context context, cl_command_queue queue);
- virtual ~CLTexImage();
- friend class ProgramCL;
- friend class PyramidCL;
- friend class ProgramBagCL;
- friend class ProgramBagCLN;
-};
-
-//////////////////////////////////////////////////
-//transfer OpenGL Texture to PBO, then to CUDA vector
-//#endif
-#endif // !defined(CU_TEX_IMAGE_H)
-#endif
-
-
diff --git a/3rdparty/SiftGPU/src/SiftGPU/CMakeLists.txt b/3rdparty/SiftGPU/src/SiftGPU/CMakeLists.txt
deleted file mode 100644
index e280fe72..00000000
--- a/3rdparty/SiftGPU/src/SiftGPU/CMakeLists.txt
+++ /dev/null
@@ -1,50 +0,0 @@
-find_package(OpenGL REQUIRED)
-find_package(GLUT REQUIRED)
-find_package(GLEW)
-
-OPTION(SIFTGPU_ENABLE_SERVER FALSE)
-SET(SIFTGPU_ENABLE_OPENCL FALSE)
-SET(SIFTGPU_ENABLE_CUDA TRUE)
-SET(SIFTGPU_ENABLE_SSE TRUE)
-SET(SIFTGPU_SSE_OPTIONS -march=core2 -mfpmath=sse)
-SET(SIFTGPU_PREFER_GLUT TRUE)
-SET(SIFTGPU_DISABLE_DEVIL TRUE)
-
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -Wno-deprecated" )
-
-IF(SIFTGPU_ENABLE_SSE)
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=core2 -mfpmath=sse" )
-ENDIF(SIFTGPU_ENABLE_SSE)
-
-IF(SIFTGPU_PREFER_GLUT)
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWINDOW_PREFER_GLUT" )
-ENDIF(SIFTGPU_PREFER_GLUT)
-
-IF(SIFTGPU_ENABLE_OPENCL)
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCL_SIFTGPU_ENABLED" )
-ENDIF(SIFTGPU_ENABLE_OPENCL)
-
-IF(APPLE)
- SET(LIBS_SIFTGPU )
-ELSE(APPLE)
- SET(LIBS_SIFTGPU glut GL X11 )
-ENDIF(APPLE)
-
-IF(SIFTGPU_DISABLE_DEVIL)
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSIFTGPU_NO_DEVIL" )
-ELSE(SIFTGPU_DISABLE_DEVIL)
- SET(LIBS_SIFTGPU ${LIBS_SIFTGPU} IL )
-ENDIF(SIFTGPU_DISABLE_DEVIL)
-
-if (GLEW_FOUND)
- include_directories( ${GLEW_INCLUDE_DIRS} )
- SET (GLEW_LIBRARIES GLEW)
-endif (GLEW_FOUND)
-
-ADD_LIBRARY(siftgpu STATIC FrameBufferObject.cpp GlobalUtil.cpp GLTexImage.cpp ProgramGLSL.cpp
- ProgramGPU.cpp ShaderMan.cpp SiftGPU.cpp SiftPyramid.cpp PyramidGL.cpp SiftMatch.cpp)
-
-TARGET_LINK_LIBRARIES(siftgpu ${LIBS_SIFTGPU} ${GLEW_LIBRARIES} ${GLUT_LIBRARIES} ${OPENGL_LIBRARIES} )
-
-INSTALL(FILES SiftGPU.h DESTINATION include)
-INSTALL(TARGETS siftgpu DESTINATION lib )
diff --git a/3rdparty/SiftGPU/src/SiftGPU/CuTexImage.cpp b/3rdparty/SiftGPU/src/SiftGPU/CuTexImage.cpp
deleted file mode 100644
index c8feeb74..00000000
--- a/3rdparty/SiftGPU/src/SiftGPU/CuTexImage.cpp
+++ /dev/null
@@ -1,259 +0,0 @@
-////////////////////////////////////////////////////////////////////////////
-// File: CuTexImage.cpp
-// Author: Changchang Wu
-// Description : implementation of the CuTexImage class.
-//
-// Copyright (c) 2007 University of North Carolina at Chapel Hill
-// All Rights Reserved
-//
-// Permission to use, copy, modify and distribute this software and its
-// documentation for educational, research and non-profit purposes, without
-// fee, and without a written agreement is hereby granted, provided that the
-// above copyright notice and the following paragraph appear in all copies.
-//
-// The University of North Carolina at Chapel Hill make no representations
-// about the suitability of this software for any purpose. It is provided
-// 'as is' without express or implied warranty.
-//
-// Please send BUG REPORTS to ccwu@cs.unc.edu
-//
-////////////////////////////////////////////////////////////////////////////
-
-#if defined(CUDA_SIFTGPU_ENABLED)
-
-#include "GL/glew.h"
-#include
-#include
-#include
-#include
-#include
-using namespace std;
-
-
-#include
-#include
-#include
-
-#include "GlobalUtil.h"
-#include "GLTexImage.h"
-#include "CuTexImage.h"
-#include "ProgramCU.h"
-
-#if CUDA_VERSION <= 2010 && defined(SIFTGPU_ENABLE_LINEAR_TEX2D)
-#error "Require CUDA 2.2 or higher"
-#endif
-
-
-CuTexImage::CuTexImage()
-{
- _cuData = NULL;
- _cuData2D = NULL;
- _fromPBO = 0;
- _numChannel = _numBytes = 0;
- _imgWidth = _imgHeight = _texWidth = _texHeight = 0;
-}
-
-CuTexImage::CuTexImage(int width, int height, int nchannel, GLuint pbo)
-{
- _cuData = NULL;
-
- //check size of pbo
- GLint bsize, esize = width * height * nchannel * sizeof(float);
- glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, pbo);
- glGetBufferParameteriv(GL_PIXEL_PACK_BUFFER_ARB, GL_BUFFER_SIZE, &bsize);
- if(bsize < esize)
- {
- glBufferData(GL_PIXEL_PACK_BUFFER_ARB, esize, NULL, GL_STATIC_DRAW_ARB);
- glGetBufferParameteriv(GL_PIXEL_PACK_BUFFER_ARB, GL_BUFFER_SIZE, &bsize);
- }
- glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0);
- if(bsize >=esize)
- {
-
- cudaGLRegisterBufferObject(pbo);
- cudaGLMapBufferObject(&_cuData, pbo);
- ProgramCU::CheckErrorCUDA("cudaGLMapBufferObject");
- _fromPBO = pbo;
- }else
- {
- _cuData = NULL;
- _fromPBO = 0;
- }
- if(_cuData)
- {
- _numBytes = bsize;
- _imgWidth = width;
- _imgHeight = height;
- _numChannel = nchannel;
- }else
- {
- _numBytes = 0;
- _imgWidth = 0;
- _imgHeight = 0;
- _numChannel = 0;
- }
-
- _texWidth = _texHeight =0;
-
- _cuData2D = NULL;
-}
-
-CuTexImage::~CuTexImage()
-{
-
-
- if(_fromPBO)
- {
- cudaGLUnmapBufferObject(_fromPBO);
- cudaGLUnregisterBufferObject(_fromPBO);
- }else if(_cuData)
- {
- cudaFree(_cuData);
- }
- if(_cuData2D) cudaFreeArray(_cuData2D);
-}
-
-void CuTexImage::SetImageSize(int width, int height)
-{
- _imgWidth = width;
- _imgHeight = height;
-}
-
-void CuTexImage::InitTexture(int width, int height, int nchannel)
-{
- int size;
- _imgWidth = width;
- _imgHeight = height;
- _numChannel = min(max(nchannel, 1), 4);
-
- size = width * height * _numChannel * sizeof(float);
-
- if(size <= _numBytes) return;
-
- if(_cuData) cudaFree(_cuData);
-
- //allocate the array data
- cudaMalloc(&_cuData, _numBytes = size);
-
-#ifdef _DEBUG
- ProgramCU::CheckErrorCUDA("CuTexImage::InitTexture");
-#endif
-}
-
-void CuTexImage::CopyFromHost(const void * buf)
-{
- if(_cuData == NULL) return;
- cudaMemcpy( _cuData, buf, _imgWidth * _imgHeight * _numChannel * sizeof(float), cudaMemcpyHostToDevice);
-}
-
-void CuTexImage::CopyToHost(void * buf)
-{
- if(_cuData == NULL) return;
- cudaMemcpy(buf, _cuData, _imgWidth * _imgHeight * _numChannel * sizeof(float), cudaMemcpyDeviceToHost);
-}
-
-void CuTexImage::CopyToHost(void * buf, int stream)
-{
- if(_cuData == NULL) return;
- cudaMemcpyAsync(buf, _cuData, _imgWidth * _imgHeight * _numChannel * sizeof(float), cudaMemcpyDeviceToHost, (cudaStream_t)stream);
-}
-
-void CuTexImage::InitTexture2D()
-{
-#if !defined(SIFTGPU_ENABLE_LINEAR_TEX2D)
- if(_cuData2D && (_texWidth < _imgWidth || _texHeight < _imgHeight))
- {
- cudaFreeArray(_cuData2D);
- _cuData2D = NULL;
- }
-
- if(_cuData2D == NULL)
- {
- _texWidth = max(_texWidth, _imgWidth);
- _texHeight = max(_texHeight, _imgHeight);
- cudaChannelFormatDesc desc;
- desc.f = cudaChannelFormatKindFloat;
- desc.x = sizeof(float) * 8;
- desc.y = _numChannel >=2 ? sizeof(float) * 8 : 0;
- desc.z = _numChannel >=3 ? sizeof(float) * 8 : 0;
- desc.w = _numChannel >=4 ? sizeof(float) * 8 : 0;
- cudaMallocArray(&_cuData2D, &desc, _texWidth, _texHeight);
- ProgramCU::CheckErrorCUDA("cudaMallocArray");
- }
-#endif
-}
-
-void CuTexImage::CopyToTexture2D()
-{
-#if !defined(SIFTGPU_ENABLE_LINEAR_TEX2D)
- InitTexture2D();
-
- if(_cuData2D)
- {
- cudaMemcpy2DToArray(_cuData2D, 0, 0, _cuData, _imgWidth* _numChannel* sizeof(float) ,
- _imgWidth * _numChannel*sizeof(float), _imgHeight, cudaMemcpyDeviceToDevice);
- ProgramCU::CheckErrorCUDA("cudaMemcpy2DToArray");
- }
-#endif
-
-}
-
-int CuTexImage::DebugCopyToTexture2D()
-{
-
-/* CuTexImage tex;
- float data1[2][3] = {{1, 2, 5}, {3, 4, 5}}, data2[2][5];
- tex.InitTexture(3, 2, 1);
- cudaMemcpy(tex._cuData, data1[0], 6 * sizeof(float), cudaMemcpyHostToDevice);
- cudaMemcpy(data1, tex._cuData, 4 * sizeof(float) , cudaMemcpyDeviceToHost);
- tex._texWidth =5; tex._texHeight = 2;
- tex.CopyToTexture2D();
- cudaMemcpyFromArray(data2[0], tex._cuData2D, 0, 0, 10 * sizeof(float), cudaMemcpyDeviceToHost);*/
-
- return 1;
-}
-
-
-
-void CuTexImage::CopyFromPBO(int width, int height, GLuint pbo)
-{
- void* pbuf =NULL;
- GLint esize = width * height * sizeof(float);
- cudaGLRegisterBufferObject(pbo);
- cudaGLMapBufferObject(&pbuf, pbo);
-
- cudaMemcpy(_cuData, pbuf, esize, cudaMemcpyDeviceToDevice);
-
- cudaGLUnmapBufferObject(pbo);
- cudaGLUnregisterBufferObject(pbo);
-}
-
-int CuTexImage::CopyToPBO(GLuint pbo)
-{
- void* pbuf =NULL;
- GLint bsize, esize = _imgWidth * _imgHeight * sizeof(float) * _numChannel;
- glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, pbo);
- glGetBufferParameteriv(GL_PIXEL_PACK_BUFFER_ARB, GL_BUFFER_SIZE, &bsize);
- if(bsize < esize)
- {
- glBufferData(GL_PIXEL_PACK_BUFFER_ARB, esize*3/2, NULL, GL_STATIC_DRAW_ARB);
- glGetBufferParameteriv(GL_PIXEL_PACK_BUFFER_ARB, GL_BUFFER_SIZE, &bsize);
- }
- glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0);
-
- if(bsize >= esize)
- {
- cudaGLRegisterBufferObject(pbo);
- cudaGLMapBufferObject(&pbuf, pbo);
- cudaMemcpy(pbuf, _cuData, esize, cudaMemcpyDeviceToDevice);
- cudaGLUnmapBufferObject(pbo);
- cudaGLUnregisterBufferObject(pbo);
- return 1;
- }else
- {
- return 0;
- }
-}
-
-#endif
-
diff --git a/3rdparty/SiftGPU/src/SiftGPU/CuTexImage.h b/3rdparty/SiftGPU/src/SiftGPU/CuTexImage.h
deleted file mode 100644
index 6785c8d7..00000000
--- a/3rdparty/SiftGPU/src/SiftGPU/CuTexImage.h
+++ /dev/null
@@ -1,76 +0,0 @@
-////////////////////////////////////////////////////////////////////////////
-// File: CuTexImage.h
-// Author: Changchang Wu
-// Description : interface for the CuTexImage class.
-// class for storing data in CUDA.
-//
-// Copyright (c) 2007 University of North Carolina at Chapel Hill
-// All Rights Reserved
-//
-// Permission to use, copy, modify and distribute this software and its
-// documentation for educational, research and non-profit purposes, without
-// fee, and without a written agreement is hereby granted, provided that the
-// above copyright notice and the following paragraph appear in all copies.
-//
-// The University of North Carolina at Chapel Hill make no representations
-// about the suitability of this software for any purpose. It is provided
-// 'as is' without express or implied warranty.
-//
-// Please send BUG REPORTS to ccwu@cs.unc.edu
-//
-////////////////////////////////////////////////////////////////////////////
-
-
-#ifndef CU_TEX_IMAGE_H
-#define CU_TEX_IMAGE_H
-
-class GLTexImage;
-struct cudaArray;
-struct textureReference;
-
-//using texture2D from linear memory
-
-#define SIFTGPU_ENABLE_LINEAR_TEX2D
-
-class CuTexImage
-{
-protected:
- void* _cuData;
- cudaArray* _cuData2D;
- int _numChannel;
- int _numBytes;
- int _imgWidth;
- int _imgHeight;
- int _texWidth;
- int _texHeight;
- GLuint _fromPBO;
-public:
- virtual void SetImageSize(int width, int height);
- virtual void InitTexture(int width, int height, int nchannel = 1);
- void InitTexture2D();
- inline void BindTexture(textureReference& texRef);
- inline void BindTexture2D(textureReference& texRef);
- void CopyToTexture2D();
- void CopyToHost(void* buf);
- void CopyToHost(void* buf, int stream);
- void CopyFromHost(const void* buf);
- int CopyToPBO(GLuint pbo);
- void CopyFromPBO(int width, int height, GLuint pbo);
- static int DebugCopyToTexture2D();
-public:
- inline int GetImgWidth(){return _imgWidth;}
- inline int GetImgHeight(){return _imgHeight;}
- inline int GetDataSize(){return _numBytes;}
-public:
- CuTexImage();
- CuTexImage(int width, int height, int nchannel, GLuint pbo);
- virtual ~CuTexImage();
- friend class ProgramCU;
- friend class PyramidCU;
-};
-
-//////////////////////////////////////////////////
-//transfer OpenGL Texture to PBO, then to CUDA vector
-//#endif
-#endif // !defined(CU_TEX_IMAGE_H)
-
diff --git a/3rdparty/SiftGPU/src/SiftGPU/FrameBufferObject.cpp b/3rdparty/SiftGPU/src/SiftGPU/FrameBufferObject.cpp
deleted file mode 100644
index b586d9b0..00000000
--- a/3rdparty/SiftGPU/src/SiftGPU/FrameBufferObject.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-////////////////////////////////////////////////////////////////////////////
-// File: FrameBufferObject.cpp
-// Author: Changchang Wu
-// Description : Implementation of FrameBufferObject Class
-//
-//
-//
-// Copyright (c) 2007 University of North Carolina at Chapel Hill
-// All Rights Reserved
-//
-// Permission to use, copy, modify and distribute this software and its
-// documentation for educational, research and non-profit purposes, without
-// fee, and without a written agreement is hereby granted, provided that the
-// above copyright notice and the following paragraph appear in all copies.
-//
-// The University of North Carolina at Chapel Hill make no representations
-// about the suitability of this software for any purpose. It is provided
-// 'as is' without express or implied warranty.
-//
-// Please send BUG REPORTS to ccwu@cs.unc.edu
-//
-////////////////////////////////////////////////////////////////////////////
-
-
-#include "GL/glew.h"
-#include
-#include "GlobalUtil.h"
-#include "FrameBufferObject.h"
-
-//whether use only one FBO globally
-int FrameBufferObject::UseSingleFBO=1;
-GLuint FrameBufferObject::GlobalFBO=0;
-
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
-
-FrameBufferObject::FrameBufferObject(int autobind)
-{
- if(UseSingleFBO && GlobalFBO)
- {
- _fboID = GlobalFBO;
- }else
- {
- glGenFramebuffersEXT(1, &_fboID);
- if(UseSingleFBO )GlobalFBO = _fboID;
- }
- if(autobind ) glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _fboID);
-}
-
-FrameBufferObject::~FrameBufferObject()
-{
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- if(!UseSingleFBO )
- {
- glDeleteFramebuffersEXT (1,&_fboID);
- }
-}
-
-void FrameBufferObject::DeleteGlobalFBO()
-{
- if(UseSingleFBO)
- {
- glDeleteFramebuffersEXT (1,&GlobalFBO);
- GlobalFBO = 0;
- }
-}
-
-void FrameBufferObject::AttachDepthTexture(GLenum textureTarget, GLuint texID)
-{
-
- glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, textureTarget, texID, 0);
-}
-
-void FrameBufferObject::AttachTexture(GLenum textureTarget, GLenum attachment, GLuint texId)
-{
- glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, attachment, textureTarget, texId, 0);
-}
-
-void FrameBufferObject::BindFBO()
-{
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _fboID);
-}
-
-void FrameBufferObject::UnbindFBO()
-{
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
-}
-
-void FrameBufferObject::UnattachTex(GLenum attachment)
-{
- glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_2D, 0, 0 );
-}
-
-void FrameBufferObject::AttachRenderBuffer(GLenum attachment, GLuint buffID)
-{
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, attachment, GL_RENDERBUFFER_EXT, buffID);
-
-}
-
-void FrameBufferObject:: UnattachRenderBuffer(GLenum attachment)
-{
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, attachment, GL_RENDERBUFFER_EXT, 0);
-}
-
diff --git a/3rdparty/SiftGPU/src/SiftGPU/FrameBufferObject.h b/3rdparty/SiftGPU/src/SiftGPU/FrameBufferObject.h
deleted file mode 100644
index e4cc5263..00000000
--- a/3rdparty/SiftGPU/src/SiftGPU/FrameBufferObject.h
+++ /dev/null
@@ -1,49 +0,0 @@
-////////////////////////////////////////////////////////////////////////////
-// File: FrameBufferObject.h
-// Author: Changchang Wu
-// Description : interface for the FrameBufferObject class.
-//
-//
-//
-// Copyright (c) 2007 University of North Carolina at Chapel Hill
-// All Rights Reserved
-//
-// Permission to use, copy, modify and distribute this software and its
-// documentation for educational, research and non-profit purposes, without
-// fee, and without a written agreement is hereby granted, provided that the
-// above copyright notice and the following paragraph appear in all copies.
-//
-// The University of North Carolina at Chapel Hill make no representations
-// about the suitability of this software for any purpose. It is provided
-// 'as is' without express or implied warranty.
-//
-// Please send BUG REPORTS to ccwu@cs.unc.edu
-//
-////////////////////////////////////////////////////////////////////////////
-
-
-#if !defined(_FRAME_BUFFER_OBJECT_H)
-#define _FRAME_BUFFER_OBJECT_H
-
-class FrameBufferObject
-{
- static GLuint GlobalFBO; //not thread-safe
- GLuint _fboID;
-public:
- static int UseSingleFBO;
-public:
- static void DeleteGlobalFBO();
- static void UnattachTex(GLenum attachment);
- static void UnbindFBO();
- static void AttachDepthTexture(GLenum textureTarget, GLuint texID);
- static void AttachTexture( GLenum textureTarget, GLenum attachment, GLuint texID);
- static void AttachRenderBuffer(GLenum attachment, GLuint buffID );
- static void UnattachRenderBuffer(GLenum attachment);
-public:
- void BindFBO();
- FrameBufferObject(int autobind = 1);
- ~FrameBufferObject();
-
-};
-
-#endif
diff --git a/3rdparty/SiftGPU/src/SiftGPU/GLTexImage.cpp b/3rdparty/SiftGPU/src/SiftGPU/GLTexImage.cpp
deleted file mode 100644
index a6a28098..00000000
--- a/3rdparty/SiftGPU/src/SiftGPU/GLTexImage.cpp
+++ /dev/null
@@ -1,1264 +0,0 @@
-////////////////////////////////////////////////////////////////////////////
-// File: GLTexImage.cpp
-// Author: Changchang Wu
-// Description : implementation of the GLTexImage class.
-//
-//
-//
-// Copyright (c) 2007 University of North Carolina at Chapel Hill
-// All Rights Reserved
-//
-// Permission to use, copy, modify and distribute this software and its
-// documentation for educational, research and non-profit purposes, without
-// fee, and without a written agreement is hereby granted, provided that the
-// above copyright notice and the following paragraph appear in all copies.
-//
-// The University of North Carolina at Chapel Hill make no representations
-// about the suitability of this software for any purpose. It is provided
-// 'as is' without express or implied warranty.
-//
-// Please send BUG REPORTS to ccwu@cs.unc.edu
-//
-////////////////////////////////////////////////////////////////////////////
-
-
-#include "GL/glew.h"
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-using namespace std;
-
-
-
-#include "GlobalUtil.h"
-
-#include "GLTexImage.h"
-#include "FrameBufferObject.h"
-#include "ShaderMan.h"
-
-
-//#define SIFTGPU_NO_DEVIL
-
-#ifndef SIFTGPU_NO_DEVIL
- #include "IL/il.h"
- #if defined(_WIN64)
- #pragma comment(lib, "../../lib/DevIL64.lib")
- #elif defined(_WIN32)
- #pragma comment(lib, "../../lib/DevIL.lib")
- #endif
-#else
- #include
-#endif
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
-
-
-GLTexImage::GLTexImage()
-{
- _imgWidth = _imgHeight = 0;
- _texWidth = _texHeight = 0;
- _drawWidth = _drawHeight = 0;
- _texID = 0;
-
-}
-
-GLTexImage::~GLTexImage()
-{
- if(_texID) glDeleteTextures(1, &_texID);
-}
-
-int GLTexImage::CheckTexture()
-{
- if(_texID)
- {
- GLint tw, th;
- BindTex();
- glGetTexLevelParameteriv(_texTarget, 0, GL_TEXTURE_WIDTH , &tw);
- glGetTexLevelParameteriv(_texTarget, 0, GL_TEXTURE_HEIGHT , &th);
- UnbindTex();
- return tw == _texWidth && th == _texHeight;
- }else
- {
- return _texWidth == 0 && _texHeight ==0;
-
- }
-}
-//set a dimension that is smaller than the actuall size
-//for drawQuad
-void GLTexImage::SetImageSize( int width, int height)
-{
- _drawWidth = _imgWidth = width;
- _drawHeight = _imgHeight = height;
-}
-
-void GLTexImage::InitTexture( int width, int height, int clamp_to_edge)
-{
-
- if(_texID && width == _texWidth && height == _texHeight ) return;
- if(_texID==0) glGenTextures(1, &_texID);
-
- _texWidth = _imgWidth = _drawWidth = width;
- _texHeight = _imgHeight = _drawHeight = height;
-
- BindTex();
-
- if(clamp_to_edge)
- {
- glTexParameteri (_texTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri (_texTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- }else
- {
- //out of bound tex read returns 0??
- glTexParameteri (_texTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
- glTexParameteri (_texTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
- }
- glTexParameteri(_texTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(_texTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-
- glTexImage2D(_texTarget, 0, _iTexFormat,
- _texWidth, _texHeight, 0, GL_RGBA, GL_FLOAT, NULL);
- CheckErrorsGL("glTexImage2D");
-
-
- UnbindTex();
-
-}
-
-
-void GLTexImage::InitTexture( int width, int height, int clamp_to_edge, GLuint format)
-{
-
- if(_texID && width == _texWidth && height == _texHeight ) return;
- if(_texID==0) glGenTextures(1, &_texID);
-
- _texWidth = _imgWidth = _drawWidth = width;
- _texHeight = _imgHeight = _drawHeight = height;
-
- BindTex();
-
- if(clamp_to_edge)
- {
- glTexParameteri (_texTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri (_texTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- }else
- {
- //out of bound tex read returns 0??
- glTexParameteri (_texTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
- glTexParameteri (_texTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
- }
- glTexParameteri(_texTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(_texTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-
- glTexImage2D(_texTarget, 0, format, _texWidth, _texHeight, 0, GL_RGBA, GL_FLOAT, NULL);
-
- UnbindTex();
-
-}
-void GLTexImage::BindTex()
-{
- glBindTexture(_texTarget, _texID);
-}
-
-void GLTexImage::UnbindTex()
-{
- glBindTexture(_texTarget, 0);
-}
-
-
-void GLTexImage::DrawQuad()
-{
- glBegin (GL_QUADS);
- glTexCoord2i ( 0 , 0 ); glVertex2i ( 0 , 0 );
- glTexCoord2i ( 0 , _drawHeight ); glVertex2i ( 0 , _drawHeight );
- glTexCoord2i ( _drawWidth , _drawHeight ); glVertex2i ( _drawWidth , _drawHeight );
- glTexCoord2i ( _drawWidth , 0 ); glVertex2i ( _drawWidth , 0 );
- glEnd ();
- glFlush();
-}
-
-void GLTexImage::FillMargin(int marginx, int marginy)
-{
- //
- marginx = min(marginx, _texWidth - _imgWidth);
- marginy = min(marginy, _texHeight - _imgHeight);
- if(marginx >0 || marginy > 0)
- {
- GlobalUtil::FitViewPort(_imgWidth + marginx, _imgHeight + marginy);
- AttachToFBO(0);
- BindTex();
- ShaderMan::UseShaderMarginCopy(_imgWidth, _imgHeight);
- DrawMargin(_imgWidth + marginx, _imgHeight + marginy);
- }
-}
-
-void GLTexImage::ZeroHistoMargin()
-{
- ZeroHistoMargin(_imgWidth, _imgHeight);
-}
-
-void GLTexImage::ZeroHistoMargin(int width, int height)
-{
- int marginx = width & 0x01;
- int marginy = height & 0x01;
- if(marginx >0 || marginy > 0)
- {
- int right = width + marginx;
- int bottom = height + marginy;
- GlobalUtil::FitViewPort(right, bottom);
- AttachToFBO(0);
- ShaderMan::UseShaderZeroPass();
- glBegin(GL_QUADS);
- if(right > width && _texWidth > width)
- {
- glTexCoord2i ( width , 0 ); glVertex2i ( width , 0 );
- glTexCoord2i ( width , bottom ); glVertex2i ( width , bottom );
- glTexCoord2i ( right , bottom ); glVertex2i ( right , bottom );
- glTexCoord2i ( right , 0 ); glVertex2i ( right , 0 );
- }
- if(bottom>height && _texHeight > height)
- {
- glTexCoord2i ( 0 , height ); glVertex2i ( 0 , height );
- glTexCoord2i ( 0 , bottom ); glVertex2i ( 0 , bottom );
- glTexCoord2i ( width , bottom ); glVertex2i ( width , bottom );
- glTexCoord2i ( width , height ); glVertex2i ( width , height );
- }
- glEnd();
- glFlush();
- }
-
-}
-
-void GLTexImage::DrawMargin(int right, int bottom)
-{
- glBegin(GL_QUADS);
- if(right > _drawWidth)
- {
- glTexCoord2i ( _drawWidth , 0 ); glVertex2i ( _drawWidth , 0 );
- glTexCoord2i ( _drawWidth , bottom ); glVertex2i ( _drawWidth , bottom );
- glTexCoord2i ( right , bottom ); glVertex2i ( right , bottom );
- glTexCoord2i ( right , 0 ); glVertex2i ( right , 0 );
- }
- if(bottom>_drawHeight)
- {
- glTexCoord2i ( 0 , _drawHeight ); glVertex2i ( 0 , _drawHeight );
- glTexCoord2i ( 0 , bottom ); glVertex2i ( 0 , bottom );
- glTexCoord2i ( _drawWidth , bottom ); glVertex2i ( _drawWidth , bottom );
- glTexCoord2i ( _drawWidth , _drawHeight ); glVertex2i ( _drawWidth , _drawHeight );
- }
- glEnd();
- glFlush();
-
-
-}
-
-
-void GLTexImage::DrawQuadMT4()
-{
- int w = _drawWidth, h = _drawHeight;
- glBegin (GL_QUADS);
- glMultiTexCoord2i( GL_TEXTURE0, 0 , 0 );
- glMultiTexCoord2i( GL_TEXTURE1, -1 , 0 );
- glMultiTexCoord2i( GL_TEXTURE2, 1 , 0 );
- glMultiTexCoord2i( GL_TEXTURE3, 0 , -1 );
- glMultiTexCoord2i( GL_TEXTURE4, 0 , 1 );
- glVertex2i ( 0 , 0 );
-
- glMultiTexCoord2i( GL_TEXTURE0, 0 , h );
- glMultiTexCoord2i( GL_TEXTURE1, -1 , h );
- glMultiTexCoord2i( GL_TEXTURE2, 1 , h );
- glMultiTexCoord2i( GL_TEXTURE3, 0 , h -1 );
- glMultiTexCoord2i( GL_TEXTURE4, 0 , h +1 );
- glVertex2i ( 0 , h );
-
-
- glMultiTexCoord2i( GL_TEXTURE0, w , h );
- glMultiTexCoord2i( GL_TEXTURE1, w-1 , h );
- glMultiTexCoord2i( GL_TEXTURE2, w+1 , h );
- glMultiTexCoord2i( GL_TEXTURE3, w , h-1 );
- glMultiTexCoord2i( GL_TEXTURE4, w , h+1 );
- glVertex2i ( w , h );
-
- glMultiTexCoord2i( GL_TEXTURE0, w , 0 );
- glMultiTexCoord2i( GL_TEXTURE1, w-1 , 0 );
- glMultiTexCoord2i( GL_TEXTURE2, w+1 , 0 );
- glMultiTexCoord2i( GL_TEXTURE3, w , -1 );
- glMultiTexCoord2i( GL_TEXTURE4, w , 1 );
- glVertex2i ( w , 0 );
- glEnd ();
- glFlush();
-}
-
-
-void GLTexImage::DrawQuadMT8()
-{
- int w = _drawWidth;
- int h = _drawHeight;
- glBegin (GL_QUADS);
- glMultiTexCoord2i( GL_TEXTURE0, 0 , 0 );
- glMultiTexCoord2i( GL_TEXTURE1, -1 , 0 );
- glMultiTexCoord2i( GL_TEXTURE2, 1 , 0 );
- glMultiTexCoord2i( GL_TEXTURE3, 0 , -1 );
- glMultiTexCoord2i( GL_TEXTURE4, 0 , 1 );
- glMultiTexCoord2i( GL_TEXTURE5, -1 , -1 );
- glMultiTexCoord2i( GL_TEXTURE6, -1 , 1 );
- glMultiTexCoord2i( GL_TEXTURE7, 1 , -1 );
- glVertex2i ( 0 , 0 );
-
- glMultiTexCoord2i( GL_TEXTURE0, 0 , h );
- glMultiTexCoord2i( GL_TEXTURE1, -1 , h );
- glMultiTexCoord2i( GL_TEXTURE2, 1 , h );
- glMultiTexCoord2i( GL_TEXTURE3, 0 , h -1 );
- glMultiTexCoord2i( GL_TEXTURE4, 0 , h +1 );
- glMultiTexCoord2i( GL_TEXTURE5, -1 , h -1 );
- glMultiTexCoord2i( GL_TEXTURE6, -1 , h +1 );
- glMultiTexCoord2i( GL_TEXTURE7, 1 , h -1 );
- glVertex2i ( 0 , h );
-
-
- glMultiTexCoord2i( GL_TEXTURE0, w , h );
- glMultiTexCoord2i( GL_TEXTURE1, w-1 , h );
- glMultiTexCoord2i( GL_TEXTURE2, w+1 , h );
- glMultiTexCoord2i( GL_TEXTURE3, w , h -1 );
- glMultiTexCoord2i( GL_TEXTURE4, w , h +1 );
- glMultiTexCoord2i( GL_TEXTURE5, w-1 , h -1 );
- glMultiTexCoord2i( GL_TEXTURE6, w-1 , h +1 );
- glMultiTexCoord2i( GL_TEXTURE7, w+1 , h -1 );
- glVertex2i ( w , h );
-
- glMultiTexCoord2i( GL_TEXTURE0, w , 0 );
- glMultiTexCoord2i( GL_TEXTURE1, w-1 , 0 );
- glMultiTexCoord2i( GL_TEXTURE2, w+1 , 0 );
- glMultiTexCoord2i( GL_TEXTURE3, w , -1 );
- glMultiTexCoord2i( GL_TEXTURE4, w , 1 );
- glMultiTexCoord2i( GL_TEXTURE5, w-1 , -1 );
- glMultiTexCoord2i( GL_TEXTURE6, w-1 , 1 );
- glMultiTexCoord2i( GL_TEXTURE7, w+1 , -1 );
- glVertex2i ( w , 0 );
- glEnd ();
- glFlush();
-}
-
-
-
-
-void GLTexImage::DrawImage()
-{
- DrawQuad();
-}
-
-
-
-void GLTexImage::FitTexViewPort()
-{
- GlobalUtil::FitViewPort(_drawWidth, _drawHeight);
-}
-
-void GLTexImage::FitRealTexViewPort()
-{
- GlobalUtil::FitViewPort(_texWidth, _texHeight);
-}
-
-void GLTexImage::AttachToFBO(int i)
-{
- glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, i+GL_COLOR_ATTACHMENT0_EXT, _texTarget, _texID, 0 );
-}
-
-void GLTexImage::DetachFBO(int i)
-{
- glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, i+GL_COLOR_ATTACHMENT0_EXT, _texTarget, 0, 0 );
-}
-
-
-void GLTexImage::DrawQuad(float x1, float x2, float y1, float y2)
-{
-
- glBegin (GL_QUADS);
- glTexCoord2f ( x1 , y1 ); glVertex2f ( x1 , y1 );
- glTexCoord2f ( x1 , y2 ); glVertex2f ( x1 , y2 );
- glTexCoord2f ( x2 , y2 ); glVertex2f ( x2 , y2 );
- glTexCoord2f ( x2 , y1 ); glVertex2f ( x2 , y1 );
- glEnd ();
- glFlush();
-}
-
-void GLTexImage::TexConvertRGB()
-{
- //change 3/22/09
- FrameBufferObject fbo;
- //GlobalUtil::FitViewPort(1, 1);
- FitTexViewPort();
-
- AttachToFBO(0);
- ShaderMan::UseShaderRGB2Gray();
- glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
- DrawQuad();
- ShaderMan::UnloadProgram();
- DetachFBO(0);
-}
-
-void GLTexImage::DrawQuadDS(int scale)
-{
- DrawScaledQuad(float(scale));
-}
-
-void GLTexImage::DrawQuadUS(int scale)
-{
- DrawScaledQuad(1.0f/scale);
-}
-
-void GLTexImage::DrawScaledQuad(float texscale)
-{
-
- ////the texture coordinate for 0.5 is to + 0.5*texscale
- float to = 0.5f -0.5f * texscale;
- float tx = _imgWidth*texscale +to;
- float ty = _imgHeight*texscale +to;
- glBegin (GL_QUADS);
- glTexCoord2f ( to , to ); glVertex2i ( 0 , 0 );
- glTexCoord2f ( to , ty ); glVertex2i ( 0 , _imgHeight );
- glTexCoord2f ( tx , ty ); glVertex2i ( _imgWidth , _imgHeight );
- glTexCoord2f ( tx , to ); glVertex2i ( _imgWidth , 0 );
- glEnd ();
- glFlush();
-}
-
-
-void GLTexImage::DrawQuadReduction(int w , int h)
-{
- float to = -0.5f;
- float tx = w*2 +to;
- float ty = h*2 +to;
- glBegin (GL_QUADS);
- glMultiTexCoord2f ( GL_TEXTURE0, to , to );
- glMultiTexCoord2f ( GL_TEXTURE1, to +1, to );
- glMultiTexCoord2f ( GL_TEXTURE2, to , to+1 );
- glMultiTexCoord2f ( GL_TEXTURE3, to +1, to+1 );
- glVertex2i ( 0 , 0 );
-
- glMultiTexCoord2f ( GL_TEXTURE0, to , ty );
- glMultiTexCoord2f ( GL_TEXTURE1, to +1, ty );
- glMultiTexCoord2f ( GL_TEXTURE2, to , ty +1 );
- glMultiTexCoord2f ( GL_TEXTURE3, to +1, ty +1 );
- glVertex2i ( 0 , h );
-
- glMultiTexCoord2f ( GL_TEXTURE0, tx , ty );
- glMultiTexCoord2f ( GL_TEXTURE1, tx +1, ty );
- glMultiTexCoord2f ( GL_TEXTURE2, tx , ty +1);
- glMultiTexCoord2f ( GL_TEXTURE3, tx +1, ty +1);
-
- glVertex2i ( w , h );
-
- glMultiTexCoord2f ( GL_TEXTURE0, tx , to );
- glMultiTexCoord2f ( GL_TEXTURE1, tx +1, to );
- glMultiTexCoord2f ( GL_TEXTURE2, tx , to +1 );
- glMultiTexCoord2f ( GL_TEXTURE3, tx +1, to +1 );
- glVertex2i ( w , 0 );
- glEnd ();
-
- glFlush();
-}
-
-
-void GLTexImage::DrawQuadReduction()
-{
- float to = -0.5f;
- float tx = _drawWidth*2 +to;
- float ty = _drawHeight*2 +to;
- glBegin (GL_QUADS);
- glMultiTexCoord2f ( GL_TEXTURE0, to , to );
- glMultiTexCoord2f ( GL_TEXTURE1, to +1, to );
- glMultiTexCoord2f ( GL_TEXTURE2, to , to+1 );
- glMultiTexCoord2f ( GL_TEXTURE3, to +1, to+1 );
- glVertex2i ( 0 , 0 );
-
- glMultiTexCoord2f ( GL_TEXTURE0, to , ty );
- glMultiTexCoord2f ( GL_TEXTURE1, to +1, ty );
- glMultiTexCoord2f ( GL_TEXTURE2, to , ty +1 );
- glMultiTexCoord2f ( GL_TEXTURE3, to +1, ty +1 );
- glVertex2i ( 0 , _drawHeight );
-
- glMultiTexCoord2f ( GL_TEXTURE0, tx , ty );
- glMultiTexCoord2f ( GL_TEXTURE1, tx +1, ty );
- glMultiTexCoord2f ( GL_TEXTURE2, tx , ty +1);
- glMultiTexCoord2f ( GL_TEXTURE3, tx +1, ty +1);
-
- glVertex2i ( _drawWidth , _drawHeight );
-
- glMultiTexCoord2f ( GL_TEXTURE0, tx , to );
- glMultiTexCoord2f ( GL_TEXTURE1, tx +1, to );
- glMultiTexCoord2f ( GL_TEXTURE2, tx , to +1 );
- glMultiTexCoord2f ( GL_TEXTURE3, tx +1, to +1 );
- glVertex2i ( _drawWidth , 0 );
- glEnd ();
-
- glFlush();
-}
-
-void GLTexPacked::TexConvertRGB()
-{
- //update the actual size of daw area
- _drawWidth = (1 + _imgWidth) >> 1;
- _drawHeight = (1 + _imgHeight) >> 1;
- ///
- FrameBufferObject fbo;
- GLuint oldTexID = _texID;
- glGenTextures(1, &_texID);
- glBindTexture(_texTarget, _texID);
- glTexImage2D(_texTarget, 0, _iTexFormat, _texWidth, _texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
-
- //input
- glBindTexture(_texTarget, oldTexID);
- //output
- AttachToFBO(0);
- //program
- ShaderMan::UseShaderRGB2Gray();
- //draw buffer
- glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
- //run
- DrawQuadDS(2);
- ShaderMan::UnloadProgram();
-
- glDeleteTextures(1, &oldTexID);
- DetachFBO(0);
-}
-
-
-void GLTexPacked::SetImageSize( int width, int height)
-{
- _imgWidth = width; _drawWidth = (width + 1) >> 1;
- _imgHeight = height; _drawHeight = (height + 1) >> 1;
-}
-
-void GLTexPacked::InitTexture( int width, int height, int clamp_to_edge)
-{
-
- if(_texID && width == _imgWidth && height == _imgHeight ) return;
- if(_texID==0) glGenTextures(1, &_texID);
-
- _imgWidth = width;
- _imgHeight = height;
- if(GlobalUtil::_PreciseBorder)
- {
- _texWidth = (width + 2) >> 1;
- _texHeight = (height + 2) >> 1;
- }else
- {
- _texWidth = (width + 1) >> 1;
- _texHeight = (height + 1) >> 1;
- }
- _drawWidth = (width + 1) >> 1;
- _drawHeight = (height + 1) >> 1;
-
- BindTex();
-
- if(clamp_to_edge)
- {
- glTexParameteri (_texTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri (_texTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- }else
- {
- //out of bound tex read returns 0??
- glTexParameteri (_texTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
- glTexParameteri (_texTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
- }
- glTexParameteri(_texTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(_texTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-
- glTexImage2D(_texTarget, 0, _iTexFormat,
- _texWidth, _texHeight, 0, GL_RGBA, GL_FLOAT, NULL);
-
- UnbindTex();
-
-}
-
-
-void GLTexPacked::DrawImage()
-{
- float x1 =0, y1 = 0; //border..
- float x2 = _imgWidth*0.5f +x1;
- float y2 = _imgHeight*0.5f + y1;
- glBegin (GL_QUADS);
- glTexCoord2f ( x1 , y1 ); glVertex2i ( 0 , 0 );
- glTexCoord2f ( x1 , y2 ); glVertex2i ( 0 , _imgHeight );
- glTexCoord2f ( x2 , y2 ); glVertex2i ( _imgWidth , _imgHeight );
- glTexCoord2f ( x2 , y1 ); glVertex2i ( _imgWidth , 0 );
- glEnd ();
- glFlush();
-}
-
-void GLTexPacked::DrawQuadUS(int scale)
-{
- int tw =_drawWidth, th = _drawHeight;
- float texscale = 1.0f / scale;
- float x1 = 0.5f - 0.5f*scale, y1 = x1;
- float x2 = tw * texscale + x1;
- float y2 = th * texscale + y1;
- float step = texscale *0.5f;
- glBegin (GL_QUADS);
- glMultiTexCoord2f( GL_TEXTURE0, x1 , y1 );
- glMultiTexCoord2f( GL_TEXTURE1, x1+step , y1 );
- glMultiTexCoord2f( GL_TEXTURE2, x1 , y1 +step);
- glMultiTexCoord2f( GL_TEXTURE3, x1+step , y1 +step);
- glVertex2i ( 0 , 0 );
-
- glMultiTexCoord2f( GL_TEXTURE0, x1 , y2 );
- glMultiTexCoord2f( GL_TEXTURE1, x1+step , y2 );
- glMultiTexCoord2f( GL_TEXTURE2, x1 , y2 +step);
- glMultiTexCoord2f( GL_TEXTURE3, x1+step , y2 +step);
- glVertex2i ( 0 , th );
-
- glMultiTexCoord2f( GL_TEXTURE0, x2 , y2 );
- glMultiTexCoord2f( GL_TEXTURE1, x2+step , y2 );
- glMultiTexCoord2f( GL_TEXTURE2, x2 , y2 +step);
- glMultiTexCoord2f( GL_TEXTURE3, x2+step , y2 +step);
- glVertex2i ( tw , th );
-
- glMultiTexCoord2f( GL_TEXTURE0, x2 , y1 );
- glMultiTexCoord2f( GL_TEXTURE1, x2+step , y1 );
- glMultiTexCoord2f( GL_TEXTURE2, x2 , y1 +step);
- glMultiTexCoord2f( GL_TEXTURE3, x2+step , y1 +step);
- glVertex2i ( tw , 0 );
- glEnd ();
-}
-
-void GLTexPacked::DrawQuadDS(int scale)
-{
- int tw = _drawWidth;
- int th = _drawHeight;
- float x1 = 0.5f - 0.5f*scale;
- float x2 = tw * scale + x1;
- float y1 = 0.5f - 0.5f * scale;
- float y2 = th * scale + y1;
- int step = scale / 2;
-
- glBegin (GL_QUADS);
- glMultiTexCoord2f( GL_TEXTURE0, x1 , y1 );
- glMultiTexCoord2f( GL_TEXTURE1, x1+step , y1 );
- glMultiTexCoord2f( GL_TEXTURE2, x1 , y1 +step);
- glMultiTexCoord2f( GL_TEXTURE3, x1+step , y1 +step);
- glVertex2i ( 0 , 0 );
-
- glMultiTexCoord2f( GL_TEXTURE0, x1 , y2 );
- glMultiTexCoord2f( GL_TEXTURE1, x1+step , y2 );
- glMultiTexCoord2f( GL_TEXTURE2, x1 , y2 +step);
- glMultiTexCoord2f( GL_TEXTURE3, x1+step , y2 +step);
- glVertex2i ( 0 , th );
-
- glMultiTexCoord2f( GL_TEXTURE0, x2 , y2 );
- glMultiTexCoord2f( GL_TEXTURE1, x2+step , y2 );
- glMultiTexCoord2f( GL_TEXTURE2, x2 , y2 +step);
- glMultiTexCoord2f( GL_TEXTURE3, x2+step , y2 +step);
- glVertex2i ( tw , th );
-
- glMultiTexCoord2f( GL_TEXTURE0, x2 , y1 );
- glMultiTexCoord2f( GL_TEXTURE1, x2+step , y1 );
- glMultiTexCoord2f( GL_TEXTURE2, x2 , y1 +step);
- glMultiTexCoord2f( GL_TEXTURE3, x2+step , y1 +step);
- glVertex2i ( tw , 0 );
- glEnd ();
-}
-
-void GLTexPacked::ZeroHistoMargin()
-{
- int marginx = (((_imgWidth + 3) /4)*4) - _imgWidth;
- int marginy = (((-_imgHeight + 3)/4)*4) - _imgHeight;
- if(marginx >0 || marginy > 0)
- {
- int tw = (_imgWidth + marginx ) >> 1;
- int th = (_imgHeight + marginy ) >> 1;
- tw = min(_texWidth, tw );
- th = min(_texHeight, th);
- GlobalUtil::FitViewPort(tw, th);
- AttachToFBO(0);
- BindTex();
- ShaderMan::UseShaderZeroPass();
- DrawMargin(tw, th, 1, 1);
- }
-}
-
-
-void GLTexPacked::FillMargin(int marginx, int marginy)
-{
- //
- marginx = min(marginx, _texWidth * 2 - _imgWidth);
- marginy = min(marginy, _texHeight * 2 - _imgHeight);
- if(marginx >0 || marginy > 0)
- {
- int tw = (_imgWidth + marginx + 1) >> 1;
- int th = (_imgHeight + marginy + 1) >> 1;
- GlobalUtil::FitViewPort(tw, th);
- BindTex();
- AttachToFBO(0);
- ShaderMan::UseShaderMarginCopy(_imgWidth , _imgHeight);
- DrawMargin(tw, th, marginx, marginy);
- }
-}
-void GLTexPacked::DrawMargin(int right, int bottom, int mx, int my)
-{
- int tw = (_imgWidth >>1);
- int th = (_imgHeight >>1);
- glBegin(GL_QUADS);
- if(right>tw && mx)
- {
- glTexCoord2i ( tw , 0 ); glVertex2i ( tw , 0 );
- glTexCoord2i ( tw , bottom ); glVertex2i ( tw , bottom );
- glTexCoord2i ( right, bottom ); glVertex2i ( right, bottom );
- glTexCoord2i ( right, 0 ); glVertex2i ( right, 0 );
- }
- if(bottom>th && my)
- {
- glTexCoord2i ( 0 , th ); glVertex2i ( 0 , th );
- glTexCoord2i ( 0 , bottom ); glVertex2i ( 0 , bottom );
- glTexCoord2i ( tw , bottom ); glVertex2i ( tw , bottom );
- glTexCoord2i ( tw , th ); glVertex2i ( tw , th );
- }
- glEnd();
- glFlush();
-
-}
-
-
-void GLTexImage::UnbindMultiTex(int n)
-{
- for(int i = n-1; i>=0; i--)
- {
- glActiveTexture(GL_TEXTURE0+i);
- glBindTexture(_texTarget, 0);
- }
-}
-
-template int
-
-#if !defined(_MSC_VER) || _MSC_VER > 1200
-GLTexInput::
-#endif
-
-DownSamplePixelDataI(unsigned int gl_format, int width, int height, int ds,
- const Uint * pin, Uint * pout)
-{
- int step, linestep;
- int i, j;
- int ws = width/ds;
- int hs = height/ds;
- const Uint * line = pin, * p;
- Uint *po = pout;
- switch(gl_format)
- {
- case GL_LUMINANCE:
- case GL_LUMINANCE_ALPHA:
- step = ds * (gl_format == GL_LUMINANCE? 1: 2);
- linestep = width * step;
- for(i = 0 ; i < hs; i++, line+=linestep)
- {
- for(j = 0, p = line; j < ws; j++, p+=step)
- {
- *po++ = *p;
- }
- }
- break;
- case GL_RGB:
- case GL_RGBA:
- step = ds * (gl_format == GL_RGB? 3: 4);
- linestep = width * step;
-
- for(i = 0 ; i < hs; i++, line+=linestep)
- {
- for(j = 0, p = line; j < ws; j++, p+=step)
- {
- //*po++ = int(p[0]*0.299 + p[1] * 0.587 + p[2]* 0.114 + 0.5);
- *po++ = ((19595*p[0] + 38470*p[1] + 7471*p[2]+ 32768)>>16);
- }
- }
- break;
- case GL_BGR:
- case GL_BGRA:
- step = ds * (gl_format == GL_BGR? 3: 4);
- linestep = width * step;
- for(i = 0 ; i < hs; i++, line+=linestep)
- {
- for(j = 0, p = line; j < ws; j++, p+=step)
- {
- *po++ = ((7471*p[0] + 38470*p[1] + 19595*p[2]+ 32768)>>16);
- }
- }
- break;
- default:
- return 0;
- }
-
- return 1;
-
-}
-
-
-template int
-
-#if !defined(_MSC_VER) || _MSC_VER > 1200
-GLTexInput::
-#endif
-
-DownSamplePixelDataI2F(unsigned int gl_format, int width, int height, int ds,
- const Uint * pin, float * pout, int skip)
-{
- int step, linestep;
- int i, j;
- int ws = width/ds - skip;
- int hs = height/ds;
- const Uint * line = pin, * p;
- float *po = pout;
- const float factor = (sizeof(Uint) == 1? 255.0f : 65535.0f);
- switch(gl_format)
- {
- case GL_LUMINANCE:
- case GL_LUMINANCE_ALPHA:
- step = ds * (gl_format == GL_LUMINANCE? 1: 2);
- linestep = width * step;
- for(i = 0 ; i < hs; i++, line+=linestep)
- {
- for(j = 0, p = line; j < ws; j++, p+=step)
- {
- *po++ = (*p) / factor;
- }
- }
- break;
- case GL_RGB:
- case GL_RGBA:
- step = ds * (gl_format == GL_RGB? 3: 4);
- linestep = width * step;
-
- for(i = 0 ; i < hs; i++, line+=linestep)
- {
- for(j = 0, p = line; j < ws; j++, p+=step)
- {
- //*po++ = int(p[0]*0.299 + p[1] * 0.587 + p[2]* 0.114 + 0.5);
- *po++ = ((19595*p[0] + 38470*p[1] + 7471*p[2]) / (65535.0f * factor));
- }
- }
- break;
- case GL_BGR:
- case GL_BGRA:
- step = ds * (gl_format == GL_BGR? 3: 4);
- linestep = width * step;
- for(i = 0 ; i < hs; i++, line+=linestep)
- {
- for(j = 0, p = line; j < ws; j++, p+=step)
- {
- *po++ = ((7471*p[0] + 38470*p[1] + 19595*p[2]) / (65535.0f * factor));
- }
- }
- break;
- default:
- return 0;
- }
- return 1;
-}
-
-int GLTexInput::DownSamplePixelDataF(unsigned int gl_format, int width, int height, int ds, const float * pin, float * pout, int skip)
-{
- int step, linestep;
- int i, j;
- int ws = width/ds - skip;
- int hs = height/ds;
- const float * line = pin, * p;
- float *po = pout;
- switch(gl_format)
- {
- case GL_LUMINANCE:
- case GL_LUMINANCE_ALPHA:
- step = ds * (gl_format == GL_LUMINANCE? 1: 2);
- linestep = width * step;
- for(i = 0 ; i < hs; i++, line+=linestep)
- {
- for(j = 0, p = line; j < ws; j++, p+=step)
- {
- *po++ = *p;
- }
- }
- break;
- case GL_RGB:
- case GL_RGBA:
- step = ds * (gl_format == GL_RGB? 3: 4);
- linestep = width * step;
- for(i = 0 ; i < hs; i++, line+=linestep)
- {
- for(j = 0, p = line; j < ws; j++, p+=step)
- {
- *po++ = (0.299f*p[0] + 0.587f*p[1] + 0.114f*p[2]);
- }
- }
- break;
- case GL_BGR:
- case GL_BGRA:
- step = ds * (gl_format == GL_BGR? 3: 4);
- linestep = width * step;
- for(i = 0 ; i < hs; i++, line+=linestep)
- {
- for(j = 0, p = line; j < ws; j++, p+=step)
- {
- *po++ = (0.114f*p[0] + 0.587f*p[1] + 0.299f * p[2]);
- }
- }
- break;
- default:
- return 0;
- }
-
- return 1;
-
-}
-
-int GLTexInput::SetImageData( int width, int height, const void * data,
- unsigned int gl_format, unsigned int gl_type )
-{
- int simple_format = IsSimpleGlFormat(gl_format, gl_type);//no cpu code to handle other formats
- int ws, hs, done = 1;
-
- if(_converted_data) {delete [] _converted_data; _converted_data = NULL; }
-
- _rgb_converted = 1;
- _data_modified = 0;
-
- if( simple_format
- && ( width > _texMaxDim || height > _texMaxDim || GlobalUtil::_PreProcessOnCPU)
- && GlobalUtil::_octave_min_default >0 )
- {
- _down_sampled = GlobalUtil::_octave_min_default;
- ws = width >> GlobalUtil::_octave_min_default;
- hs = height >> GlobalUtil::_octave_min_default;
- }else
- {
- _down_sampled = 0;
- ws = width;
- hs = height;
- }
-
- if ( ws > _texMaxDim || hs > _texMaxDim)
- {
- if(simple_format)
- {
- if(GlobalUtil::_verbose) std::cout<<"Automatic down-sampling is used\n";
- do
- {
- _down_sampled ++;
- ws >>= 1;
- hs >>= 1;
- }while(ws > _texMaxDim || hs > _texMaxDim);
- }else
- {
- std::cerr<<"Input images is too big to fit into a texture\n";
- return 0;
- }
- }
-
- _texWidth = _imgWidth = _drawWidth = ws;
- _texHeight = _imgHeight = _drawHeight = hs;
-
- if(GlobalUtil::_verbose)
- {
- std::cout<<"Image size :\t"<0) std::cout<<"Down sample to \t"< 0 || gl_format != GL_LUMINANCE || gl_type != GL_FLOAT)
- {
- _converted_data = new float [_imgWidth * _imgHeight];
- if(gl_type == GL_UNSIGNED_BYTE)
- DownSamplePixelDataI2F(gl_format, width, height, 1<<_down_sampled,
- ((const unsigned char*) data), _converted_data, skip);
- else if(gl_type == GL_UNSIGNED_SHORT)
- DownSamplePixelDataI2F(gl_format, width, height, 1<<_down_sampled,
- ((const unsigned short*) data), _converted_data, skip);
- else
- DownSamplePixelDataF(gl_format, width, height, 1<<_down_sampled, (float*)data, _converted_data, skip);
- _rgb_converted = 2; //indidates a new data copy
- _pixel_data = _converted_data;
- }else
- {
- //Luminance data that doesn't need to down sample
- _rgb_converted = 1;
- _pixel_data = data;
- if(skip > 0)
- {
- for(int i = 1; i < _imgHeight; ++i)
- {
- float * dst = ((float*)data) + i * tWidth, * src = ((float*)data) + i * _imgWidth;
- for(int j = 0; j < tWidth; ++j) *dst++ = * src++;
- }
- }
- }
- _texWidth = _imgWidth = _drawWidth = tWidth;
- _data_modified = 1;
- }else
- {
- if(_texID ==0) glGenTextures(1, &_texID);
- glBindTexture(_texTarget, _texID);
- CheckErrorsGL("glBindTexture");
- glTexParameteri (_texTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri (_texTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glPixelStorei(GL_UNPACK_ALIGNMENT , 1);
-
- if(simple_format && ( _down_sampled> 0 || (gl_format != GL_LUMINANCE && GlobalUtil::_PreProcessOnCPU) ))
- {
-
- if(gl_type == GL_UNSIGNED_BYTE)
- {
- unsigned char * newdata = new unsigned char [_imgWidth * _imgHeight];
- DownSamplePixelDataI(gl_format, width, height, 1<<_down_sampled, ((const unsigned char*) data), newdata);
- glTexImage2D(_texTarget, 0, GL_LUMINANCE32F_ARB, //internal format changed
- _imgWidth, _imgHeight, 0,
- GL_LUMINANCE, GL_UNSIGNED_BYTE, newdata);
- delete[] newdata;
- }else if(gl_type == GL_UNSIGNED_SHORT)
- {
- unsigned short * newdata = new unsigned short [_imgWidth * _imgHeight];
- DownSamplePixelDataI(gl_format, width, height, 1<<_down_sampled, ((const unsigned short*) data), newdata);
-
- glTexImage2D(_texTarget, 0, GL_LUMINANCE32F_ARB, //internal format changed
- _imgWidth, _imgHeight, 0,
- GL_LUMINANCE, GL_UNSIGNED_SHORT, newdata);
- delete[] newdata;
- }else if(gl_type == GL_FLOAT)
- {
- float * newdata = new float [_imgWidth * _imgHeight];
- DownSamplePixelDataF(gl_format, width, height, 1<<_down_sampled, (float*)data, newdata);
- glTexImage2D(_texTarget, 0, GL_LUMINANCE32F_ARB, //internal format changed
- _imgWidth, _imgHeight, 0,
- GL_LUMINANCE, GL_FLOAT, newdata);
- delete[] newdata;
- }else
- {
- //impossible
- done = 0;
- _rgb_converted = 0;
- }
- GlobalUtil::FitViewPort(1, 1); //this used to be necessary
- }else
- {
- //ds must be 0 here if not simpleformat
- if(gl_format == GL_LUMINANCE || gl_format == GL_LUMINANCE_ALPHA)
- {
- //use one channel internal format if data is intensity image
- glTexImage2D(_texTarget, 0, GL_LUMINANCE32F_ARB,
- _imgWidth, _imgHeight, 0, gl_format, gl_type, data);
- GlobalUtil::FitViewPort(1, 1); //this used to be necessary
- }
- else
- {
- //convert RGB 2 GRAY if needed
- glTexImage2D(_texTarget, 0, _iTexFormat, _imgWidth, _imgHeight, 0, gl_format, gl_type, data);
- if(ShaderMan::HaveShaderMan())
- TexConvertRGB();
- else
- _rgb_converted = 0; //In CUDA mode, the conversion will be done by CUDA kernel
- }
- }
- UnbindTex();
- }
- return done;
-}
-
-
-GLTexInput::~GLTexInput()
-{
- if(_converted_data) delete [] _converted_data;
-}
-
-
-int GLTexInput::LoadImageFile(char *imagepath, int &w, int &h )
-{
-#ifndef SIFTGPU_NO_DEVIL
- static int devil_loaded = 0;
- unsigned int imID;
- int done = 1;
-
- if(devil_loaded == 0)
- {
- ilInit();
- ilOriginFunc(IL_ORIGIN_UPPER_LEFT);
- ilEnable(IL_ORIGIN_SET);
- devil_loaded = 1;
- }
-
- ///
- ilGenImages(1, &imID);
- ilBindImage(imID);
-
- if(ilLoadImage(imagepath))
- {
- w = ilGetInteger(IL_IMAGE_WIDTH);
- h = ilGetInteger(IL_IMAGE_HEIGHT);
- int ilformat = ilGetInteger(IL_IMAGE_FORMAT);
-
- if(SetImageData(w, h, ilGetData(), ilformat, GL_UNSIGNED_BYTE)==0)
- {
- done =0;
- }else if(GlobalUtil::_verbose)
- {
- std::cout<<"Image loaded :\t"< 255 || width < 0 || height < 0)
- {
- fclose(file);
- std::cerr << "ERROR: fileformat not supported\n";
- return 0;
- }else
- {
- w = width;
- h = height;
- }
- unsigned char * data = new unsigned char[width * height];
- unsigned char * pixels = data;
- if (strcmp(buf, "P5")==0 )
- {
- fscanf(file, "%c",buf);//skip one byte
- fread(pixels, 1, width*height, file);
- }else if (strcmp(buf, "P2")==0 )
- {
- for (int i = 0 ; i< height; i++)
- {
- for ( int j = 0; j < width; j++)
- {
- fscanf(file, "%d", &g);
- *pixels++ = (unsigned char) g;
- }
- }
- }else if (strcmp(buf, "P6")==0 )
- {
- fscanf(file, "%c", buf);//skip one byte
- int j, num = height*width;
- unsigned char buf[3];
- for ( j =0 ; j< num; j++)
- {
- fread(buf,1,3, file);
- *pixels++=int(0.10454f* buf[2]+0.60581f* buf[1]+0.28965f* buf[0]);
- }
- }else if (strcmp(buf, "P3")==0 )
- {
- int r, g, b;
- int i , num =height*width;
- for ( i = 0 ; i< num; i++)
- {
- fscanf(file, "%d %d %d", &r, &g, &b);
- *pixels++ = int(0.10454f* b+0.60581f* g+0.28965f* r);
- }
-
- }else
- {
- std::cerr << "ERROR: fileformat not supported\n";
- done = 0;
- }
- if(done) SetImageData(width, height, data, GL_LUMINANCE, GL_UNSIGNED_BYTE);
- fclose(file);
- delete data;
- if(GlobalUtil::_verbose && done) std::cout<< "Image loaded :\t" << imagepath << "\n";
- return 1;
-#endif
-}
-
-int GLTexImage::CopyToPBO(GLuint pbo, int width, int height, GLenum format)
-{
- /////////
- if(format != GL_RGBA && format != GL_LUMINANCE) return 0;
-
- FrameBufferObject fbo;
- GLint bsize, esize = width * height * sizeof(float) * (format == GL_RGBA ? 4 : 1);
- AttachToFBO(0);
- glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, pbo);
- glGetBufferParameteriv(GL_PIXEL_PACK_BUFFER_ARB, GL_BUFFER_SIZE, &bsize);
- if(bsize < esize)
- {
- glBufferData(GL_PIXEL_PACK_BUFFER_ARB, esize, NULL, GL_STATIC_DRAW_ARB);
- glGetBufferParameteriv(GL_PIXEL_PACK_BUFFER_ARB, GL_BUFFER_SIZE, &bsize);
- }
- if(bsize >= esize)
- {
- glReadPixels(0, 0, width, height, format, GL_FLOAT, 0);
- }
- glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0);
- DetachFBO(0);
-
- return bsize >= esize;
-}
-
-void GLTexImage::SaveToASCII(const char* path)
-{
- vector buf(GetImgWidth() * GetImgHeight() * 4);
- FrameBufferObject fbo;
- AttachToFBO(0);
- glReadPixels(0, 0, GetImgWidth(), GetImgHeight(), GL_RGBA, GL_FLOAT, &buf[0]);
- ofstream out(path);
-
- for(int i = 0, idx = 0; i < GetImgHeight(); ++i)
- {
- for(int j = 0; j < GetImgWidth(); ++j, idx += 4)
- {
- out << i << " " << j << " " << buf[idx] << " " << buf[idx + 1] << " "
- << buf[idx + 2] << " " << buf[idx + 3] << "\n";
- }
- }
-}
-
-
-void GLTexInput::VerifyTexture()
-{
- //for CUDA or OpenCL the texture is not generated by default
- if(!_data_modified) return;
- if(_pixel_data== NULL) return;
- InitTexture(_imgWidth, _imgHeight);
- BindTex();
- glTexImage2D( _texTarget, 0, GL_LUMINANCE32F_ARB, //internal format changed
- _imgWidth, _imgHeight, 0,
- GL_LUMINANCE, GL_FLOAT, _pixel_data);
- UnbindTex();
- _data_modified = 0;
-}
-
-void GLTexImage::CopyFromPBO(GLuint pbo, int width, int height, GLenum format)
-{
- InitTexture(max(width, _texWidth), max(height, _texHeight));
- SetImageSize(width, height);
- if(width > 0 && height > 0)
- {
- BindTex();
- glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, pbo);
- glTexSubImage2D(GlobalUtil::_texTarget, 0, 0, 0, width, height, format, GL_FLOAT, 0);
- GlobalUtil::CheckErrorsGL("GLTexImage::CopyFromPBO->glTexSubImage2D");
- glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
- UnbindTex();
- }
-}
-
diff --git a/3rdparty/SiftGPU/src/SiftGPU/GLTexImage.h b/3rdparty/SiftGPU/src/SiftGPU/GLTexImage.h
deleted file mode 100644
index 0862e7a9..00000000
--- a/3rdparty/SiftGPU/src/SiftGPU/GLTexImage.h
+++ /dev/null
@@ -1,158 +0,0 @@
-////////////////////////////////////////////////////////////////////////////
-// File: GLTexImage.h
-// Author: Changchang Wu
-// Description : interface for the GLTexImage class.
-// GLTexImage: naive texture class.
-// sevral different quad drawing functions are provied
-// GLTexPacked: packed version (four value packed as four channels of a pixel)
-// GLTexInput: GLTexImage + some input information
-//
-// Copyright (c) 2007 University of North Carolina at Chapel Hill
-// All Rights Reserved
-//
-// Permission to use, copy, modify and distribute this software and its
-// documentation for educational, research and non-profit purposes, without
-// fee, and without a written agreement is hereby granted, provided that the
-// above copyright notice and the following paragraph appear in all copies.
-//
-// The University of North Carolina at Chapel Hill make no representations
-// about the suitability of this software for any purpose. It is provided
-// 'as is' without express or implied warranty.
-//
-// Please send BUG REPORTS to ccwu@cs.unc.edu
-//
-////////////////////////////////////////////////////////////////////////////
-
-
-#ifndef GL_TEX_IMAGE_H
-#define GL_TEX_IMAGE_H
-
-class GlobalUtil;
-class GLTexImage :public GlobalUtil
-{
-protected:
- GLuint _texID;
- int _imgWidth;
- int _imgHeight;
- int _texWidth;
- int _texHeight;
- int _drawWidth;
- int _drawHeight;
-public:
- static void DetachFBO(int i);
- static void UnbindTex();
- static void UnbindMultiTex(int n);
- static void DrawQuad(float x1, float x2, float y1, float y2);
-
-public:
- virtual void DrawQuadUS(int scale);
- virtual void DrawQuadDS(int scale);
- virtual void DrawImage();
- virtual void TexConvertRGB();
- virtual void ZeroHistoMargin();
- virtual void SetImageSize(int width, int height);
- virtual void InitTexture(int width, int height, int clamp_to_edge =1 );
- void InitTexture(int width, int height, int clamp_to_edge, GLuint format);
- virtual void FillMargin(int marginx, int marginy);
-public:
- void DrawScaledQuad(float scale);
- int CopyToPBO(GLuint pbo, int width, int height, GLenum format = GL_RGBA);
- void CopyFromPBO(GLuint pbo, int width, int height, GLenum format = GL_RGBA);
- void FitRealTexViewPort();
- void DrawQuadMT8();
- void DrawQuadMT4();
- void DrawQuadReduction();
- void DrawQuadReduction(int w, int h);
- void DrawMargin(int right, int bottom);
- void DrawQuad();
- void FitTexViewPort();
- void ZeroHistoMargin(int hw, int hh);
- int CheckTexture();
- void SaveToASCII(const char* path);
-public:
- void AttachToFBO(int i );
- void BindTex();
- operator GLuint (){return _texID;}
- GLuint GetTexID(){return _texID;}
- int GetImgPixelCount(){return _imgWidth*_imgHeight;}
- int GetTexPixelCount(){return _texWidth*_texHeight;}
- int GetImgWidth(){return _imgWidth;}
- int GetImgHeight(){return _imgHeight;}
- int GetTexWidth(){return _texWidth;}
- int GetTexHeight(){return _texHeight;}
- int GetDrawWidth(){return _drawWidth;}
- int GetDrawHeight(){return _drawHeight;}
- //int IsTexTight(){return _texWidth == _drawWidth && _texHeight == _drawHeight;}
- int IsTexPacked(){return _drawWidth != _imgWidth;}
- GLTexImage();
- virtual ~GLTexImage();
- friend class SiftGPU;
-};
-
-//class for handle data input, to support all openGL-supported data format,
-//data are first uploaded to an openGL texture then converted, and optionally
-//when the datatype is simple, we downsample/convert on cpu
-class GLTexInput:public GLTexImage
-{
-public:
- int _down_sampled;
- int _rgb_converted;
- int _data_modified;
-
- //////////////////////////
- float * _converted_data;
- const void* _pixel_data;
-public:
- static int IsSimpleGlFormat(unsigned int gl_format, unsigned int gl_type)
- {
- //the formats there is a cpu code to conver rgb and downsample
- return (gl_format ==GL_LUMINANCE ||gl_format == GL_LUMINANCE_ALPHA||
- gl_format == GL_RGB|| gl_format == GL_RGBA||
- gl_format == GL_BGR || gl_format == GL_BGRA) &&
- (gl_type == GL_UNSIGNED_BYTE || gl_type == GL_FLOAT || gl_type == GL_UNSIGNED_SHORT);
- }
-//in vc6, template member function doesn't work
-#if !defined(_MSC_VER) || _MSC_VER > 1200
- template
- static int DownSamplePixelDataI(unsigned int gl_format, int width, int height,
- int ds, const Uint * pin, Uint * pout);
- template
- static int DownSamplePixelDataI2F(unsigned int gl_format, int width, int height,
- int ds, const Uint * pin, float * pout, int skip = 0);
-#endif
- static int DownSamplePixelDataF(unsigned int gl_format, int width, int height,
- int ds, const float * pin, float * pout, int skip = 0);
- static int TruncateWidthCU(int w) {return w & 0xfffffffc; }
-public:
- GLTexInput() : _down_sampled(0), _rgb_converted(0), _data_modified(0),
- _converted_data(0), _pixel_data(0){}
- int SetImageData(int width, int height, const void * data,
- unsigned int gl_format, unsigned int gl_type);
- int LoadImageFile(char * imagepath, int & w, int &h);
- void VerifyTexture();
- virtual ~GLTexInput();
-};
-
-//GLTexPacked doesn't have any data
-//so that we can use the GLTexImage* pointer to index a GLTexPacked Vector
-
-class GLTexPacked:public GLTexImage
-{
-public:
- virtual void DrawImage();
- virtual void DrawQuadUS(int scale);
- virtual void DrawQuadDS(int scale);
- virtual void FillMargin(int marginx, int marginy);
- virtual void InitTexture(int width, int height, int clamp_to_edge =1);
- virtual void TexConvertRGB();
- virtual void SetImageSize(int width, int height);
- virtual void ZeroHistoMargin();
- //virtual void GetHistWH(int& w, int& h){return w = (3 + sz)>>1;}
-public:
- void DrawMargin(int right, int bottom, int mx, int my);
- GLTexPacked():GLTexImage(){}
-};
-
-
-#endif // !defined(GL_TEX_IMAGE_H)
-
diff --git a/3rdparty/SiftGPU/src/SiftGPU/GlobalUtil.cpp b/3rdparty/SiftGPU/src/SiftGPU/GlobalUtil.cpp
deleted file mode 100644
index e068e18d..00000000
--- a/3rdparty/SiftGPU/src/SiftGPU/GlobalUtil.cpp
+++ /dev/null
@@ -1,519 +0,0 @@
-////////////////////////////////////////////////////////////////////////////
-// File: GlobalUtil.cpp
-// Author: Changchang Wu
-// Description : Global Utility class for SiftGPU
-//
-//
-//
-// Copyright (c) 2007 University of North Carolina at Chapel Hill
-// All Rights Reserved
-//
-// Permission to use, copy, modify and distribute this software and its
-// documentation for educational, research and non-profit purposes, without
-// fee, and without a written agreement is hereby granted, provided that the
-// above copyright notice and the following paragraph appear in all copies.
-//
-// The University of North Carolina at Chapel Hill make no representations
-// about the suitability of this software for any purpose. It is provided
-// 'as is' without express or implied warranty.
-//
-// Please send BUG REPORTS to ccwu@cs.unc.edu
-//
-////////////////////////////////////////////////////////////////////////////
-#include
-#include
-using std::cout;
-
-#include "GL/glew.h"
-#include "GlobalUtil.h"
-
-//for windows, the default timing uses timeGetTime, you can define TIMING_BY_CLOCK to use clock()
-//for other os, the timing uses gettimeofday
-
-
-#if defined(_WIN32)
- #if defined(TIMING_BY_CLOCK)
- #include
- #else
- #define WIN32_LEAN_AND_MEAN
- #include
- #include
- #endif
-#else
- #include
- #include
-#endif
-
-#include "LiteWindow.h"
-
-//
-int GlobalParam:: _verbose = 1;
-int GlobalParam:: _timingS = 1; //print out information of each step
-int GlobalParam:: _timingO = 0; //print out information of each octave
-int GlobalParam:: _timingL = 0; //print out information of each level
-GLuint GlobalParam:: _texTarget = GL_TEXTURE_RECTANGLE_ARB; //only this one is supported
-GLuint GlobalParam:: _iTexFormat =GL_RGBA32F_ARB; //or GL_RGBA16F_ARB
-int GlobalParam:: _debug = 0; //enable debug code?
-int GlobalParam:: _usePackedTex = 1;//packed implementation
-int GlobalParam:: _UseCUDA = 0;
-int GlobalParam:: _UseOpenCL = 0;
-int GlobalParam:: _MaxFilterWidth = -1; //maximum filter width, use when GPU is not good enough
-float GlobalParam:: _FilterWidthFactor = 4.0f; //the filter size will be _FilterWidthFactor*sigma*2+1
-float GlobalParam:: _DescriptorWindowFactor = 3.0f; //descriptor sampling window factor
-int GlobalParam:: _SubpixelLocalization = 1; //sub-pixel and sub-scale localization
-int GlobalParam:: _MaxOrientation = 2; //whether we find multiple orientations for each feature
-int GlobalParam:: _OrientationPack2 = 0; //use one float to store two orientations
-float GlobalParam:: _MaxFeaturePercent = 0.005f;//at most 0.005 of all pixels
-int GlobalParam:: _MaxLevelFeatureNum = 4096; //maximum number of features of a level
-int GlobalParam:: _FeatureTexBlock = 4; //feature texture storagte alignment
-int GlobalParam:: _NarrowFeatureTex = 0;
-
-//if _ForceTightPyramid is not 0, pyramid will be reallocated to fit the size of input images.
-//otherwise, pyramid can be reused for smaller input images.
-int GlobalParam:: _ForceTightPyramid = 0;
-
-//use gpu or cpu to generate feature list ...gpu is a little bit faster
-int GlobalParam:: _ListGenGPU = 1;
-int GlobalParam:: _ListGenSkipGPU = 6; //how many levels are skipped on gpu
-int GlobalParam:: _PreProcessOnCPU = 1; //convert rgb 2 intensity on gpu, down sample on GPU
-
-//hardware parameter, automatically retrieved
-int GlobalParam:: _texMaxDim = 3200; //Maximum working size for SiftGPU, 3200 for packed
-int GlobalParam:: _texMaxDimGL = 4096; //GPU texture limit
-int GlobalParam:: _texMinDim = 16; //
-int GlobalParam:: _MemCapGPU = 0;
-int GlobalParam:: _FitMemoryCap = 0;
-int GlobalParam:: _IsNvidia = 0; //GPU vendor
-int GlobalParam:: _KeepShaderLoop = 0;
-
-//you can't change the following 2 values
-//all other versions of code are now dropped
-int GlobalParam:: _DescriptorPPR = 8;
-int GlobalParam:: _DescriptorPPT = 16;
-
-//whether orientation/descriptor is supported by hardware
-int GlobalParam:: _SupportNVFloat = 0;
-int GlobalParam:: _SupportTextureRG = 0;
-int GlobalParam:: _UseDynamicIndexing = 0;
-int GlobalParam:: _FullSupported = 1;
-
-//when SiftGPUEX is not used, display VBO generation is skipped
-int GlobalParam:: _UseSiftGPUEX = 0;
-int GlobalParam:: _InitPyramidWidth=0;
-int GlobalParam:: _InitPyramidHeight=0;
-int GlobalParam:: _octave_min_default=0;
-int GlobalParam:: _octave_num_default=-1;
-
-
-//////////////////////////////////////////////////////////////////
-int GlobalParam:: _GoodOpenGL = -1; //indicates OpenGl initialization status
-int GlobalParam:: _FixedOrientation = 0; //upright
-int GlobalParam:: _LoweOrigin = 0; //(0, 0) to be at the top-left corner.
-int GlobalParam:: _NormalizedSIFT = 1; //normalize descriptor
-int GlobalParam:: _BinarySIFT = 0; //saving binary format
-int GlobalParam:: _ExitAfterSIFT = 0; //exif after saving result
-int GlobalParam:: _KeepExtremumSign = 0; // if 1, scales of dog-minimum will be multiplied by -1
-///
-int GlobalParam:: _KeyPointListForceLevel0 = 0;
-int GlobalParam:: _DarknessAdaption = 0;
-int GlobalParam:: _ProcessOBO = 0;
-int GlobalParam:: _TruncateMethod = 0;
-int GlobalParam:: _PreciseBorder = 1;
-
-// parameter changing for better matching with Lowe's SIFT
-float GlobalParam:: _OrientationWindowFactor = 2.0f; // 1.0(-v292), 2(v293-),
-float GlobalParam:: _OrientationGaussianFactor = 1.5f; // 4.5(-v292), 1.5(v293-)
-float GlobalParam:: _MulitiOrientationThreshold = 0.8f;
-///
-int GlobalParam:: _FeatureCountThreshold = -1;
-
-///////////////////////////////////////////////
-int GlobalParam:: _WindowInitX = -1;
-int GlobalParam:: _WindowInitY = -1;
-int GlobalParam:: _DeviceIndex = 0;
-const char * GlobalParam:: _WindowDisplay = NULL;
-
-
-
-/////////////////
-////
-ClockTimer GlobalUtil:: _globalTimer;
-
-
-#ifdef _DEBUG
-void GlobalUtil::CheckErrorsGL(const char* location)
-{
- GLuint errnum;
- const char *errstr;
- while (errnum = glGetError())
- {
- errstr = (const char *)(gluErrorString(errnum));
- if(errstr) {
- std::cerr << errstr;
- }
- else {
- std::cerr << "Error " << errnum;
- }
-
- if(location) std::cerr << " at " << location;
- std::cerr << "\n";
- }
- return;
-}
-
-#endif
-
-void GlobalUtil::CleanupOpenGL()
-{
- glActiveTexture(GL_TEXTURE0);
-}
-
-void GlobalUtil::SetDeviceParam(int argc, char** argv)
-{
- if(GlobalParam::_GoodOpenGL!= -1) return;
-
- #define CHAR1_TO_INT(x) ((x >= 'A' && x <= 'Z') ? x + 32 : x)
- #define CHAR2_TO_INT(str, i) (str[i] ? CHAR1_TO_INT(str[i]) + (CHAR1_TO_INT(str[i+1]) << 8) : 0)
- #define CHAR3_TO_INT(str, i) (str[i] ? CHAR1_TO_INT(str[i]) + (CHAR2_TO_INT(str, i + 1) << 8) : 0)
- #define STRING_TO_INT(str) (CHAR1_TO_INT(str[0]) + (CHAR3_TO_INT(str, 1) << 8))
-
- char* arg, * opt;
- for(int i = 0; i< argc; i++)
- {
- arg = argv[i];
- if(arg == NULL || arg[0] != '-')continue;
- opt = arg+1;
-
- ////////////////////////////////
- switch( STRING_TO_INT(opt))
- {
- case 'w' + ('i' << 8) + ('n' << 16) + ('p' << 24):
- if(_GoodOpenGL != 2 && i + 1 < argc)
- {
- int x =0, y=0;
- if(sscanf(argv[++i], "%dx%d", &x, &y) == 2)
- {
- GlobalParam::_WindowInitX = x;
- GlobalParam::_WindowInitY = y;
- }
- }
- break;
- case 'd' + ('i' << 8) + ('s' << 16) + ('p' << 24):
- if(_GoodOpenGL != 2 && i + 1 < argc)
- {
- GlobalParam::_WindowDisplay = argv[++i];
- }
- break;
- case 'c' + ('u' << 8) + ('d' << 16) + ('a' << 24):
- if(i + 1 < argc)
- {
- int device = 0;
- scanf(argv[++i], "%d", &device) ;
- GlobalParam::_DeviceIndex = device;
- }
- break;
- default:
- break;
- }
- }
-}
-
-void GlobalUtil::SetTextureParameter()
-{
-
- glTexParameteri (_texTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri (_texTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glTexParameteri(_texTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(_texTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-}
-
-//if image need to be up sampled ..use this one
-
-void GlobalUtil::SetTextureParameterUS()
-{
-
- glTexParameteri (_texTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri (_texTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glTexParameteri(_texTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(_texTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-}
-
-
-void GlobalUtil::FitViewPort(int width, int height)
-{
- GLint port[4];
- glGetIntegerv(GL_VIEWPORT, port);
- if(port[2] !=width || port[3] !=height)
- {
- glViewport(0, 0, width, height);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0, width, 0, height, 0, 1);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- }
-}
-
-
-bool GlobalUtil::CheckFramebufferStatus() {
- GLenum status;
- status=(GLenum)glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
- switch(status) {
- case GL_FRAMEBUFFER_COMPLETE_EXT:
- return true;
- case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
- std::cerr<<("Framebuffer incomplete,incomplete attachment\n");
- return false;
- case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
- std::cerr<<("Unsupported framebuffer format\n");
- return false;
- case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
- std::cerr<<("Framebuffer incomplete,missing attachment\n");
- return false;
- case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
- std::cerr<<("Framebuffer incomplete,attached images must have same dimensions\n");
- return false;
- case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
- std::cerr<<("Framebuffer incomplete,attached images must have same format\n");
- return false;
- case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
- std::cerr<<("Framebuffer incomplete,missing draw buffer\n");
- return false;
- case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
- std::cerr<<("Framebuffer incomplete,missing read buffer\n");
- return false;
- }
- return false;
-}
-
-
-int ClockTimer::ClockMS()
-{
-#if defined(_WIN32)
- #if defined(TIMING_BY_CLOCK)
- return clock() * 1000 / CLOCKS_PER_SEC;
- #else
- static int started = 0;
- static int tstart;
- if(started == 0)
- {
- tstart = timeGetTime();
- started = 1;
- return 0;
- }else
- {
- return timeGetTime() - tstart;
- }
- #endif
-#else
- static int started = 0;
- static struct timeval tstart;
- if(started == 0)
- {
- gettimeofday(&tstart, NULL);
- started = 1;
- return 0;
- }else
- {
- struct timeval now;
- gettimeofday(&now, NULL) ;
- return (now.tv_usec - tstart.tv_usec + (now.tv_sec - tstart.tv_sec) * 1000000)/1000;
- }
-#endif
-}
-
-double ClockTimer::CLOCK()
-{
- return ClockMS() * 0.001;
-}
-
-void ClockTimer::InitHighResolution()
-{
-#if defined(_WIN32)
- timeBeginPeriod(1);
-#endif
-}
-
-void ClockTimer::StartTimer(const char* event, int verb)
-{
- strcpy(_current_event, event);
- _time_start = ClockMS();
- if(verb && GlobalUtil::_verbose)
- {
- std::cout<<"\n["<<_current_event<<"]:\tbegin ...\n";
- }
-}
-
-void ClockTimer::StopTimer(int verb)
-{
- _time_stop = ClockMS();
- if(verb && GlobalUtil::_verbose)
- {
- std::cout<<"["<<_current_event<<"]:\t"< GlobalUtil::_texMaxDimGL)
- {
- GlobalUtil::_texMaxDim = GlobalUtil::_texMaxDimGL;
- }
- glEnable(GlobalUtil::_texTarget);
- }else
- {
- std::cerr << "GL_ARB_texture_rectangle not supported!\n";
- GlobalUtil::_GoodOpenGL = 0;
- }
-
- GlobalUtil::_SupportNVFloat = glewGetExtension("GL_NV_float_buffer");
- GlobalUtil::_SupportTextureRG = glewGetExtension("GL_ARB_texture_rg");
-
-
- glShadeModel(GL_FLAT);
- glPolygonMode(GL_FRONT, GL_FILL);
-
- GlobalUtil::SetTextureParameter();
-
- }
-}
-
-void GlobalUtil::SelectDisplay()
-{
-#ifdef WIN32
- if(_WindowDisplay == NULL) return;
-
- HDC hdc = CreateDC(_WindowDisplay, _WindowDisplay, NULL, NULL);
- _WindowDisplay = NULL;
- if(hdc == NULL)
- {
- std::cout << "ERROR: invalid dispaly specified\n";
- return;
- }
-
- PIXELFORMATDESCRIPTOR pfd =
- {
- sizeof(PIXELFORMATDESCRIPTOR),1,
- PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER,
- PFD_TYPE_RGBA,24,0, 0, 0, 0, 0, 0,0,0,0,0, 0, 0, 0,16,0,0,
- PFD_MAIN_PLANE,0,0, 0, 0
- };
- ChoosePixelFormat(hdc, &pfd);
-#endif
-}
-
-int GlobalUtil::CreateWindowEZ(LiteWindow* window)
-{
- if(window == NULL) return 0;
- if(!window->IsValid())window->Create(_WindowInitX, _WindowInitY, _WindowDisplay);
- if(window->IsValid())
- {
- window->MakeCurrent();
- return 1;
- }
- else
- {
- std::cerr << "Unable to create OpenGL Context!\n";
- std::cerr << "For nVidia cards, you can try change to CUDA mode in this case\n";
- return 0;
- }
-}
-
-int GlobalUtil::CreateWindowEZ()
-{
- static LiteWindow window;
- return CreateWindowEZ(&window);
-}
-
-int CreateLiteWindow(LiteWindow* window)
-{
- return GlobalUtil::CreateWindowEZ(window);
-}
diff --git a/3rdparty/SiftGPU/src/SiftGPU/GlobalUtil.h b/3rdparty/SiftGPU/src/SiftGPU/GlobalUtil.h
deleted file mode 100644
index 4a0f6e63..00000000
--- a/3rdparty/SiftGPU/src/SiftGPU/GlobalUtil.h
+++ /dev/null
@@ -1,157 +0,0 @@
-////////////////////////////////////////////////////////////////////////////
-// File: GlobalUtil.h
-// Author: Changchang Wu
-// Description :
-// GlobalParam: Global parameters
-// ClockTimer: Timer
-// GlobalUtil: Global Function wrapper
-//
-// Copyright (c) 2007 University of North Carolina at Chapel Hill
-// All Rights Reserved
-//
-// Permission to use, copy, modify and distribute this software and its
-// documentation for educational, research and non-profit purposes, without
-// fee, and without a written agreement is hereby granted, provided that the
-// above copyright notice and the following paragraph appear in all copies.
-//
-// The University of North Carolina at Chapel Hill make no representations
-// about the suitability of this software for any purpose. It is provided
-// 'as is' without express or implied warranty.
-//
-// Please send BUG REPORTS to ccwu@cs.unc.edu
-//
-////////////////////////////////////////////////////////////////////////////
-
-
-#ifndef _GLOBAL_UTILITY_H
-#define _GLOBAL_UTILITY_H
-
-
-//wrapper for some shader function
-//class ProgramGPU;
-class LiteWindow;
-
-class GlobalParam
-{
-public:
- static GLuint _texTarget;
- static GLuint _iTexFormat;
- static int _texMaxDim;
- static int _texMaxDimGL;
- static int _texMinDim;
- static int _MemCapGPU;
- static int _FitMemoryCap;
- static int _verbose;
- static int _timingS;
- static int _timingO;
- static int _timingL;
- static int _usePackedTex;
- static int _IsNvidia;
- static int _KeepShaderLoop;
- static int _UseCUDA;
- static int _UseOpenCL;
- static int _UseDynamicIndexing;
- static int _debug;
- static int _MaxFilterWidth;
- static float _FilterWidthFactor;
- static float _OrientationWindowFactor;
- static float _DescriptorWindowFactor;
- static int _MaxOrientation;
- static int _OrientationPack2;
- static int _ListGenGPU;
- static int _ListGenSkipGPU;
- static int _SupportNVFloat;
- static int _SupportTextureRG;
- static int _FullSupported;
- static float _MaxFeaturePercent;
- static int _MaxLevelFeatureNum;
- static int _DescriptorPPR;
- static int _DescriptorPPT; //pixel per texture for one descriptor
- static int _FeatureTexBlock;
- static int _NarrowFeatureTex; //implemented but no performance improvement
- static int _SubpixelLocalization;
- static int _ProcessOBO; //not implemented yet
- static int _TruncateMethod;
- static int _PreciseBorder; //implemented
- static int _UseSiftGPUEX;
- static int _ForceTightPyramid;
- static int _octave_min_default;
- static int _octave_num_default;
- static int _InitPyramidWidth;
- static int _InitPyramidHeight;
- static int _PreProcessOnCPU;
- static int _GoodOpenGL;
- static int _FixedOrientation;
- static int _LoweOrigin;
- static int _ExitAfterSIFT;
- static int _NormalizedSIFT;
- static int _BinarySIFT;
- static int _KeepExtremumSign;
- static int _FeatureCountThreshold;
- static int _KeyPointListForceLevel0;
- static int _DarknessAdaption;
-
- //for compatability with old version:
- static float _OrientationExtraFactor;
- static float _OrientationGaussianFactor;
- static float _MulitiOrientationThreshold;
-
- ////////////////////////////////////////
- static int _WindowInitX;
- static int _WindowInitY;
- static const char* _WindowDisplay;
- static int _DeviceIndex;
-};
-
-
-class ClockTimer
-{
-private:
- char _current_event[256];
- int _time_start;
- int _time_stop;
-public:
- static int ClockMS();
- static double CLOCK();
- static void InitHighResolution();
- void StopTimer(int verb = 1);
- void StartTimer(const char * event, int verb=0);
- float GetElapsedTime();
-};
-
-class GlobalUtil:public GlobalParam
-{
- static ClockTimer _globalTimer;
-public:
- inline static double CLOCK() { return ClockTimer::CLOCK(); }
- inline static void StopTimer() { _globalTimer.StopTimer(_timingS); }
- inline static void StartTimer(const char * event) { _globalTimer.StartTimer(event, _timingO); }
- inline static float GetElapsedTime() { return _globalTimer.GetElapsedTime(); }
-
- static void FitViewPort(int width, int height);
- static void SetTextureParameter();
- static void SetTextureParameterUS();
-#ifdef _DEBUG
- static void CheckErrorsGL(const char* location = NULL);
-#else
- static void inline CheckErrorsGL(const char* location = NULL){};
-#endif
- static bool CheckFramebufferStatus();
- //initialize Opengl parameters
- static void SelectDisplay();
- static void InitGLParam(int NotTargetGL = 0);
- static void SetGLParam();
- static int CreateWindowEZ();
- static void CleanupOpenGL();
- static void SetDeviceParam(int argc, char** argv);
- static int CreateWindowEZ(LiteWindow* window);
-};
-
-
-#if defined(_MSC_VER) && _MSC_VER == 1200
-#define max(a,b) (((a) > (b)) ? (a) : (b))
-#define min(a,b) (((a) < (b)) ? (a) : (b))
-#endif
-
-#endif
-
diff --git a/3rdparty/SiftGPU/src/SiftGPU/LiteWindow.h b/3rdparty/SiftGPU/src/SiftGPU/LiteWindow.h
deleted file mode 100644
index 9c053ebd..00000000
--- a/3rdparty/SiftGPU/src/SiftGPU/LiteWindow.h
+++ /dev/null
@@ -1,197 +0,0 @@
-#ifndef LITE_WINDOW_H
-#define LITE_WINDOW_H
-
-//#define WINDOW_PREFER_GLUT
-
-#if defined(WINDOW_PREFER_GLUT)
-
-#ifdef __APPLE__
- #include "GLUT/glut.h"
-#else
- #include "GL/glut.h"
-#endif
-//for apple, use GLUT to create the window..
-class LiteWindow
-{
- int glut_id;
-public:
- LiteWindow() { glut_id = 0; }
- int IsValid() { return glut_id > 0; }
- virtual ~LiteWindow() { if(glut_id > 0) glutDestroyWindow(glut_id); }
- void MakeCurrent() { glutSetWindow(glut_id); }
- void Create(int x = -1, int y = -1, const char* display = NULL)
- {
- static int _glut_init_called = 0;
- if(glut_id != 0) return;
-
- //see if there is an existing window
- if(_glut_init_called) glut_id = glutGetWindow();
-
- //create one if no glut window exists
- if(glut_id != 0) return;
-
- if(_glut_init_called == 0)
- {
- int argc = 1;
- char * argv[4] = { "-iconic", 0 , 0, 0};
- if(display)
- {
- argc = 3;
- argv[1] = "-display";
- argv[2] = (char*) display;
- }
- glutInit(&argc, argv);
- glutInitDisplayMode (GLUT_RGBA );
- _glut_init_called = 1;
- }
- if(x != -1) glutInitWindowPosition(x, y);
- if(display || x != -1) std::cout << "Using display ["
- << (display? display : "\0" )<< "] at (" << x << "," << y << ")\n";
- glut_id = glutCreateWindow ("SIFT_GPU_GLUT");
- glutHideWindow();
- }
-};
-#elif defined( _WIN32)
-
-#ifndef _INC_WINDOWS
-#ifndef WIN32_LEAN_AND_MEAN
- #define WIN32_LEAN_AND_MEAN
-#endif
-#include
-#endif
-
-class LiteWindow
-{
- HWND hWnd;
- HGLRC hContext;
- HDC hdc;
-public:
- LiteWindow()
- {
- hWnd = NULL;
- hContext = NULL;
- hdc = NULL;
- }
- virtual ~LiteWindow()
- {
- if(hContext)wglDeleteContext(hContext);
- if(hdc)ReleaseDC(hWnd, hdc);
- if(hWnd)DestroyWindow(hWnd);
- }
- int IsValid()
- {
- return hContext != NULL;
- }
-
- //display is ignored under Win32
- void Create(int x = -1, int y = -1, const char* display = NULL)
- {
- if(hContext) return;
- WNDCLASSEX wcex = { sizeof(WNDCLASSEX), CS_HREDRAW | CS_VREDRAW,
- (WNDPROC)DefWindowProc, 0, 4, 0, 0, 0, 0, 0,
- ("SIFT_GPU_LITE"), 0};
- RegisterClassEx(&wcex);
- hWnd = CreateWindow("SIFT_GPU_LITE", "SIFT_GPU", 0,
- CW_USEDEFAULT, CW_USEDEFAULT,
- 100, 100, NULL, NULL, 0, 0);
-
- //move the window so that it can be on the second monitor
- if(x !=-1)
- {
- MoveWindow(hWnd, x, y, 100, 100, 0);
- std::cout << "CreateWindow at (" << x << "," << y<<")\n";
- }
-
- ///////////////////////////////////////////////////
- PIXELFORMATDESCRIPTOR pfd =
- {
- sizeof(PIXELFORMATDESCRIPTOR), 1,
- PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL ,
- PFD_TYPE_RGBA,16,0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0
- };
- hdc=GetDC(hWnd);
- ////////////////////////////////////
- int pixelformat = ChoosePixelFormat(hdc, &pfd);
- DescribePixelFormat(hdc, pixelformat, sizeof(pfd), &pfd);
- SetPixelFormat(hdc, pixelformat, &pfd);
- hContext = wglCreateContext(hdc);
-
- }
- void MakeCurrent()
- {
- wglMakeCurrent(hdc, hContext);
- }
-};
-
-#else
-
-#include
-#include
-#include
-
-class LiteWindow
-{
- Display* xDisplay;
- XVisualInfo* xVisual;
- Window xWin;
- GLXContext xContext;
- Colormap xColormap;
-public:
- LiteWindow()
- {
- xDisplay = NULL;
- xVisual = NULL;
- xWin = 0;
- xColormap = 0;
- xContext = NULL;
- }
- int IsValid ()
- {
- return xContext != NULL && glXIsDirect(xDisplay, xContext);
- }
- virtual ~LiteWindow()
- {
- if(xWin) XDestroyWindow(xDisplay, xWin);
- if(xContext) glXDestroyContext(xDisplay, xContext);
- if(xColormap) XFreeColormap(xDisplay, xColormap);
- if(xDisplay) XCloseDisplay(xDisplay);
- }
- void Create(int x = 0, int y = 0, const char * display = NULL)
- {
- if(xDisplay) return;
- if(display) std::cout << "Using display ["<screen),
- xVisual->visual, AllocNone);
-
- XSetWindowAttributes wa;
- wa.event_mask = 0;
- wa.border_pixel = 0;
- wa.colormap = xColormap;
-
- xWin = XCreateWindow( xDisplay, RootWindow(xDisplay, xVisual->screen) ,
- x, y, 100, 100, 0, xVisual->depth,
- InputOutput, xVisual->visual,
- CWBorderPixel |CWColormap | CWEventMask, &wa);
-
- xContext = glXCreateContext(xDisplay, xVisual, 0, GL_TRUE);
- }
- void MakeCurrent()
- {
- if(xContext) glXMakeCurrent(xDisplay, xWin, xContext);
- }
-};
-
-#endif
-
-
-#endif
-
diff --git a/3rdparty/SiftGPU/src/SiftGPU/ProgramCG.cpp b/3rdparty/SiftGPU/src/SiftGPU/ProgramCG.cpp
deleted file mode 100644
index 09c3f915..00000000
--- a/3rdparty/SiftGPU/src/SiftGPU/ProgramCG.cpp
+++ /dev/null
@@ -1,2765 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// File: ProgramCG.cpp
-// Author: Changchang Wu
-// Description : implementation of cg related class.
-// class ProgramCG A simple wrapper of Cg programs
-// class ShaderBagCG cg shaders for SIFT
-// class FilterCGGL cg gaussian filters for SIFT
-//
-// Copyright (c) 2007 University of North Carolina at Chapel Hill
-// All Rights Reserved
-//
-// Permission to use, copy, modify and distribute this software and its
-// documentation for educational, research and non-profit purposes, without
-// fee, and without a written agreement is hereby granted, provided that the
-// above copyright notice and the following paragraph appear in all copies.
-//
-// The University of North Carolina at Chapel Hill make no representations
-// about the suitability of this software for any purpose. It is provided
-// 'as is' without express or implied warranty.
-//
-// Please send BUG REPORTS to ccwu@cs.unc.edu
-//
-////////////////////////////////////////////////////////////////////////////
-
-#if defined(CG_SIFTGPU_ENABLED)
-
-#include "GL/glew.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-using namespace std;
-
-#include "GlobalUtil.h"
-#include "ProgramCG.h"
-#include "GLTexImage.h"
-#include "ShaderMan.h"
-#include "FrameBufferObject.h"
-
-
-
-#if defined(_WIN32)
- #pragma comment (lib, "../../lib/cg.lib")
- #pragma comment (lib, "../../lib/cggl.lib")
-#endif
-
-CGcontext ProgramCG::_Context =0;
-CGprofile ProgramCG::_FProfile;
-
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
-
-ProgramCG::ProgramCG()
-{
- _programID = NULL;
-}
-
-ProgramCG::~ProgramCG()
-{
- if(_programID) cgDestroyProgram(_programID);
-}
-
-ProgramCG::ProgramCG(const char *code, const char** cg_compile_args, CGprofile profile)
-{
- _valid = 0;
- _profile = profile;
- GLint epos;
- const char* ati_args[] = {"-po", "ATI_draw_buffers",0};
- const char* fp40_args[] = {"-ifcvt", "none","-unroll", "all", GlobalUtil::_UseFastMath? "-fastmath" : 0, 0};
- if(cg_compile_args == NULL) cg_compile_args = GlobalUtil::_IsNvidia? (GlobalUtil::_SupportFP40? fp40_args:NULL) : ati_args;
- _programID = ::cgCreateProgram(_Context, CG_SOURCE, code, profile, NULL, cg_compile_args);
- if(_programID)
- {
- cgGLLoadProgram(_programID );
- //_texParamID = cgGetNamedParameter(_programID, "tex");
-
- glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &epos);
- if(epos >=0)
- {
- std::cout<=0)
- {
- std::cout< 0.9)? size : -size);\n"
- " dxy.y = type < 0.2 ? 0 : ((type < 0.3 || type > 0.7 )? -size :size); \n"
- " sincos(cc.b, s, c);\n"
- " FragColor.x = cc.x + c*dxy.x-s*dxy.y;\n"
- " FragColor.y = cc.y + c*dxy.y+s*dxy.x;}\n"
- "}\n\0");
- /*FragColor = float4(tpos, 0.0, 1.0);}\n\0");*/
-
- _param_genvbo_size = cgGetNamedParameter(*program, "sizes");
-
-
- s_display_gaussian = new ProgramCG(
- "void main(float4 TexCoord0 : TEXCOORD0, out float4 FragColor : COLOR0, uniform samplerRECT tex){\n"
- "float r = texRECT(tex, TexCoord0.xy).r;\n"
- "FragColor = float4(r, r, r, 1.0);}");
-
-
- s_display_dog = new ProgramCG(
- "void main(float4 TexCoord0 : TEXCOORD0, out float4 FragColor : COLOR0, uniform samplerRECT tex){\n"
- "float g = (0.5+20.0*texRECT(tex, TexCoord0.xy).g);\n"
- "FragColor = float4(g, g, g, 1.0);}" );
-
-
- s_display_grad = new ProgramCG(
- "void main(float4 TexCoord0 : TEXCOORD0, out float4 FragColor : COLOR0, uniform samplerRECT tex){\n"
- "float4 cc = texRECT(tex, TexCoord0.xy); FragColor = float4(5.0 * cc.bbb, 1.0); }");
-
-
- s_display_keys= new ProgramCG(
- "void main(float4 TexCoord0 : TEXCOORD0, out float4 FragColor : COLOR0, uniform samplerRECT tex){\n"
- "float4 cc = texRECT(tex, TexCoord0.xy);\n"
- "if(cc.r ==1.0) FragColor = float4(1.0, 0, 0,1.0); \n"
- "else {if (cc.r ==0.5) FragColor = float4(0.0,1.0,0.0,1.0); else discard;}}");
-
-}
-
-void ShaderBagCG::SetMarginCopyParam(int xmax, int ymax)
-{
- float truncate[2] = {xmax - 0.5f , ymax - 0.5f};
- cgGLSetParameter2fv(_param_margin_copy_truncate, truncate);
-}
-
-
-int ShaderBagCG::LoadKeypointShaderMR(float threshold, float edge_threshold)
-{
- char buffer[10240];
- float threshold0 = threshold * 0.8f;
- float threshold1 = threshold;
- float threshold2 = (edge_threshold+1)*(edge_threshold+1)/edge_threshold;
- int max_refine = max(2, GlobalUtil::_SubpixelLocalization);
- ostrstream out(buffer, 10240);
-
- out << "#define THRESHOLD0 " << threshold0 << "\n"
- "#define THRESHOLD1 " << threshold1 << "\n"
- "#define THRESHOLD2 " << threshold2 << "\n"
- "#define MAX_REFINE " << max_refine << "\n";
- out<<
- "void main (\n"
- "float4 TexCC : TEXCOORD0, float4 TexLC : TEXCOORD1,\n"
- "float4 TexRC : TEXCOORD2, float4 TexCD : TEXCOORD3, \n"
- "float4 TexCU : TEXCOORD4, float4 TexLD : TEXCOORD5, \n"
- "float4 TexLU : TEXCOORD6, float4 TexRD : TEXCOORD7,\n"
- "out float4 FragData0 : COLOR0, out float4 FragData1 : COLOR1, \n"
- "uniform samplerRECT tex, uniform samplerRECT texU, uniform samplerRECT texD)\n"
- "{\n"
- " float4 v1, v2, gg;\n"
- " float2 TexRU = float2(TexRC.x, TexCU.y); \n"
- " float4 cc = texRECT(tex, TexCC.xy);\n"
- " v1.x = texRECT(tex, TexLC.xy).g;\n"
- " gg.x = texRECT(tex, TexLC.xy).r;\n"
- " v1.y = texRECT(tex, TexRC.xy).g;\n"
- " gg.y = texRECT(tex, TexRC.xy).r;\n"
- " v1.z = texRECT(tex, TexCD.xy).g;\n"
- " gg.z = texRECT(tex, TexCD.xy).r;\n"
- " v1.w = texRECT(tex, TexCU.xy).g;\n"
- " gg.w = texRECT(tex, TexCU.xy).r;\n"
- " v2.x = texRECT(tex, TexLD.xy).g;\n"
- " v2.y = texRECT(tex, TexLU.xy).g;\n"
- " v2.z = texRECT(tex, TexRD.xy).g;\n"
- " v2.w = texRECT(tex, TexRU.xy).g;\n"
- " float2 dxdy = 0.5*(gg.yw - gg.xz); \n"
- " float grad = length(dxdy);\n"
- " float theta = grad==0? 0: atan2(dxdy.y, dxdy.x);\n"
- " FragData0 = float4(cc.rg, grad, theta);\n"
- <<
- " float dog = 0.0; \n"
- " FragData1 = float4(0, 0, 0, 0); \n"
- " float2 v3; float4 v4, v5, v6;\n"
- <<
- " if( cc.g > THRESHOLD0 && all(cc.gggg > max(v1, v2)))\n"
- " {\n"
- " v3.x = texRECT(texU, TexCC.xy).g;\n"
- " v4.x = texRECT(texU, TexLC.xy).g;\n"
- " v4.y = texRECT(texU, TexRC.xy).g;\n"
- " v4.z = texRECT(texU, TexCD.xy).g;\n"
- " v4.w = texRECT(texU, TexCU.xy).g;\n"
- " v6.x = texRECT(texU, TexLD.xy).g;\n"
- " v6.y = texRECT(texU, TexLU.xy).g;\n"
- " v6.z = texRECT(texU, TexRD.xy).g;\n"
- " v6.w = texRECT(texU, TexRU.xy).g;\n"
- " if(cc.g < v3.x || any(cc.gggg v3.x || any(cc.gggg>v4.xyzw || cc.gggg>v6.xyzw))return; \n"
- " v3.y = texRECT(texD, TexCC.xy).g;\n"
- " v5.x = texRECT(texD, TexLC.xy).g;\n"
- " v5.y = texRECT(texD, TexRC.xy).g;\n"
- " v5.z = texRECT(texD, TexCD.xy).g;\n"
- " v5.w = texRECT(texD, TexCU.xy).g;\n"
- " v6.x = texRECT(texD, TexLD.xy).g;\n"
- " v6.y = texRECT(texD, TexLU.xy).g;\n"
- " v6.z = texRECT(texD, TexRD.xy).g;\n"
- " v6.w = texRECT(texD, TexRU.xy).g;\n"
- " if(cc.g > v3.y || any(cc.gggg>v5.xyzw || cc.gggg>v6.xyzw))return; \n"
- " dog = 0.5 ; \n"
- " }\n"
- " else\n"
- " return;\n"
- <<
- " int i = 0; \n"
- " float2 offset = float2(0, 0);\n"
- " float2 offsets = float2(0, 0);\n"
- " float3 dxys; bool key_moved; \n"
- " float fx, fy, fs; \n"
- " float fxx, fyy, fxy; \n"
- " float fxs, fys, fss; \n"
- " do\n"
- " {\n"
- " dxys = float3(0, 0, 0);\n"
- " offset = float2(0, 0);\n"
- " float4 D2 = v1.xyzw - cc.gggg;\n"
- " fxx = D2.x + D2.y;\n"
- " fyy = D2.z + D2.w;\n"
- " float2 D4 = v2.xw - v2.yz;\n"
- " fxy = 0.25*(D4.x + D4.y);\n"
- " float2 D5 = 0.5*(v1.yw-v1.xz); \n"
- " fx = D5.x;\n"
- " fy = D5.y ; \n"
- " fs = 0.5*( v3.x - v3.y ); \n"
- " fss = v3.x + v3.y - cc.g - cc.g;\n"
- " fxs = 0.25 * ( v4.y + v5.x - v4.x - v5.y);\n"
- " fys = 0.25 * ( v4.w + v5.z - v4.z - v5.w);\n"
- " float4 A0, A1, A2 ; \n"
- " A0 = float4(fxx, fxy, fxs, -fx); \n"
- " A1 = float4(fxy, fyy, fys, -fy); \n"
- " A2 = float4(fxs, fys, fss, -fs); \n"
- " float3 x3 = abs(float3(fxx, fxy, fxs)); \n"
- " float maxa = max(max(x3.x, x3.y), x3.z); \n"
- " if(maxa > 1e-10 ) \n"
- " {\n"
- " if(x3.y ==maxa ) \n"
- " { \n"
- " float4 TEMP = A1; A1 = A0; A0 = TEMP; \n"
- " }else if( x3.z == maxa ) \n"
- " { \n"
- " float4 TEMP = A2; A2 = A0; A0 = TEMP; \n"
- " } \n"
- " A0 /= A0.x; \n"
- " A1 -= A1.x * A0; \n"
- " A2 -= A2.x * A0; \n"
- " float2 x2 = abs(float2(A1.y, A2.y)); \n"
- " if( x2.y > x2.x ) \n"
- " { \n"
- " float3 TEMP = A2.yzw; \n"
- " A2.yzw = A1.yzw; \n"
- " A1.yzw = TEMP; \n"
- " x2.x = x2.y; \n"
- " } \n"
- " if(x2.x > 1e-10) \n"
- " {\n"
- " A1.yzw /= A1.y; \n"
- " A2.yzw -= A2.y * A1.yzw; \n"
- " if(abs(A2.z) > 1e-10) \n"
- " {\n"
- // compute dx, dy, ds:
- <<
- " dxys.z = A2.w /A2.z; \n"
- " dxys.y = A1.w - dxys.z*A1.z; \n"
- " dxys.x = A0.w - dxys.z*A0.z - dxys.y*A0.y; \n"
- " }\n"
- " }\n"
- " }\n"
- " offset.x = dxys.x > 0.6 ? 1 : 0 + dxys.x < -0.6 ? -1 : 0;\n"
- " offset.y = dxys.y > 0.6 ? 1 : 0 + dxys.y < - 0.6? -1 : 0;\n"
- " i++; key_moved = i < MAX_REFINE && any(abs(offset)>0) ; \n"
- " if(key_moved)\n"
- " {\n"
- " offsets += offset; \n"
- " cc = texRECT(tex, TexCC.xy + offsets);\n"
- " v1.x = texRECT(tex , TexLC.xy + offsets).g;\n"
- " v1.y = texRECT(tex , TexRC.xy + offsets).g;\n"
- " v1.z = texRECT(tex , TexCD.xy + offsets).g;\n"
- " v1.w = texRECT(tex , TexCU.xy + offsets).g;\n"
- " v2.x = texRECT(tex , TexLD.xy + offsets).g;\n"
- " v2.y = texRECT(tex , TexLU.xy + offsets).g;\n"
- " v2.z = texRECT(tex , TexRD.xy + offsets).g;\n"
- " v2.w = texRECT(tex , TexRU.xy + offsets).g;\n"
- " v3.x = texRECT(texU, TexCC.xy + offsets).g;\n"
- " v4.x = texRECT(texU, TexLC.xy + offsets).g;\n"
- " v4.y = texRECT(texU, TexRC.xy + offsets).g;\n"
- " v4.z = texRECT(texU, TexCD.xy + offsets).g;\n"
- " v4.w = texRECT(texU, TexCU.xy + offsets).g;\n"
- " v3.y = texRECT(texD, TexCC.xy + offsets).g;\n"
- " v5.x = texRECT(texD, TexLC.xy + offsets).g;\n"
- " v5.y = texRECT(texD, TexRC.xy + offsets).g;\n"
- " v5.z = texRECT(texD, TexCD.xy + offsets).g;\n"
- " v5.w = texRECT(texD, TexCU.xy + offsets).g;\n"
- " }\n"
- " }while(key_moved);\n"
- <<
- " bool test1 = (abs(cc.g + 0.5*dot(float3(fx, fy, fs), dxys ))> THRESHOLD1) ;\n"
- " float test2_v1= fxx*fyy - fxy *fxy; \n"
- " float test2_v2 = (fxx+fyy); \n"
- " test2_v2 = test2_v2*test2_v2;\n"
- " bool test2 = test2_v1>0 && test2_v2 < THRESHOLD2 * test2_v1; \n "
- //keep the point when the offset is less than 1
- <<
- " FragData1 = test1 && test2 && all( abs(dxys) < 1)? float4( dog, dxys.xy+offsets, dxys.z) : float4(0, 0, 0, 0); \n"
- "}\n"
- <<'\0';
-
- ProgramCG * program;
- s_keypoint = program = new ProgramCG(buffer);
- //parameter
- _param_dog_texu = cgGetNamedParameter(*program, "texU");
- _param_dog_texd = cgGetNamedParameter(*program, "texD");
-
- return 1;
-
-}
-
-//keypoint detection shader
-//1. compare with 26 neighbours
-//2. sub-pixel sub-scale localization
-//3. output: [dog, offset(x,y,s)]
-
-void ShaderBagCG:: LoadKeypointShader(float threshold, float edge_threshold)
-{
- char buffer[10240];
- float threshold0 = threshold* (GlobalUtil::_SubpixelLocalization?0.8f:1.0f);
- float threshold1 = threshold;
- float threshold2 = (edge_threshold+1)*(edge_threshold+1)/edge_threshold;
- ostrstream out(buffer, 10240);
- out< THRESHOLD0 && all(cc.gggg > max(v1, v2))?1.0: 0.0;\n"
- " dog = cc.g < -THRESHOLD0 && all(cc.gggg < min(v1, v2))?0.5: dog;\n";
-
- pos = out.tellp();
- //do edge supression first..
- //vector v1 is < (-1, 0), (1, 0), (0,-1), (0, 1)>
- //vector v2 is < (-1,-1), (-1,1), (1,-1), (1, 1)>
-
- out<<
- " if(dog == 0.0) return;\n"
- " float fxx, fyy, fxy; \n"
- " float4 D2 = v1.xyzw - cc.gggg;\n"
- " float2 D4 = v2.xw - v2.yz;\n"
- " fxx = D2.x + D2.y;\n"
- " fyy = D2.z + D2.w;\n"
- " fxy = 0.25*(D4.x + D4.y);\n"
- " float fxx_plus_fyy = fxx + fyy;\n"
- " float score_up = fxx_plus_fyy*fxx_plus_fyy; \n"
- " float score_down = (fxx*fyy - fxy*fxy);\n"
- " if( score_down <= 0 || score_up > THRESHOLD2 * score_down)return;\n"
- //...
- <<
- " float2 D5 = 0.5*(v1.yw-v1.xz); \n"
- " float fx = D5.x, fy = D5.y ; \n"
- " float fs, fss , fxs, fys ; \n"
- " float2 v3; float4 v4, v5, v6;\n"
- //read 9 pixels of upper level
- <<
- " v3.x = texRECT(texU, TexCC.xy).g;\n"
- " v4.x = texRECT(texU, TexLC.xy).g;\n"
- " v4.y = texRECT(texU, TexRC.xy).g;\n"
- " v4.z = texRECT(texU, TexCD.xy).g;\n"
- " v4.w = texRECT(texU, TexCU.xy).g;\n"
- " v6.x = texRECT(texU, TexLD.xy).g;\n"
- " v6.y = texRECT(texU, TexLU.xy).g;\n"
- " v6.z = texRECT(texU, TexRD.xy).g;\n"
- " v6.w = texRECT(texU, TexRU.xy).g;\n"
- //compare with 9 pixels of upper level
- //read and compare with 9 pixels of lower level
- //the maximum case
- <<
- " if(dog == 1.0)\n"
- " {\n"
- " bool4 test = cc.gggg < max(v4, v6); \n"
- " if(cc.g < v3.x || any(test.xy||test.zw))return; \n"
- " v3.y = texRECT(texD, TexCC.xy).g;\n"
- " v5.x = texRECT(texD, TexLC.xy).g;\n"
- " v5.y = texRECT(texD, TexRC.xy).g;\n"
- " v5.z = texRECT(texD, TexCD.xy).g;\n"
- " v5.w = texRECT(texD, TexCU.xy).g;\n"
- " v6.x = texRECT(texD, TexLD.xy).g;\n"
- " v6.y = texRECT(texD, TexLU.xy).g;\n"
- " v6.z = texRECT(texD, TexRD.xy).g;\n"
- " v6.w = texRECT(texD, TexRU.xy).g;\n"
- " test = cc.ggggmin(v4, v6); \n"
- " if(cc.g > v3.x || any(test.xy||test.zw))return; \n"
- " v3.y = texRECT(texD, TexCC.xy).g;\n"
- " v5.x = texRECT(texD, TexLC.xy).g;\n"
- " v5.y = texRECT(texD, TexRC.xy).g;\n"
- " v5.z = texRECT(texD, TexCD.xy).g;\n"
- " v5.w = texRECT(texD, TexCU.xy).g;\n"
- " v6.x = texRECT(texD, TexLD.xy).g;\n"
- " v6.y = texRECT(texD, TexLU.xy).g;\n"
- " v6.z = texRECT(texD, TexRD.xy).g;\n"
- " v6.w = texRECT(texD, TexRU.xy).g;\n"
- " test = cc.gggg>min(v5, v6); \n"
- " if(cc.g > v3.y || any(test.xy||test.zw))return; \n"
- " }\n";
-
- if(GlobalUtil::_SubpixelLocalization)
-
- // sub-pixel localization FragData1 = float4(dog, 0, 0, 0); return;
- out <<
- " fs = 0.5*( v3.x - v3.y ); //bug fix 9/12/2007 \n"
- " fss = v3.x + v3.y - cc.g - cc.g;\n"
- " fxs = 0.25 * ( v4.y + v5.x - v4.x - v5.y);\n"
- " fys = 0.25 * ( v4.w + v5.z - v4.z - v5.w);\n"
-
- /////////////////////////////////////////////////////////////////
- // let dog difference be quatratic function of dx, dy, ds;
- // df(dx, dy, ds) = fx * dx + fy*dy + fs * ds +
- // + 0.5 * ( fxx * dx * dx + fyy * dy * dy + fss * ds * ds)
- // + (fxy * dx * dy + fxs * dx * ds + fys * dy * ds)
- // (fx, fy, fs, fxx, fyy, fss, fxy, fxs, fys are the derivatives)
-
- //the local extremum satisfies
- // df/dx = 0, df/dy = 0, df/dz = 0
-
- //that is
- // |-fx| | fxx fxy fxs | |dx|
- // |-fy| = | fxy fyy fys | * |dy|
- // |-fs| | fxs fys fss | |ds|
- // need to solve dx, dy, ds
-
- // Use Gauss elimination to solve the linear system
- <<
- " float3 dxys = float3(0.0); \n"
- " float4 A0, A1, A2 ; \n"
- " A0 = float4(fxx, fxy, fxs, -fx); \n"
- " A1 = float4(fxy, fyy, fys, -fy); \n"
- " A2 = float4(fxs, fys, fss, -fs); \n"
- " float3 x3 = abs(float3(fxx, fxy, fxs)); \n"
- " float maxa = max(max(x3.x, x3.y), x3.z); \n"
- " if(maxa >= 1e-10 ) { \n"
- " if(x3.y ==maxa ) \n"
- " { \n"
- " float4 TEMP = A1; A1 = A0; A0 = TEMP; \n"
- " }else if( x3.z == maxa ) \n"
- " { \n"
- " float4 TEMP = A2; A2 = A0; A0 = TEMP; \n"
- " } \n"
- " A0 /= A0.x; \n"
- " A1 -= A1.x * A0; \n"
- " A2 -= A2.x * A0; \n"
- " float2 x2 = abs(float2(A1.y, A2.y)); \n"
- " if( x2.y > x2.x ) \n"
- " { \n"
- " float3 TEMP = A2.yzw; \n"
- " A2.yzw = A1.yzw; \n"
- " A1.yzw = TEMP; \n"
- " x2.x = x2.y; \n"
- " } \n"
- " if(x2.x >= 1e-10) { \n"
- " A1.yzw /= A1.y; \n"
- " A2.yzw -= A2.y * A1.yzw; \n"
- " if(abs(A2.z) >= 1e-10) { \n"
- // compute dx, dy, ds:
- <<
- " dxys.z = A2.w /A2.z; \n"
- " dxys.y = A1.w - dxys.z*A1.z; \n"
- " dxys.x = A0.w - dxys.z*A0.z - dxys.y*A0.y; \n"
-
- //one more threshold which I forgot in versions prior to 286
- <<
- " bool bugfix_test = (abs(cc.g + 0.5*dot(float3(fx, fy, fs), dxys )) < THRESHOLD1) ;\n"
- " if(bugfix_test || any(abs(dxys) >= 1.0)) dog = 0; \n"
- " }}}\n"
- //keep the point when the offset is less than 1
- <<
- " FragData1 = float4( dog, dxys); \n"
- "}\n" <<'\0';
-
- else out<<
- " FragData1 = float4( dog, 0, 0, 0) ; \n"
- "}\n" <<'\0';
-
- ProgramCG * program;
- s_keypoint = program = new ProgramCG(buffer);
- if(!program->IsValidProgram())
- {
- delete program;
- out.seekp(pos);
- out <<
- " FragData1 = float4( fabs(cc.g) > 2.0 * THRESHOLD0? dog : 0, 0, 0, 0) ; \n"
- "}\n" <<'\0';
- s_keypoint = program = new ProgramCG(buffer);
- GlobalUtil::_SubpixelLocalization = 0;
- std::cerr<<"Detection simplified on this hardware"<= width)
- {
- out<<"0";
- }else if(offset[j]==0.0)
- {
- out<<"or";
- }else
- {
- out<<"texRECT(tex, TexCoord0.xy + float2(float("<= width) out<<"0";
- else out<= height)
- {
- out<<"0";
- }else if(offset[j]==0.0)
- {
- out<<"orb.y";
- }else
- {
- out<<"texRECT(tex, TexCoord0.xy + float2(0, float("<= height) out<<"0";
- else out<>1;
- float * pf = kernel + halfwidth;
- int nhpixel = (halfwidth+1)>>1; //how many neighbour pixels need to be looked up
- int npixel = (nhpixel<<1)+1;//
- char buffer[10240];
- float weight[3];
- ostrstream out(buffer, 10240);
- out< halfwidth? 0 : pf[xwn];
- }
- //if(weight[1]!=0.0) out<<"FragColor += "<>1;
- float * pf = kernel + halfh;
- int nhpixel = (halfh+1)>>1; //how many neighbour pixels need to be looked up
- int npixel = (nhpixel<<1)+1;//
- char buffer[10240];
- float weight[3];
- ostrstream out(buffer, 10240);
- out< halfh? 0 : pf[ywn];
- }
- //if(weight[1]!=0.0) out<<"FragColor += "<0.0);\n"
- "}");
-
- s_genlist_init_ex = program = new ProgramCG(
- "void main (uniform float2 bbox, \n"
- "uniform samplerRECT tex, \n"
- "in float4 TexCoord0 : TEXCOORD0,\n"
- "in float4 TexCoord1 : TEXCOORD1, \n"
- "in float4 TexCoord2 : TEXCOORD2, \n"
- "in float4 TexCoord3 : TEXCOORD3,\n"
- "out float4 FragColor : COLOR0){\n"
- "float4 helper = float4( \n"
- "texRECT(tex, TexCoord0.xy).r, texRECT(tex, TexCoord1.xy).r,\n"
- "texRECT(tex, TexCoord2.xy).r, texRECT(tex, TexCoord3.xy).r);\n"
- "bool4 helper4 = bool4(TexCoord0.xy < bbox, TexCoord3.xy < bbox); \n"
- "bool4 helper2 = helper4.xzxz && helper4.yyww; \n"
- "FragColor = float4(helper2 && (helper>0.0 ));\n"
- "}");
- _param_genlist_init_bbox = cgGetNamedParameter( *program, "bbox");
-
-
- //reduction ...
- s_genlist_histo = new ProgramCG(
- "void main (\n"
- "uniform samplerRECT tex, in float2 TexCoord0 : TEXCOORD0,\n"
- "in float2 TexCoord1 : TEXCOORD1, in float2 TexCoord2 : TEXCOORD2, in float2 TexCoord3 : TEXCOORD3,\n"
- "out float4 FragColor : COLOR0){\n"
- "float4 helper; float4 helper2; \n"
- "helper = texRECT(tex, TexCoord0); helper2.xy = helper.xy + helper.zw; \n"
- "helper = texRECT(tex, TexCoord1); helper2.zw = helper.xy + helper.zw; \n"
- "FragColor.rg = helper2.xz + helper2.yw;\n"
- "helper = texRECT(tex, TexCoord2); helper2.xy = helper.xy + helper.zw; \n"
- "helper = texRECT(tex, TexCoord3); helper2.zw = helper.xy + helper.zw; \n"
- "FragColor.ba= helper2.xz+helper2.yw;\n"
- "}");
-
-
- //read of the first part, which generates tex coordinates
-
- s_genlist_start= program = LoadGenListStepShader(1, 1);
- _param_ftex_width= cgGetNamedParameter(*program, "width");
- _param_genlist_start_tex0 = cgGetNamedParameter(*program, "tex0");
- //stepping
- s_genlist_step = program = LoadGenListStepShader(0, 1);
- _param_genlist_step_tex= cgGetNamedParameter(*program, "tex");
- _param_genlist_step_tex0= cgGetNamedParameter(*program, "tex0");
-
-
-}
-
-ProgramCG* ShaderBagCG::LoadGenListStepShader(int start, int step)
-{
- int i;
- char buffer[10240];
- //char chanels[5] = "rgba";
- ostrstream out(buffer, 10240);
- out<<"void main(out float4 FragColor : COLOR0, \n";
-
- for(i = 0; i < step; i++) out<<"uniform samplerRECT tex"<0)
- {
- out<<"float2 cpos = float2(-0.5, 0.5);\t float2 opos;\n";
- for(i = 0; i < step; i++)
- {
-//#define SETP_CODE_2
-
-#ifndef SETP_CODE_2
-/* out<<"cc = texRECT(tex"< float3(sum3[0], sum3[1], sum3[2]));\n";
- out<<"opos.y = -0.5 + cmp.y; opos.x = -0.5 + cmp.x + (cmp.z - cmp.y);\n";
- out<<"index -= dot(cmp, cc.rgb);\n";
- out<<"pos = (pos + pos + opos);\n";*/
-
- out<<"cc = texRECT(tex"<=dim-1)) "
- " //discard; \n"
- " { FragData0 = FragData1 = float4(0.0); return; }\n"
- " float anglef = texRECT(tex, coord).z;\n"
- " if(anglef > M_PI) anglef -= TWO_PI;\n"
- " float sigma = texRECT(tex, coord).w; \n"
- " float spt = abs(sigma * WF); //default to be 3*sigma \n";
-
- //rotation
- out<<
- " float4 cscs, rots; \n"
- " sincos(anglef, cscs.y, cscs.x); \n"
- " cscs.zw = - cscs.xy; \n"
- " rots = cscs /spt; \n"
- " cscs *= spt; \n";
-
- //here cscs is actually (cos, sin, -cos, -sin) * (factor: 3)*sigma
- //and rots is (cos, sin, -cos, -sin ) /(factor*sigma)
- //devide the 4x4 sift grid into 16 1x1 block, and each corresponds to a shader thread
- //To use linear interoplation, 1x1 is increased to 2x2, by adding 0.5 to each side
- out<<
- " float4 temp; float2 pt, offsetpt; \n"
- " /*the fraction part of idx is .5*/ \n"
- " offsetpt.x = 4.0 * frac(idx*0.25) - 2.0; \n"
- " offsetpt.y = floor(idx*0.25) - 1.5; \n"
- " temp = cscs.xwyx*offsetpt.xyxy; \n"
- " pt = pos + temp.xz + temp.yw; \n";
-
- //get a horizontal bounding box of the rotated rectangle
- out<<
- " float2 bwin = abs(cscs.xy); \n"
- " float bsz = bwin.x + bwin.y; \n"
- " float4 sz; float2 spos; \n"
- " sz.xy = max(pt - bsz, float2(1,1));\n"
- " sz.zw = min(pt + bsz, dim - 2); \n"
- " sz = floor(sz)+0.5;"; //move sample point to pixel center
-
- //get voting for two box
- out<<"\n"
- " float4 DA, DB; \n"
- " DA = DB = float4(0, 0, 0, 0); \n"
- " for(spos.y = sz.y; spos.y <= sz.w; spos.y+=1.0) \n"
- " { \n"
- " for(spos.x = sz.x; spos.x <= sz.z; spos.x+=1.0) \n"
- " { \n"
- " float2 diff = spos - pt; \n"
- " temp = rots.xywx * diff.xyxy; \n"
- " float2 nxy = (temp.xz + temp.yw); \n"
- " float2 nxyn = abs(nxy); \n"
- " if(all(nxyn < float2(1.0)))\n"
- " {\n"
- " float4 cc = texRECT(gradTex, spos); \n"
- " float mod = cc.b; float angle = cc.a; \n"
- " float theta0 = (anglef - angle)*RPI; \n"
- " float theta = theta0 < 0? theta0 + 8.0 : theta0; // fmod(theta0 + 8.0, 8.0); \n"
- " diff = nxy + offsetpt.xy; \n"
- " float ww = exp(-0.125*dot(diff, diff));\n"
- " float2 weights = 1 - nxyn;\n"
- " float weight = weights.x * weights.y *mod*ww; \n"
- " float theta1 = floor(theta); \n"
- " float weight2 = (theta - theta1) * weight; \n"
- " float weight1 = weight - weight2;\n"
- " DA += float4(theta1 == float4(0, 1, 2, 3))*weight1; \n"
- " DA += float4(theta1 == float4(7, 0, 1, 2))*weight2; \n"
- " DB += float4(theta1 == float4(4, 5, 6, 7))*weight1; \n"
- " DB += float4(theta1 == float4(3, 4, 5, 6))*weight2; \n"
- " }\n"
- " }\n"
- " }\n";
-
- out<<
- " FragData0 = DA; FragData1 = DB;\n"
- "}\n"<<'\0';
-
- ProgramCG * program;
- s_descriptor_fp = program = new ProgramCG(buffer);
- _param_descriptor_gtex = cgGetNamedParameter(*program, "gradTex");
- _param_descriptor_size = cgGetNamedParameter(*program, "size");
- _param_descriptor_dsize = cgGetNamedParameter(*program, "dsize");
-
-
-}
-
-//the shader that computes the descriptors
-void ShaderBagCG::LoadDescriptorShader()
-{
- GlobalUtil::_DescriptorPPT = 16;
- LoadDescriptorShaderF2();
-}
-
-void ShaderBagCG::LoadOrientationShader()
-{
-
- char buffer[10240];
- ostrstream out(buffer,10240);
-
-
- out<<"\n"
- "#define GAUSSIAN_WF "<1 && GlobalUtil::_OrientationPack2 == 0)
- out<<", out float4 OrientationData : COLOR1";
-
- if(GlobalUtil::_SubpixelLocalization || GlobalUtil::_KeepExtremumSign)
- {
- //data for sub-pixel localization
- out<<", uniform samplerRECT texS";
- }
-
- //use 9 float4 to store histogram of 36 directions
- out<<") \n"
- "{ \n"
- " float4 bins[10]; \n"
- " for (int i=0; i<9; i++) bins[i] = float4(0,0,0,0); \n"
- " const float4 loc = texRECT(tex, TexCoord0); \n"
- " const bool orientation_mode = (size.z != 0); \n"
- " float2 pos = loc.xy; \n"
- " float sigma = orientation_mode? abs(size.z) : loc.w; \n";
- if(GlobalUtil::_SubpixelLocalization || GlobalUtil::_KeepExtremumSign)
- {
- out<<
- " if(orientation_mode) {\n"
- " float4 keyx = texRECT(texS, pos);\n"
- " sigma = sigma * pow(size.w, keyx.w); \n"
- " pos.xy = pos.xy + keyx.yz; \n"
- " #if " << GlobalUtil::_KeepExtremumSign << "\n"
- " if(keyx.x<0.6) sigma = - sigma;\n"
- " #endif\n"
- " }\n";
- }
-
- out<<
- " //bool fixed_orientation = (size.z < 0); \n"
- " if(size.z < 0) {FeatureData = float4(pos, 0, sigma); return;}"
- " const float gsigma = sigma * GAUSSIAN_WF; \n"
- " const float2 win = abs(sigma.xx) * (SAMPLE_WF * GAUSSIAN_WF); \n"
- " const float2 dim = size.xy; \n"
- " const float dist_threshold = win.x*win.x+0.5; \n"
- " const float factor = -0.5/(gsigma*gsigma); \n"
- " float4 sz; float2 spos; \n"
- " //if(any(pos.xy <= 1)) discard; \n"
- " sz.xy = max( pos - win, float2(1,1)); \n"
- " sz.zw = min( pos + win, dim-2); \n"
- " sz = floor(sz)+0.5;";
- //loop to get the histogram
-
- out<<"\n"
- " for(spos.y = sz.y; spos.y <= sz.w; spos.y+=1.0) \n"
- " { \n"
- " for(spos.x = sz.x; spos.x <= sz.z; spos.x+=1.0) \n"
- " { \n"
- " const float2 offset = spos - pos; \n"
- " const float sq_dist = dot(offset,offset); \n"
- " if( sq_dist < dist_threshold){ \n"
- " const float4 cc = texRECT(gradTex, spos); \n"
- " const float grad = cc.b; float theta = cc.a; \n"
- " float idx = floor(degrees(theta)*0.1); \n"
- " const float weight = grad*exp(sq_dist * factor); \n"
- " if(idx < 0 ) idx += 36; \n"
- " const float vidx = 4.0 * fract(idx * 0.25);//fmod(idx, 4); \n"
- " const float4 inc = weight*float4(vidx == float4(0,1,2,3)); ";
-
- if(GlobalUtil::_UseDynamicIndexing && strcmp(cgGetProfileString(ProgramCG::_FProfile), "gp4fp")==0)
-// if(ProgramCG::_FProfile == CG_PROFILE_GPU_FP) this enumerant is not defined in cg1.5
- {
- //gp_fp supports dynamic indexing
- out<<"\n"
- " int iidx = int(floor(idx*0.25)); \n"
- " bins[iidx]+=inc; \n"
- " } \n"
- " } \n"
- " }";
-
- }else
- {
- //nvfp40 still does not support dynamic array indexing
- //unrolled binary search...
- out<<"\n"
- " if(idx < 16) \n"
- " { \n"
- " if(idx < 8) \n"
- " { \n"
- " if(idx < 4) { bins[0]+=inc;} \n"
- " else { bins[1]+=inc;} \n"
- " }else \n"
- " { \n"
- " if(idx < 12){ bins[2]+=inc;} \n"
- " else { bins[3]+=inc;} \n"
- " } \n"
- " }else if(idx < 32) \n"
- " { \n"
- " if(idx < 24) \n"
- " { \n"
- " if(idx <20) { bins[4]+=inc;} \n"
- " else { bins[5]+=inc;} \n"
- " }else \n"
- " { \n"
- " if(idx < 28){ bins[6]+=inc;} \n"
- " else { bins[7]+=inc;} \n"
- " } \n"
- " }else \n"
- " { \n"
- " bins[8]+=inc; \n"
- " } \n"
- " } \n"
- " } \n"
- " }";
-
- }
-
- WriteOrientationCodeToStream(out);
-
- ProgramCG * program;
- s_orientation = program = new ProgramCG(buffer);
- _param_orientation_gtex = cgGetNamedParameter(*program, "gradTex");
- _param_orientation_size = cgGetNamedParameter(*program, "size");
- _param_orientation_stex = cgGetNamedParameter(*program, "texS");
-}
-
-void ShaderBagCG::WriteOrientationCodeToStream(std::ostream& out)
-{
- //smooth histogram and find the largest
-/*
- smoothing kernel: (1 3 6 7 6 3 1 )/27
- the same as 3 pass of (1 1 1)/3 averaging
- maybe better to use 4 pass on the vectors...
-*/
-
-
- //the inner loop on different array numbers is always unrolled in fp40
-
- //bug fixed here:)
- out<<"\n"
- " float3x3 mat1 = float3x3(1, 0, 0, 3, 1, 0, 6, 3, 1)/27.0;; //bug fix.. \n"
- " float4x4 mat2 = float4x4( 7, 6, 3, 1, 6, 7, 6, 3, 3, 6, 7, 6, 1, 3, 6, 7)/27.0;;\n"
- " for (int j=0; j<2; j++) \n"
- " { \n"
- " float4 prev = bins[8]; \n"
- " bins[9] = bins[0]; \n"
- " for (int i=0; i<9; i++) \n"
- " { \n"
- " float4 newb = mul ( bins[i], mat2); \n"
- " newb.xyz += mul ( prev.yzw, mat1); \n"
- " prev = bins[i]; \n"
- " newb.wzy += mul ( bins[i+1].zyx, mat1); \n"
- " bins[i] = newb; \n"
- " } \n"
- " }";
-
-
- //find the maximum voting
- out<<"\n"
- " float4 maxh; float2 maxh2; float4 maxh4 = bins[0]; \n"
- " for (int i=1; i<9; i++) maxh4 = max(maxh4, bins[i]); \n"
- " maxh2 = max(maxh4.xy, maxh4.zw); maxh = float4(max(maxh2.x, maxh2.y));";
-
- char *testpeak_code;
- char *savepeak_code;
-
-
-
- //save two/three/four orientations with the largest votings?
-
- //
- if(GlobalUtil::_MaxOrientation>1)
- {
- out<<"\n"
- " float4 Orientations = float4(0, 0, 0, 0); \n"
- " float4 weights = float4(0,0,0,0); ";
-
- testpeak_code = "\n"
- " {test = bins[i]>hh;";
-
- //save the orientations in weight-decreasing order
- if(GlobalUtil::_MaxOrientation ==2)
- {
- savepeak_code = "\n"
- " if(weight <=weights.g){}\n"
- " else if(weight >weights.r)\n"
- " {weights.rg = float2(weight, weights.r); Orientations.rg = float2(th, Orientations.r);}\n"
- " else {weights.g = weight; Orientations.g = th;}";
-
- }else if(GlobalUtil::_MaxOrientation ==3)
- {
- savepeak_code = "\n"
- " if(weight <=weights.b){}\n"
- " else if(weight >weights.r)\n"
- " {weights.rgb = float3(weight, weights.rg); Orientations.rgb = float3(th, Orientations.rg);}\n"
- " else if(weight >weights.g)\n"
- " {weights.gb = float2(weight, weights.g); Orientations.gb = float2(th, Orientations.g);}\n"
- " else {weights.b = weight; Orientations.b = th;}";
- }else
- {
- savepeak_code = "\n"
- " if(weight <=weights.a){}\n"
- " else if(weight >weights.r)\n"
- " {weights = float4(weight, weights.rgb); Orientations = float4(th, Orientations.rgb);}\n"
- " else if(weight >weights.g)\n"
- " {weights.gba = float3(weight, weights.gb); Orientations.gba = float3(th, Orientations.gb);}\n"
- " else if(weight >weights.b)\n"
- " {weights.ba = float2(weight, weights.b); Orientations.ba = float2(th, Orientations.b);}\n"
- " else {weights.a = weight; Orientations.a = th;}";
- }
-
- }else
- {
- out<<"\n"
- " float Orientations = 0; ";
- testpeak_code ="\n"
- " if(npeaks==0){ \n"
- " test = (bins[i] >= maxh) ;";
- savepeak_code="\n"
- " npeaks++; \n"
- " Orientations = th.x;";
-
- }
-
- //find the peaks
- //the following loop will be unrolled
-
- out<<"\n"
- " const float4 hh = maxh * ORIENTATION_THRESHOLD; bool4 test; \n"
- " bins[9] = bins[0]; \n"
- " float npeaks = 0, k = 0; \n"
- " float prevb = bins[8].w; \n"
- " for (int i = 0; i <9 ; i++) \n"
- " {"
- < prevb && bins[i].x > bins[i].y ) \n"
- " { \n"
- " float di = 0.5 * (bins[i].y-prevb) / (bins[i].x *2.0 -bins[i].y -prevb) ; \n"
- " float th = (k+di+0.5); float weight = bins[i].x;"
- < bins[i].xz) ) \n"
- " { \n"
- " float di = 0.5 * (bins[i].z-bins[i].x) / (bins[i].y * 2.0 - bins[i].z - bins[i].x) ; \n"
- " float th = (k+di+1.5); float weight = bins[i].y; "
- < bins[i].yw) ) \n"
- " { \n"
- " float di = 0.5 * (bins[i].w-bins[i].y) / (bins[i].z * 2.0-bins[i].w-bins[i].y) ; \n"
- " float th = (k+di+2.5); float weight = bins[i].z; "
- < bins[i].z && bins[i].w > bins[i+1].x ) \n"
- " { \n"
- " float di = 0.5 * (bins[i+1].x-bins[i].z) / (bins[i].w * 2.0- bins[i+1].x-bins[i].z) ; \n"
- " float th = (k+di+3.5); float weight = bins[i].w; "
- <1)
- {
- out<<"\n"
- " if(orientation_mode){\n"
- " npeaks = dot(float4(1,1,"
- <<(GlobalUtil::_MaxOrientation>2 ? 1 : 0)<<","
- <<(GlobalUtil::_MaxOrientation >3? 1 : 0)<<"), float4(weights>hh));\n"
- " OrientationData = radians((Orientations )*10.0);\n"
- " FeatureData = float4(pos, npeaks, sigma);\n"
- " }else{\n"
- " FeatureData = float4(pos, radians((Orientations.x)*10.0), sigma);\n"
- " }\n";
- }else
- {
- out<<"\n"
- " FeatureData = float4(pos, radians((Orientations.x)*10.0), sigma);";
- }
- //end
- out<<"\n"
- "}\n"<<'\0';
-
-
-}
-
-void ShaderBagCG::SetSimpleOrientationInput(int oTex, float sigma, float sigma_step)
-{
- cgGLSetTextureParameter(_param_orientation_gtex, oTex);
- cgGLEnableTextureParameter(_param_orientation_gtex);
- cgGLSetParameter1f(_param_orientation_size, sigma);
-}
-
-void ShaderBagCG::SetFeatureOrientationParam(int gtex, int width, int height, float sigma, int stex, float step)
-{
- ///
- cgGLSetTextureParameter(_param_orientation_gtex, gtex);
- cgGLEnableTextureParameter(_param_orientation_gtex);
-
- if((GlobalUtil::_SubpixelLocalization || GlobalUtil::_KeepExtremumSign)&& stex)
- {
- //specify texutre for subpixel subscale localization
- cgGLSetTextureParameter(_param_orientation_stex, stex);
- cgGLEnableTextureParameter(_param_orientation_stex);
- }
-
- float size[4];
- size[0] = (float)width;
- size[1] = (float)height;
- size[2] = sigma;
- size[3] = step;
- cgGLSetParameter4fv(_param_orientation_size, size);
-
-}
-
-void ShaderBagCG::SetFeatureDescirptorParam(int gtex, int otex, float dwidth, float fwidth, float width, float height, float sigma)
-{
- ///
- cgGLSetTextureParameter(_param_descriptor_gtex, gtex);
- cgGLEnableTextureParameter(_param_descriptor_gtex);
-
- float dsize[4] ={dwidth, 1.0f/dwidth, fwidth, 1.0f/fwidth};
- cgGLSetParameter4fv(_param_descriptor_dsize, dsize);
- float size[3];
- size[0] = width;
- size[1] = height;
- size[2] = GlobalUtil::_DescriptorWindowFactor;
- cgGLSetParameter3fv(_param_descriptor_size, size);
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////PACKED VERSION?///////////////////////////////////
-
-ShaderBagPKCG::ShaderBagPKCG()
-{
- ProgramCG::InitContext();
-}
-
-void ShaderBagPKCG::UnloadProgram()
-{
-
- cgGLUnbindProgram(ProgramCG::_FProfile);
- cgGLDisableProfile(ProgramCG::_FProfile);
-}
-
-void ShaderBagPKCG::LoadFixedShaders()
-{
- ProgramCG * program;
-
- /*
- char *rgb2gray_packing_code =
- "void main(uniform samplerRECT rgbTex, in float4 TexCoord0 : TEXCOORD0, \n"
- " in float4 TexCoord1 : TEXCOORD1, in float4 TexCoord2 : TEXCOORD2, \n"
- " in float4 TexCoord3 : TEXCOORD3, out float4 FragData : COLOR0){\n"
- " const float3 weight = vec3(0.299, 0.587, 0.114);\n"
- " FragData.r = dot(weight, texRECT(rgbTex,TexCoord0.st ).rgb);\n"
- " FragData.g = dot(weight, texRECT(rgbTex,TexCoord1.st ).rgb);\n"
- " FragData.b = dot(weight, texRECT(rgbTex,TexCoord2.st ).rgb);\n"
- " FragData.a = dot(weight, texRECT(rgbTex,TexCoord3.st ).rgb);}";//
- s_gray = new ProgramCG( rgb2gray_packing_code);
- */
-
- s_gray = new ProgramCG(
- "void main(float4 TexCoord0 : TEXCOORD0, out float4 FragColor : COLOR0, uniform samplerRECT tex){\n"
- "float intensity = dot(float3(0.299, 0.587, 0.114), texRECT(tex,TexCoord0.xy ).rgb);\n"
- "FragColor= float4(intensity, intensity, intensity, 1.0);}" );
-
-
- s_sampling = new ProgramCG(
- "void main(uniform samplerRECT tex, in float4 TexCoord0 : TEXCOORD0, \n"
- " in float4 TexCoord1 : TEXCOORD1, in float4 TexCoord2 : TEXCOORD2, \n"
- " in float4 TexCoord3 : TEXCOORD3, out float4 FragData : COLOR0 ){\n"
- " FragData= float4( texRECT(tex,TexCoord0.st ).r,texRECT(tex,TexCoord1.st ).r,\n"
- " texRECT(tex,TexCoord2.st ).r,texRECT(tex,TexCoord3.st ).r);}" );
-
-
- s_margin_copy = program = new ProgramCG(
- "void main(in float4 texCoord0: TEXCOORD0, out float4 FragColor: COLOR0, \n"
- "uniform samplerRECT tex, uniform float4 truncate){\n"
- "float4 cc = texRECT(tex, min(texCoord0.xy, truncate.xy)); \n"
- "bool2 ob = texCoord0.xy < truncate.xy;\n"
- "if(ob.y) { FragColor = (truncate.z ==0 ? cc.rrbb : cc.ggaa); } \n"
- "else if(ob.x) {FragColor = (truncate.w <1.5 ? cc.rgrg : cc.baba);} \n"
- "else { float4 weights = float4(float4(0, 1, 2, 3) == truncate.w);\n"
- "float v = dot(weights, cc); FragColor = v.xxxx;}}");
-
- _param_margin_copy_truncate = cgGetNamedParameter(*program, "truncate");
-
-
- s_zero_pass = new ProgramCG("void main(out float4 FragColor : COLOR0){FragColor = 0;}");
-
- s_grad_pass = program = new ProgramCG(
- "void main (\n"
- "float4 TexCC : TEXCOORD0, float4 TexLC : TEXCOORD1,\n"
- "float4 TexRC : TEXCOORD2, float4 TexCD : TEXCOORD3, float4 TexCU : TEXCOORD4,\n"
- "out float4 FragData0 : COLOR0, out float4 FragData1 : COLOR1, \n"
- "out float4 FragData2 : COLOR2, uniform samplerRECT tex, uniform samplerRECT texp)\n"
- "{\n"
- " float4 v1, v2, gg;\n"
- " float4 cc = texRECT(tex, TexCC.xy);\n"
- " float4 cp = texRECT(texp, TexCC.xy);\n"
- " FragData0 = cc - cp; \n"
- " float4 cl = texRECT(tex, TexLC.xy); float4 cr = texRECT(tex, TexRC.xy);\n"
- " float4 cd = texRECT(tex, TexCD.xy); float4 cu = texRECT(tex, TexCU.xy);\n"
- " float4 dx = (float4(cr.rb, cc.ga) - float4(cc.rb, cl.ga)).zxwy;\n"
- " float4 dy = (float4(cu.rg, cc.ba) - float4(cc.rg, cd.ba)).zwxy;\n"
- " FragData1 = 0.5 * sqrt(dx*dx + dy * dy);\n"
- " FragData2 = FragData1 > 0? atan2(dy, dx) : float4(0);\n"
- "}\n\0");
-
- _param_grad_pass_texp = cgGetNamedParameter(*program, "texp");
-
-
- s_dog_pass = program = new ProgramCG(
- "void main (float4 TexCC : TEXCOORD0, out float4 FragData0 : COLOR0, \n"
- " uniform samplerRECT tex, uniform samplerRECT texp)\n"
- "{\n"
- " float4 cc = texRECT(tex, TexCC.xy);\n"
- " float4 cp = texRECT(texp, TexCC.xy);\n"
- " FragData0 = cc - cp; \n"
- "}\n\0");
-
- ////
- if(GlobalUtil::_SupportFP40)
- {
- LoadOrientationShader();
- if(GlobalUtil::_DescriptorPPT) LoadDescriptorShader();
- }else
- {
- s_orientation = program = new ProgramCG(
- "void main(out float4 FragColor : COLOR0, \n"
- " uniform samplerRECT fTex, uniform samplerRECT oTex, \n"
- " uniform float2 size, \n"
- " in float2 tpos : TEXCOORD0){\n"
- " float4 cc = texRECT(fTex, tpos);\n"
- " float2 co = cc.xy * 0.5; \n"
- " float4 oo = texRECT(oTex, co);\n"
- " bool2 bo = frac(co) < 0.5; \n"
- " float o = bo.y? (bo.x? oo.r : oo.g) : (bo.x? oo.b : oo.a); \n"
- " FragColor = float4(cc.rg, o, size.x * pow(size.y, cc.a));}");
- _param_orientation_gtex= cgGetNamedParameter(*program, "oTex");
- _param_orientation_size= cgGetNamedParameter(*program, "size");
-
- GlobalUtil::_FullSupported = 0;
- GlobalUtil::_MaxOrientation = 0;
- GlobalUtil::_DescriptorPPT = 0;
- std::cerr<<"Orientation simplified on this hardware"< 0.9)? size : -size);\n"
- " dxy.y = type < 0.2 ? 0 : ((type < 0.3 || type > 0.7 )? -size :size); \n"
- " sincos(cc.b, s, c);\n"
- " FragColor.x = cc.x + c*dxy.x-s*dxy.y;\n"
- " FragColor.y = cc.y + c*dxy.y+s*dxy.x;}\n"
- "}\n\0");
- /*FragColor = float4(tpos, 0.0, 1.0);}\n\0");*/
-
- _param_genvbo_size = cgGetNamedParameter(*program, "sizes");
-
- s_display_gaussian = new ProgramCG(
- "void main(uniform samplerRECT tex, in float4 TexCoord0:TEXCOORD0, out float4 FragData: COLOR0 ){\n"
- "float4 pc = texRECT(tex, TexCoord0.xy); bool2 ff = (frac(TexCoord0.xy) < 0.5);\n"
- "float v = ff.y?(ff.x? pc.r : pc.g):(ff.x?pc.b:pc.a); FragData = float4(v.xxx, 1.0);}");
-
- s_display_dog = new ProgramCG(
- "void main(in float4 TexCoord0 : TEXCOORD0, out float4 FragColor : COLOR0, uniform samplerRECT tex){\n"
- "float4 pc = texRECT(tex, TexCoord0.xy); bool2 ff = (frac(TexCoord0.xy) < 0.5);\n"
- "float v = ff.y ?(ff.x ? pc.r : pc.g):(ff.x ? pc.b : pc.a);float g = (0.5+20.0*v);\n"
- "FragColor = float4(g, g, g, 1.0);}" );
-
-
- s_display_grad = new ProgramCG(
- "void main(in float4 TexCoord0 : TEXCOORD0, out float4 FragColor : COLOR0, uniform samplerRECT tex){\n"
- "float4 pc = texRECT(tex, TexCoord0.xy); bool2 ff = (frac(TexCoord0.xy) < 0.5);\n"
- "float v = ff.y ?(ff.x ? pc.r : pc.g):(ff.x ? pc.b : pc.a); FragColor = float4(5.0 *v.xxx, 1.0); }");
-
- s_display_keys= new ProgramCG(
- "void main(in float4 TexCoord0 : TEXCOORD0, out float4 FragColor : COLOR0, uniform samplerRECT tex){\n"
- "float4 oc = texRECT(tex, TexCoord0.xy); \n"
- "float4 cc = float4(abs(oc.r) == float4(1.0, 2.0, 3.0, 4.0));\n"
- "bool2 ff = (frac(TexCoord0.xy) < 0.5);\n"
- "float v = ff.y ?(ff.x ? cc.r : cc.g):(ff.x ? cc.b : cc.a);\n"
- "if(oc.r == 0) discard;\n"
- "else if(oc.r > 0) FragColor = float4(1.0, 0, 0,1.0); \n"
- "else FragColor = float4(0.0,1.0,0.0,1.0); }" );
-}
-
-void ShaderBagPKCG::LoadGenListShader(int ndoglev, int nlev)
-{
-
- //the V2 algorithms are only slightly faster, but way more complicated
- //LoadGenListShaderV2(ndoglev, nlev); return;
- ProgramCG * program;
-
- s_genlist_init_tight = new ProgramCG(
- "void main (uniform samplerRECT tex, in float4 TexCoord0 : TEXCOORD0,\n"
- "in float4 TexCoord1 : TEXCOORD1, in float4 TexCoord2 : TEXCOORD2, \n"
- "in float4 TexCoord3 : TEXCOORD3, out float4 FragColor : COLOR0)\n"
- "{\n"
- " float4 data = float4( texRECT(tex, TexCoord0.xy).r,\n"
- " texRECT(tex, TexCoord1.xy).r,\n"
- " texRECT(tex, TexCoord2.xy).r,\n"
- " texRECT(tex, TexCoord3.xy).r);\n"
- " FragColor = float4(data != 0);\n"
- "}");
-
- s_genlist_init_ex = program = new ProgramCG(
- "void main (uniform float4 bbox, uniform samplerRECT tex, \n"
- "in float4 TexCoord0 : TEXCOORD0, in float4 TexCoord1 : TEXCOORD1, \n"
- "in float4 TexCoord2 : TEXCOORD2, in float4 TexCoord3 : TEXCOORD3,\n"
- "out float4 FragColor : COLOR0)\n"
- "{\n"
- " bool4 helper1 = abs(texRECT(tex, TexCoord0.xy).r)== float4(1.0, 2.0, 3.0, 4.0); \n"
- " bool4 helper2 = abs(texRECT(tex, TexCoord1.xy).r)== float4(1.0, 2.0, 3.0, 4.0);\n"
- " bool4 helper3 = abs(texRECT(tex, TexCoord2.xy).r)== float4(1.0, 2.0, 3.0, 4.0);\n"
- " bool4 helper4 = abs(texRECT(tex, TexCoord3.xy).r)== float4(1.0, 2.0, 3.0, 4.0);\n"
- " bool4 bx1 = TexCoord0.xxyy < bbox; \n"
- " bool4 bx4 = TexCoord3.xxyy < bbox; \n"
- " bool4 bx2 = bool4(bx4.xy, bx1.zw); \n"
- " bool4 bx3 = bool4(bx1.xy, bx4.zw);\n"
- " helper1 = (bx1.xyxy && bx1.zzww && helper1);\n"
- " helper2 = (bx2.xyxy && bx2.zzww && helper2);\n"
- " helper3 = (bx3.xyxy && bx3.zzww && helper3);\n"
- " helper4 = (bx4.xyxy && bx4.zzww && helper4);\n"
- " FragColor.r = any(helper1.xy || helper1.zw); \n"
- " FragColor.g = any(helper2.xy || helper2.zw); \n"
- " FragColor.b = any(helper3.xy || helper3.zw); \n"
- " FragColor.a = any(helper4.xy || helper4.zw); \n"
- "}");
- _param_genlist_init_bbox = cgGetNamedParameter( *program, "bbox");
-
- s_genlist_end = program = new ProgramCG(
- GlobalUtil::_KeepExtremumSign == 0 ?
-
- "void main( uniform samplerRECT tex, uniform samplerRECT ktex,\n"
- " in float4 tpos : TEXCOORD0, out float4 FragColor : COLOR0)\n"
- "{\n"
- " float4 tc = texRECT( tex, tpos.xy);\n"
- " float2 pos = tc.rg; float index = tc.b;\n"
- " float4 tk = texRECT( ktex, pos); \n"
- " float4 keys = float4(abs(tk.x) == float4(1.0, 2.0, 3.0, 4.0)); \n"
- " float2 opos; \n"
- " opos.x = dot(keys, float4(-0.5, 0.5, -0.5, 0.5));\n"
- " opos.y = dot(keys, float4(-0.5, -0.5, 0.5, 0.5));\n"
- " FragColor = float4(opos + pos + pos + tk.yz, 1.0, tk.w);\n"
- "}" :
-
- "void main( uniform samplerRECT tex, uniform samplerRECT ktex,\n"
- " in float4 tpos : TEXCOORD0, out float4 FragColor : COLOR0)\n"
- "{\n"
- " float4 tc = texRECT( tex, tpos.xy);\n"
- " float2 pos = tc.rg; float index = tc.b;\n"
- " float4 tk = texRECT( ktex, pos); \n"
- " float4 keys = float4(abs(tk.x) == float4(1.0, 2.0, 3.0, 4.0)); \n"
- " float2 opos; \n"
- " opos.x = dot(keys, float4(-0.5, 0.5, -0.5, 0.5));\n"
- " opos.y = dot(keys, float4(-0.5, -0.5, 0.5, 0.5));\n"
- " FragColor = float4(opos + pos + pos + tk.yz, sign(tk.x), tk.w);\n"
- "}"
- );
- _param_genlist_end_ktex = cgGetNamedParameter(*program, "ktex");
-
- //reduction ...
- s_genlist_histo = new ProgramCG(
- "void main (uniform samplerRECT tex, in float2 TexCoord0 : TEXCOORD0,\n"
- "in float2 TexCoord1 : TEXCOORD1, in float2 TexCoord2 : TEXCOORD2, \n"
- "in float2 TexCoord3 : TEXCOORD3, out float4 FragColor : COLOR0)\n"
- "{\n"
- " float4 helper; float4 helper2; \n"
- " helper = texRECT(tex, TexCoord0); helper2.xy = helper.xy + helper.zw; \n"
- " helper = texRECT(tex, TexCoord1); helper2.zw = helper.xy + helper.zw; \n"
- " FragColor.rg = helper2.xz + helper2.yw;\n"
- " helper = texRECT(tex, TexCoord2); helper2.xy = helper.xy + helper.zw; \n"
- " helper = texRECT(tex, TexCoord3); helper2.zw = helper.xy + helper.zw; \n"
- " FragColor.ba= helper2.xz+helper2.yw;\n"
- "}");
-
-
- //read of the first part, which generates tex coordinates
-
- s_genlist_start= program = ShaderBagCG::LoadGenListStepShader(1, 1);
- _param_ftex_width= cgGetNamedParameter(*program, "width");
- _param_genlist_start_tex0 = cgGetNamedParameter(*program, "tex0");
- //stepping
- s_genlist_step = program = ShaderBagCG::LoadGenListStepShader(0, 1);
- _param_genlist_step_tex= cgGetNamedParameter(*program, "tex");
- _param_genlist_step_tex0= cgGetNamedParameter(*program, "tex0");
-
-
-}
-
-
-
-void ShaderBagPKCG::LoadGenListShaderV2(int ndoglev, int nlev)
-{
- ProgramCG * program;
-
- s_genlist_init_tight = new ProgramCG(
- "void main (uniform samplerRECT tex, in float4 TexCoord0 : TEXCOORD0,\n"
- "in float4 TexCoord1 : TEXCOORD1, in float4 TexCoord2 : TEXCOORD2, \n"
- "in float4 TexCoord3 : TEXCOORD3, out float4 FragColor : COLOR0)\n"
- "{\n"
- " float4 data1 = texRECT(tex, TexCoord0.xy);\n"
- " float4 data2 = texRECT(tex, TexCoord1.xy);\n"
- " float4 data3 = texRECT(tex, TexCoord2.xy);\n"
- " float4 data4 = texRECT(tex, TexCoord3.xy);\n"
- " bool4 helper1 = (abs(data1.r), float4(1.0, 2.0, 3.0, 4.0)); \n"
- " bool4 helper2 = (abs(data2.r), float4(1.0, 2.0, 3.0, 4.0));\n"
- " bool4 helper3 = (abs(data3.r), float4(1.0, 2.0, 3.0, 4.0));\n"
- " bool4 helper4 = (abs(data4.r), float4(1.0, 2.0, 3.0, 4.0));\n"
- " FragColor.r = any(helper1.xy || helper1.zw); \n"
- " FragColor.g = any(helper2.xy || helper2.zw); \n"
- " FragColor.b = any(helper3.xy || helper3.zw); \n"
- " FragColor.a = any(helper4.xy || helper4.zw); \n"
- " if(dot(FragColor, float4(1,1,1,1)) == 1) \n"
- " {\n"
- " //use a special method if there is only one in the 16, \n"
- " float4 data, helper; float2 pos, opos; \n"
- " if(FragColor.r){ \n"
- " data = data1; helper = helper1; pos = TexCoord0.xy;\n"
- " }else if(FragColor.g){\n"
- " data = data2; helper = helper2; pos = TexCoord1.xy;\n"
- " }else if(FragColor.b){\n"
- " data = data3; helper = helper3; pos = TexCoord2.xy;\n"
- " }else{\n"
- " data = data4; helper = helper4; pos = TexCoord3.xy;\n"
- " }\n"
- " opos.x = dot(helper, float4(-0.5, 0.5, -0.5, 0.5));\n"
- " opos.y = dot(helper, float4(-0.5, -0.5, 0.5, 0.5));\n"
- " FragColor = float4( pos + pos + opos + data.yz, -1, data.w); \n"
- " }\n"
- "}");
-
- s_genlist_init_ex = program = new ProgramCG(
- "void main (uniform float4 bbox, uniform samplerRECT tex, \n"
- "in float4 TexCoord0 : TEXCOORD0, in float4 TexCoord1 : TEXCOORD1, \n"
- "in float4 TexCoord2 : TEXCOORD2, in float4 TexCoord3 : TEXCOORD3,\n"
- "out float4 FragColor : COLOR0)\n"
- "{\n"
- " float4 data1 = texRECT(tex, TexCoord0.xy);\n"
- " float4 data2 = texRECT(tex, TexCoord1.xy);\n"
- " float4 data3 = texRECT(tex, TexCoord2.xy);\n"
- " float4 data4 = texRECT(tex, TexCoord3.xy);\n"
- " bool4 helper1 = (abs(data1.r), float4(1.0, 2.0, 3.0, 4.0)); \n"
- " bool4 helper2 = (abs(data2.r), float4(1.0, 2.0, 3.0, 4.0));\n"
- " bool4 helper3 = (abs(data3.r), float4(1.0, 2.0, 3.0, 4.0));\n"
- " bool4 helper4 = (abs(data4.r), float4(1.0, 2.0, 3.0, 4.0));\n"
- " bool4 bx1 = TexCoord0.xxyy < bbox; \n"
- " bool4 bx4 = TexCoord3.xxyy < bbox; \n"
- " bool4 bx2 = bool4(bx4.xy, bx1.zw); \n"
- " bool4 bx3 = bool4(bx1.xy, bx4.zw);\n"
- " helper1 = bx1.xyxy && bx1.zzww && helper1; \n"
- " helper2 = bx2.xyxy && bx2.zzww && helper2; \n"
- " helper3 = bx3.xyxy && bx3.zzww && helper3; \n"
- " helper4 = bx4.xyxy && bx4.zzww && helper4; \n"
- " FragColor.r = any(helper1.xy || helper1.zw); \n"
- " FragColor.g = any(helper2.xy || helper2.zw); \n"
- " FragColor.b = any(helper3.xy || helper3.zw); \n"
- " FragColor.a = any(helper4.xy || helper4.zw); \n"
- " if(dot(FragColor, float4(1,1,1,1)) == 1) \n"
- " {\n"
- " //use a special method if there is only one in the 16, \n"
- " float4 data, helper; bool4 bhelper; float2 pos, opos; \n"
- " if(FragColor.r){ \n"
- " data = data1; bhelper = helper1; pos = TexCoord0.xy;\n"
- " }else if(FragColor.g){\n"
- " data = data2; bhelper = helper2; pos = TexCoord1.xy;\n"
- " }else if(FragColor.b){\n"
- " data = data3; bhelper = helper3; pos = TexCoord2.xy;\n"
- " }else{\n"
- " data = data4; bhelper = helper4; pos = TexCoord3.xy;\n"
- " }\n"
- " helper = float4(bhelper); \n"
- " opos.x = dot(helper, float4(-0.5, 0.5, -0.5, 0.5));\n"
- " opos.y = dot(helper, float4(-0.5, -0.5, 0.5, 0.5));\n"
- " FragColor = float4(pos + pos + opos + data.yz, -1, data.w); \n"
- " }\n"
- "}");
- _param_genlist_init_bbox = cgGetNamedParameter( *program, "bbox");
-
- s_genlist_end = program = new ProgramCG(
-
- "void main( uniform samplerRECT tex, uniform samplerRECT ktex,\n"
- " in float4 tpos : TEXCOORD0, out float4 FragColor : COLOR0)\n"
- "{\n"
- " float4 tc = texRECT( tex, tpos.xy);\n"
- " float2 pos = tc.rg; float index = tc.b;\n"
- " if(index == -1)\n"
- " {\n"
- " FragColor = float4(tc.xy, 0, tc.w);\n"
- " }else\n"
- " {\n"
- " float4 tk = texRECT( ktex, pos); \n"
- " float4 keys = float4(abs(tk.r) == float4(1.0, 2.0, 3.0, 4.0)); \n"
- " float2 opos; \n"
- " opos.x = dot(keys, float4(-0.5, 0.5, -0.5, 0.5));\n"
- " opos.y = dot(keys, float4(-0.5, -0.5, 0.5, 0.5));\n"
- " FragColor = float4(opos + pos + pos + tk.yz, 0, tk.w);\n"
- " }\n"
- "}");
- _param_genlist_end_ktex = cgGetNamedParameter(*program, "ktex");
-
- //reduction ...
- s_genlist_histo = new ProgramCG(
- "void main (uniform samplerRECT tex, in float2 TexCoord0 : TEXCOORD0,\n"
- "in float2 TexCoord1 : TEXCOORD1, in float2 TexCoord2 : TEXCOORD2, \n"
- "in float2 TexCoord3 : TEXCOORD3, out float4 FragColor : COLOR0)\n"
- "{\n"
- " float4 helper[4]; float4 helper2; \n"
- " helper[0] = texRECT(tex, TexCoord0); helper2.xy = helper[0].xy + helper[0].zw; \n"
- " helper[1] = texRECT(tex, TexCoord1); helper2.zw = helper[1].xy + helper[1].zw; \n"
- " FragColor.rg = helper2.xz + helper2.yw;\n"
- " helper[2] = texRECT(tex, TexCoord2); helper2.xy = helper[2].xy + helper[2].zw; \n"
- " helper[3] = texRECT(tex, TexCoord3); helper2.zw = helper[3].xy + helper[3].zw; \n"
- " FragColor.ba= helper2.xz+helper2.yw;\n"
- " bool4 keyt = float4(helper[0].z, helper[1].z, helper[2].z, helper[3].z) == -1.0; \n"
- " float keyc = dot(float4(keyt), float4(1,1,1,1)); \n"
- " if(keyc == 1.0 && dot(FragColor, float4(1,1,1,1)) == -1.0) \n"
- " {\n"
- " if(keyt.x) FragColor = helper[0];\n"
- " else if(keyt.y) FragColor = helper[1]; \n"
- " else if(keyt.z) FragColor = helper[2]; \n"
- " else FragColor = helper[3]; \n"
- " }else\n"
- " {\n"
- " FragColor = keyt? float4(1,1,1,1) : FragColor;\n"
- " }\n"
- "}");
-
- //read of the first part, which generates tex coordinates
-
- s_genlist_start= program = ShaderBagCG::LoadGenListStepShaderV2(1, 1);
- _param_ftex_width= cgGetNamedParameter(*program, "width");
- _param_genlist_start_tex0 = cgGetNamedParameter(*program, "tex0");
- //stepping
- s_genlist_step = program = ShaderBagCG::LoadGenListStepShaderV2(0, 1);
- _param_genlist_step_tex= cgGetNamedParameter(*program, "tex");
- _param_genlist_step_tex0= cgGetNamedParameter(*program, "tex0");
-
-
-}
-
-
-
-ProgramCG* ShaderBagCG::LoadGenListStepShaderV2(int start, int step)
-{
- int i;
- char buffer[10240];
- //char chanels[5] = "rgba";
- ostrstream out(buffer, 10240);
- out<<"void main(out float4 FragColor : COLOR0, \n";
-
- for(i = 0; i < step; i++) out<<"uniform samplerRECT tex"<0)
- {
- out<<"float2 cpos = float2(-0.5, 0.5);\t float2 opos;\n";
- for(i = 0; i < step; i++)
- {
-
- out<<"cc = texRECT(tex"< max(v1[i], v2[i]), test2 = cc[i] < min(v1[i], v2[i]);\n"
- " key[i] = cc[i] > THRESHOLD0 && all(test1.xy&&test1.zw)?1.0: 0.0;\n"
- " key[i] = cc[i] < -THRESHOLD0 && all(test2.xy&&test2.zw)? -1.0: key[i];\n"
- " }\n"
- " if(TexCC.x < 1.0) {key.rb = 0;}\n"
- " if(TexCC.y < 1.0) {key.rg = 0;}\n"
- " FragData0 = float4(0.0);\n"
- " if(all(key == 0.0)) return; \n";
-
- //do edge supression first..
- //vector v1 is < (-1, 0), (1, 0), (0,-1), (0, 1)>
- //vector v2 is < (-1,-1), (-1,1), (1,-1), (1, 1)>
-
- out<<
- " float fxx[4], fyy[4], fxy[4], fx[4], fy[4];\n"
- " for(int i = 0; i < 4; i++) \n"
- " {\n"
- " if(key[i] != 0)\n"
- " {\n"
- " float4 D2 = v1[i].xyzw - cc[i];\n"
- " float2 D4 = v2[i].xw - v2[i].yz;\n"
- " float2 D5 = 0.5*(v1[i].yw-v1[i].xz); \n"
- " fx[i] = D5.x;\n"
- " fy[i] = D5.y ;\n"
- " fxx[i] = D2.x + D2.y;\n"
- " fyy[i] = D2.z + D2.w;\n"
- " fxy[i] = 0.25*(D4.x + D4.y);\n"
- " float fxx_plus_fyy = fxx[i] + fyy[i];\n"
- " float score_up = fxx_plus_fyy*fxx_plus_fyy; \n"
- " float score_down = (fxx[i]*fyy[i] - fxy[i]*fxy[i]);\n"
- " if( score_down <= 0 || score_up > THRESHOLD2 * score_down)key[i] = 0;\n"
- " }\n"
- " }\n"
- " if(all(key == 0.0)) return; \n\n";
-
- ////////////////////////////////////////////////
- //read 9 pixels of upper/lower level
- out<<
- " float4 v4[4], v5[4], v6[4];\n"
- " ccc = texRECT(texU, TexCC.xy);\n"
- " clc = texRECT(texU, TexLC.xy);\n"
- " crc = texRECT(texU, TexRC.xy);\n"
- " ccd = texRECT(texU, TexCD.xy);\n"
- " ccu = texRECT(texU, TexCU.xy);\n"
- " cld = texRECT(texU, TexLD.xy);\n"
- " clu = texRECT(texU, TexLU.xy);\n"
- " crd = texRECT(texU, TexRD.xy);\n"
- " cru = texRECT(texU, TexRU.xy);\n"
- " float4 cu = ccc;\n"
- " v4[0] = float4(clc.g, ccc.g, ccd.b, ccc.b);\n"
- " v4[1] = float4(ccc.r, crc.r, ccd.a, ccc.a);\n"
- " v4[2] = float4(clc.a, ccc.a, ccc.r, ccu.r);\n"
- " v4[3] = float4(ccc.b, crc.b, ccc.g, ccu.g);\n"
- " v6[0] = float4(cld.a, clc.a, ccd.a, ccc.a);\n"
- " v6[1] = float4(ccd.b, ccc.b, crd.b, crc.b);\n"
- " v6[2] = float4(clc.g, clu.g, ccc.g, ccu.g);\n"
- " v6[3] = float4(ccc.r, ccu.r, crc.r, cru.r);\n"
- <<
- " for(int i = 0; i < 4; i++)\n"
- " {\n"
- " if(key[i] == 1.0)\n"
- " {\n"
- " bool4 test = cc[i]< max(v4[i], v6[i]); \n"
- " if(cc[i] < cu[i] || any(test.xy||test.zw))key[i] = 0.0; \n"
- " }else if(key[i] == -1.0)\n"
- " {\n"
- " bool4 test = cc[i]> min( v4[i], v6[i]); \n"
- " if(cc[i] > cu[i] || any(test.xy||test.zw))key[i] = 0.0; \n"
- " }\n"
- " }\n"
- " if(all(key == 0.0)) return; \n"
- <<
- " ccc = texRECT(texD, TexCC.xy);\n"
- " clc = texRECT(texD, TexLC.xy);\n"
- " crc = texRECT(texD, TexRC.xy);\n"
- " ccd = texRECT(texD, TexCD.xy);\n"
- " ccu = texRECT(texD, TexCU.xy);\n"
- " cld = texRECT(texD, TexLD.xy);\n"
- " clu = texRECT(texD, TexLU.xy);\n"
- " crd = texRECT(texD, TexRD.xy);\n"
- " cru = texRECT(texD, TexRU.xy);\n"
- " float4 cd = ccc;\n"
- " v5[0] = float4(clc.g, ccc.g, ccd.b, ccc.b);\n"
- " v5[1] = float4(ccc.r, crc.r, ccd.a, ccc.a);\n"
- " v5[2] = float4(clc.a, ccc.a, ccc.r, ccu.r);\n"
- " v5[3] = float4(ccc.b, crc.b, ccc.g, ccu.g);\n"
- " v6[0] = float4(cld.a, clc.a, ccd.a, ccc.a);\n"
- " v6[1] = float4(ccd.b, ccc.b, crd.b, crc.b);\n"
- " v6[2] = float4(clc.g, clu.g, ccc.g, ccu.g);\n"
- " v6[3] = float4(ccc.r, ccu.r, crc.r, cru.r);\n"
- <<
- " for(int i = 0; i < 4; i++)\n"
- " {\n"
- " if(key[i] == 1.0)\n"
- " {\n"
- " bool4 test = cc[i]< max(v5[i], v6[i]);\n"
- " if(cc[i] < cd[i] || any(test.xy||test.zw))key[i] = 0.0; \n"
- " }else if(key[i] == -1.0)\n"
- " {\n"
- " bool4 test = cc[i]>min(v5[i],v6[i]);\n"
- " if(cc[i] > cd[i] || any(test.xy||test.zw))key[i] = 0.0; \n"
- " }\n"
- " }\n"
- " float keysum = dot(abs(key), float4(1, 1, 1, 1)) ;\n"
- " //assume there is only one keypoint in the four. \n"
- " if(keysum != 1.0) return; \n";
-
- //////////////////////////////////////////////////////////////////////
- if(GlobalUtil::_SubpixelLocalization)
-
- out <<
- " float3 offset = float3(0, 0, 0); \n"
- " /*The unrolled follwing loop is faster than a dynamic indexing version.*/\n"
- " for(int idx = 1; idx < 4; idx++)\n"
- " {\n"
- " if(key[idx] != 0) \n"
- " {\n"
- " cu[0] = cu[idx]; cd[0] = cd[idx]; cc[0] = cc[idx]; \n"
- " v4[0] = v4[idx]; v5[0] = v5[idx]; \n"
- " fxy[0] = fxy[idx]; fxx[0] = fxx[idx]; fyy[0] = fyy[idx]; \n"
- " fx[0] = fx[idx]; fy[0] = fy[idx]; \n"
- " }\n"
- " }\n"
- <<
-
- " float fs = 0.5*( cu[0] - cd[0] ); \n"
- " float fss = cu[0] + cd[0] - cc[0] - cc[0];\n"
- " float fxs = 0.25 * (v4[0].y + v5[0].x - v4[0].x - v5[0].y);\n"
- " float fys = 0.25 * (v4[0].w + v5[0].z - v4[0].z - v5[0].w);\n"
- " float4 A0, A1, A2 ; \n"
- " A0 = float4(fxx[0], fxy[0], fxs, -fx[0]); \n"
- " A1 = float4(fxy[0], fyy[0], fys, -fy[0]); \n"
- " A2 = float4(fxs, fys, fss, -fs); \n"
- " float3 x3 = abs(float3(fxx[0], fxy[0], fxs)); \n"
- " float maxa = max(max(x3.x, x3.y), x3.z); \n"
- " if(maxa >= 1e-10 ) \n"
- " { \n"
- " if(x3.y ==maxa ) \n"
- " { \n"
- " float4 TEMP = A1; A1 = A0; A0 = TEMP; \n"
- " }else if( x3.z == maxa ) \n"
- " { \n"
- " float4 TEMP = A2; A2 = A0; A0 = TEMP; \n"
- " } \n"
- " A0 /= A0.x; \n"
- " A1 -= A1.x * A0; \n"
- " A2 -= A2.x * A0; \n"
- " float2 x2 = abs(float2(A1.y, A2.y)); \n"
- " if( x2.y > x2.x ) \n"
- " { \n"
- " float3 TEMP = A2.yzw; \n"
- " A2.yzw = A1.yzw; \n"
- " A1.yzw = TEMP; \n"
- " x2.x = x2.y; \n"
- " } \n"
- " if(x2.x >= 1e-10) { \n"
- " A1.yzw /= A1.y; \n"
- " A2.yzw -= A2.y * A1.yzw; \n"
- " if(abs(A2.z) >= 1e-10) {\n"
- " offset.z = A2.w /A2.z; \n"
- " offset.y = A1.w - offset.z*A1.z; \n"
- " offset.x = A0.w - offset.z*A0.z - offset.y*A0.y; \n"
- " bool test = (abs(cc[0] + 0.5*dot(float3(fx[0], fy[0], fs), offset ))>THRESHOLD1) ;\n"
- " if(!test || any( abs(offset) >= 1.0)) return;\n"
- " }\n"
- " }\n"
- " }\n"
- <<"\n"
- " float keyv = dot(key, float4(1.0, 2.0, 3.0, 4.0));\n"
- " FragData0 = float4(keyv, offset);\n"
- "}\n" <<'\0';
-
- else out << "\n"
- " float keyv = dot(key, float4(1.0, 2.0, 3.0, 4.0));\n"
- " FragData0 = float4(keyv, 0, 0, 0);\n"
- "}\n" <<'\0';
-
- s_keypoint = program = new ProgramCG(buffer);
- //parameter
- _param_dog_texu = cgGetNamedParameter(*program, "texU");
- _param_dog_texd = cgGetNamedParameter(*program, "texD");
-}
-
-void ShaderBagPKCG::LoadOrientationShader()
-{
- char buffer[10240];
- ostrstream out(buffer,10240);
-
- out<<"\n"
- "#define GAUSSIAN_WF "<1 && GlobalUtil::_OrientationPack2 == 0)
- out<<", out float4 OrientationData : COLOR1";
-
-
- //use 9 float4 to store histogram of 36 directions
- out<<") \n"
- "{ \n"
- " float4 bins[10]; \n"
- " for (int i=0; i<9; i++) bins[i] = float4(0,0,0,0); \n"
- " float4 sift = texRECT(tex, TexCoord0); \n"
- " float2 pos = sift.xy; \n"
- " bool orientation_mode = (size.z != 0); \n"
- " float sigma = orientation_mode? (abs(size.z) * pow(size.w, sift.w) * sift.z) : (sift.w); \n"
- " //bool fixed_orientation = (size.z < 0); \n"
- " if(size.z < 0) {FeatureData = float4(pos, 0, sigma); return;}"
- " float gsigma = sigma * GAUSSIAN_WF; \n"
- " float2 win = abs(sigma.xx) * (SAMPLE_WF * GAUSSIAN_WF); \n"
- " float2 dim = size.xy; \n"
- " float4 dist_threshold = float4(win.x*win.x+0.5); \n"
- " float factor = -0.5/(gsigma*gsigma); \n"
- " float4 sz; float2 spos; \n"
- " //if(any(pos.xy <= 1)) discard; \n"
- " sz.xy = max( pos - win, float2(2,2)); \n"
- " sz.zw = min( pos + win, dim-3); \n"
- " sz = floor(sz*0.5) + 0.5; ";
- //loop to get the histogram
-
- out<<"\n"
- " for(spos.y = sz.y; spos.y <= sz.w; spos.y+=1.0) \n"
- " { \n"
- " for(spos.x = sz.x; spos.x <= sz.z; spos.x+=1.0) \n"
- " { \n"
- " float2 offset = 2* spos - pos - 0.5; \n"
- " float4 off = float4(offset, offset + 1); \n"
- " float4 distsq = off.xzxz * off.xzxz + off.yyww * off.yyww; \n"
- " bool4 inside = distsq < dist_threshold; \n"
- " if(any(inside.xy||inside.zw)) \n"
- " { \n"
- " float4 gg = texRECT(gtex, spos); \n"
- " float4 oo = texRECT(otex, spos); \n"
- " float4 weight = gg * exp(distsq * factor); \n"
- " float4 idxv = floor(degrees(oo)*0.1); \n"
- " idxv = idxv<0? idxv + 36.0: idxv; \n"
- " float4 vidx = 4.0* fract(idxv * 0.25);//fmod(idxv, 4.0);\n";
-
- //
- if(GlobalUtil::_UseDynamicIndexing && strcmp(cgGetProfileString(ProgramCG::_FProfile), "gp4fp")==0)
- //if(ProgramCG::_FProfile == CG_PROFILE_GPU_FP) this enumerant is not defined in cg1.5
- {
- //gp4fp supports dynamic indexing, but it might be slow on some GPUs
- out<<"\n"
- " for(int i = 0 ; i < 4; i++)\n"
- " {\n"
- " if(inside[i])\n"
- " {\n"
- " float idx = idxv[i]; \n"
- " float4 inc = weight[i] * float4(vidx[i] == float4(0,1,2,3)); \n"
- " int iidx = int(floor(idx*0.25)); \n"
- " bins[iidx]+=inc; \n"
- " } \n"
- " } \n"
- " } \n"
- " } \n"
- " }";
-
- }else
- {
- //nvfp40 still does not support dynamic array indexing
- //unrolled binary search
- //it seems to be faster than the dyanmic indexing version on some GPUs
- out<<"\n"
- " for(int i = 0 ; i < 4; i++)\n"
- " {\n"
- " if(inside[i])\n"
- " {\n"
- " float idx = idxv[i]; \n"
- " float4 inc = weight[i] * float4(vidx[i] == float4(0,1,2,3)); \n"
- " if(idx < 16) \n"
- " { \n"
- " if(idx < 8) \n"
- " { \n"
- " if(idx < 4) { bins[0]+=inc;} \n"
- " else { bins[1]+=inc;} \n"
- " }else \n"
- " { \n"
- " if(idx < 12){ bins[2]+=inc;} \n"
- " else { bins[3]+=inc;} \n"
- " } \n"
- " }else if(idx < 32) \n"
- " { \n"
- " if(idx < 24) \n"
- " { \n"
- " if(idx <20) { bins[4]+=inc;} \n"
- " else { bins[5]+=inc;} \n"
- " }else \n"
- " { \n"
- " if(idx < 28){ bins[6]+=inc;} \n"
- " else { bins[7]+=inc;} \n"
- " } \n"
- " }else \n"
- " { \n"
- " bins[8]+=inc; \n"
- " } \n"
- " } \n"
- " } \n"
- " } \n"
- " } \n"
- " }";
-
- }
-
- //reuse the code from the unpacked version..
- ShaderBagCG::WriteOrientationCodeToStream(out);
-
-
- ProgramCG * program;
- s_orientation = program = new ProgramCG(buffer);
- _param_orientation_gtex = cgGetNamedParameter(*program, "gtex");
- _param_orientation_otex = cgGetNamedParameter(*program, "otex");
- _param_orientation_size = cgGetNamedParameter(*program, "size");
-
-
-}
-
-void ShaderBagPKCG::LoadDescriptorShader()
-{
- GlobalUtil::_DescriptorPPT = 16;
- LoadDescriptorShaderF2();
-
-}
-
-void ShaderBagPKCG::LoadDescriptorShaderF2()
-{
- //one shader outpout 128/8 = 16 , each fragout encodes 4
- //const double twopi = 2.0*3.14159265358979323846;
- //const double rpi = 8.0/twopi;
- char buffer[10240];
- ostrstream out(buffer, 10240);
-
- out<=dim-1)) "
- " //discard; \n"
- " { FragData0 = FragData1 = float4(0.0); return; }\n"
- " float anglef = texRECT(tex, coord).z;\n"
- " if(anglef > M_PI) anglef -= TWO_PI;\n"
- " float sigma = texRECT(tex, coord).w; \n"
- " float spt = abs(sigma * WF); //default to be 3*sigma \n";
- //rotation
- out<<
- " float4 cscs, rots; \n"
- " sincos(anglef, cscs.y, cscs.x); \n"
- " cscs.zw = - cscs.xy; \n"
- " rots = cscs /spt; \n"
- " cscs *= spt; \n";
-
- //here cscs is actually (cos, sin, -cos, -sin) * (factor: 3)*sigma
- //and rots is (cos, sin, -cos, -sin ) /(factor*sigma)
- //devide the 4x4 sift grid into 16 1x1 block, and each corresponds to a shader thread
- //To use linear interoplation, 1x1 is increased to 2x2, by adding 0.5 to each side
- out<<
- " float4 temp; float2 pt, offsetpt; \n"
- " /*the fraction part of idx is .5*/ \n"
- " offsetpt.x = 4.0 * fract(idx * 0.25) - 2.0; \n"
- " offsetpt.y = floor(idx*0.25) - 1.5; \n"
- " temp = cscs.xwyx*offsetpt.xyxy; \n"
- " pt = pos + temp.xz + temp.yw; \n";
-
- //get a horizontal bounding box of the rotated rectangle
- out<<
- " float2 bwin = abs(cscs.xy); \n"
- " float bsz = bwin.x + bwin.y; \n"
- " float4 sz; float2 spos; \n"
- " sz.xy = max(pt - bsz, float2(2,2));\n"
- " sz.zw = min(pt + bsz, dim - 3); \n"
- " sz = floor(sz * 0.5) + 0.5;"; //move sample point to pixel center
- //get voting for two box
-
- out<<"\n"
- " float4 DA, DB; \n"
- " DA = DB = float4(0, 0, 0, 0); \n"
- " float4 nox = float4(0, rots.xy, rots.x + rots.y); \n"
- " float4 noy = float4(0, rots.wx, rots.w + rots.x); \n"
- " for(spos.y = sz.y; spos.y <= sz.w; spos.y+=1.0) \n"
- " { \n"
- " for(spos.x = sz.x; spos.x <= sz.z; spos.x+=1.0) \n"
- " { \n"
- " float2 tpt = spos * 2.0 - pt - 0.5; \n"
- " float4 temp = rots.xywx * tpt.xyxy; \n"
- " float2 temp2 = temp.xz + temp.yw; \n"
- " float4 nx = temp2.x + nox; \n"
- " float4 ny = temp2.y + noy; \n"
- " float4 nxn = abs(nx), nyn = abs(ny); \n"
- " bool4 inside = (max(nxn, nyn) < 1.0); \n"
- " if(any(inside.xy || inside.zw))\n"
- " {\n"
- " float4 gg = texRECT(gtex, spos);\n"
- " float4 oo = texRECT(otex, spos);\n"
- " float4 theta0 = (anglef - oo)*RPI;\n"
- " float4 theta = theta0 < 0? theta0 + 8.0 : theta0;//8.0 * frac(1.0 + 0.125 * theta0);// \n"
- " float4 theta1 = floor(theta); \n"
- " float4 diffx = nx + offsetpt.x, diffy = ny + offsetpt.y; \n"
- " float4 ww = exp(-0.125 * (diffx * diffx + diffy * diffy )); \n"
- " float4 weight = (1 - nxn) * (1 - nyn) * gg * ww; \n"
- " float4 weight2 = (theta - theta1) * weight; \n"
- " float4 weight1 = weight - weight2; \n"
- " for(int i = 0;i < 4; i++)\n"
- " {\n"
- " if(inside[i])\n"
- " {\n"
- " DA += float4(theta1[i] == float4(0, 1, 2, 3))*weight1[i]; \n"
- " DA += float4(theta1[i] == float4(7, 0, 1, 2))*weight2[i]; \n"
- " DB += float4(theta1[i] == float4(4, 5, 6, 7))*weight1[i]; \n"
- " DB += float4(theta1[i] == float4(3, 4, 5, 6))*weight2[i]; \n"
- " }\n"
- " }\n"
- " }\n"
- " }\n"
- " }\n";
- out<<
- " FragData0 = DA; FragData1 = DB;\n"
- "}\n"<<'\0';
- ProgramCG * program;
-
- s_descriptor_fp = program = new ProgramCG(buffer);
- _param_descriptor_gtex = cgGetNamedParameter(*program, "gtex");
- _param_descriptor_otex = cgGetNamedParameter(*program, "otex");
- _param_descriptor_size = cgGetNamedParameter(*program, "size");
- _param_descriptor_dsize = cgGetNamedParameter(*program, "dsize");
-
-}
-
-void ShaderBagPKCG::SetMarginCopyParam(int xmax, int ymax)
-{
- float truncate[4];
- truncate[0] = (xmax - 0.5f) * 0.5f; //((xmax + 1) >> 1) - 0.5f;
- truncate[1] = (ymax - 0.5f) * 0.5f; //((ymax + 1) >> 1) - 0.5f;
- truncate[2] = (xmax %2 == 1)? 0.0f: 1.0f;
- truncate[3] = truncate[2] + (((ymax % 2) == 1)? 0.0f : 2.0f);
- cgGLSetParameter4fv(_param_margin_copy_truncate, truncate);
-}
-
-void ShaderBagPKCG::SetGradPassParam(int texP)
-{
- cgGLSetTextureParameter(_param_grad_pass_texp, texP);
- cgGLEnableTextureParameter(_param_grad_pass_texp);
-}
-
-void ShaderBagPKCG::SetGenListEndParam(int ktex)
-{
- cgGLSetTextureParameter(_param_genlist_end_ktex, ktex);
- cgGLEnableTextureParameter(_param_genlist_end_ktex);
-}
-
-void ShaderBagPKCG::SetDogTexParam(int texU, int texD)
-{
- cgGLSetTextureParameter(_param_dog_texu, texU);
- cgGLEnableTextureParameter(_param_dog_texu);
- cgGLSetTextureParameter(_param_dog_texd, texD);
- cgGLEnableTextureParameter(_param_dog_texd);
-}
-
-void ShaderBagPKCG::SetGenListInitParam(int w, int h)
-{
- float bbox[4] = {(w -1.0f) * 0.5f +0.25f, (w-1.0f) * 0.5f - 0.25f, (h - 1.0f) * 0.5f + 0.25f, (h-1.0f) * 0.5f - 0.25f};
- cgGLSetParameter4fv(_param_genlist_init_bbox, bbox);
-}
-
-
-void ShaderBagPKCG::SetGenListStartParam(float width, int tex0)
-{
- cgGLSetParameter1f(_param_ftex_width, width);
-
- if(_param_genlist_start_tex0)
- {
- cgGLSetTextureParameter(_param_genlist_start_tex0, tex0);
- cgGLEnableTextureParameter(_param_genlist_start_tex0);
- }
-}
-
-
-
-void ShaderBagPKCG::SetGenListStepParam(int tex, int tex0)
-{
- cgGLSetTextureParameter(_param_genlist_step_tex, tex);
- cgGLEnableTextureParameter(_param_genlist_step_tex);
- cgGLSetTextureParameter(_param_genlist_step_tex0, tex0);
- cgGLEnableTextureParameter(_param_genlist_step_tex0);
-}
-
-void ShaderBagPKCG::SetGenVBOParam(float width, float fwidth, float size)
-{
- float sizes[4] = {size*3.0f, fwidth, width, 1.0f/width};
- cgGLSetParameter4fv(_param_genvbo_size, sizes);
-}
-
-void ShaderBagPKCG::SetSimpleOrientationInput(int oTex, float sigma, float sigma_step)
-{
- cgGLSetTextureParameter(_param_orientation_gtex, oTex);
- cgGLEnableTextureParameter(_param_orientation_gtex);
- cgGLSetParameter2f(_param_orientation_size, sigma, sigma_step);
-}
-
-
-void ShaderBagPKCG::SetFeatureOrientationParam(int gtex, int width, int height, float sigma, int otex, float step)
-{
- ///
- cgGLSetTextureParameter(_param_orientation_gtex, gtex);
- cgGLEnableTextureParameter(_param_orientation_gtex);
- cgGLSetTextureParameter(_param_orientation_otex, otex);
- cgGLEnableTextureParameter(_param_orientation_otex);
-
- float size[4];
- size[0] = (float)width;
- size[1] = (float)height;
- size[2] = sigma;
- size[3] = step;
- cgGLSetParameter4fv(_param_orientation_size, size);
-
-}
-
-void ShaderBagPKCG::SetFeatureDescirptorParam(int gtex, int otex, float dwidth, float fwidth, float width, float height, float sigma)
-{
- ///
-
- cgGLSetTextureParameter(_param_descriptor_gtex, gtex);
- cgGLEnableTextureParameter(_param_descriptor_gtex);
- cgGLSetTextureParameter(_param_descriptor_otex, otex);
- cgGLEnableTextureParameter(_param_descriptor_otex);
-
-
- float dsize[4] ={dwidth, 1.0f/dwidth, fwidth, 1.0f/fwidth};
- cgGLSetParameter4fv(_param_descriptor_dsize, dsize);
- float size[3];
- size[0] = width;
- size[1] = height;
- size[2] = GlobalUtil::_DescriptorWindowFactor;
- cgGLSetParameter3fv(_param_descriptor_size, size);
-
-
-}
-
-#endif
-
diff --git a/3rdparty/SiftGPU/src/SiftGPU/ProgramCG.h b/3rdparty/SiftGPU/src/SiftGPU/ProgramCG.h
deleted file mode 100644
index 6ce072cd..00000000
--- a/3rdparty/SiftGPU/src/SiftGPU/ProgramCG.h
+++ /dev/null
@@ -1,161 +0,0 @@
-////////////////////////////////////////////////////////////////////////////
-// File: ProgramCG.h
-// Author: Changchang Wu
-// Description : interface for the ProgramCG classes.
-// ProgramCG: Cg programs
-// ShaderBagCG: All Cg shaders for Sift in a bag
-// FilterGLCG: Cg Gaussian Filters
-//
-// Copyright (c) 2007 University of North Carolina at Chapel Hill
-// All Rights Reserved
-//
-// Permission to use, copy, modify and distribute this software and its
-// documentation for educational, research and non-profit purposes, without
-// fee, and without a written agreement is hereby granted, provided that the
-// above copyright notice and the following paragraph appear in all copies.
-//
-// The University of North Carolina at Chapel Hill make no representations
-// about the suitability of this software for any purpose. It is provided
-// 'as is' without express or implied warranty.
-//
-// Please send BUG REPORTS to ccwu@cs.unc.edu
-//
-////////////////////////////////////////////////////////////////////////////
-
-
-#if defined(CG_SIFTGPU_ENABLED)
-
-#ifndef _PROGRAM_CG_H
-#define _PROGRAM_CG_H
-
-#include "ProgramGPU.h"
-class FragmentProgram;
-#include "Cg/cgGL.h"
-
-class ProgramCG:public ProgramGPU
-{
- CGprogram _programID;
- CGprofile _profile;
- int _valid;
-public:
- static CGcontext _Context;
- static CGprofile _FProfile;
-public:
- operator CGprogram (){return _programID;}
- CGprogram GetProgramID(){return _programID;}
- int UseProgram();
- int IsValidProgram(){return _programID && _valid;}
- static void ErrorCallback();
- static void InitContext();
- static void DestroyContext();
- ProgramCG(const char * code, const char** cg_compile_args= NULL, CGprofile profile = ProgramCG::_FProfile);
- ProgramCG();
- virtual ~ProgramCG();
-
-};
-
-class ShaderBagCG:public ShaderBag
-{
- CGparameter _param_dog_texu;
- CGparameter _param_dog_texd;
- CGparameter _param_genlist_start_tex0;
- CGparameter _param_ftex_width;
- CGparameter _param_genlist_step_tex;
- CGparameter _param_genlist_step_tex0;
- CGparameter _param_genvbo_size;
- CGparameter _param_orientation_gtex;
- CGparameter _param_orientation_stex;
- CGparameter _param_orientation_size;
- CGparameter _param_descriptor_gtex;
- CGparameter _param_descriptor_size;
- CGparameter _param_descriptor_dsize;
- CGparameter _param_margin_copy_truncate;
- CGparameter _param_genlist_init_bbox;
-public:
- virtual void LoadDescriptorShader();
- void LoadDescriptorShaderF2();
- static void WriteOrientationCodeToStream(ostream& out);
- virtual void SetGenListInitParam(int w, int h);
- virtual void SetMarginCopyParam(int xmax, int ymax);
- virtual void SetFeatureOrientationParam(int gtex, int width, int height, float sigma, int stex = 0, float step = 1.0f);
- virtual void SetFeatureDescirptorParam(int gtex, int otex, float dwidth, float fwidth, float width, float height, float sigma);
- virtual void SetSimpleOrientationInput(int oTex, float sigma, float sigma_step);
- void LoadOrientationShader();
- virtual void SetGenListStartParam(float width, int tex0);
- static ProgramCG* LoadGenListStepShader(int start, int step);
- static ProgramCG* LoadGenListStepShaderV2(int start, int step);
- void LoadGenListShader(int ndoglev, int nlev);
- virtual void UnloadProgram();
- virtual void SetDogTexParam(int texU, int texD);
- virtual void SetGenListStepParam(int tex, int tex0);
- virtual void SetGenVBOParam( float width, float fwidth, float size);
- virtual void LoadFixedShaders();
- virtual void LoadDisplayShaders();
- virtual void LoadKeypointShader(float threshold, float edgeThreshold);
- virtual int LoadKeypointShaderMR(float threshold, float edgeThreshold);
- ShaderBagCG();
- virtual ~ShaderBagCG(){}
-};
-
-
-class FilterGLCG : public FilterProgram
-{
-private:
- ProgramGPU* CreateFilterH(float kernel[], float offset[], int width);
- ProgramGPU* CreateFilterV(float kernel[], float offset[], int height);
- //packed version
- ProgramGPU* CreateFilterHPK(float kernel[], float offset[], int width);
- ProgramGPU* CreateFilterVPK(float kernel[], float offset[], int height);
-};
-
-class ShaderBagPKCG:public ShaderBag
-{
-private:
- CGparameter _param_dog_texu;
- CGparameter _param_dog_texd;
- CGparameter _param_margin_copy_truncate;
- CGparameter _param_grad_pass_texp;
- CGparameter _param_genlist_init_bbox;
- CGparameter _param_genlist_start_tex0;
- CGparameter _param_ftex_width;
- CGparameter _param_genlist_step_tex;
- CGparameter _param_genlist_step_tex0;
- CGparameter _param_genlist_end_ktex;
- CGparameter _param_genvbo_size;
- CGparameter _param_orientation_gtex;
- CGparameter _param_orientation_otex;
- CGparameter _param_orientation_size;
- CGparameter _param_descriptor_gtex;
- CGparameter _param_descriptor_otex;
- CGparameter _param_descriptor_size;
- CGparameter _param_descriptor_dsize;
-
-public:
- ShaderBagPKCG();
- virtual ~ShaderBagPKCG(){}
- virtual void LoadDescriptorShader();
- virtual void LoadDescriptorShaderF2();
- virtual void LoadOrientationShader();
- virtual void LoadGenListShader(int ndoglev, int nlev);
- virtual void LoadGenListShaderV2(int ndoglev, int nlev);
- virtual void UnloadProgram() ;
- virtual void LoadKeypointShader(float threshold, float edgeTrheshold);
- virtual void LoadFixedShaders();
- virtual void LoadDisplayShaders();
- virtual void SetGradPassParam(int texP);
- virtual void SetGenListEndParam(int ktex);
-public:
- //parameters
- virtual void SetGenListStartParam(float width, int tex0);
- virtual void SetGenListInitParam(int w, int h);
- virtual void SetMarginCopyParam(int xmax, int ymax);
- virtual void SetDogTexParam(int texU, int texD);
- virtual void SetGenListStepParam(int tex, int tex0);
- virtual void SetGenVBOParam( float width, float fwidth, float size);
- virtual void SetFeatureDescirptorParam(int gtex, int otex, float dwidth, float fwidth, float width, float height, float sigma);
- virtual void SetFeatureOrientationParam(int gtex, int width, int height, float sigma, int stex, float step);
- virtual void SetSimpleOrientationInput(int oTex, float sigma, float sigma_step);
-};
-#endif
-#endif
-
diff --git a/3rdparty/SiftGPU/src/SiftGPU/ProgramCL.cpp b/3rdparty/SiftGPU/src/SiftGPU/ProgramCL.cpp
deleted file mode 100644
index 3b13ff12..00000000
--- a/3rdparty/SiftGPU/src/SiftGPU/ProgramCL.cpp
+++ /dev/null
@@ -1,1592 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// File: ProgramCL.cpp
-// Author: Changchang Wu
-// Description : implementation of CL related class.
-// class ProgramCL A simple wrapper of Cg programs
-//
-// Copyright (c) 2007 University of North Carolina at Chapel Hill
-// All Rights Reserved
-//
-// Permission to use, copy, modify and distribute this software and its
-// documentation for educational, research and non-profit purposes, without
-// fee, and without a written agreement is hereby granted, provided that the
-// above copyright notice and the following paragraph appear in all copies.
-//
-// The University of North Carolina at Chapel Hill make no representations
-// about the suitability of this software for any purpose. It is provided
-// 'as is' without express or implied warranty.
-//
-// Please send BUG REPORTS to ccwu@cs.unc.edu
-//
-////////////////////////////////////////////////////////////////////////////
-
-#if defined(CL_SIFTGPU_ENABLED)
-
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-using namespace std;
-
-#include "GlobalUtil.h"
-#include "CLTexImage.h"
-#include "ProgramCL.h"
-#include "SiftGPU.h"
-
-
-#if defined(_WIN32)
- #pragma comment (lib, "OpenCL.lib")
-#endif
-
-#ifndef _INC_WINDOWS
-#ifndef WIN32_LEAN_AND_MEAN
- #define WIN32_LEAN_AND_MEAN
-#endif
-#include
-#endif
-
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
-
-ProgramCL::ProgramCL()
-{
- _program = NULL;
- _kernel = NULL;
- _valid = 0;
-}
-
-ProgramCL::~ProgramCL()
-{
- if(_kernel) clReleaseKernel(_kernel);
- if(_program) clReleaseProgram(_program);
-}
-
-ProgramCL::ProgramCL(const char* name, const char * code, cl_context context, cl_device_id device) : _valid(1)
-{
- const char * src[1] = {code}; cl_int status;
-
- _program = clCreateProgramWithSource(context, 1, src, NULL, &status);
- if(status != CL_SUCCESS) _valid = 0;
-
- status = clBuildProgram(_program, 0, NULL,
- GlobalUtil::_debug ?
- "-cl-fast-relaxed-math -cl-single-precision-constant -cl-nv-verbose" :
- "-cl-fast-relaxed-math -cl-single-precision-constant", NULL, NULL);
-
- if(status != CL_SUCCESS) {PrintBuildLog(device, 1); _valid = 0;}
- else if(GlobalUtil::_debug) PrintBuildLog(device, 0);
-
- _kernel = clCreateKernel(_program, name, &status);
- if(status != CL_SUCCESS) _valid = 0;
-}
-
-void ProgramCL::PrintBuildLog(cl_device_id device, int all)
-{
- char buffer[10240] = "\0";
- cl_int status = clGetProgramBuildInfo(
- _program, device, CL_PROGRAM_BUILD_LOG, sizeof(buffer), buffer, NULL);
- if(all )
- {
- std::cerr << buffer << endl;
- }else
- {
- const char * pos = strstr(buffer, "ptxas");
- if(pos) std::cerr << pos << endl;
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////PACKED VERSION?///////////////////////////////////
-
-ProgramBagCL::ProgramBagCL()
-{
- ////////////////////////////////////
- _context = NULL; _queue = NULL;
- s_gray = s_sampling = NULL;
- s_packup = s_zero_pass = NULL;
- s_gray_pack = s_unpack = NULL;
- s_sampling_u = NULL;
- s_dog_pass = NULL;
- s_grad_pass = NULL;
- s_grad_pass2 = NULL;
- s_unpack_dog = NULL;
- s_unpack_grd = NULL;
- s_unpack_key = NULL;
- s_keypoint = NULL;
- f_gaussian_skip0 = NULL;
- f_gaussian_skip1 = NULL;
- f_gaussian_step = 0;
-
- ////////////////////////////////
- GlobalUtil::StartTimer("Initialize OpenCL");
- if(!InitializeContext()) return;
- GlobalUtil::StopTimer();
-
-}
-
-
-
-ProgramBagCL::~ProgramBagCL()
-{
- if(s_gray) delete s_gray;
- if(s_sampling) delete s_sampling;
- if(s_zero_pass) delete s_zero_pass;
- if(s_packup) delete s_packup;
- if(s_unpack) delete s_unpack;
- if(s_gray_pack) delete s_gray_pack;
- if(s_sampling_u) delete s_sampling_u;
- if(s_dog_pass) delete s_dog_pass;
- if(s_grad_pass) delete s_grad_pass;
- if(s_grad_pass2) delete s_grad_pass2;
- if(s_unpack_dog) delete s_unpack_dog;
- if(s_unpack_grd) delete s_unpack_grd;
- if(s_unpack_key) delete s_unpack_key;
- if(s_keypoint) delete s_keypoint;
-
- if(f_gaussian_skip1) delete f_gaussian_skip1;
-
- for(unsigned int i = 0; i < f_gaussian_skip0_v.size(); i++)
- {
- if(f_gaussian_skip0_v[i]) delete f_gaussian_skip0_v[i];
- }
- if(f_gaussian_step && _gaussian_step_num > 0)
- {
- for(int i = 0; i< _gaussian_step_num; i++)
- {
- delete f_gaussian_step[i];
- }
- delete[] f_gaussian_step;
- }
-
- //////////////////////////////////////
- if(_context) clReleaseContext(_context);
- if(_queue) clReleaseCommandQueue(_queue);
-}
-
-bool ProgramBagCL::InitializeContext()
-{
- cl_uint num_platform, num_device;
- cl_int status;
- // Get OpenCL platform count
- status = clGetPlatformIDs (0, NULL, &num_platform);
- if (status != CL_SUCCESS || num_platform == 0) return false;
-
- cl_platform_id platforms[16];
- if(num_platform > 16 ) num_platform = 16;
- status = clGetPlatformIDs (num_platform, platforms, NULL);
- _platform = platforms[0];
-
- ///////////////////////////////
- status = clGetDeviceIDs(_platform, CL_DEVICE_TYPE_GPU, 0, NULL, &num_device);
- if(status != CL_SUCCESS || num_device == 0) return false;
-
- // Create the device list
- cl_device_id* devices = new cl_device_id [num_device];
- status = clGetDeviceIDs(_platform, CL_DEVICE_TYPE_GPU, num_device, devices, NULL);
- _device = (status == CL_SUCCESS? devices[0] : 0); delete[] devices;
- if(status != CL_SUCCESS) return false;
-
-
- if(GlobalUtil::_verbose)
- {
- cl_device_mem_cache_type is_gcache;
- clGetDeviceInfo(_device, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, sizeof(is_gcache), &is_gcache, NULL);
- if(is_gcache == CL_NONE) std::cout << "No cache for global memory\n";
- //else if(is_gcache == CL_READ_ONLY_CACHE) std::cout << "Read only cache for global memory\n";
- //else std::cout << "Read/Write cache for global memory\n";
- }
-
- //context;
- if(GlobalUtil::_UseSiftGPUEX)
- {
- cl_context_properties prop[] = {
- CL_CONTEXT_PLATFORM, (cl_context_properties)_platform,
- CL_GL_CONTEXT_KHR, (cl_context_properties)wglGetCurrentContext(),
- CL_WGL_HDC_KHR, (cl_context_properties)wglGetCurrentDC(), 0 };
- _context = clCreateContext(prop, 1, &_device, NULL, NULL, &status);
- if(status != CL_SUCCESS) return false;
- }else
- {
- _context = clCreateContext(0, 1, &_device, NULL, NULL, &status);
- if(status != CL_SUCCESS) return false;
- }
-
- //command queue
- _queue = clCreateCommandQueue(_context, _device, 0, &status);
- return status == CL_SUCCESS;
-}
-
-void ProgramBagCL::InitProgramBag(SiftParam¶m)
-{
- GlobalUtil::StartTimer("Load Programs");
- LoadFixedShaders();
- LoadDynamicShaders(param);
- if(GlobalUtil::_UseSiftGPUEX) LoadDisplayShaders();
- GlobalUtil::StopTimer();
-}
-
-
-void ProgramBagCL::UnloadProgram()
-{
-
-}
-
-void ProgramBagCL::FinishCL()
-{
- clFinish(_queue);
-}
-
-void ProgramBagCL::LoadFixedShaders()
-{
-
-
- s_gray = new ProgramCL( "gray",
- "__kernel void gray(__read_only image2d_t input, __write_only image2d_t output) {\n"
- "sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;\n"
- "int2 coord = (int2)(get_global_id(0), get_global_id(1));\n"
- "float4 weight = (float4)(0.299, 0.587, 0.114, 0.0);\n"
- "float intensity = dot(weight, read_imagef(input,sampler, coord ));\n"
- "float4 result= (float4)(intensity, intensity, intensity, 1.0);\n"
- "write_imagef(output, coord, result); }", _context, _device );
-
-
- s_sampling = new ProgramCL("sampling",
- "__kernel void sampling(__read_only image2d_t input, __write_only image2d_t output,\n"
- " int width, int height) {\n"
- "sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;\n"
- "int x = get_global_id(0), y = get_global_id(1); \n"
- "if( x >= width || y >= height) return;\n"
- "int xa = x + x, ya = y + y; \n"
- "int xb = xa + 1, yb = ya + 1; \n"
- "float v1 = read_imagef(input, sampler, (int2) (xa, ya)).x; \n"
- "float v2 = read_imagef(input, sampler, (int2) (xb, ya)).x; \n"
- "float v3 = read_imagef(input, sampler, (int2) (xa, yb)).x; \n"
- "float v4 = read_imagef(input, sampler, (int2) (xb, yb)).x; \n"
- "float4 result = (float4) (v1, v2, v3, v4);"
- "write_imagef(output, (int2) (x, y), result); }" , _context, _device);
-
- s_sampling_k = new ProgramCL("sampling_k",
- "__kernel void sampling_k(__read_only image2d_t input, __write_only image2d_t output, "
- " int width, int height,\n"
- " int step, int halfstep) {\n"
- "sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;\n"
- "int x = get_global_id(0), y = get_global_id(1); \n"
- "if( x >= width || y >= height) return;\n"
- "int xa = x * step, ya = y *step; \n"
- "int xb = xa + halfstep, yb = ya + halfstep; \n"
- "float v1 = read_imagef(input, sampler, (int2) (xa, ya)).x; \n"
- "float v2 = read_imagef(input, sampler, (int2) (xb, ya)).x; \n"
- "float v3 = read_imagef(input, sampler, (int2) (xa, yb)).x; \n"
- "float v4 = read_imagef(input, sampler, (int2) (xb, yb)).x; \n"
- "float4 result = (float4) (v1, v2, v3, v4);"
- "write_imagef(output, (int2) (x, y), result); }" , _context, _device);
-
-
- s_sampling_u = new ProgramCL("sampling_u",
- "__kernel void sampling_u(__read_only image2d_t input, \n"
- " __write_only image2d_t output,\n"
- " int width, int height,\n"
- " float step, float halfstep) {\n"
- "sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_LINEAR;\n"
- "int x = get_global_id(0), y = get_global_id(1); \n"
- "if( x >= width || y >= height) return;\n"
- "float xa = x * step, ya = y *step; \n"
- "float xb = xa + halfstep, yb = ya + halfstep; \n"
- "float v1 = read_imagef(input, sampler, (float2) (xa, ya)).x; \n"
- "float v2 = read_imagef(input, sampler, (float2) (xb, ya)).x; \n"
- "float v3 = read_imagef(input, sampler, (float2) (xa, yb)).x; \n"
- "float v4 = read_imagef(input, sampler, (float2) (xb, yb)).x; \n"
- "float4 result = (float4) (v1, v2, v3, v4);"
- "write_imagef(output, (int2) (x, y), result); }" , _context, _device);
-
-
- s_zero_pass = new ProgramCL("zero_pass",
- "__kernel void zero_pass(__write_only image2d_t output){\n"
- "int2 coord = (int2)(get_global_id(0), get_global_id(1));\n"
- "write_imagef(output, coord, (float4)(0.0));}", _context, _device);
-
- s_packup = new ProgramCL("packup",
- "__kernel void packup(__global float* input, __write_only image2d_t output,\n"
- " int twidth, int theight, int width){\n"
- "int2 coord = (int2)(get_global_id(0), get_global_id(1));\n"
- "if(coord.x >= twidth || coord.y >= theight) return;\n"
- "int index0 = (coord.y + coord.y) * width; \n"
- "int index1 = index0 + coord.x;\n"
- "int x2 = min(width -1, coord.x); \n"
- "float v1 = input[index1 + coord.x], v2 = input[index1 + x2]; \n"
- "int index2 = index1 + width; \n"
- "float v3 = input[index2 + coord.x], v4 = input[index2 + x2]; \n "
- "write_imagef(output, coord, (float4) (v1, v2, v3, v4));}", _context, _device);
-
- s_dog_pass = new ProgramCL("dog_pass",
- "__kernel void dog_pass(__read_only image2d_t tex, __read_only image2d_t texp,\n"
- " __write_only image2d_t dog, int width, int height) {\n"
- "sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE |\n"
- " CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;\n"
- "int2 coord = (int2)(get_global_id(0), get_global_id(1)); \n"
- "if( coord.x >= width || coord.y >= height) return;\n"
- "float4 cc = read_imagef(tex , sampler, coord); \n"
- "float4 cp = read_imagef(texp, sampler, coord);\n"
- "write_imagef(dog, coord, cc - cp); }\n", _context, _device);
-
- s_grad_pass = new ProgramCL("grad_pass",
- "__kernel void grad_pass(__read_only image2d_t tex, __read_only image2d_t texp,\n"
- " __write_only image2d_t dog, int width, int height,\n"
- " __write_only image2d_t grad, __write_only image2d_t rot) {\n"
- "sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE |\n"
- " CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;\n"
- "int x = get_global_id(0), y = get_global_id(1); \n"
- "if( x >= width || y >= height) return;\n"
- "int2 coord = (int2) (x, y);\n"
- "float4 cc = read_imagef(tex , sampler, coord); \n"
- "float4 cp = read_imagef(texp, sampler, coord);\n"
- "float2 cl = read_imagef(tex, sampler, (int2)(x - 1, y)).yw;\n"
- "float2 cr = read_imagef(tex, sampler, (int2)(x + 1, y)).xz;\n"
- "float2 cd = read_imagef(tex, sampler, (int2)(x, y - 1)).zw;\n"
- "float2 cu = read_imagef(tex, sampler, (int2)(x, y + 1)).xy;\n"
- "write_imagef(dog, coord, cc - cp); \n"
- "float4 dx = (float4)(cc.y - cl.x, cr.x - cc.x, cc.w - cl.y, cr.y - cc.z);\n"
- "float4 dy = (float4)(cc.zw - cd.xy, cu.xy - cc.xy);\n"
- "write_imagef(grad, coord, 0.5 * sqrt(dx*dx + dy * dy));\n"
- "write_imagef(rot, coord, atan2(dy, dx + (float4) (FLT_MIN)));}\n", _context, _device);
-
- s_grad_pass2 = new ProgramCL("grad_pass2",
- "#define BLOCK_DIMX 32\n"
- "#define BLOCK_DIMY 14\n"
- "#define BLOCK_SIZE (BLOCK_DIMX * BLOCK_DIMY)\n"
- "__kernel void grad_pass2(__read_only image2d_t tex, __read_only image2d_t texp,\n"
- " __write_only image2d_t dog, int width, int height,\n"
- " __write_only image2d_t grd, __write_only image2d_t rot){\n"//, __local float* block) {\n"
- "__local float block[BLOCK_SIZE * 4]; \n"
- "sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE |\n"
- " CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;\n"
- "int2 coord = (int2) ( get_global_id(0) - get_group_id(0) * 2 - 1, \n"
- " get_global_id(1) - get_group_id(1) * 2- 1); \n"
- "int idx = mad24(get_local_id(1), BLOCK_DIMX, get_local_id(0));\n"
- "float4 cc = read_imagef(tex, sampler, coord);\n"
- "block[idx ] = cc.x;\n"
- "block[idx + BLOCK_SIZE ] = cc.y;\n"
- "block[idx + BLOCK_SIZE * 2] = cc.z;\n"
- "block[idx + BLOCK_SIZE * 3] = cc.w;\n"
- "barrier(CLK_LOCAL_MEM_FENCE);\n"
- "if( get_local_id(0) == 0 || get_local_id(0) == BLOCK_DIMX - 1) return;\n"
- "if( get_local_id(1) == 0 || get_local_id(1) == BLOCK_DIMY - 1) return;\n"
- "if( coord.x >= width) return; \n"
- "if( coord.y >= height) return;\n"
- "float4 cp = read_imagef(texp, sampler, coord);\n"
- "float4 dx = (float4)( cc.y - block[idx - 1 + BLOCK_SIZE], \n"
- " block[idx + 1] - cc.x, \n"
- " cc.w - block[idx - 1 + 3 * BLOCK_SIZE], \n"
- " block[idx + 1 + 2 * BLOCK_SIZE] - cc.z);\n"
- "float4 dy = (float4)( cc.z - block[idx - BLOCK_DIMX + 2 * BLOCK_SIZE], \n"
- " cc.w - block[idx - BLOCK_DIMX + 3 * BLOCK_SIZE],"
- //" cc.zw - block[idx - BLOCK_DIMX].zw, \n"
- " block[idx + BLOCK_DIMX] - cc.x,\n "
- " block[idx + BLOCK_DIMX + BLOCK_SIZE] - cc.y);\n"
- //" block[idx + BLOCK_DIMX].xy - cc.xy);\n"
- "write_imagef(dog, coord, cc - cp); \n"
- "write_imagef(grd, coord, 0.5 * sqrt(dx*dx + dy * dy));\n"
- "write_imagef(rot, coord, atan2(dy, dx + (float4) (FLT_MIN)));}\n", _context, _device);
-}
-
-void ProgramBagCL::LoadDynamicShaders(SiftParam& param)
-{
- LoadKeypointShader();
- LoadGenListShader(param._dog_level_num, 0);
- CreateGaussianFilters(param);
-}
-
-
-void ProgramBagCL::SelectInitialSmoothingFilter(int octave_min, SiftParam¶m)
-{
- float sigma = param.GetInitialSmoothSigma(octave_min);
- if(sigma == 0)
- {
- f_gaussian_skip0 = NULL;
- }else
- {
- for(unsigned int i = 0; i < f_gaussian_skip0_v.size(); i++)
- {
- if(f_gaussian_skip0_v[i]->_id == octave_min)
- {
- f_gaussian_skip0 = f_gaussian_skip0_v[i];
- return ;
- }
- }
- FilterCL * filter = CreateGaussianFilter(sigma);
- filter->_id = octave_min;
- f_gaussian_skip0_v.push_back(filter);
- f_gaussian_skip0 = filter;
- }
-
-}
-
-void ProgramBagCL::CreateGaussianFilters(SiftParam¶m)
-{
- if(param._sigma_skip0>0.0f)
- {
- f_gaussian_skip0 = CreateGaussianFilter(param._sigma_skip0);
- f_gaussian_skip0->_id = GlobalUtil::_octave_min_default;
- f_gaussian_skip0_v.push_back(f_gaussian_skip0);
- }
- if(param._sigma_skip1>0.0f)
- {
- f_gaussian_skip1 = CreateGaussianFilter(param._sigma_skip1);
- }
-
- f_gaussian_step = new FilterCL*[param._sigma_num];
- for(int i = 0; i< param._sigma_num; i++)
- {
- f_gaussian_step[i] = CreateGaussianFilter(param._sigma[i]);
- }
- _gaussian_step_num = param._sigma_num;
-}
-
-
-FilterCL* ProgramBagCL::CreateGaussianFilter(float sigma)
-{
- //pixel inside 3*sigma box
- int sz = int( ceil( GlobalUtil::_FilterWidthFactor * sigma -0.5) ) ;//
- int width = 2*sz + 1;
-
- //filter size truncation
- if(GlobalUtil::_MaxFilterWidth >0 && width > GlobalUtil::_MaxFilterWidth)
- {
- std::cout<<"Filter size truncated from "<>1;
- width = 2 * sz + 1;
- }
-
- int i;
- float * kernel = new float[width];
- float rv = 1.0f/(sigma*sigma);
- float v, ksum =0;
-
- // pre-compute filter
- for( i = -sz ; i <= sz ; ++i)
- {
- kernel[i+sz] = v = exp(-0.5f * i * i *rv) ;
- ksum += v;
- }
-
- //normalize the kernel
- rv = 1.0f / ksum;
- for(i = 0; i< width ;i++) kernel[i]*=rv;
-
- FilterCL * filter = CreateFilter(kernel, width);
- delete [] kernel;
- if(GlobalUtil::_verbose && GlobalUtil::_timingL) std::cout<<"Filter: sigma = "<s_shader_h = CreateFilterH(kernel, width);
- filter->s_shader_v = CreateFilterV(kernel, width);
- filter->_size = width;
- filter->_id = 0;
- return filter;
-}
-
-ProgramCL* ProgramBagCL::CreateFilterH(float kernel[], int width)
-{
- int halfwidth = width >>1;
- float * pf = kernel + halfwidth;
- int nhpixel = (halfwidth+1)>>1; //how many neighbour pixels need to be looked up
- int npixel = (nhpixel<<1)+1;//
- float weight[3];
-
- ////////////////////////////
- char buffer[10240];
- ostrstream out(buffer, 10240);
- out< width_ || y > height_) return; \n"
- "float4 pc; int2 coord; \n"
- "float4 result = (float4)(0.0);\n";
- for(int i = 0 ; i < npixel ; i++)
- {
- out<<"coord = (int2)(x + ("<< (i - nhpixel) << "), y);\n";
- out<<"pc= read_imagef(input, sampler, coord);\n";
- if(GlobalUtil::_PreciseBorder)
- out<<"if(coord.x < 0) pc = pc.xxzz; else if (coord.x > width_) pc = pc.yyww; \n";
- //for each sub-pixel j in center, the weight of sub-pixel k
- int xw = (i - nhpixel)*2;
- for(int j = 0; j < 3; j++)
- {
- int xwn = xw + j -1;
- weight[j] = xwn < -halfwidth || xwn > halfwidth? 0 : pf[xwn];
- }
- if(weight[1] == 0.0)
- {
- out<<"result += (float4)("<>1;
- float * pf = kernel + halfwidth;
- int nhpixel = (halfwidth+1)>>1; //how many neighbour pixels need to be looked up
- int npixel = (nhpixel<<1)+1;//
- float weight[3];
-
- ////////////////////////////
- char buffer[10240];
- ostrstream out(buffer, 10240);
- out< width_ || y >= height_) return; \n"
- "float4 pc; int2 coord; \n"
- "float4 result = (float4)(0.0);\n";
- for(int i = 0 ; i < npixel ; i++)
- {
- out<<"coord = (int2)(x, y + ("<< (i - nhpixel) << "));\n";
- out<<"pc= read_imagef(input, sampler, coord);\n";
- if(GlobalUtil::_PreciseBorder)
- out<<"if(coord.y < 0) pc = pc.xyxy; else if (coord.y > height_) pc = pc.zwzw; \n";
- //for each sub-pixel j in center, the weight of sub-pixel k
- int xw = (i - nhpixel)*2;
- for(int j = 0; j < 3; j++)
- {
- int xwn = xw + j -1;
- weight[j] = xwn < -halfwidth || xwn > halfwidth? 0 : pf[xwn];
- }
- if(weight[1] == 0.0)
- {
- out<<"result += (float4)("<s_shader_h->_kernel;
- cl_kernel kernelv = filter->s_shader_v->_kernel;
- //////////////////////////////////////////////////////////////////
-
- cl_int status, w = dst->GetImgWidth(), h = dst->GetImgHeight();
- cl_int w_ = w - 1, h_ = h - 1;
-
- size_t dim0 = 16, dim1 = 16;
- size_t gsz[2] = {(w + dim0 - 1) / dim0 * dim0, (h + dim1 - 1) / dim1 * dim1}, lsz[2] = {dim0, dim1};
-
- clSetKernelArg(kernelh, 0, sizeof(cl_mem), &src->_clData);
- clSetKernelArg(kernelh, 1, sizeof(cl_mem), &tmp->_clData);
- clSetKernelArg(kernelh, 2, sizeof(cl_int), &w_);
- clSetKernelArg(kernelh, 3, sizeof(cl_int), &h_);
- status = clEnqueueNDRangeKernel(_queue, kernelh, 2, NULL, gsz, lsz, 0, NULL, NULL);
- CheckErrorCL(status, "ProgramBagCL::FilterImageH");
- if(status != CL_SUCCESS) return;
-
- clSetKernelArg(kernelv, 0, sizeof(cl_mem), &tmp->_clData);
- clSetKernelArg(kernelv, 1, sizeof(cl_mem), &dst->_clData);
- clSetKernelArg(kernelv, 2, sizeof(cl_int), &w_);
- clSetKernelArg(kernelv, 3, sizeof(cl_int), &h_);
- size_t gsz2[2] = {(w + dim1 - 1) / dim1 * dim1, (h + dim0 - 1) / dim0 * dim0}, lsz2[2] = {dim1, dim0};
- status = clEnqueueNDRangeKernel(_queue, kernelv, 2, NULL, gsz2, lsz2, 0, NULL, NULL);
- CheckErrorCL(status, "ProgramBagCL::FilterImageV");
- //clReleaseEvent(event);
-}
-
-void ProgramBagCL::SampleImageU(CLTexImage *dst, CLTexImage *src, int log_scale)
-{
- cl_kernel kernel= s_sampling_u->_kernel;
- float scale = 1.0f / (1 << log_scale);
- float offset = scale * 0.5f;
- cl_int w = dst->GetImgWidth(), h = dst->GetImgHeight();
- clSetKernelArg(kernel, 0, sizeof(cl_mem), &(src->_clData));
- clSetKernelArg(kernel, 1, sizeof(cl_mem), &(dst->_clData));
- clSetKernelArg(kernel, 2, sizeof(cl_int), &(w));
- clSetKernelArg(kernel, 3, sizeof(cl_int), &(h));
- clSetKernelArg(kernel, 4, sizeof(cl_float), &(scale));
- clSetKernelArg(kernel, 5, sizeof(cl_float), &(offset));
-
- size_t dim0 = 16, dim1 = 16;
- //while( w * h / dim0 / dim1 < 8 && dim1 > 1) dim1 /= 2;
- size_t gsz[2] = {(w + dim0 - 1) / dim0 * dim0, (h + dim1 - 1) / dim1 * dim1}, lsz[2] = {dim0, dim1};
- cl_int status = clEnqueueNDRangeKernel(_queue, kernel, 2, NULL, gsz, lsz, 0, NULL, NULL);
- CheckErrorCL(status, "ProgramBagCL::SampleImageU");
-}
-
-void ProgramBagCL::SampleImageD(CLTexImage *dst, CLTexImage *src, int log_scale)
-{
- cl_kernel kernel;
- cl_int w = dst->GetImgWidth(), h = dst->GetImgHeight();
- if(log_scale == 1)
- {
- kernel = s_sampling->_kernel;
- clSetKernelArg(kernel, 0, sizeof(cl_mem), &(src->_clData));
- clSetKernelArg(kernel, 1, sizeof(cl_mem), &(dst->_clData));
- clSetKernelArg(kernel, 2, sizeof(cl_int), &(w));
- clSetKernelArg(kernel, 3, sizeof(cl_int), &(h));
- }else
- {
- cl_int fullstep = (1 << log_scale);
- cl_int halfstep = fullstep >> 1;
- kernel = s_sampling_k->_kernel;
- clSetKernelArg(kernel, 0, sizeof(cl_mem), &(src->_clData));
- clSetKernelArg(kernel, 1, sizeof(cl_mem), &(dst->_clData));
- clSetKernelArg(kernel, 2, sizeof(cl_int), &(w));
- clSetKernelArg(kernel, 3, sizeof(cl_int), &(h));
- clSetKernelArg(kernel, 4, sizeof(cl_int), &(fullstep));
- clSetKernelArg(kernel, 5, sizeof(cl_int), &(halfstep));
- }
- size_t dim0 = 128, dim1 = 1;
- //while( w * h / dim0 / dim1 < 8 && dim1 > 1) dim1 /= 2;
- size_t gsz[2] = {(w + dim0 - 1) / dim0 * dim0, (h + dim1 - 1) / dim1 * dim1}, lsz[2] = {dim0, dim1};
- cl_int status = clEnqueueNDRangeKernel(_queue, kernel, 2, NULL, gsz, lsz, 0, NULL, NULL);
- CheckErrorCL(status, "ProgramBagCL::SampleImageD");
-}
-
-void ProgramBagCL::FilterInitialImage(CLTexImage* tex, CLTexImage* buf)
-{
- if(f_gaussian_skip0) FilterImage(f_gaussian_skip0, tex, tex, buf);
-}
-
-void ProgramBagCL::FilterSampledImage(CLTexImage* tex, CLTexImage* buf)
-{
- if(f_gaussian_skip1) FilterImage(f_gaussian_skip1, tex, tex, buf);
-}
-
-void ProgramBagCL::ComputeDOG(CLTexImage*tex, CLTexImage* texp, CLTexImage* dog, CLTexImage* grad, CLTexImage* rot)
-{
- int margin = 0, use_gm2 = 1;
- bool both_grad_dog = rot->_clData && grad->_clData;
- cl_int w = tex->GetImgWidth(), h = tex->GetImgHeight();
- cl_kernel kernel ; size_t dim0, dim1;
- if(!both_grad_dog) {kernel = s_dog_pass->_kernel; dim0 = 16; dim1 = 12; }
- else if(use_gm2) {kernel = s_grad_pass2->_kernel; dim0 = 32; dim1 = 14; margin = 2; }
- else {kernel = s_grad_pass->_kernel; dim0 = 16; dim1 = 20; }
- size_t gsz[2] = { (w + dim0 - 1 - margin) / (dim0 - margin) * dim0,
- (h + dim1 - 1 - margin) / (dim1 - margin) * dim1};
- size_t lsz[2] = {dim0, dim1};
- clSetKernelArg(kernel, 0, sizeof(cl_mem), &(tex->_clData));
- clSetKernelArg(kernel, 1, sizeof(cl_mem), &(texp->_clData));
- clSetKernelArg(kernel, 2, sizeof(cl_mem), &(dog->_clData));
- clSetKernelArg(kernel, 3, sizeof(cl_int), &(w));
- clSetKernelArg(kernel, 4, sizeof(cl_int), &(h));
- if(both_grad_dog)
- {
- clSetKernelArg(kernel, 5, sizeof(cl_mem), &(grad->_clData));
- clSetKernelArg(kernel, 6, sizeof(cl_mem), &(rot->_clData));
- }
- ///////////////////////////////////////////////////////
- cl_int status = clEnqueueNDRangeKernel(_queue, kernel, 2, NULL, gsz, lsz, 0, NULL, NULL);
- CheckErrorCL(status, "ProgramBagCL::ComputeDOG");
-}
-
-
-void ProgramBagCL::ComputeKEY(CLTexImage*dog, CLTexImage* key, float Tdog, float Tedge)
-{
- cl_kernel kernel = s_keypoint->_kernel;
- cl_int w = key->GetImgWidth(), h = key->GetImgHeight();
- float threshold0 = Tdog* (GlobalUtil::_SubpixelLocalization?0.8f:1.0f);
- float threshold1 = Tdog;
- float threshold2 = (Tedge+1)*(Tedge+1)/Tedge;
-
- clSetKernelArg(kernel, 0, sizeof(cl_mem), &(dog->_clData));
- clSetKernelArg(kernel, 1, sizeof(cl_mem), &((dog + 1)->_clData));
- clSetKernelArg(kernel, 2, sizeof(cl_mem), &((dog - 1)->_clData));
- clSetKernelArg(kernel, 3, sizeof(cl_mem), &(key->_clData));
- clSetKernelArg(kernel, 4, sizeof(cl_float), &(threshold0));
- clSetKernelArg(kernel, 5, sizeof(cl_float), &(threshold1));
- clSetKernelArg(kernel, 6, sizeof(cl_float), &(threshold2));
- clSetKernelArg(kernel, 7, sizeof(cl_int), &(w));
- clSetKernelArg(kernel, 8, sizeof(cl_int), &(h));
-
- size_t dim0 = 8, dim1 = 8;
- //if( w * h / dim0 / dim1 < 16) dim1 /= 2;
- size_t gsz[2] = {(w + dim0 - 1) / dim0 * dim0, (h + dim1 - 1) / dim1 * dim1}, lsz[2] = {dim0, dim1};
- cl_int status = clEnqueueNDRangeKernel(_queue, kernel, 2, NULL, gsz, lsz, 0, NULL, NULL);
- CheckErrorCL(status, "ProgramBagCL::ComputeKEY");
-}
-
-void ProgramBagCL::UnpackImage(CLTexImage*src, CLTexImage* dst)
-{
- cl_kernel kernel = s_unpack->_kernel;
- cl_int w = dst->GetImgWidth(), h = dst->GetImgHeight();
- clSetKernelArg(kernel, 0, sizeof(cl_mem), &(src->_clData));
- clSetKernelArg(kernel, 1, sizeof(cl_mem), &(dst->_clData));
- clSetKernelArg(kernel, 2, sizeof(cl_int), &(w));
- clSetKernelArg(kernel, 3, sizeof(cl_int), &(h));
- const size_t dim0 = 16, dim1 = 16;
- size_t gsz[2] = {(w + dim0 - 1) / dim0 * dim0, (h + dim1 - 1) / dim1 * dim1}, lsz[2] = {dim0, dim1};
- cl_int status = clEnqueueNDRangeKernel(_queue, kernel, 2, NULL, gsz, lsz, 0, NULL, NULL);
-
- CheckErrorCL(status, "ProgramBagCL::UnpackImage");
- FinishCL();
-
-}
-
-void ProgramBagCL::UnpackImageDOG(CLTexImage*src, CLTexImage* dst)
-{
- if(s_unpack_dog == NULL) return;
- cl_kernel kernel = s_unpack_dog->_kernel;
- cl_int w = dst->GetImgWidth(), h = dst->GetImgHeight();
- clSetKernelArg(kernel, 0, sizeof(cl_mem), &(src->_clData));
- clSetKernelArg(kernel, 1, sizeof(cl_mem), &(dst->_clData));
- clSetKernelArg(kernel, 2, sizeof(cl_int), &(w));
- clSetKernelArg(kernel, 3, sizeof(cl_int), &(h));
- const size_t dim0 = 16, dim1 = 16;
- size_t gsz[2] = {(w + dim0 - 1) / dim0 * dim0, (h + dim1 - 1) / dim1 * dim1}, lsz[2] = {dim0, dim1};
- cl_int status = clEnqueueNDRangeKernel(_queue, kernel, 2, NULL, gsz, lsz, 0, NULL, NULL);
-
- CheckErrorCL(status, "ProgramBagCL::UnpackImage");
- FinishCL();
-}
-
-void ProgramBagCL::UnpackImageGRD(CLTexImage*src, CLTexImage* dst)
-{
- if(s_unpack_grd == NULL) return;
- cl_kernel kernel = s_unpack_grd->_kernel;
- cl_int w = dst->GetImgWidth(), h = dst->GetImgHeight();
- clSetKernelArg(kernel, 0, sizeof(cl_mem), &(src->_clData));
- clSetKernelArg(kernel, 1, sizeof(cl_mem), &(dst->_clData));
- clSetKernelArg(kernel, 2, sizeof(cl_int), &(w));
- clSetKernelArg(kernel, 3, sizeof(cl_int), &(h));
- const size_t dim0 = 16, dim1 = 16;
- size_t gsz[2] = {(w + dim0 - 1) / dim0 * dim0, (h + dim1 - 1) / dim1 * dim1}, lsz[2] = {dim0, dim1};
- cl_int status = clEnqueueNDRangeKernel(_queue, kernel, 2, NULL, gsz, lsz, 0, NULL, NULL);
-
- CheckErrorCL(status, "ProgramBagCL::UnpackImage");
- FinishCL();
-}
-void ProgramBagCL::UnpackImageKEY(CLTexImage*src, CLTexImage* dog, CLTexImage* dst)
-{
- if(s_unpack_key == NULL) return;
- cl_kernel kernel = s_unpack_key->_kernel;
- cl_int w = dst->GetImgWidth(), h = dst->GetImgHeight();
- clSetKernelArg(kernel, 0, sizeof(cl_mem), &(dog->_clData));
- clSetKernelArg(kernel, 1, sizeof(cl_mem), &(src->_clData));
- clSetKernelArg(kernel, 2, sizeof(cl_mem), &(dst->_clData));
- clSetKernelArg(kernel, 3, sizeof(cl_int), &(w));
- clSetKernelArg(kernel, 4, sizeof(cl_int), &(h));
- const size_t dim0 = 16, dim1 = 16;
- size_t gsz[2] = {(w + dim0 - 1) / dim0 * dim0, (h + dim1 - 1) / dim1 * dim1}, lsz[2] = {dim0, dim1};
- cl_int status = clEnqueueNDRangeKernel(_queue, kernel, 2, NULL, gsz, lsz, 0, NULL, NULL);
-
- CheckErrorCL(status, "ProgramBagCL::UnpackImageKEY");
- FinishCL();
-}
-void ProgramBagCL::LoadDescriptorShader()
-{
- GlobalUtil::_DescriptorPPT = 16;
- LoadDescriptorShaderF2();
-}
-
-void ProgramBagCL::LoadDescriptorShaderF2()
-{
-
-}
-
-void ProgramBagCL::LoadOrientationShader(void)
-{
-
-}
-
-void ProgramBagCL::LoadGenListShader(int ndoglev,int nlev)
-{
-
-}
-
-void ProgramBagCL::LoadKeypointShader()
-{
- int i; char buffer[20240];
- ostrstream out(buffer, 20240);
- streampos pos;
-
- //tex(X)(Y)
- //X: (CLR) (CENTER 0, LEFT -1, RIGHT +1)
- //Y: (CDU) (CENTER 0, DOWN -1, UP +1)
- out<<
- "__kernel void keypoint(__read_only image2d_t tex, __read_only image2d_t texU,\n"
- " __read_only image2d_t texD, __write_only image2d_t texK,\n"
- " float THRESHOLD0, float THRESHOLD1, \n"
- " float THRESHOLD2, int width, int height)\n"
- "{\n"
- " sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | \n"
- " CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;"
- " int x = get_global_id(0), y = get_global_id(1);\n"
- " if(x >= width || y >= height) return; \n"
- " int xp = x - 1, xn = x + 1;\n"
- " int yp = y - 1, yn = y + 1;\n"
- " int2 coord0 = (int2) (x, y); \n"
- " int2 coord1 = (int2) (xp, y); \n"
- " int2 coord2 = (int2) (xn, y); \n"
- " int2 coord3 = (int2) (x, yp); \n"
- " int2 coord4 = (int2) (x, yn); \n"
- " int2 coord5 = (int2) (xp, yp); \n"
- " int2 coord6 = (int2) (xp, yn); \n"
- " int2 coord7 = (int2) (xn, yp); \n"
- " int2 coord8 = (int2) (xn, yn); \n"
- " float4 ccc = read_imagef(tex, sampler,coord0);\n"
- " float4 clc = read_imagef(tex, sampler,coord1);\n"
- " float4 crc = read_imagef(tex, sampler,coord2);\n"
- " float4 ccd = read_imagef(tex, sampler,coord3);\n"
- " float4 ccu = read_imagef(tex, sampler,coord4);\n"
- " float4 cld = read_imagef(tex, sampler,coord5);\n"
- " float4 clu = read_imagef(tex, sampler,coord6);\n"
- " float4 crd = read_imagef(tex, sampler,coord7);\n"
- " float4 cru = read_imagef(tex, sampler,coord8);\n"
- " float4 cc = ccc;\n"
- " float4 v1[4], v2[4];\n"
- " v1[0] = (float4)(clc.y, ccc.y, ccd.z, ccc.z);\n"
- " v1[1] = (float4)(ccc.x, crc.x, ccd.w, ccc.w);\n"
- " v1[2] = (float4)(clc.w, ccc.w, ccc.x, ccu.x);\n"
- " v1[3] = (float4)(ccc.z, crc.z, ccc.y, ccu.y);\n"
- " v2[0] = (float4)(cld.w, clc.w, ccd.w, ccc.w);\n"
- " v2[1] = (float4)(ccd.z, ccc.z, crd.z, crc.z);\n"
- " v2[2] = (float4)(clc.y, clu.y, ccc.y, ccu.y);\n"
- " v2[3] = (float4)(ccc.x, ccu.x, crc.x, cru.x);\n"
- " float4 key4 = (float4)(0); \n";
- //test against 8 neighbours
- //use variable to identify type of extremum
- //1.0 for local maximum and -1.0 for minimum
- for(i = 0; i < 4; ++i)
- out<<
- " if(cc.s"< THRESHOLD0){ \n"
- " if(all(isgreater((float4)(cc.s"<
- //vector v2 is < (-1,-1), (-1,1), (1,-1), (1, 1)>
- for(i = 0; i < 4; ++i)
- out <<
- " if(key4.s"< THRESHOLD2 * score_down)keysum = 0;\n"
- " }\n";
-
- out <<
- " if(keysum == 1) {\n";
- ////////////////////////////////////////////////
- //read 9 pixels of upper/lower level
- out<<
- " float4 v4[4], v5[4], v6[4];\n"
- " ccc = read_imagef(texU, sampler,coord0);\n"
- " clc = read_imagef(texU, sampler,coord1);\n"
- " crc = read_imagef(texU, sampler,coord2);\n"
- " ccd = read_imagef(texU, sampler,coord3);\n"
- " ccu = read_imagef(texU, sampler,coord4);\n"
- " cld = read_imagef(texU, sampler,coord5);\n"
- " clu = read_imagef(texU, sampler,coord6);\n"
- " crd = read_imagef(texU, sampler,coord7);\n"
- " cru = read_imagef(texU, sampler,coord8);\n"
- " float4 cu = ccc;\n"
- " v4[0] = (float4)(clc.y, ccc.y, ccd.z, ccc.z);\n"
- " v4[1] = (float4)(ccc.x, crc.x, ccd.w, ccc.w);\n"
- " v4[2] = (float4)(clc.w, ccc.w, ccc.x, ccu.x);\n"
- " v4[3] = (float4)(ccc.z, crc.z, ccc.y, ccu.y);\n"
- " v6[0] = (float4)(cld.w, clc.w, ccd.w, ccc.w);\n"
- " v6[1] = (float4)(ccd.z, ccc.z, crd.z, crc.z);\n"
- " v6[2] = (float4)(clc.y, clu.y, ccc.y, ccu.y);\n"
- " v6[3] = (float4)(ccc.x, ccu.x, crc.x, cru.x);\n";
-
- for(i = 0; i < 4; ++i)
- out <<
- " if(key4.s"< cu.s"< cd.s"<= 1e-10 ) \n"
- " { \n"
- " if(x3.y ==maxa ) \n"
- " { \n"
- " float4 TEMP = A1; A1 = A0; A0 = TEMP; \n"
- " }else if( x3.z == maxa ) \n"
- " { \n"
- " float4 TEMP = A2; A2 = A0; A0 = TEMP; \n"
- " } \n"
- " A0 /= A0.x; \n"
- " A1 -= A1.x * A0; \n"
- " A2 -= A2.x * A0; \n"
- " float2 x2 = fabs((float2)(A1.y, A2.y)); \n"
- " if( x2.y > x2.x ) \n"
- " { \n"
- " float4 TEMP = A2.yzwx; \n"
- " A2.yzw = A1.yzw; \n"
- " A1.yzw = TEMP.xyz; \n"
- " x2.x = x2.y; \n"
- " } \n"
- " if(x2.x >= 1e-10) { \n"
- " A1.yzw /= A1.y; \n"
- " A2.yzw -= A2.y * A1.yzw; \n"
- " if(fabs(A2.z) >= 1e-10) {\n"
- " offset.z = A2.w /A2.z; \n"
- " offset.y = A1.w - offset.z*A1.z; \n"
- " offset.x = A0.w - offset.z*A0.z - offset.y*A0.y; \n"
- " if(fabs(cc.s0 + 0.5*dot((float4)(fx[0], fy[0], fs, 0), offset ))<=THRESHOLD1\n"
- " || any( isgreater(fabs(offset), (float4)(1.0)))) key4 = (float4)(0.0);\n"
- " }\n"
- " }\n"
- " }\n"
- <<"\n"
- " float keyv = dot(key4, (float4)(1.0, 2.0, 3.0, 4.0));\n"
- " result = (float4)(keyv, offset.xyz);\n"
- " }}}}\n"
- " write_imagef(texK, coord0, result);\n "
- "}\n" <<'\0';
- }
- else
- {
- out << "\n"
- " float keyv = dot(key4, (float4)(1.0, 2.0, 3.0, 4.0));\n"
- " result = (float4)(keyv, 0, 0, 0);\n"
- " }}}}\n"
- " write_imagef(texK, coord0, result);\n "
- "}\n" <<'\0';
- }
-
- s_keypoint = new ProgramCL("keypoint", buffer, _context, _device);
-}
-
-void ProgramBagCL::LoadDisplayShaders()
-{
- //"uniform sampler2DRect tex; void main(){\n"
- //"vec4 pc = texture2DRect(tex, gl_TexCoord[0].xy); bvec2 ff = lessThan(fract(gl_TexCoord[0].xy), vec2(0.5));\n"
- //"float v = ff.y?(ff.x? pc.r : pc.g):(ff.x?pc.b:pc.a); gl_FragColor = vec4(vec3(v), 1.0);}");
- s_unpack = new ProgramCL("main",
- "__kernel void main(__read_only image2d_t input, __write_only image2d_t output,\n"
- " int width, int height) {\n"
- "sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;\n"
- "int x = get_global_id(0), y = get_global_id(1); \n"
- "if(x >= width || y >= height) return;\n"
- "int xx = x / 2, yy = y / 2; \n"
- "float4 vv = read_imagef(input, sampler, (int2) (xx, yy)); \n"
- "float v1 = (x & 1 ? vv.w : vv.z); \n"
- "float v2 = (x & 1 ? vv.y : vv.x);\n"
- "float v = y & 1 ? v1 : v2;\n"
- "float4 result = (float4) (v, v, v, 1);"
- "write_imagef(output, (int2) (x, y), result); }" , _context, _device);
-
- s_unpack_dog = new ProgramCL("main",
- "__kernel void main(__read_only image2d_t input, __write_only image2d_t output,\n"
- " int width, int height) {\n"
- "sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;\n"
- "int x = get_global_id(0), y = get_global_id(1); \n"
- "if(x >= width || y >= height) return;\n"
- "int xx = x / 2, yy = y / 2; \n"
- "float4 vv = read_imagef(input, sampler, (int2) (xx, yy)); \n"
- "float v1 = (x & 1 ? vv.w : vv.z); \n"
- "float v2 = (x & 1 ? vv.y : vv.x);\n"
- "float v0 = y & 1 ? v1 : v2;\n"
- "float v = 0.5 + 20.0 * v0;\n "
- "float4 result = (float4) (v, v, v, 1);"
- "write_imagef(output, (int2) (x, y), result); }" , _context, _device);
-
- s_unpack_grd = new ProgramCL("main",
- "__kernel void main(__read_only image2d_t input, __write_only image2d_t output,\n"
- " int width, int height) {\n"
- "sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;\n"
- "int x = get_global_id(0), y = get_global_id(1); \n"
- "if(x >= width || y >= height) return;\n"
- "int xx = x / 2, yy = y / 2; \n"
- "float4 vv = read_imagef(input, sampler, (int2) (xx, yy)); \n"
- "float v1 = (x & 1 ? vv.w : vv.z); \n"
- "float v2 = (x & 1 ? vv.y : vv.x);\n"
- "float v0 = y & 1 ? v1 : v2;\n"
- "float v = 5.0 * v0;\n "
- "float4 result = (float4) (v, v, v, 1);"
- "write_imagef(output, (int2) (x, y), result); }" , _context, _device);
-
- s_unpack_key = new ProgramCL("main",
- "__kernel void main(__read_only image2d_t dog,\n"
- " __read_only image2d_t key,\n"
- " __write_only image2d_t output,\n"
- " int width, int height) {\n"
- "sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;\n"
- "int x = get_global_id(0), y = get_global_id(1); \n"
- "if(x >= width || y >= height) return;\n"
- "int xx = x / 2, yy = y / 2; \n"
- "float4 kk = read_imagef(key, sampler, (int2) (xx, yy));\n"
- "int4 cc = isequal(fabs(kk.xxxx), (float4)(1.0, 2.0, 3.0, 4.0));\n"
- "int k1 = (x & 1 ? cc.w : cc.z); \n"
- "int k2 = (x & 1 ? cc.y : cc.x);\n"
- "int k0 = y & 1 ? k1 : k2;\n"
- "float4 result;\n"
- "if(k0 != 0){\n"
- " //result = kk.x > 0 ? ((float4)(1.0, 0, 0, 1.0)) : ((float4) (0.0, 1.0, 0.0, 1.0)); \n"
- " result = kk.x < 0 ? ((float4)(0, 1.0, 0, 1.0)) : ((float4) (1.0, 0.0, 0.0, 1.0)); \n"
- "}else{"
- "float4 vv = read_imagef(dog, sampler, (int2) (xx, yy));\n"
- "float v1 = (x & 1 ? vv.w : vv.z); \n"
- "float v2 = (x & 1 ? vv.y : vv.x);\n"
- "float v0 = y & 1 ? v1 : v2;\n"
- "float v = 0.5 + 20.0 * v0;\n "
- "result = (float4) (v, v, v, 1);"
- "}\n"
- "write_imagef(output, (int2) (x, y), result); }" , _context, _device);
-}
-
-
-void ProgramBagCL::SetMarginCopyParam(int xmax, int ymax)
-{
-
-}
-
-void ProgramBagCL::SetGradPassParam(int texP)
-{
-
-}
-
-void ProgramBagCL::SetGenListEndParam(int ktex)
-{
-
-}
-
-void ProgramBagCL::SetDogTexParam(int texU, int texD)
-{
-
-}
-
-void ProgramBagCL::SetGenListInitParam(int w, int h)
-{
- float bbox[4] = {(w -1.0f) * 0.5f +0.25f, (w-1.0f) * 0.5f - 0.25f, (h - 1.0f) * 0.5f + 0.25f, (h-1.0f) * 0.5f - 0.25f};
-
-}
-
-
-void ProgramBagCL::SetGenListStartParam(float width, int tex0)
-{
-
-}
-
-
-
-void ProgramBagCL::SetGenListStepParam(int tex, int tex0)
-{
-
-}
-
-void ProgramBagCL::SetGenVBOParam(float width, float fwidth, float size)
-{
-
-}
-
-void ProgramBagCL::SetSimpleOrientationInput(int oTex, float sigma, float sigma_step)
-{
-
-}
-
-
-void ProgramBagCL::SetFeatureOrientationParam(int gtex, int width, int height, float sigma, int otex, float step)
-{
-
-
-}
-
-void ProgramBagCL::SetFeatureDescirptorParam(int gtex, int otex, float dwidth, float fwidth, float width, float height, float sigma)
-{
-
-}
-
-
-
-const char* ProgramBagCL::GetErrorString(cl_int error)
-{
- static const char* errorString[] = {
- "CL_SUCCESS",
- "CL_DEVICE_NOT_FOUND",
- "CL_DEVICE_NOT_AVAILABLE",
- "CL_COMPILER_NOT_AVAILABLE",
- "CL_MEM_OBJECT_ALLOCATION_FAILURE",
- "CL_OUT_OF_RESOURCES",
- "CL_OUT_OF_HOST_MEMORY",
- "CL_PROFILING_INFO_NOT_AVAILABLE",
- "CL_MEM_COPY_OVERLAP",
- "CL_IMAGE_FORMAT_MISMATCH",
- "CL_IMAGE_FORMAT_NOT_SUPPORTED",
- "CL_BUILD_PROGRAM_FAILURE",
- "CL_MAP_FAILURE",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "CL_INVALID_VALUE",
- "CL_INVALID_DEVICE_TYPE",
- "CL_INVALID_PLATFORM",
- "CL_INVALID_DEVICE",
- "CL_INVALID_CONTEXT",
- "CL_INVALID_QUEUE_PROPERTIES",
- "CL_INVALID_COMMAND_QUEUE",
- "CL_INVALID_HOST_PTR",
- "CL_INVALID_MEM_OBJECT",
- "CL_INVALID_IMAGE_FORMAT_DESCRIPTOR",
- "CL_INVALID_IMAGE_SIZE",
- "CL_INVALID_SAMPLER",
- "CL_INVALID_BINARY",
- "CL_INVALID_BUILD_OPTIONS",
- "CL_INVALID_PROGRAM",
- "CL_INVALID_PROGRAM_EXECUTABLE",
- "CL_INVALID_KERNEL_NAME",
- "CL_INVALID_KERNEL_DEFINITION",
- "CL_INVALID_KERNEL",
- "CL_INVALID_ARG_INDEX",
- "CL_INVALID_ARG_VALUE",
- "CL_INVALID_ARG_SIZE",
- "CL_INVALID_KERNEL_ARGS",
- "CL_INVALID_WORK_DIMENSION",
- "CL_INVALID_WORK_GROUP_SIZE",
- "CL_INVALID_WORK_ITEM_SIZE",
- "CL_INVALID_GLOBAL_OFFSET",
- "CL_INVALID_EVENT_WAIT_LIST",
- "CL_INVALID_EVENT",
- "CL_INVALID_OPERATION",
- "CL_INVALID_GL_OBJECT",
- "CL_INVALID_BUFFER_SIZE",
- "CL_INVALID_MIP_LEVEL",
- "CL_INVALID_GLOBAL_WORK_SIZE",
- };
-
- const int errorCount = sizeof(errorString) / sizeof(errorString[0]);
-
- const int index = -error;
-
- return (index >= 0 && index < errorCount) ? errorString[index] : "";
-}
-
-bool ProgramBagCL::CheckErrorCL(cl_int error, const char* location)
-{
- if(error == CL_SUCCESS) return true;
- const char *errstr = GetErrorString(error);
- if(errstr && errstr[0]) std::cerr << errstr;
- else std::cerr << "Error " << error;
- if(location) std::cerr << " at " << location;
- std::cerr << "\n";
- exit(0);
- return false;
-
-}
-
-
-////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////
-
-void ProgramBagCLN::LoadFixedShaders()
-{
- s_sampling = new ProgramCL("sampling",
- "const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;\n"
- "__kernel void sampling(__read_only image2d_t input, __write_only image2d_t output, "
- " int width, int height) {\n"
- "int2 coord = (int2)(get_global_id(0), get_global_id(1)); \n"
- "if( coord.x >= width || coord.y >= height) return;\n"
- "write_imagef(output, coord, read_imagef(input, sampler, coord << 1)); }" , _context, _device);
-
- s_sampling_k = new ProgramCL("sampling_k",
- "const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;\n"
- "__kernel void sampling_k(__read_only image2d_t input, __write_only image2d_t output, "
- " int width, int height, int step) {\n"
- "int x = get_global_id(0), y = get_global_id(1); \n"
- "if( x >= width || y >= height) return;\n"
- "int xa = x * step, ya = y *step; \n"
- "float4 v1 = read_imagef(input, sampler, (int2) (xa, ya)); \n"
- "write_imagef(output, (int2) (x, y), v1); }" , _context, _device);
-
-
- s_sampling_u = new ProgramCL("sampling_u",
- "const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_LINEAR;\n"
- "__kernel void sampling_u(__read_only image2d_t input, \n"
- " __write_only image2d_t output,\n"
- " int width, int height, float step) {\n"
- "int x = get_global_id(0), y = get_global_id(1); \n"
- "if( x >= width || y >= height) return;\n"
- "float xa = x * step, ya = y *step; \n"
- "float v1 = read_imagef(input, sampler, (float2) (xa, ya)).x; \n"
- "write_imagef(output, (int2) (x, y), (float4)(v1)); }" , _context, _device);
-
- s_dog_pass = new ProgramCL("dog_pass",
- "const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;\n"
- "__kernel void dog_pass(__read_only image2d_t tex, __read_only image2d_t texp,\n"
- " __write_only image2d_t dog, int width, int height) {\n"
- "int2 coord = (int2)(get_global_id(0), get_global_id(1)); \n"
- "if( coord.x >= width || coord.y >= height) return;\n"
- "float cc = read_imagef(tex , sampler, coord).x; \n"
- "float cp = read_imagef(texp, sampler, coord).x;\n"
- "write_imagef(dog, coord, (float4)(cc - cp)); }\n", _context, _device);
-
- s_grad_pass = new ProgramCL("grad_pass",
- "const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;\n"
- "__kernel void grad_pass(__read_only image2d_t tex, __read_only image2d_t texp,\n"
- " __write_only image2d_t dog, int width, int height, \n"
- " __write_only image2d_t grad, __write_only image2d_t rot) {\n"
- "int x = get_global_id(0), y = get_global_id(1); \n"
- "if( x >= width || y >= height) return;\n"
- "int2 coord = (int2) (x, y);\n"
- "float cl = read_imagef(tex, sampler, (int2)(x - 1, y)).x;\n"
- "float cc = read_imagef(tex , sampler, coord).x; \n"
- "float cr = read_imagef(tex, sampler, (int2)(x + 1, y)).x;\n"
- "float cp = read_imagef(texp, sampler, coord).x;\n"
- "write_imagef(dog, coord, (float4)(cc - cp)); \n"
- "float cd = read_imagef(tex, sampler, (int2)(x, y - 1)).x;\n"
- "float cu = read_imagef(tex, sampler, (int2)(x, y + 1)).x;\n"
- "float dx = cr - cl, dy = cu - cd; \n"
- "float gg = 0.5 * sqrt(dx*dx + dy * dy);\n"
- "write_imagef(grad, coord, (float4)(gg));\n"
- "float oo = atan2(dy, dx + FLT_MIN);\n"
- "write_imagef(rot, coord, (float4)(oo));}\n", _context, _device);
-
- s_grad_pass2 = new ProgramCL("grad_pass2",
- "#define BLOCK_DIMX 32\n"
- "#define BLOCK_DIMY 14\n"
- "#define BLOCK_SIZE (BLOCK_DIMX * BLOCK_DIMY)\n"
- "__kernel void grad_pass2(__read_only image2d_t tex, __read_only image2d_t texp,\n"
- " __write_only image2d_t dog, int width, int height,\n"
- " __write_only image2d_t grd, __write_only image2d_t rot){\n"//, __local float* block) {\n"
- "__local float block[BLOCK_SIZE]; \n"
- "sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE |\n"
- " CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;\n"
- "int2 coord = (int2) ( get_global_id(0) - get_group_id(0) * 2 - 1, \n"
- " get_global_id(1) - get_group_id(1) * 2 - 1); \n"
- "int idx = mad24(get_local_id(1), BLOCK_DIMX, get_local_id(0));\n"
- "float cc = read_imagef(tex, sampler, coord).x;\n"
- "block[idx] = cc;\n"
- "barrier(CLK_LOCAL_MEM_FENCE);\n"
- "if( get_local_id(0) == 0 || get_local_id(0) == BLOCK_DIMX - 1) return;\n"
- "if( get_local_id(1) == 0 || get_local_id(1) == BLOCK_DIMY - 1) return;\n"
- "if( coord.x >= width) return; \n"
- "if( coord.y >= height) return;\n"
- "float cp = read_imagef(texp, sampler, coord).x;\n"
- "float dx = block[idx + 1] - block[idx - 1];\n"
- "float dy = block[idx + BLOCK_DIMX ] - block[idx - BLOCK_DIMX];\n"
- "write_imagef(dog, coord, (float4)(cc - cp)); \n"
- "write_imagef(grd, coord, (float4)(0.5 * sqrt(dx*dx + dy * dy)));\n"
- "write_imagef(rot, coord, (float4)(atan2(dy, dx + FLT_MIN)));}\n", _context, _device);
-}
-
-void ProgramBagCLN::LoadDisplayShaders()
-{
- s_unpack = new ProgramCL("main",
- "const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;\n"
- "__kernel void main(__read_only image2d_t input, __write_only image2d_t output,\n"
- " int width, int height) {\n"
- "int x = get_global_id(0), y = get_global_id(1); \n"
- "if(x >= width || y >= height) return;\n"
- "float v = read_imagef(input, sampler, (int2) (x, y)).x; \n"
- "float4 result = (float4) (v, v, v, 1);"
- "write_imagef(output, (int2) (x, y), result); }" , _context, _device);
-
- s_unpack_grd = new ProgramCL("main",
- "const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE |\n"
- " CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;\n"
- "__kernel void main(__read_only image2d_t input, __write_only image2d_t output,\n"
- " int width, int height) {\n"
- "int x = get_global_id(0), y = get_global_id(1); \n"
- "if(x >= width || y >= height) return;\n"
- "float v0 = read_imagef(input, sampler, (int2) (x, y)).x; \n"
- "float v = 5.0 * v0; float4 result = (float4) (v, v, v, 1);"
- "write_imagef(output, (int2) (x, y), result); }" , _context, _device);
-
- s_unpack_dog = new ProgramCL("main",
- "const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;\n"
- "__kernel void main(__read_only image2d_t input, __write_only image2d_t output,\n"
- " int width, int height) {\n"
- "int x = get_global_id(0), y = get_global_id(1); \n"
- "if(x >= width || y >= height) return;\n"
- "float v0 = read_imagef(input, sampler, (int2) (x, y)).x; \n"
- "float v = 0.5 + 20.0 * v0; float4 result = (float4) (v, v, v, 1);"
- "write_imagef(output, (int2) (x, y), result); }" , _context, _device);
-}
-
-ProgramCL* ProgramBagCLN::CreateFilterH(float kernel[], int width)
-{
- ////////////////////////////
- char buffer[10240];
- ostrstream out(buffer, 10240);
- out << "#define KERNEL_WIDTH " << width << "\n"
- << "#define KERNEL_HALF_WIDTH " << (width / 2) << "\n"
- "#define BLOCK_WIDTH 128\n"
- "#define BLOCK_HEIGHT 1\n"
- "#define CACHE_WIDTH (BLOCK_WIDTH + KERNEL_WIDTH - 1)\n"
- "#define CACHE_WIDTH_ALIGNED ((CACHE_WIDTH + 15) / 16 * 16)\n"
- "#define CACHE_COUNT (2 + (CACHE_WIDTH - 2) / BLOCK_WIDTH)\n"
- "const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;\n"
- "__kernel void filter_h(__read_only image2d_t input, \n"
- " __write_only image2d_t output, int width_, int height_, \n"
- " __constant float* weight) {\n"
- "__local float data[CACHE_WIDTH]; \n"
- "int x = get_global_id(0), y = get_global_id(1);\n"
- "#pragma unroll\n"
- "for(int j = 0; j < CACHE_COUNT; ++j)\n"
- "{\n"
- " if(get_local_id(0) + j * BLOCK_WIDTH < CACHE_WIDTH)\n"
- " {\n"
- " int fetch_index = min(x + j * BLOCK_WIDTH - KERNEL_HALF_WIDTH, width_);\n"
- " data[get_local_id(0) + j * BLOCK_WIDTH] = read_imagef(input, sampler, (int2)(fetch_index, y)).x;\n"
- " }\n"
- "}\n"
- "barrier(CLK_LOCAL_MEM_FENCE); \n"
- "if( x > width_ || y > height_) return; \n"
- "float result = 0; \n"
- "#pragma unroll\n"
- "for(int i = 0; i < KERNEL_WIDTH; ++i)\n"
- "{\n"
- " result += data[get_local_id(0) + i] * weight[i];\n"
- "}\n"
- << "write_imagef(output, (int2)(x, y), (float4)(result)); }\n" << '\0';
- return new ProgramCL("filter_h", buffer, _context, _device);
-}
-
-
-
-ProgramCL* ProgramBagCLN::CreateFilterV(float kernel[], int width)
-{
- ////////////////////////////
- char buffer[10240];
- ostrstream out(buffer, 10240);
- out << "#define KERNEL_WIDTH " << width << "\n"
- << "#define KERNEL_HALF_WIDTH " << (width / 2) << "\n"
- "#define BLOCK_WIDTH 128\n"
- "#define CACHE_WIDTH (BLOCK_WIDTH + KERNEL_WIDTH - 1)\n"
- "#define CACHE_WIDTH_ALIGNED ((CACHE_WIDTH + 15) / 16 * 16)\n"
- "#define CACHE_COUNT (2 + (CACHE_WIDTH - 2) / BLOCK_WIDTH)\n"
- "const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | \n"
- " CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;\n"
- "__kernel void filter_v(__read_only image2d_t input, \n"
- " __write_only image2d_t output, int width_, int height_, \n"
- " __constant float* weight) {\n"
- "__local float data[CACHE_WIDTH]; \n"
- "int x = get_global_id(0), y = get_global_id(1);\n"
- "#pragma unroll\n"
- "for(int j = 0; j < CACHE_COUNT; ++j)\n"
- "{\n"
- " if(get_local_id(1) + j * BLOCK_WIDTH < CACHE_WIDTH)\n"
- " {\n"
- " int fetch_index = min(y + j * BLOCK_WIDTH - KERNEL_HALF_WIDTH, height_);\n"
- " data[get_local_id(1) + j * BLOCK_WIDTH ] = read_imagef(input, sampler, (int2)(x, fetch_index)).x;\n"
- " }\n"
- "}\n"
- "barrier(CLK_LOCAL_MEM_FENCE); \n"
- "if( x > width_ || y > height_) return; \n"
- "float result = 0; \n"
- "#pragma unroll\n"
- "for(int i = 0; i < KERNEL_WIDTH; ++i)\n"
- "{\n"
- " result += data[get_local_id(1) + i] * weight[i];\n"
- "}\n"
- << "write_imagef(output, (int2)(x, y), (float4)(result)); }\n" << '\0';
-
- return new ProgramCL("filter_v", buffer, _context, _device);
-}
-
-FilterCL* ProgramBagCLN::CreateFilter(float kernel[], int width)
-{
- FilterCL * filter = new FilterCL;
- filter->s_shader_h = CreateFilterH(kernel, width);
- filter->s_shader_v = CreateFilterV(kernel, width);
- filter->_weight = new CLTexImage(_context, _queue);
- filter->_weight->InitBufferTex(width, 1, 1);
- filter->_weight->CopyFromHost(kernel);
- filter->_size = width;
- return filter;
-}
-
-
-void ProgramBagCLN::FilterImage(FilterCL* filter, CLTexImage *dst, CLTexImage *src, CLTexImage*tmp)
-{
- cl_kernel kernelh = filter->s_shader_h->_kernel;
- cl_kernel kernelv = filter->s_shader_v->_kernel;
- //////////////////////////////////////////////////////////////////
-
- cl_int status, w = dst->GetImgWidth(), h = dst->GetImgHeight();
- cl_mem weight = (cl_mem) filter->_weight->_clData;
- cl_int w_ = w - 1, h_ = h - 1;
-
-
- clSetKernelArg(kernelh, 0, sizeof(cl_mem), &src->_clData);
- clSetKernelArg(kernelh, 1, sizeof(cl_mem), &tmp->_clData);
- clSetKernelArg(kernelh, 2, sizeof(cl_int), &w_);
- clSetKernelArg(kernelh, 3, sizeof(cl_int), &h_);
- clSetKernelArg(kernelh, 4, sizeof(cl_mem), &weight);
-
- size_t dim00 = 128, dim01 = 1;
- size_t gsz1[2] = {(w + dim00 - 1) / dim00 * dim00, (h + dim01 - 1) / dim01 * dim01}, lsz1[2] = {dim00, dim01};
- status = clEnqueueNDRangeKernel(_queue, kernelh, 2, NULL, gsz1, lsz1, 0, NULL, NULL);
- CheckErrorCL(status, "ProgramBagCLN::FilterImageH");
- if(status != CL_SUCCESS) return;
-
-
- clSetKernelArg(kernelv, 0, sizeof(cl_mem), &tmp->_clData);
- clSetKernelArg(kernelv, 1, sizeof(cl_mem), &dst->_clData);
- clSetKernelArg(kernelv, 2, sizeof(cl_int), &w_);
- clSetKernelArg(kernelv, 3, sizeof(cl_int), &h_);
- clSetKernelArg(kernelv, 4, sizeof(cl_mem), &weight);
-
- size_t dim10 = 1, dim11 = 128;
- size_t gsz2[2] = {(w + dim10 - 1) / dim10 * dim10, (h + dim11 - 1) / dim11 * dim11}, lsz2[2] = {dim10, dim11};
- status = clEnqueueNDRangeKernel(_queue, kernelv, 2, NULL, gsz2, lsz2, 0, NULL, NULL);
- CheckErrorCL(status, "ProgramBagCLN::FilterImageV");
- //clReleaseEvent(event);
-}
-
-void ProgramBagCLN::SampleImageD(CLTexImage *dst, CLTexImage *src, int log_scale)
-{
- cl_kernel kernel;
- cl_int w = dst->GetImgWidth(), h = dst->GetImgHeight();
-
- cl_int fullstep = (1 << log_scale);
- kernel = log_scale == 1? s_sampling->_kernel : s_sampling_k->_kernel;
- clSetKernelArg(kernel, 0, sizeof(cl_mem), &(src->_clData));
- clSetKernelArg(kernel, 1, sizeof(cl_mem), &(dst->_clData));
- clSetKernelArg(kernel, 2, sizeof(cl_int), &(w));
- clSetKernelArg(kernel, 3, sizeof(cl_int), &(h));
- if(log_scale > 1) clSetKernelArg(kernel, 4, sizeof(cl_int), &(fullstep));
-
- size_t dim0 = 128, dim1 = 1;
- //while( w * h / dim0 / dim1 < 8 && dim1 > 1) dim1 /= 2;
- size_t gsz[2] = {(w + dim0 - 1) / dim0 * dim0, (h + dim1 - 1) / dim1 * dim1}, lsz[2] = {dim0, dim1};
- cl_int status = clEnqueueNDRangeKernel(_queue, kernel, 2, NULL, gsz, lsz, 0, NULL, NULL);
- CheckErrorCL(status, "ProgramBagCLN::SampleImageD");
-}
-
-
-#endif
-
diff --git a/3rdparty/SiftGPU/src/SiftGPU/ProgramCL.h b/3rdparty/SiftGPU/src/SiftGPU/ProgramCL.h
deleted file mode 100644
index e134992b..00000000
--- a/3rdparty/SiftGPU/src/SiftGPU/ProgramCL.h
+++ /dev/null
@@ -1,164 +0,0 @@
-////////////////////////////////////////////////////////////////////////////
-// File: ProgramCL.h
-// Author: Changchang Wu
-// Description : interface for the ProgramCL classes.
-// ProgramCL: Cg programs
-// ShaderBagCG: All Cg shaders for Sift in a bag
-// FilterCL: Cg Gaussian Filters
-//
-// Copyright (c) 2007 University of North Carolina at Chapel Hill
-// All Rights Reserved
-//
-// Permission to use, copy, modify and distribute this software and its
-// documentation for educational, research and non-profit purposes, without
-// fee, and without a written agreement is hereby granted, provided that the
-// above copyright notice and the following paragraph appear in all copies.
-//
-// The University of North Carolina at Chapel Hill make no representations
-// about the suitability of this software for any purpose. It is provided
-// 'as is' without express or implied warranty.
-//
-// Please send BUG REPORTS to ccwu@cs.unc.edu
-//
-////////////////////////////////////////////////////////////////////////////
-
-
-#if defined(CL_SIFTGPU_ENABLED)
-
-#ifndef _PROGRAM_CL_H
-#define _PROGRAM_CL_H
-
-#include "ProgramGPU.h"
-
-class ProgramCL: public ProgramGPU
-{
- cl_program _program;
- cl_kernel _kernel;
- int _valid;
-public:
- int IsValidProgram(){return _program && _valid;}
- ProgramCL(const char* name, const char * code, cl_context contex, cl_device_id device);
- ProgramCL();
- void PrintBuildLog(cl_device_id device, int all);
- virtual ~ProgramCL();
- virtual int UseProgram(){return 1;}
- virtual void * GetProgramID() {return _kernel;}
- friend class ProgramBagCL;
- friend class ProgramBagCLN;
-};
-
-class CLTexImage;
-class FilterCL
-{
-public:
- ProgramCL* s_shader_h;
- ProgramCL* s_shader_v;
- int _size;
- int _id;
- CLTexImage * _weight;
-public:
- FilterCL() : s_shader_h(NULL), s_shader_v(NULL), _size(0), _id(0), _weight(NULL) {}
- ~FilterCL() {if(s_shader_h) delete s_shader_h; if(s_shader_v) delete s_shader_v; if(_weight) delete _weight; }
-};
-
-class SiftParam;
-
-class ProgramBagCL
-{
-protected:
- cl_platform_id _platform;
- cl_device_id _device;
- cl_context _context;
- cl_command_queue _queue;
-protected:
- ProgramCL * s_gray;
- ProgramCL * s_sampling;
- ProgramCL * s_sampling_k;
- ProgramCL * s_sampling_u;
- ProgramCL * s_zero_pass;
- ProgramCL * s_packup;
- ProgramCL * s_unpack;
- ProgramCL * s_unpack_dog;
- ProgramCL * s_unpack_grd;
- ProgramCL * s_unpack_key;
- ProgramCL * s_dog_pass;
- ProgramCL * s_grad_pass;
- ProgramCL * s_grad_pass2;
- ProgramCL * s_gray_pack;
- ProgramCL * s_keypoint;
-public:
- FilterCL * f_gaussian_skip0;
- vector f_gaussian_skip0_v;
- FilterCL * f_gaussian_skip1;
- FilterCL ** f_gaussian_step;
- int _gaussian_step_num;
-public:
- ProgramBagCL();
- bool InitializeContext();
- virtual ~ProgramBagCL();
- void FinishCL();
- cl_context GetContextCL() {return _context;}
- cl_command_queue GetCommandQueue() {return _queue;}
- static const char* GetErrorString(cl_int error);
- static bool CheckErrorCL(cl_int error, const char* location = NULL);
-public:
- FilterCL * CreateGaussianFilter(float sigma);
- void CreateGaussianFilters(SiftParam¶m);
- void SelectInitialSmoothingFilter(int octave_min, SiftParam¶m);
- void FilterInitialImage(CLTexImage* tex, CLTexImage* buf);
- void FilterSampledImage(CLTexImage* tex, CLTexImage* buf);
- void UnpackImage(CLTexImage*src, CLTexImage* dst);
- void UnpackImageDOG(CLTexImage*src, CLTexImage* dst);
- void UnpackImageGRD(CLTexImage*src, CLTexImage* dst);
- void UnpackImageKEY(CLTexImage*src, CLTexImage* dog, CLTexImage* dst);
- void ComputeDOG(CLTexImage*tex, CLTexImage* texp, CLTexImage* dog, CLTexImage* grad, CLTexImage* rot);
- void ComputeKEY(CLTexImage*dog, CLTexImage* key, float Tdog, float Tedge);
-public:
- virtual void SampleImageU(CLTexImage *dst, CLTexImage *src, int log_scale);
- virtual void SampleImageD(CLTexImage *dst, CLTexImage *src, int log_scale = 1);
- virtual void FilterImage(FilterCL* filter, CLTexImage *dst, CLTexImage *src, CLTexImage*tmp);
- virtual ProgramCL* CreateFilterH(float kernel[], int width);
- virtual ProgramCL* CreateFilterV(float kernel[], int width);
- virtual FilterCL* CreateFilter(float kernel[], int width);
-public:
- virtual void InitProgramBag(SiftParam¶m);
- virtual void LoadDescriptorShader();
- virtual void LoadDescriptorShaderF2();
- virtual void LoadOrientationShader();
- virtual void LoadGenListShader(int ndoglev, int nlev);
- virtual void UnloadProgram() ;
- virtual void LoadKeypointShader();
- virtual void LoadFixedShaders();
- virtual void LoadDisplayShaders();
- virtual void LoadDynamicShaders(SiftParam& param);
-public:
- //parameters
- virtual void SetGradPassParam(int texP);
- virtual void SetGenListEndParam(int ktex);
- virtual void SetGenListStartParam(float width, int tex0);
- virtual void SetGenListInitParam(int w, int h);
- virtual void SetMarginCopyParam(int xmax, int ymax);
- virtual void SetDogTexParam(int texU, int texD);
- virtual void SetGenListStepParam(int tex, int tex0);
- virtual void SetGenVBOParam( float width, float fwidth, float size);
- virtual void SetFeatureDescirptorParam(int gtex, int otex, float dwidth, float fwidth, float width, float height, float sigma);
- virtual void SetFeatureOrientationParam(int gtex, int width, int height, float sigma, int stex, float step);
- virtual void SetSimpleOrientationInput(int oTex, float sigma, float sigma_step);
-
-};
-
-class CLTexImage ;
-class ProgramBagCLN: public ProgramBagCL
-{
-public:
- virtual void SampleImageD(CLTexImage *dst, CLTexImage *src, int log_scale = 1);
- virtual FilterCL* CreateFilter(float kernel[], int width);
- virtual ProgramCL* CreateFilterH(float kernel[], int width);
- virtual ProgramCL* CreateFilterV(float kernel[], int width);
- virtual void FilterImage(FilterCL* filter, CLTexImage *dst, CLTexImage *src, CLTexImage*tmp);
- virtual void LoadFixedShaders();
- virtual void LoadDisplayShaders();
-};
-#endif
-#endif
-
diff --git a/3rdparty/SiftGPU/src/SiftGPU/ProgramCU.cu b/3rdparty/SiftGPU/src/SiftGPU/ProgramCU.cu
deleted file mode 100644
index 257dda08..00000000
--- a/3rdparty/SiftGPU/src/SiftGPU/ProgramCU.cu
+++ /dev/null
@@ -1,1795 +0,0 @@
-////////////////////////////////////////////////////////////////////////////
-// File: ProgramCU.cu
-// Author: Changchang Wu
-// Description : implementation of ProgramCU and all CUDA kernels
-//
-// Copyright (c) 2007 University of North Carolina at Chapel Hill
-// All Rights Reserved
-//
-// Permission to use, copy, modify and distribute this software and its
-// documentation for educational, research and non-profit purposes, without
-// fee, and without a written agreement is hereby granted, provided that the
-// above copyright notice and the following paragraph appear in all copies.
-//
-// The University of North Carolina at Chapel Hill make no representations
-// about the suitability of this software for any purpose. It is provided
-// 'as is' without express or implied warranty.
-//
-// Please send BUG REPORTS to ccwu@cs.unc.edu
-//
-////////////////////////////////////////////////////////////////////////////
-
-#if defined(CUDA_SIFTGPU_ENABLED)
-
-#include "GL/glew.h"
-#include "stdio.h"
-
-#include "CuTexImage.h"
-#include "ProgramCU.h"
-#include "GlobalUtil.h"
-
-//----------------------------------------------------------------
-//Begin SiftGPU setting section.
-//////////////////////////////////////////////////////////
-#define IMUL(X,Y) __mul24(X,Y)
-//#define FDIV(X,Y) ((X)/(Y))
-#define FDIV(X,Y) __fdividef(X,Y)
-
-/////////////////////////////////////////////////////////
-//filter kernel width range (don't change this)
-#define KERNEL_MAX_WIDTH 33
-#define KERNEL_MIN_WIDTH 5
-
-//////////////////////////////////////////////////////////
-//horizontal filter block size (32, 64, 128, 256, 512)
-#define FILTERH_TILE_WIDTH 128
-//thread block for vertical filter. FILTERV_BLOCK_WIDTH can be (4, 8 or 16)
-#define FILTERV_BLOCK_WIDTH 16
-#define FILTERV_BLOCK_HEIGHT 32
-//The corresponding image patch for a thread block
-#define FILTERV_PIXEL_PER_THREAD 4
-#define FILTERV_TILE_WIDTH FILTERV_BLOCK_WIDTH
-#define FILTERV_TILE_HEIGHT (FILTERV_PIXEL_PER_THREAD * FILTERV_BLOCK_HEIGHT)
-
-
-//////////////////////////////////////////////////////////
-//thread block size for computing Difference of Gaussian
-#define DOG_BLOCK_LOG_DIMX 7
-#define DOG_BLOCK_LOG_DIMY 0
-#define DOG_BLOCK_DIMX (1 << DOG_BLOCK_LOG_DIMX)
-#define DOG_BLOCK_DIMY (1 << DOG_BLOCK_LOG_DIMY)
-
-//////////////////////////////////////////////////////////
-//thread block size for keypoint detection
-#define KEY_BLOCK_LOG_DIMX 3
-#define KEY_BLOCK_LOG_DIMY 3
-#define KEY_BLOCK_DIMX (1< texData;
-texture texDataB;
-texture texDataF2;
-texture texDataF4;
-texture texDataI4;
-texture texDataList;
-
-//template __device__ float Conv(float *data) { return Conv(data) + data[i]*d_kernel[i];}
-//template<> __device__ float Conv<0>(float *data) { return data[0] * d_kernel[0]; }
-
-
-//////////////////////////////////////////////////////////////
-template __global__ void FilterH( float* d_result, int width)
-{
-
- const int HALF_WIDTH = FW >> 1;
- const int CACHE_WIDTH = FILTERH_TILE_WIDTH + FW -1;
- const int CACHE_COUNT = 2 + (CACHE_WIDTH - 2)/ FILTERH_TILE_WIDTH;
- __shared__ float data[CACHE_WIDTH];
- const int bcol = IMUL(blockIdx.x, FILTERH_TILE_WIDTH);
- const int col = bcol + threadIdx.x;
- const int index_min = IMUL(blockIdx.y, width);
- const int index_max = index_min + width - 1;
- int src_index = index_min + bcol - HALF_WIDTH + threadIdx.x;
- int cache_index = threadIdx.x;
- float value = 0;
-#pragma unroll
- for(int j = 0; j < CACHE_COUNT; ++j)
- {
- if(cache_index < CACHE_WIDTH)
- {
- int fetch_index = src_index < index_min? index_min : (src_index > index_max ? index_max : src_index);
- data[cache_index] = tex1Dfetch(texData,fetch_index);
- src_index += FILTERH_TILE_WIDTH;
- cache_index += FILTERH_TILE_WIDTH;
- }
- }
- __syncthreads();
- if(col >= width) return;
-#pragma unroll
- for(int i = 0; i < FW; ++i)
- {
- value += (data[threadIdx.x + i]* d_kernel[i]);
- }
-// value = Conv(data + threadIdx.x);
- d_result[index_min + col] = value;
-}
-
-
-
-////////////////////////////////////////////////////////////////////
-template __global__ void FilterV(float* d_result, int width, int height)
-{
- const int HALF_WIDTH = FW >> 1;
- const int CACHE_WIDTH = FW + FILTERV_TILE_HEIGHT - 1;
- const int TEMP = CACHE_WIDTH & 0xf;
-//add some extra space to avoid bank conflict
-#if FILTERV_TILE_WIDTH == 16
- //make the stride 16 * n +/- 1
- const int EXTRA = (TEMP == 1 || TEMP == 0) ? 1 - TEMP : 15 - TEMP;
-#elif FILTERV_TILE_WIDTH == 8
- //make the stride 16 * n +/- 2
- const int EXTRA = (TEMP == 2 || TEMP == 1 || TEMP == 0) ? 2 - TEMP : (TEMP == 15? 3 : 14 - TEMP);
-#elif FILTERV_TILE_WIDTH == 4
- //make the stride 16 * n +/- 4
- const int EXTRA = (TEMP >=0 && TEMP <=4) ? 4 - TEMP : (TEMP > 12? 20 - TEMP : 12 - TEMP);
-#else
-#error
-#endif
- const int CACHE_TRUE_WIDTH = CACHE_WIDTH + EXTRA;
- const int CACHE_COUNT = (CACHE_WIDTH + FILTERV_BLOCK_HEIGHT - 1) / FILTERV_BLOCK_HEIGHT;
- const int WRITE_COUNT = (FILTERV_TILE_HEIGHT + FILTERV_BLOCK_HEIGHT -1) / FILTERV_BLOCK_HEIGHT;
- __shared__ float data[CACHE_TRUE_WIDTH * FILTERV_TILE_WIDTH];
- const int row_block_first = IMUL(blockIdx.y, FILTERV_TILE_HEIGHT);
- const int col = IMUL(blockIdx.x, FILTERV_TILE_WIDTH) + threadIdx.x;
- const int row_first = row_block_first - HALF_WIDTH;
- const int data_index_max = IMUL(height - 1, width) + col;
- const int cache_col_start = threadIdx.y;
- const int cache_row_start = IMUL(threadIdx.x, CACHE_TRUE_WIDTH);
- int cache_index = cache_col_start + cache_row_start;
- int data_index = IMUL(row_first + cache_col_start, width) + col;
-
- if(col < width)
- {
-#pragma unroll
- for(int i = 0; i < CACHE_COUNT; ++i)
- {
- if(cache_col_start < CACHE_WIDTH - i * FILTERV_BLOCK_HEIGHT)
- {
- int fetch_index = data_index < col ? col : (data_index > data_index_max? data_index_max : data_index);
- data[cache_index + i * FILTERV_BLOCK_HEIGHT] = tex1Dfetch(texData,fetch_index);
- data_index += IMUL(FILTERV_BLOCK_HEIGHT, width);
- }
- }
- }
- __syncthreads();
-
- if(col >= width) return;
-
- int row = row_block_first + threadIdx.y;
- int index_start = cache_row_start + threadIdx.y;
-#pragma unroll
- for(int i = 0; i < WRITE_COUNT; ++i,
- row += FILTERV_BLOCK_HEIGHT, index_start += FILTERV_BLOCK_HEIGHT)
- {
- if(row < height)
- {
- int index_dest = IMUL(row, width) + col;
- float value = 0;
-#pragma unroll
- for(int i = 0; i < FW; ++i)
- {
- value += (data[index_start + i] * d_kernel[i]);
- }
- d_result[index_dest] = value;
- }
- }
-}
-
-
-template __global__ void UpsampleKernel(float* d_result, int width)
-{
- const int SCALE = (1 << LOG_SCALE), SCALE_MASK = (SCALE - 1);
- const float INV_SCALE = 1.0f / (float(SCALE));
- int col = IMUL(blockIdx.x, FILTERH_TILE_WIDTH) + threadIdx.x;
- if(col >= width) return;
-
- int row = blockIdx.y >> LOG_SCALE;
- int index = row * width + col;
- int dst_row = blockIdx.y;
- int dst_idx= (width * dst_row + col) * SCALE;
- int helper = blockIdx.y & SCALE_MASK;
- if (helper)
- {
- float v11 = tex1Dfetch(texData, index);
- float v12 = tex1Dfetch(texData, index + 1);
- index += width;
- float v21 = tex1Dfetch(texData, index);
- float v22 = tex1Dfetch(texData, index + 1);
- float w1 = INV_SCALE * helper, w2 = 1.0 - w1;
- float v1 = (v21 * w1 + w2 * v11);
- float v2 = (v22 * w1 + w2 * v12);
- d_result[dst_idx] = v1;
-#pragma unroll
- for(int i = 1; i < SCALE; ++i)
- {
- const float r2 = i * INV_SCALE;
- const float r1 = 1.0f - r2;
- d_result[dst_idx +i] = v1 * r1 + v2 * r2;
- }
- }else
- {
- float v1 = tex1Dfetch(texData, index);
- float v2 = tex1Dfetch(texData, index + 1);
- d_result[dst_idx] = v1;
-#pragma unroll
- for(int i = 1; i < SCALE; ++i)
- {
- const float r2 = i * INV_SCALE;
- const float r1 = 1.0f - r2;
- d_result[dst_idx +i] = v1 * r1 + v2 * r2;
- }
- }
-
-}
-
-////////////////////////////////////////////////////////////////////////////////////////
-void ProgramCU::SampleImageU(CuTexImage *dst, CuTexImage *src, int log_scale)
-{
- int width = src->GetImgWidth(), height = src->GetImgHeight();
- src->BindTexture(texData);
- dim3 grid((width + FILTERH_TILE_WIDTH - 1)/ FILTERH_TILE_WIDTH, height << log_scale);
- dim3 block(FILTERH_TILE_WIDTH);
- switch(log_scale)
- {
- case 1 : UpsampleKernel<1> <<< grid, block>>> ((float*) dst->_cuData, width); break;
- case 2 : UpsampleKernel<2> <<< grid, block>>> ((float*) dst->_cuData, width); break;
- case 3 : UpsampleKernel<3> <<< grid, block>>> ((float*) dst->_cuData, width); break;
- default: break;
- }
-}
-
-template __global__ void DownsampleKernel(float* d_result, int src_width, int dst_width)
-{
- const int dst_col = IMUL(blockIdx.x, FILTERH_TILE_WIDTH) + threadIdx.x;
- if(dst_col >= dst_width) return;
- const int src_col = min((dst_col << LOG_SCALE), (src_width - 1));
- const int dst_row = blockIdx.y;
- const int src_row = blockIdx.y << LOG_SCALE;
- const int src_idx = IMUL(src_row, src_width) + src_col;
- const int dst_idx = IMUL(dst_width, dst_row) + dst_col;
- d_result[dst_idx] = tex1Dfetch(texData, src_idx);
-
-}
-
-__global__ void DownsampleKernel(float* d_result, int src_width, int dst_width, const int log_scale)
-{
- const int dst_col = IMUL(blockIdx.x, FILTERH_TILE_WIDTH) + threadIdx.x;
- if(dst_col >= dst_width) return;
- const int src_col = min((dst_col << log_scale), (src_width - 1));
- const int dst_row = blockIdx.y;
- const int src_row = blockIdx.y << log_scale;
- const int src_idx = IMUL(src_row, src_width) + src_col;
- const int dst_idx = IMUL(dst_width, dst_row) + dst_col;
- d_result[dst_idx] = tex1Dfetch(texData, src_idx);
-
-}
-
-void ProgramCU::SampleImageD(CuTexImage *dst, CuTexImage *src, int log_scale)
-{
- int src_width = src->GetImgWidth(), dst_width = dst->GetImgWidth() ;
-
- src->BindTexture(texData);
- dim3 grid((dst_width + FILTERH_TILE_WIDTH - 1)/ FILTERH_TILE_WIDTH, dst->GetImgHeight());
- dim3 block(FILTERH_TILE_WIDTH);
- switch(log_scale)
- {
- case 1 : DownsampleKernel<1> <<< grid, block>>> ((float*) dst->_cuData, src_width, dst_width); break;
- case 2 : DownsampleKernel<2> <<< grid, block>>> ((float*) dst->_cuData, src_width, dst_width); break;
- case 3 : DownsampleKernel<3> <<< grid, block>>> ((float*) dst->_cuData, src_width, dst_width); break;
- default: DownsampleKernel <<< grid, block>>> ((float*) dst->_cuData, src_width, dst_width, log_scale);
- }
-}
-
-__global__ void ChannelReduce_Kernel(float* d_result)
-{
- int index = IMUL(blockIdx.x, FILTERH_TILE_WIDTH) + threadIdx.x;
- d_result[index] = tex1Dfetch(texData, index*4);
-}
-
-__global__ void ChannelReduce_Convert_Kernel(float* d_result)
-{
- int index = IMUL(blockIdx.x, FILTERH_TILE_WIDTH) + threadIdx.x;
- float4 rgba = tex1Dfetch(texDataF4, index);
- d_result[index] = 0.299f * rgba.x + 0.587f* rgba.y + 0.114f * rgba.z;
-}
-
-void ProgramCU::ReduceToSingleChannel(CuTexImage* dst, CuTexImage* src, int convert_rgb)
-{
- int width = src->GetImgWidth(), height = dst->GetImgHeight() ;
-
- dim3 grid((width * height + FILTERH_TILE_WIDTH - 1)/ FILTERH_TILE_WIDTH);
- dim3 block(FILTERH_TILE_WIDTH);
- if(convert_rgb)
- {
- src->BindTexture(texDataF4);
- ChannelReduce_Convert_Kernel<<>>((float*)dst->_cuData);
- }else
- {
- src->BindTexture(texData);
- ChannelReduce_Kernel<<>>((float*)dst->_cuData);
- }
-}
-
-__global__ void ConvertByteToFloat_Kernel(float* d_result)
-{
- int index = IMUL(blockIdx.x, FILTERH_TILE_WIDTH) + threadIdx.x;
- d_result[index] = tex1Dfetch(texDataB, index);
-}
-
-void ProgramCU::ConvertByteToFloat(CuTexImage*src, CuTexImage* dst)
-{
- int width = src->GetImgWidth(), height = dst->GetImgHeight() ;
- dim3 grid((width * height + FILTERH_TILE_WIDTH - 1)/ FILTERH_TILE_WIDTH);
- dim3 block(FILTERH_TILE_WIDTH);
- src->BindTexture(texDataB);
- ConvertByteToFloat_Kernel<<>>((float*)dst->_cuData);
-}
-
-void ProgramCU::CreateFilterKernel(float sigma, float* kernel, int& width)
-{
- int i, sz = int( ceil( GlobalUtil::_FilterWidthFactor * sigma -0.5) ) ;//
- width = 2*sz + 1;
-
- if(width > KERNEL_MAX_WIDTH)
- {
- //filter size truncation
- sz = KERNEL_MAX_WIDTH >> 1;
- width =KERNEL_MAX_WIDTH;
- }else if(width < KERNEL_MIN_WIDTH)
- {
- sz = KERNEL_MIN_WIDTH >> 1;
- width =KERNEL_MIN_WIDTH;
- }
-
- float rv = 1.0f/(sigma*sigma), v, ksum =0;
-
- // pre-compute filter
- for( i = -sz ; i <= sz ; ++i)
- {
- kernel[i+sz] = v = exp(-0.5f * i * i *rv) ;
- ksum += v;
- }
-
- //normalize the kernel
- rv = 1.0f/ksum;
- for(i = 0; i< width ;i++) kernel[i]*=rv;
-}
-
-
-template void ProgramCU::FilterImage(CuTexImage *dst, CuTexImage *src, CuTexImage* buf)
-{
- int width = src->GetImgWidth(), height = src->GetImgHeight();
-
- //horizontal filtering
- src->BindTexture(texData);
- dim3 gridh((width + FILTERH_TILE_WIDTH - 1)/ FILTERH_TILE_WIDTH, height);
- dim3 blockh(FILTERH_TILE_WIDTH);
- FilterH<<>>((float*)buf->_cuData, width);
- CheckErrorCUDA("FilterH");
-
- ///vertical filtering
- buf->BindTexture(texData);
- dim3 gridv((width + FILTERV_TILE_WIDTH - 1)/ FILTERV_TILE_WIDTH, (height + FILTERV_TILE_HEIGHT - 1)/FILTERV_TILE_HEIGHT);
- dim3 blockv(FILTERV_TILE_WIDTH, FILTERV_BLOCK_HEIGHT);
- FilterV<<>>((float*)dst->_cuData, width, height);
- CheckErrorCUDA("FilterV");
-}
-
-//////////////////////////////////////////////////////////////////////
-// tested on 2048x1500 image, the time on pyramid construction is
-// OpenGL version : 18ms
-// CUDA version: 28 ms
-void ProgramCU::FilterImage(CuTexImage *dst, CuTexImage *src, CuTexImage* buf, float sigma)
-{
- float filter_kernel[KERNEL_MAX_WIDTH]; int width;
- CreateFilterKernel(sigma, filter_kernel, width);
- cudaMemcpyToSymbol(d_kernel, filter_kernel, width * sizeof(float), 0, cudaMemcpyHostToDevice);
-
- switch(width)
- {
- case 5: FilterImage< 5>(dst, src, buf); break;
- case 7: FilterImage< 7>(dst, src, buf); break;
- case 9: FilterImage< 9>(dst, src, buf); break;
- case 11: FilterImage<11>(dst, src, buf); break;
- case 13: FilterImage<13>(dst, src, buf); break;
- case 15: FilterImage<15>(dst, src, buf); break;
- case 17: FilterImage<17>(dst, src, buf); break;
- case 19: FilterImage<19>(dst, src, buf); break;
- case 21: FilterImage<21>(dst, src, buf); break;
- case 23: FilterImage<23>(dst, src, buf); break;
- case 25: FilterImage<25>(dst, src, buf); break;
- case 27: FilterImage<27>(dst, src, buf); break;
- case 29: FilterImage<29>(dst, src, buf); break;
- case 31: FilterImage<31>(dst, src, buf); break;
- case 33: FilterImage<33>(dst, src, buf); break;
- default: break;
- }
-
-}
-
-
-texture texC;
-texture texP;
-texture texN;
-
-void __global__ ComputeDOG_Kernel(float* d_dog, float2* d_got, int width, int height)
-{
- int row = (blockIdx.y << DOG_BLOCK_LOG_DIMY) + threadIdx.y;
- int col = (blockIdx.x << DOG_BLOCK_LOG_DIMX) + threadIdx.x;
- if(col < width && row < height)
- {
- int index = IMUL(row, width) + col;
- float vp = tex1Dfetch(texP, index);
- float v = tex1Dfetch(texC, index);
- d_dog[index] = v - vp;
- float vxn = tex1Dfetch(texC, index + 1);
- float vxp = tex1Dfetch(texC, index - 1);
- float vyp = tex1Dfetch(texC, index - width);
- float vyn = tex1Dfetch(texC, index + width);
- float dx = vxn - vxp, dy = vyn - vyp;
- float grd = 0.5f * sqrt(dx * dx + dy * dy);
- float rot = (grd == 0.0f? 0.0f : atan2(dy, dx));
- d_got[index] = make_float2(grd, rot);
- }
-}
-
-void __global__ ComputeDOG_Kernel(float* d_dog, int width, int height)
-{
- int row = (blockIdx.y << DOG_BLOCK_LOG_DIMY) + threadIdx.y;
- int col = (blockIdx.x << DOG_BLOCK_LOG_DIMX) + threadIdx.x;
- if(col < width && row < height)
- {
- int index = IMUL(row, width) + col;
- float vp = tex1Dfetch(texP, index);
- float v = tex1Dfetch(texC, index);
- d_dog[index] = v - vp;
- }
-}
-
-void ProgramCU::ComputeDOG(CuTexImage* gus, CuTexImage* dog, CuTexImage* got)
-{
- int width = gus->GetImgWidth(), height = gus->GetImgHeight();
- dim3 grid((width + DOG_BLOCK_DIMX - 1)/ DOG_BLOCK_DIMX, (height + DOG_BLOCK_DIMY - 1)/DOG_BLOCK_DIMY);
- dim3 block(DOG_BLOCK_DIMX, DOG_BLOCK_DIMY);
- gus->BindTexture(texC);
- (gus -1)->BindTexture(texP);
- if(got->_cuData)
- ComputeDOG_Kernel<<>>((float*) dog->_cuData, (float2*) got->_cuData, width, height);
- else
- ComputeDOG_Kernel<<>>((float*) dog->_cuData, width, height);
-}
-
-
-#define READ_CMP_DOG_DATA(datai, tex, idx) \
- datai[0] = tex1Dfetch(tex, idx - 1);\
- datai[1] = tex1Dfetch(tex, idx);\
- datai[2] = tex1Dfetch(tex, idx + 1);\
- if(v > nmax)\
- {\
- nmax = max(nmax, datai[0]);\
- nmax = max(nmax, datai[1]);\
- nmax = max(nmax, datai[2]);\
- if(v < nmax) goto key_finish;\
- }else\
- {\
- nmin = min(nmin, datai[0]);\
- nmin = min(nmin, datai[1]);\
- nmin = min(nmin, datai[2]);\
- if(v > nmin) goto key_finish;\
- }
-
-
-void __global__ ComputeKEY_Kernel(float4* d_key, int width, int colmax, int rowmax,
- float dog_threshold0, float dog_threshold, float edge_threshold, int subpixel_localization)
-{
- float data[3][3], v;
- float datap[3][3], datan[3][3];
-#ifdef KEY_OFFSET_ONE
- int row = (blockIdx.y << KEY_BLOCK_LOG_DIMY) + threadIdx.y + 1;
- int col = (blockIdx.x << KEY_BLOCK_LOG_DIMX) + threadIdx.x + 1;
-#else
- int row = (blockIdx.y << KEY_BLOCK_LOG_DIMY) + threadIdx.y;
- int col = (blockIdx.x << KEY_BLOCK_LOG_DIMX) + threadIdx.x;
-#endif
- int index = IMUL(row, width) + col;
- int idx[3] ={index - width, index, index + width};
- int in_image =0;
- float nmax, nmin, result = 0.0f;
- float dx = 0, dy = 0, ds = 0;
- bool offset_test_passed = true;
-#ifdef KEY_OFFSET_ONE
- if(row < rowmax && col < colmax)
-#else
- if(row > 0 && col > 0 && row < rowmax && col < colmax)
-#endif
- {
- in_image = 1;
- data[1][1] = v = tex1Dfetch(texC, idx[1]);
- if(fabs(v) <= dog_threshold0) goto key_finish;
-
- data[1][0] = tex1Dfetch(texC, idx[1] - 1);
- data[1][2] = tex1Dfetch(texC, idx[1] + 1);
- nmax = max(data[1][0], data[1][2]);
- nmin = min(data[1][0], data[1][2]);
-
- if(v <=nmax && v >= nmin) goto key_finish;
- //if((v > nmax && v < 0 )|| (v < nmin && v > 0)) goto key_finish;
- READ_CMP_DOG_DATA(data[0], texC, idx[0]);
- READ_CMP_DOG_DATA(data[2], texC, idx[2]);
-
- //edge supression
- float vx2 = v * 2.0f;
- float fxx = data[1][0] + data[1][2] - vx2;
- float fyy = data[0][1] + data[2][1] - vx2;
- float fxy = 0.25f * (data[2][2] + data[0][0] - data[2][0] - data[0][2]);
- float temp1 = fxx * fyy - fxy * fxy;
- float temp2 = (fxx + fyy) * (fxx + fyy);
- if(temp1 <=0 || temp2 > edge_threshold * temp1) goto key_finish;
-
-
- //read the previous level
- READ_CMP_DOG_DATA(datap[0], texP, idx[0]);
- READ_CMP_DOG_DATA(datap[1], texP, idx[1]);
- READ_CMP_DOG_DATA(datap[2], texP, idx[2]);
-
-
- //read the next level
- READ_CMP_DOG_DATA(datan[0], texN, idx[0]);
- READ_CMP_DOG_DATA(datan[1], texN, idx[1]);
- READ_CMP_DOG_DATA(datan[2], texN, idx[2]);
-
- if(subpixel_localization)
- {
- //subpixel localization
- float fx = 0.5f * (data[1][2] - data[1][0]);
- float fy = 0.5f * (data[2][1] - data[0][1]);
- float fs = 0.5f * (datan[1][1] - datap[1][1]);
-
- float fss = (datan[1][1] + datap[1][1] - vx2);
- float fxs = 0.25f* (datan[1][2] + datap[1][0] - datan[1][0] - datap[1][2]);
- float fys = 0.25f* (datan[2][1] + datap[0][1] - datan[0][1] - datap[2][1]);
-
- //need to solve dx, dy, ds;
- // |-fx| | fxx fxy fxs | |dx|
- // |-fy| = | fxy fyy fys | * |dy|
- // |-fs| | fxs fys fss | |ds|
- float4 A0 = fxx > 0? make_float4(fxx, fxy, fxs, -fx) : make_float4(-fxx, -fxy, -fxs, fx);
- float4 A1 = fxy > 0? make_float4(fxy, fyy, fys, -fy) : make_float4(-fxy, -fyy, -fys, fy);
- float4 A2 = fxs > 0? make_float4(fxs, fys, fss, -fs) : make_float4(-fxs, -fys, -fss, fs);
- float maxa = max(max(A0.x, A1.x), A2.x);
- if(maxa >= 1e-10)
- {
- if(maxa == A1.x)
- {
- float4 TEMP = A1; A1 = A0; A0 = TEMP;
- }else if(maxa == A2.x)
- {
- float4 TEMP = A2; A2 = A0; A0 = TEMP;
- }
- A0.y /= A0.x; A0.z /= A0.x; A0.w/= A0.x;
- A1.y -= A1.x * A0.y; A1.z -= A1.x * A0.z; A1.w -= A1.x * A0.w;
- A2.y -= A2.x * A0.y; A2.z -= A2.x * A0.z; A2.w -= A2.x * A0.w;
- if(abs(A2.y) > abs(A1.y))
- {
- float4 TEMP = A2; A2 = A1; A1 = TEMP;
- }
- if(abs(A1.y) >= 1e-10)
- {
- A1.z /= A1.y; A1.w /= A1.y;
- A2.z -= A2.y * A1.z; A2.w -= A2.y * A1.w;
- if(abs(A2.z) >= 1e-10)
- {
- ds = A2.w / A2.z;
- dy = A1.w - ds * A1.z;
- dx = A0.w - ds * A0.z - dy * A0.y;
-
- offset_test_passed =
- fabs(data[1][1] + 0.5f * (dx * fx + dy * fy + ds * fs)) > dog_threshold
- &&fabs(ds) < 1.0f && fabs(dx) < 1.0f && fabs(dy) < 1.0f;
- }
- }
- }
- }
- if(offset_test_passed) result = v > nmax ? 1.0 : -1.0;
- }
-key_finish:
- if(in_image) d_key[index] = make_float4(result, dx, dy, ds);
-}
-
-
-void ProgramCU::ComputeKEY(CuTexImage* dog, CuTexImage* key, float Tdog, float Tedge)
-{
- int width = dog->GetImgWidth(), height = dog->GetImgHeight();
- float Tdog1 = (GlobalUtil::_SubpixelLocalization? 0.8f : 1.0f) * Tdog;
- CuTexImage* dogp = dog - 1;
- CuTexImage* dogn = dog + 1;
-#ifdef KEY_OFFSET_ONE
- dim3 grid((width - 1 + KEY_BLOCK_DIMX - 1)/ KEY_BLOCK_DIMX, (height - 1 + KEY_BLOCK_DIMY - 1)/KEY_BLOCK_DIMY);
-#else
- dim3 grid((width + KEY_BLOCK_DIMX - 1)/ KEY_BLOCK_DIMX, (height + KEY_BLOCK_DIMY - 1)/KEY_BLOCK_DIMY);
-#endif
- dim3 block(KEY_BLOCK_DIMX, KEY_BLOCK_DIMY);
- dogp->BindTexture(texP);
- dog ->BindTexture(texC);
- dogn->BindTexture(texN);
- Tedge = (Tedge+1)*(Tedge+1)/Tedge;
- ComputeKEY_Kernel<<>>((float4*) key->_cuData, width,
- width -1, height -1, Tdog1, Tdog, Tedge, GlobalUtil::_SubpixelLocalization);
-
-}
-
-
-
-void __global__ InitHist_Kernel(int4* hist, int ws, int wd, int height)
-{
- int row = IMUL(blockIdx.y, blockDim.y) + threadIdx.y;
- int col = IMUL(blockIdx.x, blockDim.x) + threadIdx.x;
- if(row < height && col < wd)
- {
- int hidx = IMUL(row, wd) + col;
- int scol = col << 2;
- int sidx = IMUL(row, ws) + scol;
- int v[4] = {0, 0, 0, 0};
- if(row > 0 && row < height -1)
- {
-#pragma unroll
- for(int i = 0; i < 4 ; ++i, ++scol)
- {
- float4 temp = tex1Dfetch(texDataF4, sidx +i);
- v[i] = (scol < ws -1 && scol > 0 && temp.x!=0) ? 1 : 0;
- }
- }
- hist[hidx] = make_int4(v[0], v[1], v[2], v[3]);
-
- }
-}
-
-
-
-void ProgramCU::InitHistogram(CuTexImage* key, CuTexImage* hist)
-{
- int ws = key->GetImgWidth(), hs = key->GetImgHeight();
- int wd = hist->GetImgWidth(), hd = hist->GetImgHeight();
- dim3 grid((wd + HIST_INIT_WIDTH - 1)/ HIST_INIT_WIDTH, hd);
- dim3 block(HIST_INIT_WIDTH, 1);
- key->BindTexture(texDataF4);
- InitHist_Kernel<<>>((int4*) hist->_cuData, ws, wd, hd);
-}
-
-
-
-void __global__ ReduceHist_Kernel(int4* d_hist, int ws, int wd, int height)
-{
- int row = IMUL(blockIdx.y, blockDim.y) + threadIdx.y;
- int col = IMUL(blockIdx.x, blockDim.x) + threadIdx.x;
- if(row < height && col < wd)
- {
- int hidx = IMUL(row, wd) + col;
- int scol = col << 2;
- int sidx = IMUL(row, ws) + scol;
- int v[4] = {0, 0, 0, 0};
-#pragma unroll
- for(int i = 0; i < 4 && scol < ws; ++i, ++scol)
- {
- int4 temp = tex1Dfetch(texDataI4, sidx + i);
- v[i] = temp.x + temp.y + temp.z + temp.w;
- }
- d_hist[hidx] = make_int4(v[0], v[1], v[2], v[3]);
- }
-}
-
-void ProgramCU::ReduceHistogram(CuTexImage*hist1, CuTexImage* hist2)
-{
- int ws = hist1->GetImgWidth(), hs = hist1->GetImgHeight();
- int wd = hist2->GetImgWidth(), hd = hist2->GetImgHeight();
- int temp = (int)floor(logf(float(wd * 2/ 3)) / logf(2.0f));
- const int wi = min(7, max(temp , 0));
- hist1->BindTexture(texDataI4);
-
- const int BW = 1 << wi, BH = 1 << (7 - wi);
- dim3 grid((wd + BW - 1)/ BW, (hd + BH -1) / BH);
- dim3 block(BW, BH);
- ReduceHist_Kernel<<>>((int4*)hist2->_cuData, ws, wd, hd);
-}
-
-
-void __global__ ListGen_Kernel(int4* d_list, int width)
-{
- int idx1 = IMUL(blockIdx.x, blockDim.x) + threadIdx.x;
- int4 pos = tex1Dfetch(texDataList, idx1);
- int idx2 = IMUL(pos.y, width) + pos.x;
- int4 temp = tex1Dfetch(texDataI4, idx2);
- int sum1 = temp.x + temp.y;
- int sum2 = sum1 + temp.z;
- pos.x <<= 2;
- if(pos.z >= sum2)
- {
- pos.x += 3;
- pos.z -= sum2;
- }else if(pos.z >= sum1)
- {
- pos.x += 2;
- pos.z -= sum1;
- }else if(pos.z >= temp.x)
- {
- pos.x += 1;
- pos.z -= temp.x;
- }
- d_list[idx1] = pos;
-}
-
-//input list (x, y) (x, y) ....
-void ProgramCU::GenerateList(CuTexImage* list, CuTexImage* hist)
-{
- int len = list->GetImgWidth();
- list->BindTexture(texDataList);
- hist->BindTexture(texDataI4);
- dim3 grid((len + LISTGEN_BLOCK_DIM -1) /LISTGEN_BLOCK_DIM);
- dim3 block(LISTGEN_BLOCK_DIM);
- ListGen_Kernel<<>>((int4*) list->_cuData, hist->GetImgWidth());
-}
-
-void __global__ ComputeOrientation_Kernel(float4* d_list,
- int list_len,
- int width, int height,
- float sigma, float sigma_step,
- float gaussian_factor, float sample_factor,
- int num_orientation,
- int existing_keypoint,
- int subpixel,
- int keepsign)
-{
- const float ten_degree_per_radius = 5.7295779513082320876798154814105;
- const float radius_per_ten_degrees = 1.0 / 5.7295779513082320876798154814105;
- int idx = IMUL(blockDim.x, blockIdx.x) + threadIdx.x;
- if(idx >= list_len) return;
- float4 key;
- if(existing_keypoint)
- {
- key = tex1Dfetch(texDataF4, idx);
- }else
- {
- int4 ikey = tex1Dfetch(texDataList, idx);
- key.x = ikey.x + 0.5f;
- key.y = ikey.y + 0.5f;
- key.z = sigma;
- if(subpixel || keepsign)
- {
- float4 offset = tex1Dfetch(texDataF4, IMUL(width, ikey.y) + ikey.x);
- if(subpixel)
- {
- key.x += offset.y;
- key.y += offset.z;
- key.z *= pow(sigma_step, offset.w);
- }
- if(keepsign) key.z *= offset.x;
- }
- }
- if(num_orientation == 0)
- {
- key.w = 0;
- d_list[idx] = key;
- return;
- }
- float vote[37];
- float gsigma = key.z * gaussian_factor;
- float win = fabs(key.z) * sample_factor;
- float dist_threshold = win * win + 0.5;
- float factor = -0.5f / (gsigma * gsigma);
- float xmin = max(1.5f, floor(key.x - win) + 0.5f);
- float ymin = max(1.5f, floor(key.y - win) + 0.5f);
- float xmax = min(width - 1.5f, floor(key.x + win) + 0.5f);
- float ymax = min(height -1.5f, floor(key.y + win) + 0.5f);
-#pragma unroll
- for(int i = 0; i < 36; ++i) vote[i] = 0.0f;
- for(float y = ymin; y <= ymax; y += 1.0f)
- {
- for(float x = xmin; x <= xmax; x += 1.0f)
- {
- float dx = x - key.x;
- float dy = y - key.y;
- float sq_dist = dx * dx + dy * dy;
- if(sq_dist >= dist_threshold) continue;
- float2 got = tex2D(texDataF2, x, y);
- float weight = got.x * exp(sq_dist * factor);
- float fidx = floor(got.y * ten_degree_per_radius);
- int oidx = fidx;
- if(oidx < 0) oidx += 36;
- vote[oidx] += weight;
- }
- }
-
- //filter the vote
-
- const float one_third = 1.0 /3.0;
-#pragma unroll
- for(int i = 0; i < 6; ++i)
- {
- vote[36] = vote[0];
- float pre = vote[35];
-#pragma unroll
- for(int j = 0; j < 36; ++j)
- {
- float temp = one_third * (pre + vote[j] + vote[j + 1]);
- pre = vote[j]; vote[j] = temp;
- }
- }
-
- vote[36] = vote[0];
- if(num_orientation == 1 || existing_keypoint)
- {
- int index_max = 0;
- float max_vote = vote[0];
-#pragma unroll
- for(int i = 1; i < 36; ++i)
- {
- index_max = vote[i] > max_vote? i : index_max;
- max_vote = max(max_vote, vote[i]);
- }
- float pre = vote[index_max == 0? 35 : index_max -1];
- float next = vote[index_max + 1];
- float weight = max_vote;
- float off = 0.5f * FDIV(next - pre, weight + weight - next - pre);
- key.w = radius_per_ten_degrees * (index_max + 0.5f + off);
- d_list[idx] = key;
-
- }else
- {
- float max_vote = vote[0];
-#pragma unroll
- for(int i = 1; i < 36; ++i) max_vote = max(max_vote, vote[i]);
-
- float vote_threshold = max_vote * 0.8f;
- float pre = vote[35];
- float max_rot[2], max_vot[2] = {0, 0};
- int ocount = 0;
-#pragma unroll
- for(int i =0; i < 36; ++i)
- {
- float next = vote[i + 1];
- if(vote[i] > vote_threshold && vote[i] > pre && vote[i] > next)
- {
- float di = 0.5f * FDIV(next - pre, vote[i] + vote[i] - next - pre);
- float rot = i + di + 0.5f;
- float weight = vote[i];
- ///
- if(weight > max_vot[1])
- {
- if(weight > max_vot[0])
- {
- max_vot[1] = max_vot[0];
- max_rot[1] = max_rot[0];
- max_vot[0] = weight;
- max_rot[0] = rot;
- }
- else
- {
- max_vot[1] = weight;
- max_rot[1] = rot;
- }
- ocount ++;
- }
- }
- pre = vote[i];
- }
- float fr1 = max_rot[0] / 36.0f;
- if(fr1 < 0) fr1 += 1.0f;
- unsigned short us1 = ocount == 0? 65535 : ((unsigned short )floor(fr1 * 65535.0f));
- unsigned short us2 = 65535;
- if(ocount > 1)
- {
- float fr2 = max_rot[1] / 36.0f;
- if(fr2 < 0) fr2 += 1.0f;
- us2 = (unsigned short ) floor(fr2 * 65535.0f);
- }
- unsigned int uspack = (us2 << 16) | us1;
- key.w = __int_as_float(uspack);
- d_list[idx] = key;
- }
-
-}
-
-
-
-
-void ProgramCU::ComputeOrientation(CuTexImage* list, CuTexImage* got, CuTexImage*key,
- float sigma, float sigma_step, int existing_keypoint)
-{
- int len = list->GetImgWidth();
- if(len <= 0) return;
- int width = got->GetImgWidth(), height = got->GetImgHeight();
- if(existing_keypoint)
- {
- list->BindTexture(texDataF4);
- }else
- {
- list->BindTexture(texDataList);
- if(GlobalUtil::_SubpixelLocalization) key->BindTexture(texDataF4);
- }
- got->BindTexture2D(texDataF2);
-
- const int block_width = len < ORIENTATION_COMPUTE_PER_BLOCK ? 16 : ORIENTATION_COMPUTE_PER_BLOCK;
- dim3 grid((len + block_width -1) / block_width);
- dim3 block(block_width);
-
- ComputeOrientation_Kernel<<>>((float4*) list->_cuData,
- len, width, height, sigma, sigma_step,
- GlobalUtil::_OrientationGaussianFactor,
- GlobalUtil::_OrientationGaussianFactor * GlobalUtil::_OrientationWindowFactor,
- GlobalUtil::_FixedOrientation? 0 : GlobalUtil::_MaxOrientation,
- existing_keypoint, GlobalUtil::_SubpixelLocalization, GlobalUtil::_KeepExtremumSign);
-
- ProgramCU::CheckErrorCUDA("ComputeOrientation");
-}
-
-template void __global__ ComputeDescriptor_Kernel(float4* d_des, int num,
- int width, int height, float window_factor)
-{
- const float rpi = 4.0/ 3.14159265358979323846;
- int idx = IMUL(blockIdx.x, blockDim.x) + threadIdx.x;
- int fidx = idx >> 4;
- if(fidx >= num) return;
- float4 key = tex1Dfetch(texDataF4, fidx);
- int bidx = idx& 0xf, ix = bidx & 0x3, iy = bidx >> 2;
- float spt = fabs(key.z * window_factor);
- float s, c; __sincosf(key.w, &s, &c);
- float anglef = key.w > 3.14159265358979323846? key.w - (2.0 * 3.14159265358979323846) : key.w ;
- float cspt = c * spt, sspt = s * spt;
- float crspt = c / spt, srspt = s / spt;
- float2 offsetpt, pt;
- float xmin, ymin, xmax, ymax, bsz;
- offsetpt.x = ix - 1.5f;
- offsetpt.y = iy - 1.5f;
- pt.x = cspt * offsetpt.x - sspt * offsetpt.y + key.x;
- pt.y = cspt * offsetpt.y + sspt * offsetpt.x + key.y;
- bsz = fabs(cspt) + fabs(sspt);
- xmin = max(1.5f, floor(pt.x - bsz) + 0.5f);
- ymin = max(1.5f, floor(pt.y - bsz) + 0.5f);
- xmax = min(width - 1.5f, floor(pt.x + bsz) + 0.5f);
- ymax = min(height - 1.5f, floor(pt.y + bsz) + 0.5f);
- float des[9];
-#pragma unroll
- for(int i =0; i < 9; ++i) des[i] = 0.0f;
- for(float y = ymin; y <= ymax; y += 1.0f)
- {
- for(float x = xmin; x <= xmax; x += 1.0f)
- {
- float dx = x - pt.x;
- float dy = y - pt.y;
- float nx = crspt * dx + srspt * dy;
- float ny = crspt * dy - srspt * dx;
- float nxn = fabs(nx);
- float nyn = fabs(ny);
- if(nxn < 1.0f && nyn < 1.0f)
- {
- float2 cc = tex2D(texDataF2, x, y);
- float dnx = nx + offsetpt.x;
- float dny = ny + offsetpt.y;
- float ww = exp(-0.125f * (dnx * dnx + dny * dny));
- float wx = 1.0 - nxn;
- float wy = 1.0 - nyn;
- float weight = ww * wx * wy * cc.x;
- float theta = (anglef - cc.y) * rpi;
- if(theta < 0) theta += 8.0f;
- float fo = floor(theta);
- int fidx = fo;
- float weight1 = fo + 1.0f - theta;
- float weight2 = theta - fo;
- if(DYNAMIC_INDEXING)
- {
- des[fidx] += (weight1 * weight);
- des[fidx + 1] += (weight2 * weight);
- //this dynamic indexing part might be slow
- }else
- {
- #pragma unroll
- for(int k = 0; k < 8; ++k)
- {
- if(k == fidx)
- {
- des[k] += (weight1 * weight);
- des[k+1] += (weight2 * weight);
- }
- }
- }
- }
- }
- }
- des[0] += des[8];
-
- int didx = idx << 1;
- d_des[didx] = make_float4(des[0], des[1], des[2], des[3]);
- d_des[didx+1] = make_float4(des[4], des[5], des[6], des[7]);
-}
-
-
-template void __global__ ComputeDescriptorRECT_Kernel(float4* d_des, int num,
- int width, int height, float window_factor)
-{
- const float rpi = 4.0/ 3.14159265358979323846;
- int idx = IMUL(blockIdx.x, blockDim.x) + threadIdx.x;
- int fidx = idx >> 4;
- if(fidx >= num) return;
- float4 key = tex1Dfetch(texDataF4, fidx);
- int bidx = idx& 0xf, ix = bidx & 0x3, iy = bidx >> 2;
- //float aspect_ratio = key.w / key.z;
- //float aspect_sq = aspect_ratio * aspect_ratio;
- float sptx = key.z * 0.25, spty = key.w * 0.25;
- float xmin, ymin, xmax, ymax; float2 pt;
- pt.x = sptx * (ix + 0.5f) + key.x;
- pt.y = spty * (iy + 0.5f) + key.y;
- xmin = max(1.5f, floor(pt.x - sptx) + 0.5f);
- ymin = max(1.5f, floor(pt.y - spty) + 0.5f);
- xmax = min(width - 1.5f, floor(pt.x + sptx) + 0.5f);
- ymax = min(height - 1.5f, floor(pt.y + spty) + 0.5f);
- float des[9];
-#pragma unroll
- for(int i =0; i < 9; ++i) des[i] = 0.0f;
- for(float y = ymin; y <= ymax; y += 1.0f)
- {
- for(float x = xmin; x <= xmax; x += 1.0f)
- {
- float nx = (x - pt.x) / sptx;
- float ny = (y - pt.y) / spty;
- float nxn = fabs(nx);
- float nyn = fabs(ny);
- if(nxn < 1.0f && nyn < 1.0f)
- {
- float2 cc = tex2D(texDataF2, x, y);
- float wx = 1.0 - nxn;
- float wy = 1.0 - nyn;
- float weight = wx * wy * cc.x;
- float theta = (- cc.y) * rpi;
- if(theta < 0) theta += 8.0f;
- float fo = floor(theta);
- int fidx = fo;
- float weight1 = fo + 1.0f - theta;
- float weight2 = theta - fo;
- if(DYNAMIC_INDEXING)
- {
- des[fidx] += (weight1 * weight);
- des[fidx + 1] += (weight2 * weight);
- //this dynamic indexing part might be slow
- }else
- {
- #pragma unroll
- for(int k = 0; k < 8; ++k)
- {
- if(k == fidx)
- {
- des[k] += (weight1 * weight);
- des[k+1] += (weight2 * weight);
- }
- }
- }
- }
- }
- }
- des[0] += des[8];
-
- int didx = idx << 1;
- d_des[didx] = make_float4(des[0], des[1], des[2], des[3]);
- d_des[didx+1] = make_float4(des[4], des[5], des[6], des[7]);
-}
-
-void __global__ NormalizeDescriptor_Kernel(float4* d_des, int num)
-{
- float4 temp[32];
- int idx = IMUL(blockIdx.x, blockDim.x) + threadIdx.x;
- if(idx >= num) return;
- int sidx = idx << 5;
- float norm1 = 0, norm2 = 0;
-#pragma unroll
- for(int i = 0; i < 32; ++i)
- {
- temp[i] = tex1Dfetch(texDataF4, sidx +i);
- norm1 += (temp[i].x * temp[i].x + temp[i].y * temp[i].y +
- temp[i].z * temp[i].z + temp[i].w * temp[i].w);
- }
- norm1 = rsqrt(norm1);
-
-#pragma unroll
- for(int i = 0; i < 32; ++i)
- {
- temp[i].x = min(0.2f, temp[i].x * norm1);
- temp[i].y = min(0.2f, temp[i].y * norm1);
- temp[i].z = min(0.2f, temp[i].z * norm1);
- temp[i].w = min(0.2f, temp[i].w * norm1);
- norm2 += (temp[i].x * temp[i].x + temp[i].y * temp[i].y +
- temp[i].z * temp[i].z + temp[i].w * temp[i].w);
- }
-
- norm2 = rsqrt(norm2);
-#pragma unroll
- for(int i = 0; i < 32; ++i)
- {
- temp[i].x *= norm2; temp[i].y *= norm2;
- temp[i].z *= norm2; temp[i].w *= norm2;
- d_des[sidx + i] = temp[i];
- }
-}
-
-void ProgramCU::ComputeDescriptor(CuTexImage*list, CuTexImage* got, CuTexImage* dtex, int rect, int stream)
-{
- int num = list->GetImgWidth();
- int width = got->GetImgWidth();
- int height = got->GetImgHeight();
-
- dtex->InitTexture(num * 128, 1, 1);
- got->BindTexture2D(texDataF2);
- list->BindTexture(texDataF4);
- int block_width = DESCRIPTOR_COMPUTE_BLOCK_SIZE;
- dim3 grid((num * 16 + block_width -1) / block_width);
- dim3 block(block_width);
-
- if(rect)
- {
- if(GlobalUtil::_UseDynamicIndexing)
- ComputeDescriptorRECT_Kernel<<>>((float4*) dtex->_cuData, num, width, height, GlobalUtil::_DescriptorWindowFactor);
- else
- ComputeDescriptorRECT_Kernel<<>>((float4*) dtex->_cuData, num, width, height, GlobalUtil::_DescriptorWindowFactor);
-
- }else
- {
- if(GlobalUtil::_UseDynamicIndexing)
- ComputeDescriptor_Kernel<<>>((float4*) dtex->_cuData, num, width, height, GlobalUtil::_DescriptorWindowFactor);
- else
- ComputeDescriptor_Kernel<<>>((float4*) dtex->_cuData, num, width, height, GlobalUtil::_DescriptorWindowFactor);
- }
- if(GlobalUtil::_NormalizedSIFT)
- {
- dtex->BindTexture(texDataF4);
- const int block_width = DESCRIPTOR_NORMALIZ_PER_BLOCK;
- dim3 grid((num + block_width -1) / block_width);
- dim3 block(block_width);
- NormalizeDescriptor_Kernel<<>>((float4*) dtex->_cuData, num);
- }
- CheckErrorCUDA("ComputeDescriptor");
-}
-
-//////////////////////////////////////////////////////
-void ProgramCU::FinishCUDA()
-{
- cudaThreadSynchronize();
-}
-
-int ProgramCU::CheckErrorCUDA(const char* location)
-{
- cudaError_t e = cudaGetLastError();
- if(e)
- {
- if(location) fprintf(stderr, "%s:\t", location);
- fprintf(stderr, "%s\n", cudaGetErrorString(e));
- //assert(0);
- return 1;
- }else
- {
- return 0;
- }
-}
-
-void __global__ ConvertDOG_Kernel(float* d_result, int width, int height)
-{
- int row = (blockIdx.y << BLOCK_LOG_DIM) + threadIdx.y;
- int col = (blockIdx.x << BLOCK_LOG_DIM) + threadIdx.x;
- if(col < width && row < height)
- {
- int index = row * width + col;
- float v = tex1Dfetch(texData, index);
- d_result[index] = (col == 0 || row == 0 || col == width -1 || row == height -1)?
- 0.5 : saturate(0.5+20.0*v);
- }
-}
-///
-void ProgramCU::DisplayConvertDOG(CuTexImage* dog, CuTexImage* out)
-{
- if(out->_cuData == NULL) return;
- int width = dog->GetImgWidth(), height = dog ->GetImgHeight();
- dog->BindTexture(texData);
- dim3 grid((width + BLOCK_DIM - 1)/ BLOCK_DIM, (height + BLOCK_DIM - 1)/BLOCK_DIM);
- dim3 block(BLOCK_DIM, BLOCK_DIM);
- ConvertDOG_Kernel<<>>((float*) out->_cuData, width, height);
- ProgramCU::CheckErrorCUDA("DisplayConvertDOG");
-}
-
-void __global__ ConvertGRD_Kernel(float* d_result, int width, int height)
-{
- int row = (blockIdx.y << BLOCK_LOG_DIM) + threadIdx.y;
- int col = (blockIdx.x << BLOCK_LOG_DIM) + threadIdx.x;
- if(col < width && row < height)
- {
- int index = row * width + col;
- float v = tex1Dfetch(texData, index << 1);
- d_result[index] = (col == 0 || row == 0 || col == width -1 || row == height -1)?
- 0 : saturate(5 * v);
-
- }
-}
-
-
-void ProgramCU::DisplayConvertGRD(CuTexImage* got, CuTexImage* out)
-{
- if(out->_cuData == NULL) return;
- int width = got->GetImgWidth(), height = got ->GetImgHeight();
- got->BindTexture(texData);
- dim3 grid((width + BLOCK_DIM - 1)/ BLOCK_DIM, (height + BLOCK_DIM - 1)/BLOCK_DIM);
- dim3 block(BLOCK_DIM, BLOCK_DIM);
- ConvertGRD_Kernel<<>>((float*) out->_cuData, width, height);
- ProgramCU::CheckErrorCUDA("DisplayConvertGRD");
-}
-
-void __global__ ConvertKEY_Kernel(float4* d_result, int width, int height)
-{
-
- int row = (blockIdx.y << BLOCK_LOG_DIM) + threadIdx.y;
- int col = (blockIdx.x << BLOCK_LOG_DIM) + threadIdx.x;
- if(col < width && row < height)
- {
- int index = row * width + col;
- float4 keyv = tex1Dfetch(texDataF4, index);
- int is_key = (keyv.x == 1.0f || keyv.x == -1.0f);
- int inside = col > 0 && row > 0 && row < height -1 && col < width - 1;
- float v = inside? saturate(0.5 + 20 * tex1Dfetch(texData, index)) : 0.5;
- d_result[index] = is_key && inside ?
- (keyv.x > 0? make_float4(1.0f, 0, 0, 1.0f) : make_float4(0.0f, 1.0f, 0.0f, 1.0f)):
- make_float4(v, v, v, 1.0f) ;
- }
-}
-void ProgramCU::DisplayConvertKEY(CuTexImage* key, CuTexImage* dog, CuTexImage* out)
-{
- if(out->_cuData == NULL) return;
- int width = key->GetImgWidth(), height = key ->GetImgHeight();
- dog->BindTexture(texData);
- key->BindTexture(texDataF4);
- dim3 grid((width + BLOCK_DIM - 1)/ BLOCK_DIM, (height + BLOCK_DIM - 1)/BLOCK_DIM);
- dim3 block(BLOCK_DIM, BLOCK_DIM);
- ConvertKEY_Kernel<<>>((float4*) out->_cuData, width, height);
-}
-
-
-void __global__ DisplayKeyPoint_Kernel(float4 * d_result, int num)
-{
- int idx = IMUL(blockIdx.x, blockDim.x) + threadIdx.x;
- if(idx >= num) return;
- float4 v = tex1Dfetch(texDataF4, idx);
- d_result[idx] = make_float4(v.x, v.y, 0, 1.0f);
-}
-
-void ProgramCU::DisplayKeyPoint(CuTexImage* ftex, CuTexImage* out)
-{
- int num = ftex->GetImgWidth();
- int block_width = 64;
- dim3 grid((num + block_width -1) /block_width);
- dim3 block(block_width);
- ftex->BindTexture(texDataF4);
- DisplayKeyPoint_Kernel<<>>((float4*) out->_cuData, num);
- ProgramCU::CheckErrorCUDA("DisplayKeyPoint");
-}
-
-void __global__ DisplayKeyBox_Kernel(float4* d_result, int num)
-{
- int idx = IMUL(blockIdx.x, blockDim.x) + threadIdx.x;
- if(idx >= num) return;
- int kidx = idx / 10, vidx = idx - IMUL(kidx , 10);
- float4 v = tex1Dfetch(texDataF4, kidx);
- float sz = fabs(v.z * 3.0f);
- ///////////////////////
- float s, c; __sincosf(v.w, &s, &c);
- ///////////////////////
- float dx = vidx == 0? 0 : ((vidx <= 4 || vidx >= 9)? sz : -sz);
- float dy = vidx <= 1? 0 : ((vidx <= 2 || vidx >= 7)? -sz : sz);
- float4 pos;
- pos.x = v.x + c * dx - s * dy;
- pos.y = v.y + c * dy + s * dx;
- pos.z = 0; pos.w = 1.0f;
- d_result[idx] = pos;
-}
-
-void ProgramCU::DisplayKeyBox(CuTexImage* ftex, CuTexImage* out)
-{
- int len = ftex->GetImgWidth();
- int block_width = 32;
- dim3 grid((len * 10 + block_width -1) / block_width);
- dim3 block(block_width);
- ftex->BindTexture(texDataF4);
- DisplayKeyBox_Kernel<<>>((float4*) out->_cuData, len * 10);
-}
-///////////////////////////////////////////////////////////////////
-inline void CuTexImage:: BindTexture(textureReference& texRef)
-{
- cudaBindTexture(NULL, &texRef, _cuData, &texRef.channelDesc, _numBytes);
-}
-
-inline void CuTexImage::BindTexture2D(textureReference& texRef)
-{
-#if defined(SIFTGPU_ENABLE_LINEAR_TEX2D)
- cudaBindTexture2D(0, &texRef, _cuData, &texRef.channelDesc, _imgWidth, _imgHeight, _imgWidth* _numChannel* sizeof(float));
-#else
- cudaChannelFormatDesc desc;
- cudaGetChannelDesc(&desc, _cuData2D);
- cudaBindTextureToArray(&texRef, _cuData2D, &desc);
-#endif
-}
-
-int ProgramCU::CheckCudaDevice(int device)
-{
- int count = 0, device_used;
- if(cudaGetDeviceCount(&count) != cudaSuccess || count <= 0)
- {
- ProgramCU::CheckErrorCUDA("CheckCudaDevice");
- return 0;
- }else if(count == 1)
- {
- cudaDeviceProp deviceProp;
- if ( cudaGetDeviceProperties(&deviceProp, 0) != cudaSuccess ||
- (deviceProp.major == 9999 && deviceProp.minor == 9999))
- {
- fprintf(stderr, "CheckCudaDevice: no device supporting CUDA.\n");
- return 0;
- }else
- {
- GlobalUtil::_MemCapGPU = deviceProp.totalGlobalMem / 1024;
- GlobalUtil::_texMaxDimGL = 32768;
- if(GlobalUtil::_verbose)
- fprintf(stdout, "NOTE: changing maximum texture dimension to %d\n", GlobalUtil::_texMaxDimGL);
-
- }
- }
- if(device >0 && device < count)
- {
- cudaSetDevice(device);
- CheckErrorCUDA("cudaSetDevice\n");
- }
- cudaGetDevice(&device_used);
- if(device != device_used)
- fprintf(stderr, "\nERROR: Cannot set device to %d\n"
- "\nWARNING: Use # %d device instead (out of %d)\n", device, device_used, count);
- return 1;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////
-// siftmatch funtions
-//////////////////////////////////////////////////////////////////////////////////////////
-
-#define MULT_TBLOCK_DIMX 128
-#define MULT_TBLOCK_DIMY 1
-#define MULT_BLOCK_DIMX (MULT_TBLOCK_DIMX)
-#define MULT_BLOCK_DIMY (8 * MULT_TBLOCK_DIMY)
-
-
-texture texDes1;
-texture texDes2;
-
-void __global__ MultiplyDescriptor_Kernel(int* d_result, int num1, int num2, int3* d_temp)
-{
- int idx01 = (blockIdx.y * MULT_BLOCK_DIMY), idx02 = (blockIdx.x * MULT_BLOCK_DIMX);
-
- int idx1 = idx01 + threadIdx.y, idx2 = idx02 + threadIdx.x;
- __shared__ int data1[17 * 2 * MULT_BLOCK_DIMY];
- int read_idx1 = idx01 * 8 + threadIdx.x, read_idx2 = idx2 * 8;
- int col4 = threadIdx.x & 0x3, row4 = threadIdx.x >> 2;
- int cache_idx1 = IMUL(row4, 17) + (col4 << 2);
-
- ///////////////////////////////////////////////////////////////
- //Load feature descriptors
- ///////////////////////////////////////////////////////////////
-#if MULT_BLOCK_DIMY == 16
- uint4 v = tex1Dfetch(texDes1, read_idx1);
- data1[cache_idx1] = v.x; data1[cache_idx1+1] = v.y;
- data1[cache_idx1+2] = v.z; data1[cache_idx1+3] = v.w;
-#elif MULT_BLOCK_DIMY == 8
- if(threadIdx.x < 64)
- {
- uint4 v = tex1Dfetch(texDes1, read_idx1);
- data1[cache_idx1] = v.x; data1[cache_idx1+1] = v.y;
- data1[cache_idx1+2] = v.z; data1[cache_idx1+3] = v.w;
- }
-#else
-#error
-#endif
- __syncthreads();
-
- ///
- if(idx2 >= num2) return;
- ///////////////////////////////////////////////////////////////////////////
- //compare descriptors
-
- int results[MULT_BLOCK_DIMY];
-#pragma unroll
- for(int i = 0; i < MULT_BLOCK_DIMY; ++i) results[i] = 0;
-
-#pragma unroll
- for(int i = 0; i < 8; ++i)
- {
- uint4 v = tex1Dfetch(texDes2, read_idx2 + i);
- unsigned char* p2 = (unsigned char*)(&v);
-#pragma unroll
- for(int k = 0; k < MULT_BLOCK_DIMY; ++k)
- {
- unsigned char* p1 = (unsigned char*) (data1 + k * 34 + i * 4 + (i/4));
- results[k] += ( IMUL(p1[0], p2[0]) + IMUL(p1[1], p2[1])
- + IMUL(p1[2], p2[2]) + IMUL(p1[3], p2[3])
- + IMUL(p1[4], p2[4]) + IMUL(p1[5], p2[5])
- + IMUL(p1[6], p2[6]) + IMUL(p1[7], p2[7])
- + IMUL(p1[8], p2[8]) + IMUL(p1[9], p2[9])
- + IMUL(p1[10], p2[10]) + IMUL(p1[11], p2[11])
- + IMUL(p1[12], p2[12]) + IMUL(p1[13], p2[13])
- + IMUL(p1[14], p2[14]) + IMUL(p1[15], p2[15]));
- }
- }
-
- int dst_idx = IMUL(idx1, num2) + idx2;
- if(d_temp)
- {
- int3 cmp_result = make_int3(0, -1, 0);
-
-#pragma unroll
- for(int i = 0; i < MULT_BLOCK_DIMY; ++i)
- {
- if(idx1 + i < num1)
- {
- cmp_result = results[i] > cmp_result.x?
- make_int3(results[i], idx1 + i, cmp_result.x) :
- make_int3(cmp_result.x, cmp_result.y, max(cmp_result.z, results[i]));
- d_result[dst_idx + IMUL(i, num2)] = results[i];
- }
- }
- d_temp[ IMUL(blockIdx.y, num2) + idx2] = cmp_result;
- }else
- {
-#pragma unroll
- for(int i = 0; i < MULT_BLOCK_DIMY; ++i)
- {
- if(idx1 + i < num1) d_result[dst_idx + IMUL(i, num2)] = results[i];
- }
- }
-
-}
-
-
-void ProgramCU::MultiplyDescriptor(CuTexImage* des1, CuTexImage* des2, CuTexImage* texDot, CuTexImage* texCRT)
-{
- int num1 = des1->GetImgWidth() / 8;
- int num2 = des2->GetImgWidth() / 8;
- dim3 grid( (num2 + MULT_BLOCK_DIMX - 1)/ MULT_BLOCK_DIMX,
- (num1 + MULT_BLOCK_DIMY - 1)/MULT_BLOCK_DIMY);
- dim3 block(MULT_TBLOCK_DIMX, MULT_TBLOCK_DIMY);
- texDot->InitTexture( num2,num1);
- if(texCRT) texCRT->InitTexture(num2, (num1 + MULT_BLOCK_DIMY - 1)/MULT_BLOCK_DIMY, 32);
- des1->BindTexture(texDes1);
- des2->BindTexture(texDes2);
-
- MultiplyDescriptor_Kernel<<>>((int*)texDot->_cuData, num1, num2,
- (texCRT? (int3*)texCRT->_cuData : NULL));
- ProgramCU::CheckErrorCUDA("MultiplyDescriptor");
-}
-
-texture texLoc1;
-texture texLoc2;
-struct Matrix33{float mat[3][3];};
-
-
-
-void __global__ MultiplyDescriptorG_Kernel(int* d_result, int num1, int num2, int3* d_temp,
- Matrix33 H, float hdistmax, Matrix33 F, float fdistmax)
-{
- int idx01 = (blockIdx.y * MULT_BLOCK_DIMY);
- int idx02 = (blockIdx.x * MULT_BLOCK_DIMX);
-
- int idx1 = idx01 + threadIdx.y;
- int idx2 = idx02 + threadIdx.x;
- __shared__ int data1[17 * 2 * MULT_BLOCK_DIMY];
- __shared__ float loc1[MULT_BLOCK_DIMY * 2];
- int read_idx1 = idx01 * 8 + threadIdx.x ;
- int read_idx2 = idx2 * 8;
- int col4 = threadIdx.x & 0x3, row4 = threadIdx.x >> 2;
- int cache_idx1 = IMUL(row4, 17) + (col4 << 2);
-#if MULT_BLOCK_DIMY == 16
- uint4 v = tex1Dfetch(texDes1, read_idx1);
- data1[cache_idx1] = v.x;
- data1[cache_idx1+1] = v.y;
- data1[cache_idx1+2] = v.z;
- data1[cache_idx1+3] = v.w;
-#elif MULT_BLOCK_DIMY == 8
- if(threadIdx.x < 64)
- {
- uint4 v = tex1Dfetch(texDes1, read_idx1);
- data1[cache_idx1] = v.x;
- data1[cache_idx1+1] = v.y;
- data1[cache_idx1+2] = v.z;
- data1[cache_idx1+3] = v.w;
- }
-#else
-#error
-#endif
- __syncthreads();
- if(threadIdx.x < MULT_BLOCK_DIMY * 2)
- {
- loc1[threadIdx.x] = tex1Dfetch(texLoc1, 2 * idx01 + threadIdx.x);
- }
- __syncthreads();
- if(idx2 >= num2) return;
- int results[MULT_BLOCK_DIMY];
- /////////////////////////////////////////////////////////////////////////////////////////////
- //geometric verification
- /////////////////////////////////////////////////////////////////////////////////////////////
- int good_count = 0;
- float2 loc2 = tex1Dfetch(texLoc2, idx2);
-#pragma unroll
- for(int i = 0; i < MULT_BLOCK_DIMY; ++i)
- {
-
- if(idx1 + i < num1)
- {
- float* loci = loc1 + i * 2;
- float locx = loci[0], locy = loci[1];
- //homography
- float x[3], diff[2];
- x[0] = H.mat[0][0] * locx + H.mat[0][1] * locy + H.mat[0][2];
- x[1] = H.mat[1][0] * locx + H.mat[1][1] * locy + H.mat[1][2];
- x[2] = H.mat[2][0] * locx + H.mat[2][1] * locy + H.mat[2][2];
- diff[0] = fabs(FDIV(x[0], x[2]) - loc2.x);
- diff[1] = fabs(FDIV(x[1], x[2]) - loc2.y);
- if(diff[0] < hdistmax && diff[1] < hdistmax)
- {
- //check fundamental matrix
- float fx1[3], ftx2[3], x2fx1, se;
- fx1[0] = F.mat[0][0] * locx + F.mat[0][1] * locy + F.mat[0][2];
- fx1[1] = F.mat[1][0] * locx + F.mat[1][1] * locy + F.mat[1][2];
- fx1[2] = F.mat[2][0] * locx + F.mat[2][1] * locy + F.mat[2][2];
-
- ftx2[0] = F.mat[0][0] * loc2.x + F.mat[1][0] * loc2.y + F.mat[2][0];
- ftx2[1] = F.mat[0][1] * loc2.x + F.mat[1][1] * loc2.y + F.mat[2][1];
- //ftx2[2] = F.mat[0][2] * loc2.x + F.mat[1][2] * loc2.y + F.mat[2][2];
-
- x2fx1 = loc2.x * fx1[0] + loc2.y * fx1[1] + fx1[2];
- se = FDIV(x2fx1 * x2fx1, fx1[0] * fx1[0] + fx1[1] * fx1[1] + ftx2[0] * ftx2[0] + ftx2[1] * ftx2[1]);
- results[i] = se < fdistmax? 0: -262144;
- }else
- {
- results[i] = -262144;
- }
- }else
- {
- results[i] = -262144;
- }
- good_count += (results[i] >=0);
- }
- /////////////////////////////////////////////////////////////////////////////////////////////
- ///compare feature descriptors anyway
- /////////////////////////////////////////////////////////////////////////////////////////////
- if(good_count > 0)
- {
-#pragma unroll
- for(int i = 0; i < 8; ++i)
- {
- uint4 v = tex1Dfetch(texDes2, read_idx2 + i);
- unsigned char* p2 = (unsigned char*)(&v);
-#pragma unroll
- for(int k = 0; k < MULT_BLOCK_DIMY; ++k)
- {
- unsigned char* p1 = (unsigned char*) (data1 + k * 34 + i * 4 + (i/4));
- results[k] += ( IMUL(p1[0], p2[0]) + IMUL(p1[1], p2[1])
- + IMUL(p1[2], p2[2]) + IMUL(p1[3], p2[3])
- + IMUL(p1[4], p2[4]) + IMUL(p1[5], p2[5])
- + IMUL(p1[6], p2[6]) + IMUL(p1[7], p2[7])
- + IMUL(p1[8], p2[8]) + IMUL(p1[9], p2[9])
- + IMUL(p1[10], p2[10]) + IMUL(p1[11], p2[11])
- + IMUL(p1[12], p2[12]) + IMUL(p1[13], p2[13])
- + IMUL(p1[14], p2[14]) + IMUL(p1[15], p2[15]));
- }
- }
- }
- int dst_idx = IMUL(idx1, num2) + idx2;
- if(d_temp)
- {
- int3 cmp_result = make_int3(0, -1, 0);
-#pragma unroll
- for(int i= 0; i < MULT_BLOCK_DIMY; ++i)
- {
- if(idx1 + i < num1)
- {
- cmp_result = results[i] > cmp_result.x?
- make_int3(results[i], idx1 + i, cmp_result.x) :
- make_int3(cmp_result.x, cmp_result.y, max(cmp_result.z, results[i]));
- d_result[dst_idx + IMUL(i, num2)] = max(results[i], 0);
- }else
- {
- break;
- }
- }
- d_temp[ IMUL(blockIdx.y, num2) + idx2] = cmp_result;
- }else
- {
-#pragma unroll
- for(int i = 0; i < MULT_BLOCK_DIMY; ++i)
- {
- if(idx1 + i < num1) d_result[dst_idx + IMUL(i, num2)] = max(results[i], 0);
- else break;
- }
- }
-
-}
-
-
-void ProgramCU::MultiplyDescriptorG(CuTexImage* des1, CuTexImage* des2,
- CuTexImage* loc1, CuTexImage* loc2, CuTexImage* texDot, CuTexImage* texCRT,
- float H[3][3], float hdistmax, float F[3][3], float fdistmax)
-{
- int num1 = des1->GetImgWidth() / 8;
- int num2 = des2->GetImgWidth() / 8;
- Matrix33 MatF, MatH;
- //copy the matrix
- memcpy(MatF.mat, F, 9 * sizeof(float));
- memcpy(MatH.mat, H, 9 * sizeof(float));
- //thread blocks
- dim3 grid( (num2 + MULT_BLOCK_DIMX - 1)/ MULT_BLOCK_DIMX,
- (num1 + MULT_BLOCK_DIMY - 1)/MULT_BLOCK_DIMY);
- dim3 block(MULT_TBLOCK_DIMX, MULT_TBLOCK_DIMY);
- //intermediate results
- texDot->InitTexture( num2,num1);
- if(texCRT) texCRT->InitTexture( num2, (num1 + MULT_BLOCK_DIMY - 1)/MULT_BLOCK_DIMY, 3);
- loc1->BindTexture(texLoc1);
- loc2->BindTexture(texLoc2);
- des1->BindTexture(texDes1);
- des2->BindTexture(texDes2);
- MultiplyDescriptorG_Kernel<<>>((int*)texDot->_cuData, num1, num2,
- (texCRT? (int3*)texCRT->_cuData : NULL),
- MatH, hdistmax, MatF, fdistmax);
-}
-
-
-texture texDOT;
-
-#define ROWMATCH_BLOCK_WIDTH 32
-#define ROWMATCH_BLOCK_HEIGHT 1
-
-void __global__ RowMatch_Kernel(int*d_dot, int* d_result, int num2, float distmax, float ratiomax)
-{
-#if ROWMATCH_BLOCK_HEIGHT == 1
- __shared__ int dotmax[ROWMATCH_BLOCK_WIDTH];
- __shared__ int dotnxt[ROWMATCH_BLOCK_WIDTH];
- __shared__ int dotidx[ROWMATCH_BLOCK_WIDTH];
- int row = blockIdx.y;
-#else
- __shared__ int x_dotmax[ROWMATCH_BLOCK_HEIGHT][ROWMATCH_BLOCK_WIDTH];
- __shared__ int x_dotnxt[ROWMATCH_BLOCK_HEIGHT][ROWMATCH_BLOCK_WIDTH];
- __shared__ int x_dotidx[ROWMATCH_BLOCK_HEIGHT][ROWMATCH_BLOCK_WIDTH];
- int* dotmax = x_dotmax[threadIdx.y];
- int* dotnxt = x_dotnxt[threadIdx.y];
- int* dotidx = x_dotidx[threadIdx.y];
- int row = IMUL(blockIdx.y, ROWMATCH_BLOCK_HEIGHT) + threadIdx.y;
-#endif
-
- int base_address = IMUL(row , num2);
- int t_dotmax = 0, t_dotnxt = 0, t_dotidx = -1;
- for(int i = 0; i < num2; i += ROWMATCH_BLOCK_WIDTH)
- {
- if(threadIdx.x + i < num2)
- {
- int v = tex1Dfetch(texDOT, base_address + threadIdx.x + i);//d_dot[base_address + threadIdx.x + i];//
- bool test = v > t_dotmax;
- t_dotnxt = test? t_dotmax : max(t_dotnxt, v);
- t_dotidx = test? (threadIdx.x + i) : t_dotidx;
- t_dotmax = test? v: t_dotmax;
- }
- __syncthreads();
- }
- dotmax[threadIdx.x] = t_dotmax;
- dotnxt[threadIdx.x] = t_dotnxt;
- dotidx[threadIdx.x] = t_dotidx;
- __syncthreads();
-
-#pragma unroll
- for(int step = ROWMATCH_BLOCK_WIDTH/2; step >0; step /= 2)
- {
- if(threadIdx.x < step)
- {
- int v1 = dotmax[threadIdx.x], v2 = dotmax[threadIdx.x + step];
- bool test = v2 > v1;
- dotnxt[threadIdx.x] = test? max(v1, dotnxt[threadIdx.x + step]) :max(dotnxt[threadIdx.x], v2);
- dotidx[threadIdx.x] = test? dotidx[threadIdx.x + step] : dotidx[threadIdx.x];
- dotmax[threadIdx.x] = test? v2 : v1;
- }
- __syncthreads();
- }
- if(threadIdx.x == 0)
- {
- float dist = acos(min(dotmax[0] * 0.000003814697265625f, 1.0));
- float distn = acos(min(dotnxt[0] * 0.000003814697265625f, 1.0));
- //float ratio = dist / distn;
- d_result[row] = (dist < distmax) && (dist < distn * ratiomax) ? dotidx[0] : -1;//? : -1;
- }
-
-}
-
-
-void ProgramCU::GetRowMatch(CuTexImage* texDot, CuTexImage* texMatch, float distmax, float ratiomax)
-{
- int num1 = texDot->GetImgHeight();
- int num2 = texDot->GetImgWidth();
- dim3 grid(1, num1/ROWMATCH_BLOCK_HEIGHT);
- dim3 block(ROWMATCH_BLOCK_WIDTH, ROWMATCH_BLOCK_HEIGHT);
- texDot->BindTexture(texDOT);
- RowMatch_Kernel<<>>((int*)texDot->_cuData,
- (int*)texMatch->_cuData, num2, distmax, ratiomax);
-}
-
-#define COLMATCH_BLOCK_WIDTH 32
-
-//texture texCT;
-
-void __global__ ColMatch_Kernel(int3*d_crt, int* d_result, int height, int num2, float distmax, float ratiomax)
-{
- int col = COLMATCH_BLOCK_WIDTH * blockIdx.x + threadIdx.x;
- if(col >= num2) return;
- int3 result = d_crt[col];//tex1Dfetch(texCT, col);
- int read_idx = col + num2;
- for(int i = 1; i < height; ++i, read_idx += num2)
- {
- int3 temp = d_crt[read_idx];//tex1Dfetch(texCT, read_idx);
- result = result.x < temp.x?
- make_int3(temp.x, temp.y, max(result.x, temp.z)) :
- make_int3(result.x, result.y, max(result.z, temp.x));
- }
-
- float dist = acos(min(result.x * 0.000003814697265625f, 1.0));
- float distn = acos(min(result.z * 0.000003814697265625f, 1.0));
- //float ratio = dist / distn;
- d_result[col] = (dist < distmax) && (dist < distn * ratiomax) ? result.y : -1;//? : -1;
-
-}
-
-void ProgramCU::GetColMatch(CuTexImage* texCRT, CuTexImage* texMatch, float distmax, float ratiomax)
-{
- int height = texCRT->GetImgHeight();
- int num2 = texCRT->GetImgWidth();
- //texCRT->BindTexture(texCT);
- dim3 grid((num2 + COLMATCH_BLOCK_WIDTH -1) / COLMATCH_BLOCK_WIDTH);
- dim3 block(COLMATCH_BLOCK_WIDTH);
- ColMatch_Kernel<<>>((int3*)texCRT->_cuData, (int*) texMatch->_cuData, height, num2, distmax, ratiomax);
-}
-
-#endif
diff --git a/3rdparty/SiftGPU/src/SiftGPU/ProgramCU.h b/3rdparty/SiftGPU/src/SiftGPU/ProgramCU.h
deleted file mode 100644
index e261b844..00000000
--- a/3rdparty/SiftGPU/src/SiftGPU/ProgramCU.h
+++ /dev/null
@@ -1,74 +0,0 @@
-////////////////////////////////////////////////////////////////////////////
-// File: ProgramCU.h
-// Author: Changchang Wu
-// Description : interface for the ProgramCU classes.
-// It is basically a wrapper around all the CUDA kernels
-//
-// Copyright (c) 2007 University of North Carolina at Chapel Hill
-// All Rights Reserved
-//
-// Permission to use, copy, modify and distribute this software and its
-// documentation for educational, research and non-profit purposes, without
-// fee, and without a written agreement is hereby granted, provided that the
-// above copyright notice and the following paragraph appear in all copies.
-//
-// The University of North Carolina at Chapel Hill make no representations
-// about the suitability of this software for any purpose. It is provided
-// 'as is' without express or implied warranty.
-//
-// Please send BUG REPORTS to ccwu@cs.unc.edu
-//
-////////////////////////////////////////////////////////////////////////////
-
-#ifndef _PROGRAM_CU_H
-#define _PROGRAM_CU_H
-#if defined(CUDA_SIFTGPU_ENABLED)
-
-class CuTexImage;
-
-class ProgramCU
-{
-public:
- //GPU FUNCTIONS
- static void FinishCUDA();
- static int CheckErrorCUDA(const char* location);
- static int CheckCudaDevice(int device);
-public:
- ////SIFTGPU FUNCTIONS
- static void CreateFilterKernel(float sigma, float* kernel, int& width);
- template static void FilterImage(CuTexImage *dst, CuTexImage *src, CuTexImage* buf);
- static void FilterImage(CuTexImage *dst, CuTexImage *src, CuTexImage* buf, float sigma);
- static void ComputeDOG(CuTexImage* gus, CuTexImage* dog, CuTexImage* got);
- static void ComputeKEY(CuTexImage* dog, CuTexImage* key, float Tdog, float Tedge);
- static void InitHistogram(CuTexImage* key, CuTexImage* hist);
- static void ReduceHistogram(CuTexImage*hist1, CuTexImage* hist2);
- static void GenerateList(CuTexImage* list, CuTexImage* hist);
- static void ComputeOrientation(CuTexImage*list, CuTexImage* got, CuTexImage*key,
- float sigma, float sigma_step, int existing_keypoint);
- static void ComputeDescriptor(CuTexImage*list, CuTexImage* got, CuTexImage* dtex, int rect = 0, int stream = 0);
-
- //data conversion
- static void SampleImageU(CuTexImage *dst, CuTexImage *src, int log_scale);
- static void SampleImageD(CuTexImage *dst, CuTexImage *src, int log_scale = 1);
- static void ReduceToSingleChannel(CuTexImage* dst, CuTexImage* src, int convert_rgb);
- static void ConvertByteToFloat(CuTexImage*src, CuTexImage* dst);
-
- //visualization
- static void DisplayConvertDOG(CuTexImage* dog, CuTexImage* out);
- static void DisplayConvertGRD(CuTexImage* got, CuTexImage* out);
- static void DisplayConvertKEY(CuTexImage* key, CuTexImage* dog, CuTexImage* out);
- static void DisplayKeyPoint(CuTexImage* ftex, CuTexImage* out);
- static void DisplayKeyBox(CuTexImage* ftex, CuTexImage* out);
-
- //SIFTMATCH FUNCTIONS
- static void MultiplyDescriptor(CuTexImage* tex1, CuTexImage* tex2, CuTexImage* texDot, CuTexImage* texCRT);
- static void MultiplyDescriptorG(CuTexImage* texDes1, CuTexImage* texDes2,
- CuTexImage* texLoc1, CuTexImage* texLoc2, CuTexImage* texDot, CuTexImage* texCRT,
- float H[3][3], float hdistmax, float F[3][3], float fdistmax);
- static void GetRowMatch(CuTexImage* texDot, CuTexImage* texMatch, float distmax, float ratiomax);
- static void GetColMatch(CuTexImage* texCRT, CuTexImage* texMatch, float distmax, float ratiomax);
-};
-
-#endif
-#endif
-
diff --git a/3rdparty/SiftGPU/src/SiftGPU/ProgramGLSL.cpp b/3rdparty/SiftGPU/src/SiftGPU/ProgramGLSL.cpp
deleted file mode 100644
index e95199dc..00000000
--- a/3rdparty/SiftGPU/src/SiftGPU/ProgramGLSL.cpp
+++ /dev/null
@@ -1,2690 +0,0 @@
-////////////////////////////////////////////////////////////////////////////
-// File: ProgramGLSL.cpp
-// Author: Changchang Wu
-// Description : GLSL related classes
-// class ProgramGLSL A simple wrapper of GLSL programs
-// class ShaderBagGLSL GLSL shaders for SIFT
-// class FilterGLSL GLSL gaussian filters for SIFT
-//
-// Copyright (c) 2007 University of North Carolina at Chapel Hill
-// All Rights Reserved
-//
-// Permission to use, copy, modify and distribute this software and its
-// documentation for educational, research and non-profit purposes, without
-// fee, and without a written agreement is hereby granted, provided that the
-// above copyright notice and the following paragraph appear in all copies.
-//
-// The University of North Carolina at Chapel Hill make no representations
-// about the suitability of this software for any purpose. It is provided
-// 'as is' without express or implied warranty.
-//
-// Please send BUG REPORTS to ccwu@cs.unc.edu
-//
-////////////////////////////////////////////////////////////////////////////
-
-
-#include "GL/glew.h"
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-using namespace std;
-
-#include "GlobalUtil.h"
-#include "ProgramGLSL.h"
-#include "GLTexImage.h"
-#include "ShaderMan.h"
-#include "SiftGPU.h"
-
-ProgramGLSL::ShaderObject::ShaderObject(int shadertype, const char * source, int filesource)
-{
-
-
- _type = shadertype;
- _compiled = 0;
-
-
- _shaderID = glCreateShader(shadertype);
- if(_shaderID == 0) return;
-
- if(source)
- {
-
- GLint code_length;
- if(filesource ==0)
- {
- const char* code = source;
- code_length = (GLint) strlen(code);
- glShaderSource(_shaderID, 1, (const char **) &code, &code_length);
- }else
- {
- char * code;
- if((code_length= ReadShaderFile(source, code)) ==0) return;
- glShaderSource(_shaderID, 1, (const char **) &code, &code_length);
- delete code;
- }
-
- glCompileShader(_shaderID);
-
- CheckCompileLog();
-
- if(!_compiled) std::cout << source;
- }
-
-
-
-
-}
-
-int ProgramGLSL::ShaderObject::ReadShaderFile(const char *sourcefile, char*& code )
-{
- code = NULL;
- FILE * file;
- int len=0;
-
- if(sourcefile == NULL) return 0;
-
- file = fopen(sourcefile,"rt");
- if(file == NULL) return 0;
-
-
- fseek(file, 0, SEEK_END);
- len = ftell(file);
- rewind(file);
- if(len >1)
- {
- code = new char[len+1];
- fread(code, sizeof( char), len, file);
- code[len] = 0;
- }else
- {
- len = 0;
- }
-
- fclose(file);
-
- return len;
-
-}
-
-void ProgramGLSL::ShaderObject::CheckCompileLog()
-{
-
- GLint status;
- glGetShaderiv(_shaderID, GL_COMPILE_STATUS, &status);
- _compiled = (status ==GL_TRUE);
-
- if(_compiled == 0) PrintCompileLog(std::cout);
-
-
-}
-
-ProgramGLSL::ShaderObject::~ShaderObject()
-{
- if(_shaderID) glDeleteShader(_shaderID);
-
-}
-
-int ProgramGLSL::ShaderObject::IsValidFragmentShader()
-{
- return _type == GL_FRAGMENT_SHADER && _shaderID && _compiled;
-}
-
-int ProgramGLSL::ShaderObject::IsValidVertexShader()
-{
- return _type == GL_VERTEX_SHADER && _shaderID && _compiled;
-}
-
-
-void ProgramGLSL::ShaderObject::PrintCompileLog(ostream&os)
-{
- GLint len = 0;
-
- glGetShaderiv(_shaderID, GL_INFO_LOG_LENGTH , &len);
- if(len <=1) return;
-
- char * compileLog = new char[len+1];
- if(compileLog == NULL) return;
-
- glGetShaderInfoLog(_shaderID, len, &len, compileLog);
-
-
- os<<"Compile Log\n"<= 0) glUniform1i(_TextureParam0, 0);
- return true;
- }
- else
- {
- return false;
- }
-}
-
-
-ProgramGLSL::ProgramGLSL(const char *frag_source)
-{
- _linked = 0;
- _programID = glCreateProgram();
- _TextureParam0 = -1;
- ShaderObject shader(GL_FRAGMENT_SHADER, frag_source);
-
- if(shader.IsValidFragmentShader())
- {
- AttachShaderObject(shader);
- LinkProgram();
-
- if(!_linked)
- {
- //shader.PrintCompileLog(std::cout);
- PrintLinkLog(std::cout);
- } else
- {
- _TextureParam0 = glGetUniformLocation(_programID, "tex");
- }
- }else
- {
- _linked = 0;
- }
-
-}
-
-/*
-ProgramGLSL::ProgramGLSL(char*frag_source, char * vert_source)
-{
- _used = 0;
- _linked = 0;
- _programID = glCreateProgram();
- ShaderObject shader(GL_FRAGMENT_SHADER, frag_source);
- ShaderObject vertex_shader(GL_VERTEX_SHADER, vert_source);
- AttachShaderObject(shader);
- AttachShaderObject(vertex_shader);
- LinkProgram();
- if(!_linked)
- {
- shader.PrintCompileLog(std::cout);
- vertex_shader.PrintCompileLog(std::cout);
- PrintLinkLog(std::cout);
- std::cout<0 && width > GlobalUtil::_MaxFilterWidth)
- {
- std::cout<<"Filter size truncated from "<>1;
- width = 2 * sz + 1;
- }
-
- int i;
- float * kernel = new float[width];
- float rv = 1.0f/(sigma*sigma);
- float v, ksum =0;
-
- // pre-compute filter
- for( i = -sz ; i <= sz ; ++i)
- {
- kernel[i+sz] = v = exp(-0.5f * i * i *rv) ;
- ksum += v;
- }
-
- //normalize the kernel
- rv = 1.0f / ksum;
- for(i = 0; i< width ;i++) kernel[i]*=rv;
- //
-
- MakeFilterProgram(kernel, width);
-
- _size = sz;
-
- delete[] kernel;
- if(GlobalUtil::_verbose && GlobalUtil::_timingL) std::cout<<"Filter: sigma = "<>1;
- float * pf = kernel + halfwidth;
- int nhpixel = (halfwidth+1)>>1; //how many neighbour pixels need to be looked up
- int npixel = (nhpixel<<1)+1;//
- float weight[3];
- ostringstream out;;
- out< halfwidth? 0 : pf[xwn];
- }
- if(weight[1] == 0.0)
- {
- out<<"result += vec4("<>1;
- float * pf = kernel + halfh;
- int nhpixel = (halfh+1)>>1; //how many neighbour pixels need to be looked up
- int npixel = (nhpixel<<1)+1;//
- float weight[3];
- ostringstream out;;
- out< halfh? 0 : pf[ywn];
- }
- if(weight[1] == 0.0)
- {
- out<<"result += vec4("< 0)
- {
- for(int i = 0; i< _gaussian_step_num; i++)
- {
- delete f_gaussian_step[i];
- }
- delete[] f_gaussian_step;
- }
-}
-
-
-void ShaderBag::SelectInitialSmoothingFilter(int octave_min, SiftParam¶m)
-{
- float sigma = param.GetInitialSmoothSigma(octave_min);
- if(sigma == 0)
- {
- f_gaussian_skip0 = NULL;
- }else
- {
- for(unsigned int i = 0; i < f_gaussian_skip0_v.size(); i++)
- {
- if(f_gaussian_skip0_v[i]->_id == octave_min)
- {
- f_gaussian_skip0 = f_gaussian_skip0_v[i];
- return ;
- }
- }
- FilterGLSL * filter = new FilterGLSL(sigma);
- filter->_id = octave_min;
- f_gaussian_skip0_v.push_back(filter);
- f_gaussian_skip0 = filter;
- }
-}
-
-void ShaderBag::CreateGaussianFilters(SiftParam¶m)
-{
- if(param._sigma_skip0>0.0f)
- {
- FilterGLSL * filter;
- f_gaussian_skip0 = filter = new FilterGLSL(param._sigma_skip0);
- filter->_id = GlobalUtil::_octave_min_default;
- f_gaussian_skip0_v.push_back(filter);
- }
- if(param._sigma_skip1>0.0f)
- {
- f_gaussian_skip1 = new FilterGLSL(param._sigma_skip1);
- }
-
- f_gaussian_step = new FilterProgram*[param._sigma_num];
- for(int i = 0; i< param._sigma_num; i++)
- {
- f_gaussian_step[i] = new FilterGLSL(param._sigma[i]);
- }
- _gaussian_step_num = param._sigma_num;
-}
-
-
-void ShaderBag::LoadDynamicShaders(SiftParam& param)
-{
- LoadKeypointShader(param._dog_threshold, param._edge_threshold);
- LoadGenListShader(param._dog_level_num, 0);
- CreateGaussianFilters(param);
-}
-
-
-void ShaderBagGLSL::LoadFixedShaders()
-{
-
-
- s_gray = new ProgramGLSL(
- "uniform sampler2DRect tex; void main(void){\n"
- "float intensity = dot(vec3(0.299, 0.587, 0.114), texture2DRect(tex, gl_TexCoord[0].st ).rgb);\n"
- "gl_FragColor = vec4(intensity, intensity, intensity, 1.0);}");
-
-
- s_debug = new ProgramGLSL( "void main(void){gl_FragColor.rg = gl_TexCoord[0].st;}");
-
-
- s_sampling = new ProgramGLSL(
- "uniform sampler2DRect tex; void main(void){gl_FragColor.rg= texture2DRect(tex, gl_TexCoord[0].st).rg;}");
-
- //
- s_grad_pass = new ProgramGLSL(
- "uniform sampler2DRect tex; void main ()\n"
- "{\n"
- " vec4 v1, v2, gg;\n"
- " vec4 cc = texture2DRect(tex, gl_TexCoord[0].xy);\n"
- " gg.x = texture2DRect(tex, gl_TexCoord[1].xy).r;\n"
- " gg.y = texture2DRect(tex, gl_TexCoord[2].xy).r;\n"
- " gg.z = texture2DRect(tex, gl_TexCoord[3].xy).r;\n"
- " gg.w = texture2DRect(tex, gl_TexCoord[4].xy).r;\n"
- " vec2 dxdy = (gg.yw - gg.xz); \n"
- " float grad = 0.5*length(dxdy);\n"
- " float theta = grad==0.0? 0.0: atan(dxdy.y, dxdy.x);\n"
- " gl_FragData[0] = vec4(cc.rg, grad, theta);\n"
- "}\n\0");
-
- ProgramGLSL * program;
- s_margin_copy = program = new ProgramGLSL(
- "uniform sampler2DRect tex; uniform vec2 truncate;\n"
- "void main(){ gl_FragColor = texture2DRect(tex, min(gl_TexCoord[0].xy, truncate)); }");
-
- _param_margin_copy_truncate = glGetUniformLocation(*program, "truncate");
-
-
- GlobalUtil::_OrientationPack2 = 0;
- LoadOrientationShader();
-
- if(s_orientation == NULL)
- {
- //Load a simplified version if the right version is not supported
- s_orientation = program = new ProgramGLSL(
- "uniform sampler2DRect tex; uniform sampler2DRect oTex;\n"
- " uniform float size; void main(){\n"
- " vec4 cc = texture2DRect(tex, gl_TexCoord[0].st);\n"
- " vec4 oo = texture2DRect(oTex, cc.rg);\n"
- " gl_FragColor.rg = cc.rg;\n"
- " gl_FragColor.b = oo.a;\n"
- " gl_FragColor.a = size;}");
-
- _param_orientation_gtex = glGetUniformLocation(*program, "oTex");
- _param_orientation_size = glGetUniformLocation(*program, "size");
- GlobalUtil::_MaxOrientation = 0;
- GlobalUtil::_FullSupported = 0;
- std::cerr<<"Orientation simplified on this hardware"< 0.9))? size : -size);\n"
- "dxy.y = type < 0.2 ? 0.0 : (((type < 0.3) || (type > 0.7) )? -size :size); \n"
- "float s = sin(cc.b); float c = cos(cc.b); \n"
- "gl_FragColor.x = cc.x + c*dxy.x-s*dxy.y;\n"
- "gl_FragColor.y = cc.y + c*dxy.y+s*dxy.x;}\n}\n");
-
- _param_genvbo_size = glGetUniformLocation(*program, "sizes");
-
- s_display_gaussian = new ProgramGLSL(
- "uniform sampler2DRect tex; void main(void){float r = texture2DRect(tex, gl_TexCoord[0].st).r;\n"
- "gl_FragColor = vec4(r, r, r, 1);}" );
-
- s_display_dog = new ProgramGLSL(
- "uniform sampler2DRect tex; void main(void){float g = 0.5+(20.0*texture2DRect(tex, gl_TexCoord[0].st).g);\n"
- "gl_FragColor = vec4(g, g, g, 0.0);}" );
-
- s_display_grad = new ProgramGLSL(
- "uniform sampler2DRect tex; void main(void){\n"
- " vec4 cc = texture2DRect(tex, gl_TexCoord[0].st);gl_FragColor = vec4(5.0* cc.bbb, 1.0);}");
-
- s_display_keys= new ProgramGLSL(
- "uniform sampler2DRect tex; void main(void){\n"
- " vec4 cc = texture2DRect(tex, gl_TexCoord[0].st);\n"
- " if(cc.r ==0.0) discard; gl_FragColor = (cc.r==1.0? vec4(1.0, 0.0, 0,1.0):vec4(0.0,1.0,0.0,1.0));}");
-}
-
-void ShaderBagGLSL::LoadKeypointShader(float threshold, float edge_threshold)
-{
- float threshold0 = threshold* (GlobalUtil::_SubpixelLocalization?0.8f:1.0f);
- float threshold1 = threshold;
- float threshold2 = (edge_threshold+1)*(edge_threshold+1)/edge_threshold;
- ostringstream out;;
- streampos pos;
-
- //tex(X)(Y)
- //X: (CLR) (CENTER 0, LEFT -1, RIGHT +1)
- //Y: (CDU) (CENTER 0, DOWN -1, UP +1)
- if(GlobalUtil::_DarknessAdaption)
- {
- out << "#define THRESHOLD0 (" << threshold0 << " * min(2.0 * cc.r + 0.1, 1.0))\n"
- "#define THRESHOLD1 (" << threshold1 << " * min(2.0 * cc.r + 0.1, 1.0))\n"
- "#define THRESHOLD2 " << threshold2 << "\n";
- }else
- {
- out << "#define THRESHOLD0 " << threshold0 << "\n"
- "#define THRESHOLD1 " << threshold1 << "\n"
- "#define THRESHOLD2 " << threshold2 << "\n";
- }
-
- out<<
- "uniform sampler2DRect tex, texU, texD; void main ()\n"
- "{\n"
- " vec4 v1, v2, gg, temp;\n"
- " vec2 TexRU = vec2(gl_TexCoord[2].x, gl_TexCoord[4].y); \n"
- " vec4 cc = texture2DRect(tex, gl_TexCoord[0].xy);\n"
- " temp = texture2DRect(tex, gl_TexCoord[1].xy);\n"
- " v1.x = temp.g; gg.x = temp.r;\n"
- " temp = texture2DRect(tex, gl_TexCoord[2].xy) ;\n"
- " v1.y = temp.g; gg.y = temp.r;\n"
- " temp = texture2DRect(tex, gl_TexCoord[3].xy) ;\n"
- " v1.z = temp.g; gg.z = temp.r;\n"
- " temp = texture2DRect(tex, gl_TexCoord[4].xy) ;\n"
- " v1.w = temp.g; gg.w = temp.r;\n"
- " v2.x = texture2DRect(tex, gl_TexCoord[5].xy).g;\n"
- " v2.y = texture2DRect(tex, gl_TexCoord[6].xy).g;\n"
- " v2.z = texture2DRect(tex, gl_TexCoord[7].xy).g;\n"
- " v2.w = texture2DRect(tex, TexRU.xy).g;\n"
- " vec2 dxdy = (gg.yw - gg.xz); \n"
- " float grad = 0.5*length(dxdy);\n"
- " float theta = grad==0.0? 0.0: atan(dxdy.y, dxdy.x);\n"
- " gl_FragData[0] = vec4(cc.rg, grad, theta);\n"
-
- //test against 8 neighbours
- //use variable to identify type of extremum
- //1.0 for local maximum and 0.5 for minimum
- <<
- " float dog = 0.0; \n"
- " gl_FragData[1] = vec4(0, 0, 0, 0); \n"
- " dog = cc.g > float(THRESHOLD0) && all(greaterThan(cc.gggg, max(v1, v2)))?1.0: 0.0;\n"
- " dog = cc.g < float(-THRESHOLD0) && all(lessThan(cc.gggg, min(v1, v2)))?0.5: dog;\n"
- " if(dog == 0.0) return;\n";
-
- pos = out.tellp();
- //do edge supression first..
- //vector v1 is < (-1, 0), (1, 0), (0,-1), (0, 1)>
- //vector v2 is < (-1,-1), (-1,1), (1,-1), (1, 1)>
-
- out<<
- " float fxx, fyy, fxy; \n"
- " vec4 D2 = v1.xyzw - cc.gggg;\n"
- " vec2 D4 = v2.xw - v2.yz;\n"
- " fxx = D2.x + D2.y;\n"
- " fyy = D2.z + D2.w;\n"
- " fxy = 0.25*(D4.x + D4.y);\n"
- " float fxx_plus_fyy = fxx + fyy;\n"
- " float score_up = fxx_plus_fyy*fxx_plus_fyy; \n"
- " float score_down = (fxx*fyy - fxy*fxy);\n"
- " if( score_down <= 0.0 || score_up > THRESHOLD2 * score_down)return;\n";
-
- //...
- out<<" \n"
- " vec2 D5 = 0.5*(v1.yw-v1.xz); \n"
- " float fx = D5.x, fy = D5.y ; \n"
- " float fs, fss , fxs, fys ; \n"
- " vec2 v3; vec4 v4, v5, v6;\n"
- //read 9 pixels of upper level
- <<
- " v3.x = texture2DRect(texU, gl_TexCoord[0].xy).g;\n"
- " v4.x = texture2DRect(texU, gl_TexCoord[1].xy).g;\n"
- " v4.y = texture2DRect(texU, gl_TexCoord[2].xy).g;\n"
- " v4.z = texture2DRect(texU, gl_TexCoord[3].xy).g;\n"
- " v4.w = texture2DRect(texU, gl_TexCoord[4].xy).g;\n"
- " v6.x = texture2DRect(texU, gl_TexCoord[5].xy).g;\n"
- " v6.y = texture2DRect(texU, gl_TexCoord[6].xy).g;\n"
- " v6.z = texture2DRect(texU, gl_TexCoord[7].xy).g;\n"
- " v6.w = texture2DRect(texU, TexRU.xy).g;\n"
- //compare with 9 pixels of upper level
- //read and compare with 9 pixels of lower level
- //the maximum case
- <<
- " if(dog == 1.0)\n"
- " {\n"
- " if(cc.g < v3.x || any(lessThan(cc.gggg, v4)) ||any(lessThan(cc.gggg, v6)))return; \n"
- " v3.y = texture2DRect(texD, gl_TexCoord[0].xy).g;\n"
- " v5.x = texture2DRect(texD, gl_TexCoord[1].xy).g;\n"
- " v5.y = texture2DRect(texD, gl_TexCoord[2].xy).g;\n"
- " v5.z = texture2DRect(texD, gl_TexCoord[3].xy).g;\n"
- " v5.w = texture2DRect(texD, gl_TexCoord[4].xy).g;\n"
- " v6.x = texture2DRect(texD, gl_TexCoord[5].xy).g;\n"
- " v6.y = texture2DRect(texD, gl_TexCoord[6].xy).g;\n"
- " v6.z = texture2DRect(texD, gl_TexCoord[7].xy).g;\n"
- " v6.w = texture2DRect(texD, TexRU.xy).g;\n"
- " if(cc.g < v3.y || any(lessThan(cc.gggg, v5)) ||any(lessThan(cc.gggg, v6)))return; \n"
- " }\n"
- //the minimum case
- <<
- " else{\n"
- " if(cc.g > v3.x || any(greaterThan(cc.gggg, v4)) ||any(greaterThan(cc.gggg, v6)))return; \n"
- " v3.y = texture2DRect(texD, gl_TexCoord[0].xy).g;\n"
- " v5.x = texture2DRect(texD, gl_TexCoord[1].xy).g;\n"
- " v5.y = texture2DRect(texD, gl_TexCoord[2].xy).g;\n"
- " v5.z = texture2DRect(texD, gl_TexCoord[3].xy).g;\n"
- " v5.w = texture2DRect(texD, gl_TexCoord[4].xy).g;\n"
- " v6.x = texture2DRect(texD, gl_TexCoord[5].xy).g;\n"
- " v6.y = texture2DRect(texD, gl_TexCoord[6].xy).g;\n"
- " v6.z = texture2DRect(texD, gl_TexCoord[7].xy).g;\n"
- " v6.w = texture2DRect(texD, TexRU.xy).g;\n"
- " if(cc.g > v3.y || any(greaterThan(cc.gggg, v5)) ||any(greaterThan(cc.gggg, v6)))return; \n"
- " }\n";
-
- if(GlobalUtil::_SubpixelLocalization)
-
- // sub-pixel localization FragData1 = vec4(dog, 0, 0, 0); return;
- out <<
- " fs = 0.5*( v3.x - v3.y ); \n"
- " fss = v3.x + v3.y - cc.g - cc.g;\n"
- " fxs = 0.25 * ( v4.y + v5.x - v4.x - v5.y);\n"
- " fys = 0.25 * ( v4.w + v5.z - v4.z - v5.w);\n"
-
- //
- // let dog difference be quatratic function of dx, dy, ds;
- // df(dx, dy, ds) = fx * dx + fy*dy + fs * ds +
- // + 0.5 * ( fxx * dx * dx + fyy * dy * dy + fss * ds * ds)
- // + (fxy * dx * dy + fxs * dx * ds + fys * dy * ds)
- // (fx, fy, fs, fxx, fyy, fss, fxy, fxs, fys are the derivatives)
-
- //the local extremum satisfies
- // df/dx = 0, df/dy = 0, df/dz = 0
-
- //that is
- // |-fx| | fxx fxy fxs | |dx|
- // |-fy| = | fxy fyy fys | * |dy|
- // |-fs| | fxs fys fss | |ds|
- // need to solve dx, dy, ds
-
- // Use Gauss elimination to solve the linear system
- <<
- " vec3 dxys = vec3(0.0); \n"
- " vec4 A0, A1, A2 ; \n"
- " A0 = vec4(fxx, fxy, fxs, -fx); \n"
- " A1 = vec4(fxy, fyy, fys, -fy); \n"
- " A2 = vec4(fxs, fys, fss, -fs); \n"
- " vec3 x3 = abs(vec3(fxx, fxy, fxs)); \n"
- " float maxa = max(max(x3.x, x3.y), x3.z); \n"
- " if(maxa >= 1e-10 ) { \n"
- " if(x3.y ==maxa ) \n"
- " { \n"
- " vec4 TEMP = A1; A1 = A0; A0 = TEMP; \n"
- " }else if( x3.z == maxa ) \n"
- " { \n"
- " vec4 TEMP = A2; A2 = A0; A0 = TEMP; \n"
- " } \n"
- " A0 /= A0.x; \n"
- " A1 -= A1.x * A0; \n"
- " A2 -= A2.x * A0; \n"
- " vec2 x2 = abs(vec2(A1.y, A2.y)); \n"
- " if( x2.y > x2.x ) \n"
- " { \n"
- " vec3 TEMP = A2.yzw; \n"
- " A2.yzw = A1.yzw; \n"
- " A1.yzw = TEMP; \n"
- " x2.x = x2.y; \n"
- " } \n"
- " if(x2.x >= 1e-10) { \n"
- " A1.yzw /= A1.y; \n"
- " A2.yzw -= A2.y * A1.yzw; \n"
- " if(abs(A2.z) >= 1e-10) { \n"
- // compute dx, dy, ds:
- <<
- " \n"
- " dxys.z = A2.w /A2.z; \n"
- " dxys.y = A1.w - dxys.z*A1.z; \n"
- " dxys.x = A0.w - dxys.z*A0.z - dxys.y*A0.y; \n"
-
- //one more threshold which I forgot in versions prior to 286
- <<
- " bool dog_test = (abs(cc.g + 0.5*dot(vec3(fx, fy, fs), dxys ))<= float(THRESHOLD1)) ;\n"
- " if(dog_test || any(greaterThan(abs(dxys), vec3(1.0)))) dog = 0.0;\n"
- " }\n"
- " }\n"
- " }\n"
- //keep the point when the offset is less than 1
- <<
- " gl_FragData[1] = vec4( dog, dxys); \n";
- else
-
- out<<
- " gl_FragData[1] = vec4( dog, 0.0, 0.0, 0.0) ; \n";
-
- out<<
- "}\n" <<'\0';
-
-
-
- ProgramGLSL * program = new ProgramGLSL(out.str().c_str());
- if(program->IsNative())
- {
- s_keypoint = program ;
- //parameter
- }else
- {
- delete program;
- out.seekp(pos);
- out <<
- " gl_FragData[1] = vec4(dog, 0.0, 0.0, 0.0) ; \n"
- "}\n" <<'\0';
- s_keypoint = program = new ProgramGLSL(out.str().c_str());
- GlobalUtil::_SubpixelLocalization = 0;
- std::cerr<<"Detection simplified on this hardware"<0.0,\n"
- "all(lessThan(gl_TexCoord[1].xy , bbox)) && helper.y >0.0,\n"
- "all(lessThan(gl_TexCoord[2].xy , bbox)) && helper.z >0.0,\n"
- "all(lessThan(gl_TexCoord[3].xy , bbox)) && helper.w >0.0);\n"
- "gl_FragColor = vec4(helper2);\n"
- "}");
- _param_genlist_init_bbox = glGetUniformLocation( *program, "bbox");
-
-
- //reduction ...
- s_genlist_histo = new ProgramGLSL(
- "uniform sampler2DRect tex; void main (void){\n"
- "vec4 helper; vec4 helper2; \n"
- "helper = texture2DRect(tex, gl_TexCoord[0].xy); helper2.xy = helper.xy + helper.zw; \n"
- "helper = texture2DRect(tex, gl_TexCoord[1].xy); helper2.zw = helper.xy + helper.zw; \n"
- "gl_FragColor.rg = helper2.xz + helper2.yw;\n"
- "helper = texture2DRect(tex, gl_TexCoord[2].xy); helper2.xy = helper.xy + helper.zw; \n"
- "helper = texture2DRect(tex, gl_TexCoord[3].xy); helper2.zw = helper.xy + helper.zw; \n"
- "gl_FragColor.ba= helper2.xz+helper2.yw;\n"
- "}");
-
-
- //read of the first part, which generates tex coordinates
- s_genlist_start= program = LoadGenListStepShader(1, 1);
- _param_ftex_width= glGetUniformLocation(*program, "width");
- _param_genlist_start_tex0 = glGetUniformLocation(*program, "tex0");
- //stepping
- s_genlist_step = program = LoadGenListStepShader(0, 1);
- _param_genlist_step_tex0= glGetUniformLocation(*program, "tex0");
-
-}
-
-void ShaderBagGLSL::SetMarginCopyParam(int xmax, int ymax)
-{
- float truncate[2] = {xmax - 0.5f , ymax - 0.5f};
- glUniform2fv(_param_margin_copy_truncate, 1, truncate);
-}
-
-void ShaderBagGLSL::SetGenListInitParam(int w, int h)
-{
- float bbox[2] = {w - 1.0f, h - 1.0f};
- glUniform2fv(_param_genlist_init_bbox, 1, bbox);
-}
-void ShaderBagGLSL::SetGenListStartParam(float width, int tex0)
-{
- glUniform1f(_param_ftex_width, width);
- glUniform1i(_param_genlist_start_tex0, 0);
-}
-
-
-ProgramGLSL* ShaderBagGLSL::LoadGenListStepShader(int start, int step)
-{
- int i;
- // char chanels[5] = "rgba";
- ostringstream out;
-
- for(i = 0; i < step; i++) out<<"uniform sampler2DRect tex"<0)
- {
- out<<"vec2 cpos = vec2(-0.5, 0.5);\t vec2 opos;\n";
- for(i = 0; i < step; i++)
- {
-
- out<<"cc = texture2DRect(tex"<IsNative())
- {
- s_orientation = program ;
- _param_orientation_gtex = glGetUniformLocation(*program, "gradTex");
- _param_orientation_size = glGetUniformLocation(*program, "size");
- _param_orientation_stex = glGetUniformLocation(*program, "texS");
- }else
- {
- delete program;
- }
-}
-
-
-void ShaderBagGLSL::WriteOrientationCodeToStream(std::ostream& out)
-{
- //smooth histogram and find the largest
-/*
- smoothing kernel: (1 3 6 7 6 3 1 )/27
- the same as 3 pass of (1 1 1)/3 averaging
- maybe better to use 4 pass on the vectors...
-*/
-
-
- //the inner loop on different array numbers is always unrolled in fp40
-
- //bug fixed here:)
- out<<"\n"
- " //mat3 m1 = mat3(1, 0, 0, 3, 1, 0, 6, 3, 1)/27.0; \n"
- " mat3 m1 = mat3(1, 3, 6, 0, 1, 3,0, 0, 1)/27.0; \n"
- " mat4 m2 = mat4(7, 6, 3, 1, 6, 7, 6, 3, 3, 6, 7, 6, 1, 3, 6, 7)/27.0;\n"
- " #define FILTER_CODE(i) { \\\n"
- " vec4 newb = (bins[i]* m2); \\\n"
- " newb.xyz += ( prev.yzw * m1); \\\n"
- " prev = bins[i]; \\\n"
- " newb.wzy += ( bins[i+1].zyx *m1); \\\n"
- " bins[i] = newb;}\n"
- " for (int j=0; j<2; j++) \n"
- " { \n"
- " vec4 prev = bins[8]; \n"
- " bins[9] = bins[0]; \n";
-
- if(GlobalUtil::_KeepShaderLoop)
- {
- out<<
- " for (int i=0; i<9; i++) \n"
- " { \n"
- " FILTER_CODE(i); \n"
- " } \n"
- " }";
-
- }else
- {
- //manually unroll the loop for ATI.
- out <<
- " FILTER_CODE(0);\n"
- " FILTER_CODE(1);\n"
- " FILTER_CODE(2);\n"
- " FILTER_CODE(3);\n"
- " FILTER_CODE(4);\n"
- " FILTER_CODE(5);\n"
- " FILTER_CODE(6);\n"
- " FILTER_CODE(7);\n"
- " FILTER_CODE(8);\n"
- " }\n";
- }
- //find the maximum voting
- out<<"\n"
- " vec4 maxh; vec2 maxh2; \n"
- " vec4 maxh4 = max(max(max(max(max(max(max(max(bins[0], bins[1]), bins[2]), \n"
- " bins[3]), bins[4]), bins[5]), bins[6]), bins[7]), bins[8]);\n"
- " maxh2 = max(maxh4.xy, maxh4.zw); maxh = vec4(max(maxh2.x, maxh2.y));";
-
- char *testpeak_code;
- char *savepeak_code;
-
- //save two/three/four orientations with the largest votings?
-
- if(GlobalUtil::_MaxOrientation>1)
- {
- out<<"\n"
- " vec4 Orientations = vec4(0.0, 0.0, 0.0, 0.0); \n"
- " vec4 weights = vec4(0.0,0.0,0.0,0.0); ";
-
- testpeak_code = "\\\n"
- " {test = greaterThan(bins[i], hh);";
-
- //save the orientations in weight-decreasing order
- if(GlobalUtil::_MaxOrientation ==2)
- {
- savepeak_code = "\\\n"
- " if(weight <=weights.g){}\\\n"
- " else if(weight >weights.r)\\\n"
- " {weights.rg = vec2(weight, weights.r); Orientations.rg = vec2(th, Orientations.r);}\\\n"
- " else {weights.g = weight; Orientations.g = th;}";
- }else if(GlobalUtil::_MaxOrientation ==3)
- {
- savepeak_code = "\\\n"
- " if(weight <=weights.b){}\\\n"
- " else if(weight >weights.r)\\\n"
- " {weights.rgb = vec3(weight, weights.rg); Orientations.rgb = vec3(th, Orientations.rg);}\\\n"
- " else if(weight >weights.g)\\\n"
- " {weights.gb = vec2(weight, weights.g); Orientations.gb = vec2(th, Orientations.g);}\\\n"
- " else {weights.b = weight; Orientations.b = th;}";
- }else
- {
- savepeak_code = "\\\n"
- " if(weight <=weights.a){}\\\n"
- " else if(weight >weights.r)\\\n"
- " {weights = vec4(weight, weights.rgb); Orientations = vec4(th, Orientations.rgb);}\\\n"
- " else if(weight >weights.g)\\\n"
- " {weights.gba = vec3(weight, weights.gb); Orientations.gba = vec3(th, Orientations.gb);}\\\n"
- " else if(weight >weights.b)\\\n"
- " {weights.ba = vec2(weight, weights.b); Orientations.ba = vec2(th, Orientations.b);}\\\n"
- " else {weights.a = weight; Orientations.a = th;}";
- }
-
- }else
- {
- out<<"\n"
- " float Orientation; ";
- testpeak_code ="\\\n"
- " if(npeaks<=0.0){\\\n"
- " test = equal(bins[i], maxh) ;";
- savepeak_code="\\\n"
- " npeaks++; \\\n"
- " Orientation = th;";
-
- }
- //find the peaks
- out <<"\n"
- " #define FINDPEAK(i, k)" < prevb && bins[i].x > bins[i].y ) \\\n"
- " { \\\n"
- " float di = -0.5 * (bins[i].y-prevb) / (bins[i].y+prevb-bins[i].x - bins[i].x) ; \\\n"
- " float th = (k+di+0.5); float weight = bins[i].x;"
- < bins[i].z && bins[i].w > bins[i+1].x ) \\\n"
- " { \\\n"
- " float di = -0.5 * (bins[i+1].x-bins[i].z) / (bins[i+1].x+bins[i].z-bins[i].w - bins[i].w) ; \\\n"
- " float th = (k+di+3.5); float weight = bins[i].w; "
- <1)
- {
- out<<"\n"
- " if(orientation_mode){\n"
- " npeaks = dot(vec4(1,1,"
- <<(GlobalUtil::_MaxOrientation>2 ? 1 : 0)<<","
- <<(GlobalUtil::_MaxOrientation >3? 1 : 0)<<"), vec4(greaterThan(weights, hh)));\n"
- " gl_FragData[0] = vec4(pos, npeaks, sigma);\n"
- " gl_FragData[1] = radians((Orientations )*10.0);\n"
- " }else{\n"
- " gl_FragData[0] = vec4(pos, radians((Orientations.x)*10.0), sigma);\n"
- " }\n";
- }else
- {
- out<<"\n"
- " gl_FragData[0] = vec4(pos, radians((Orientation)*10.0), sigma);\n";
- }
- //end
- out<<"\n"
- "}\n"<<'\0';
-
-
-}
-
-void ShaderBagGLSL::SetSimpleOrientationInput(int oTex, float sigma, float sigma_step)
-{
- glUniform1i(_param_orientation_gtex, 1);
- glUniform1f(_param_orientation_size, sigma);
-}
-
-
-
-
-void ShaderBagGLSL::SetFeatureOrientationParam(int gtex, int width, int height, float sigma, int stex, float step)
-{
- ///
- glUniform1i(_param_orientation_gtex, 1);
-
- if((GlobalUtil::_SubpixelLocalization || GlobalUtil::_KeepExtremumSign)&& stex)
- {
- //specify texutre for subpixel subscale localization
- glUniform1i(_param_orientation_stex, 2);
- }
-
- float size[4];
- size[0] = (float)width;
- size[1] = (float)height;
- size[2] = sigma;
- size[3] = step;
- glUniform4fv(_param_orientation_size, 1, size);
-}
-
-
-void ShaderBagGLSL::LoadDescriptorShaderF2()
-{
- //one shader outpout 128/8 = 16 , each fragout encodes 4
- //const double twopi = 2.0*3.14159265358979323846;
- //const double rpi = 8.0/twopi;
- ostringstream out;
- out< M_PI) anglef -= TWO_PI;\n"
- " float sigma = texture2DRect(tex, coord).w; \n"
- " float spt = abs(sigma * WF); //default to be 3*sigma \n";
-
- //rotation
- out<<
- " vec4 cscs, rots; \n"
- " cscs.y = sin(anglef); cscs.x = cos(anglef); \n"
- " cscs.zw = - cscs.xy; \n"
- " rots = cscs /spt; \n"
- " cscs *= spt; \n";
-
- //here cscs is actually (cos, sin, -cos, -sin) * (factor: 3)*sigma
- //and rots is (cos, sin, -cos, -sin ) /(factor*sigma)
- //devide the 4x4 sift grid into 16 1x1 block, and each corresponds to a shader thread
- //To use linear interoplation, 1x1 is increased to 2x2, by adding 0.5 to each side
-
- out<<
- "vec4 temp; vec2 pt, offsetpt; \n"
- " /*the fraction part of idx is .5*/ \n"
- " offsetpt.x = 4.0* fract(idx*0.25) - 2.0; \n"
- " offsetpt.y = floor(idx*0.25) - 1.5; \n"
- " temp = cscs.xwyx*offsetpt.xyxy; \n"
- " pt = pos + temp.xz + temp.yw; \n";
-
- //get a horizontal bounding box of the rotated rectangle
- out<<
- " vec2 bwin = abs(cscs.xy); \n"
- " float bsz = bwin.x + bwin.y; \n"
- " vec4 sz; \n"
- " sz.xy = max(pt - vec2(bsz), vec2(1,1));\n"
- " sz.zw = min(pt + vec2(bsz), dim - vec2(2, 2)); \n"
- " sz = floor(sz)+0.5;"; //move sample point to pixel center
- //get voting for two box
-
- out<<"\n"
- " vec4 DA, DB; vec2 spos; \n"
- " DA = DB = vec4(0.0, 0.0, 0.0, 0.0); \n"
- " for(spos.y = sz.y; spos.y <= sz.w; spos.y+=1.0) \n"
- " { \n"
- " for(spos.x = sz.x; spos.x <= sz.z; spos.x+=1.0) \n"
- " { \n"
- " vec2 diff = spos - pt; \n"
- " temp = rots.xywx * diff.xyxy;\n"
- " vec2 nxy = (temp.xz + temp.yw); \n"
- " vec2 nxyn = abs(nxy); \n"
- " if(all( lessThan(nxyn, vec2(1.0)) ))\n"
- " {\n"
- " vec4 cc = texture2DRect(gradTex, spos); \n"
- " float mod = cc.b; float angle = cc.a; \n"
- " float theta0 = RPI * (anglef - angle); \n"
- " float theta = theta0 < 0.0? theta0 + 8.0 : theta0;;\n"
- " diff = nxy + offsetpt.xy; \n"
- " float ww = exp(-0.125*dot(diff, diff));\n"
- " vec2 weights = vec2(1) - nxyn;\n"
- " float weight = weights.x * weights.y *mod*ww; \n"
- " float theta1 = floor(theta); \n"
- " float weight2 = (theta - theta1) * weight;\n"
- " float weight1 = weight - weight2;\n"
- " DA += vec4(equal(vec4(theta1), vec4(0, 1, 2, 3)))*weight1;\n"
- " DA += vec4(equal(vec4(theta1), vec4(7, 0, 1, 2)))*weight2; \n"
- " DB += vec4(equal(vec4(theta1), vec4(4, 5, 6, 7)))*weight1;\n"
- " DB += vec4(equal(vec4(theta1), vec4(3, 4, 5, 6)))*weight2; \n"
- " }\n"
- " }\n"
- " }\n";
-
- out<<
- " gl_FragData[0] = DA; gl_FragData[1] = DB;\n"
- "}\n"<<'\0';
-
- ProgramGLSL * program = new ProgramGLSL(out.str().c_str());
-
- if(program->IsNative())
- {
- s_descriptor_fp = program ;
- _param_descriptor_gtex = glGetUniformLocation(*program, "gradTex");
- _param_descriptor_size = glGetUniformLocation(*program, "size");
- _param_descriptor_dsize = glGetUniformLocation(*program, "dsize");
- }else
- {
- delete program;
- }
-
-
-}
-
-void ShaderBagGLSL::LoadDescriptorShader()
-{
- GlobalUtil::_DescriptorPPT = 16;
- LoadDescriptorShaderF2();
-}
-
-
-void ShaderBagGLSL::SetFeatureDescirptorParam(int gtex, int otex, float dwidth, float fwidth, float width, float height, float sigma)
-{
- ///
- glUniform1i(_param_descriptor_gtex, 1);
-
- float dsize[4] ={dwidth, 1.0f/dwidth, fwidth, 1.0f/fwidth};
- glUniform4fv(_param_descriptor_dsize, 1, dsize);
- float size[3];
- size[0] = width;
- size[1] = height;
- size[2] = GlobalUtil::_DescriptorWindowFactor;
- glUniform3fv(_param_descriptor_size, 1, size);
-
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-void ShaderBagPKSL::LoadFixedShaders()
-{
- ProgramGLSL * program;
-
-
- s_gray = new ProgramGLSL(
- "uniform sampler2DRect tex; void main(){\n"
- "float intensity = dot(vec3(0.299, 0.587, 0.114), texture2DRect(tex,gl_TexCoord[0].xy ).rgb);\n"
- "gl_FragColor= vec4(intensity, intensity, intensity, 1.0);}" );
-
-
- s_sampling = new ProgramGLSL(
- "uniform sampler2DRect tex; void main(){\n"
- "gl_FragColor= vec4( texture2DRect(tex,gl_TexCoord[0].st ).r,texture2DRect(tex,gl_TexCoord[1].st ).r,\n"
- " texture2DRect(tex,gl_TexCoord[2].st ).r,texture2DRect(tex,gl_TexCoord[3].st ).r);}" );
-
-
- s_margin_copy = program = new ProgramGLSL(
- "uniform sampler2DRect tex; uniform vec4 truncate; void main(){\n"
- "vec4 cc = texture2DRect(tex, min(gl_TexCoord[0].xy, truncate.xy)); \n"
- "bvec2 ob = lessThan(gl_TexCoord[0].xy, truncate.xy);\n"
- "if(ob.y) { gl_FragColor = (truncate.z ==0.0 ? cc.rrbb : cc.ggaa); } \n"
- "else if(ob.x) {gl_FragColor = (truncate.w <1.5 ? cc.rgrg : cc.baba);} \n"
- "else { vec4 weights = vec4(vec4(0.0, 1.0, 2.0, 3.0) == truncate.wwww);\n"
- "float v = dot(weights, cc); gl_FragColor = vec4(v);}}");
-
- _param_margin_copy_truncate = glGetUniformLocation(*program, "truncate");
-
-
-
- s_zero_pass = new ProgramGLSL("void main(){gl_FragColor = vec4(0.0);}");
-
-
-
- s_grad_pass = program = new ProgramGLSL(
- "uniform sampler2DRect tex; uniform sampler2DRect texp; void main ()\n"
- "{\n"
- " vec4 v1, v2, gg;\n"
- " vec4 cc = texture2DRect(tex, gl_TexCoord[0].xy);\n"
- " vec4 cp = texture2DRect(texp, gl_TexCoord[0].xy);\n"
- " gl_FragData[0] = cc - cp; \n"
- " vec4 cl = texture2DRect(tex, gl_TexCoord[1].xy); vec4 cr = texture2DRect(tex, gl_TexCoord[2].xy);\n"
- " vec4 cd = texture2DRect(tex, gl_TexCoord[3].xy); vec4 cu = texture2DRect(tex, gl_TexCoord[4].xy);\n"
- " vec4 dx = (vec4(cr.rb, cc.ga) - vec4(cc.rb, cl.ga)).zxwy;\n"
- " vec4 dy = (vec4(cu.rg, cc.ba) - vec4(cc.rg, cd.ba)).zwxy;\n"
- " vec4 grad = 0.5 * sqrt(dx*dx + dy * dy);\n"
- " gl_FragData[1] = grad;\n"
- " vec4 invalid = vec4(equal(grad, vec4(0.0))); \n"
- " vec4 ov = atan(dy, dx + invalid); \n"
- " gl_FragData[2] = ov; \n"
- "}\n\0"); //when
-
- _param_grad_pass_texp = glGetUniformLocation(*program, "texp");
-
-
- GlobalUtil::_OrientationPack2 = 0;
- LoadOrientationShader();
-
- if(s_orientation == NULL)
- {
- //Load a simplified version if the right version is not supported
- s_orientation = program = new ProgramGLSL(
- "uniform sampler2DRect tex; uniform sampler2DRect oTex; uniform vec2 size; void main(){\n"
- " vec4 cc = texture2DRect(tex, gl_TexCoord[0].xy);\n"
- " vec2 co = cc.xy * 0.5; \n"
- " vec4 oo = texture2DRect(oTex, co);\n"
- " bvec2 bo = lessThan(fract(co), vec2(0.5)); \n"
- " float o = bo.y? (bo.x? oo.r : oo.g) : (bo.x? oo.b : oo.a); \n"
- " gl_FragColor = vec4(cc.rg, o, size.x * pow(size.y, cc.a));}");
-
- _param_orientation_gtex= glGetUniformLocation(*program, "oTex");
- _param_orientation_size= glGetUniformLocation(*program, "size");
- GlobalUtil::_MaxOrientation = 0;
- GlobalUtil::_FullSupported = 0;
- std::cerr<<"Orientation simplified on this hardware"< 0.9))? size : -size);\n"
- " dxy.y = type < 0.2 ? 0.0 : (((type < 0.3) || (type > 0.7) )? -size :size); \n"
- " s = sin(cc.b); c = cos(cc.b); \n"
- " gl_FragColor.x = cc.x + c*dxy.x-s*dxy.y;\n"
- " gl_FragColor.y = cc.y + c*dxy.y+s*dxy.x;}\n"
- "}\n\0");
- /*gl_FragColor = vec4(tpos, 0.0, 1.0);}\n\0");*/
-
- _param_genvbo_size = glGetUniformLocation(*program, "sizes");
-
- s_display_gaussian = new ProgramGLSL(
- "uniform sampler2DRect tex; void main(){\n"
- "vec4 pc = texture2DRect(tex, gl_TexCoord[0].xy); bvec2 ff = lessThan(fract(gl_TexCoord[0].xy), vec2(0.5));\n"
- "float v = ff.y?(ff.x? pc.r : pc.g):(ff.x?pc.b:pc.a); gl_FragColor = vec4(vec3(v), 1.0);}");
-
- s_display_dog = new ProgramGLSL(
- "uniform sampler2DRect tex; void main(){\n"
- "vec4 pc = texture2DRect(tex, gl_TexCoord[0].xy); bvec2 ff = lessThan(fract(gl_TexCoord[0].xy), vec2(0.5));\n"
- "float v = ff.y ?(ff.x ? pc.r : pc.g):(ff.x ? pc.b : pc.a);float g = (0.5+20.0*v);\n"
- "gl_FragColor = vec4(g, g, g, 1.0);}" );
-
-
- s_display_grad = new ProgramGLSL(
- "uniform sampler2DRect tex; void main(){\n"
- "vec4 pc = texture2DRect(tex, gl_TexCoord[0].xy); bvec2 ff = lessThan(fract(gl_TexCoord[0].xy), vec2(0.5));\n"
- "float v = ff.y ?(ff.x ? pc.r : pc.g):(ff.x ? pc.b : pc.a); gl_FragColor = vec4(5.0 *vec3(v), 1.0); }");
-
- s_display_keys= new ProgramGLSL(
- "uniform sampler2DRect tex; void main(){\n"
- "vec4 oc = texture2DRect(tex, gl_TexCoord[0].xy); \n"
- "vec4 cc = vec4(equal(abs(oc.rrrr), vec4(1.0, 2.0, 3.0, 4.0))); \n"
- "bvec2 ff = lessThan(fract(gl_TexCoord[0].xy) , vec2(0.5));\n"
- "float v = ff.y ?(ff.x ? cc.r : cc.g):(ff.x ? cc.b : cc.a);\n"
- "if(v == 0.0) discard; \n"
- "else if(oc.r > 0.0) gl_FragColor = vec4(1.0, 0.0, 0,1.0); \n"
- "else gl_FragColor = vec4(0.0,1.0,0.0,1.0); }" );
-}
-
-void ShaderBagPKSL::LoadOrientationShader(void)
-{
- ostringstream out;
- if(GlobalUtil::_IsNvidia)
- {
- out << "#pragma optionNV(ifcvt none)\n"
- "#pragma optionNV(unroll all)\n";
- }
- out<<"\n"
- "#define GAUSSIAN_WF float("<IsNative())
- {
- s_orientation = program ;
- _param_orientation_gtex = glGetUniformLocation(*program, "gtex");
- _param_orientation_otex = glGetUniformLocation(*program, "otex");
- _param_orientation_size = glGetUniformLocation(*program, "size");
- }else
- {
- delete program;
- }
-}
-
-void ShaderBagPKSL::SetGenListStartParam(float width, int tex0)
-{
- glUniform1f(_param_ftex_width, width);
- glUniform1i(_param_genlist_start_tex0, 0);
-}
-
-void ShaderBagPKSL::LoadGenListShader(int ndoglev,int nlev)
-{
- ProgramGLSL * program;
-
- s_genlist_init_tight = new ProgramGLSL(
- "uniform sampler2DRect tex; void main ()\n"
- "{\n"
- " vec4 key = vec4(texture2DRect(tex, gl_TexCoord[0].xy).r, \n"
- " texture2DRect(tex, gl_TexCoord[1].xy).r, \n"
- " texture2DRect(tex, gl_TexCoord[2].xy).r, \n"
- " texture2DRect(tex, gl_TexCoord[3].xy).r); \n"
- " gl_FragColor = vec4(notEqual(key, vec4(0.0))); \n"
- "}");
-
- s_genlist_init_ex = program = new ProgramGLSL(
- "uniform sampler2DRect tex; uniform vec4 bbox; void main ()\n"
- "{\n"
- " vec4 helper1 = vec4(equal(vec4(abs(texture2DRect(tex, gl_TexCoord[0].xy).r)), vec4(1.0, 2.0, 3.0, 4.0)));\n"
- " vec4 helper2 = vec4(equal(vec4(abs(texture2DRect(tex, gl_TexCoord[1].xy).r)), vec4(1.0, 2.0, 3.0, 4.0)));\n"
- " vec4 helper3 = vec4(equal(vec4(abs(texture2DRect(tex, gl_TexCoord[2].xy).r)), vec4(1.0, 2.0, 3.0, 4.0)));\n"
- " vec4 helper4 = vec4(equal(vec4(abs(texture2DRect(tex, gl_TexCoord[3].xy).r)), vec4(1.0, 2.0, 3.0, 4.0)));\n"
- " vec4 bx1 = vec4(lessThan(gl_TexCoord[0].xxyy, bbox)); \n"
- " vec4 bx4 = vec4(lessThan(gl_TexCoord[3].xxyy, bbox)); \n"
- " vec4 bx2 = vec4(bx4.xy, bx1.zw); \n"
- " vec4 bx3 = vec4(bx1.xy, bx4.zw);\n"
- " helper1 = min(min(bx1.xyxy, bx1.zzww), helper1);\n"
- " helper2 = min(min(bx2.xyxy, bx2.zzww), helper2);\n"
- " helper3 = min(min(bx3.xyxy, bx3.zzww), helper3);\n"
- " helper4 = min(min(bx4.xyxy, bx4.zzww), helper4);\n"
- " gl_FragColor.r = float(any(greaterThan(max(helper1.xy, helper1.zw), vec2(0.0)))); \n"
- " gl_FragColor.g = float(any(greaterThan(max(helper2.xy, helper2.zw), vec2(0.0)))); \n"
- " gl_FragColor.b = float(any(greaterThan(max(helper3.xy, helper3.zw), vec2(0.0)))); \n"
- " gl_FragColor.a = float(any(greaterThan(max(helper4.xy, helper4.zw), vec2(0.0)))); \n"
- "}");
- _param_genlist_init_bbox = glGetUniformLocation( *program, "bbox");
-
- s_genlist_end = program = new ProgramGLSL(
- GlobalUtil::_KeepExtremumSign == 0 ?
-
- "uniform sampler2DRect tex; uniform sampler2DRect ktex; void main()\n"
- "{\n"
- " vec4 tc = texture2DRect( tex, gl_TexCoord[0].xy);\n"
- " vec2 pos = tc.rg; float index = tc.b;\n"
- " vec4 tk = texture2DRect( ktex, pos); \n"
- " vec4 keys = vec4(equal(abs(tk.rrrr), vec4(1.0, 2.0, 3.0, 4.0))); \n"
- " vec2 opos; \n"
- " opos.x = dot(keys, vec4(-0.5, 0.5, -0.5, 0.5));\n"
- " opos.y = dot(keys, vec4(-0.5, -0.5, 0.5, 0.5));\n"
- " gl_FragColor = vec4(opos + pos * 2.0 + tk.yz, 1.0, tk.w);\n"
- "}" :
-
- "uniform sampler2DRect tex; uniform sampler2DRect ktex; void main()\n"
- "{\n"
- " vec4 tc = texture2DRect( tex, gl_TexCoord[0].xy);\n"
- " vec2 pos = tc.rg; float index = tc.b;\n"
- " vec4 tk = texture2DRect( ktex, pos); \n"
- " vec4 keys = vec4(equal(abs(tk.rrrr), vec4(1.0, 2.0, 3.0, 4.0))) \n"
- " vec2 opos; \n"
- " opos.x = dot(keys, vec4(-0.5, 0.5, -0.5, 0.5));\n"
- " opos.y = dot(keys, vec4(-0.5, -0.5, 0.5, 0.5));\n"
- " gl_FragColor = vec4(opos + pos * 2.0 + tk.yz, sign(tk.r), tk.w);\n"
- "}"
- );
-
- _param_genlist_end_ktex = glGetUniformLocation(*program, "ktex");
-
- //reduction ...
- s_genlist_histo = new ProgramGLSL(
- "uniform sampler2DRect tex; void main ()\n"
- "{\n"
- " vec4 helper; vec4 helper2; \n"
- " helper = texture2DRect(tex, gl_TexCoord[0].xy); helper2.xy = helper.xy + helper.zw; \n"
- " helper = texture2DRect(tex, gl_TexCoord[1].xy); helper2.zw = helper.xy + helper.zw; \n"
- " gl_FragColor.rg = helper2.xz + helper2.yw;\n"
- " helper = texture2DRect(tex, gl_TexCoord[2].xy); helper2.xy = helper.xy + helper.zw; \n"
- " helper = texture2DRect(tex, gl_TexCoord[3].xy); helper2.zw = helper.xy + helper.zw; \n"
- " gl_FragColor.ba= helper2.xz+helper2.yw;\n"
- "}");
-
-
- //read of the first part, which generates tex coordinates
-
- s_genlist_start= program = ShaderBagGLSL::LoadGenListStepShader(1, 1);
- _param_ftex_width= glGetUniformLocation(*program, "width");
- _param_genlist_start_tex0 = glGetUniformLocation(*program, "tex0");
- //stepping
- s_genlist_step = program = ShaderBagGLSL::LoadGenListStepShader(0, 1);
- _param_genlist_step_tex0= glGetUniformLocation(*program, "tex0");
-
-}
-void ShaderBagPKSL::UnloadProgram(void)
-{
- glUseProgram(0);
-}
-void ShaderBagPKSL::LoadKeypointShader(float dog_threshold, float edge_threshold)
-{
- float threshold0 = dog_threshold* (GlobalUtil::_SubpixelLocalization?0.8f:1.0f);
- float threshold1 = dog_threshold;
- float threshold2 = (edge_threshold+1)*(edge_threshold+1)/edge_threshold;
- ostringstream out;;
- out< float(THRESHOLD0(i)) && all(test1)?1.0: 0.0;\\\n"
- " key[i] = cc[i] < float(-THRESHOLD0(i)) && all(test2)? -1.0: key[i];\\\n"
- " }\n"
- " REPEAT4(KEYTEST_STEP0);\n"
- " if(gl_TexCoord[0].x < 1.0) {key.rb = vec2(0.0);}\n"
- " if(gl_TexCoord[0].y < 1.0) {key.rg = vec2(0.0);}\n"
- " gl_FragColor = vec4(0.0);\n"
- " if(any(notEqual(key, vec4(0.0)))) {\n";
-
- //do edge supression first..
- //vector v1 is < (-1, 0), (1, 0), (0,-1), (0, 1)>
- //vector v2 is < (-1,-1), (-1,1), (1,-1), (1, 1)>
-
- out<<
- " float fxx[4], fyy[4], fxy[4], fx[4], fy[4];\n"
- " #define EDGE_SUPPRESION(i) \\\n"
- " if(key[i] != 0.0)\\\n"
- " {\\\n"
- " vec4 D2 = v1[i].xyzw - cc[i];\\\n"
- " vec2 D4 = v2[i].xw - v2[i].yz;\\\n"
- " vec2 D5 = 0.5*(v1[i].yw-v1[i].xz); \\\n"
- " fx[i] = D5.x; fy[i] = D5.y ;\\\n"
- " fxx[i] = D2.x + D2.y;\\\n"
- " fyy[i] = D2.z + D2.w;\\\n"
- " fxy[i] = 0.25*(D4.x + D4.y);\\\n"
- " float fxx_plus_fyy = fxx[i] + fyy[i];\\\n"
- " float score_up = fxx_plus_fyy*fxx_plus_fyy; \\\n"
- " float score_down = (fxx[i]*fyy[i] - fxy[i]*fxy[i]);\\\n"
- " if( score_down <= 0.0 || score_up > THRESHOLD2 * score_down)key[i] = 0.0;\\\n"
- " }\n"
- " REPEAT4(EDGE_SUPPRESION);\n"
- " if(any(notEqual(key, vec4(0.0)))) {\n";
-
- ////////////////////////////////////////////////
- //read 9 pixels of upper/lower level
- out<<
- " vec4 v4[4], v5[4], v6[4];\n"
- " ccc = texture2DRect(texU, gl_TexCoord[0].xy);\n"
- " clc = texture2DRect(texU, gl_TexCoord[1].xy);\n"
- " crc = texture2DRect(texU, gl_TexCoord[2].xy);\n"
- " ccd = texture2DRect(texU, gl_TexCoord[3].xy);\n"
- " ccu = texture2DRect(texU, gl_TexCoord[4].xy);\n"
- " cld = texture2DRect(texU, gl_TexCoord[5].xy);\n"
- " clu = texture2DRect(texU, gl_TexCoord[6].xy);\n"
- " crd = texture2DRect(texU, gl_TexCoord[7].xy);\n"
- " cru = texture2DRect(texU, TexRU.xy);\n"
- " vec4 cu = ccc;\n"
- " v4[0] = vec4(clc.g, ccc.g, ccd.b, ccc.b);\n"
- " v4[1] = vec4(ccc.r, crc.r, ccd.a, ccc.a);\n"
- " v4[2] = vec4(clc.a, ccc.a, ccc.r, ccu.r);\n"
- " v4[3] = vec4(ccc.b, crc.b, ccc.g, ccu.g);\n"
- " v6[0] = vec4(cld.a, clc.a, ccd.a, ccc.a);\n"
- " v6[1] = vec4(ccd.b, ccc.b, crd.b, crc.b);\n"
- " v6[2] = vec4(clc.g, clu.g, ccc.g, ccu.g);\n"
- " v6[3] = vec4(ccc.r, ccu.r, crc.r, cru.r);\n"
- <<
- " #define KEYTEST_STEP1(i)\\\n"
- " if(key[i] == 1.0)\\\n"
- " {\\\n"
- " bvec4 test = lessThan(vec4(cc[i]), max(v4[i], v6[i])); \\\n"
- " if(cc[i] < cu[i] || any(test))key[i] = 0.0; \\\n"
- " }else if(key[i] == -1.0)\\\n"
- " {\\\n"
- " bvec4 test = greaterThan(vec4(cc[i]), min(v4[i], v6[i])); \\\n"
- " if(cc[i] > cu[i] || any(test) )key[i] = 0.0; \\\n"
- " }\n"
- " REPEAT4(KEYTEST_STEP1);\n"
- " if(any(notEqual(key, vec4(0.0)))) { \n"
- <<
- " ccc = texture2DRect(texD, gl_TexCoord[0].xy);\n"
- " clc = texture2DRect(texD, gl_TexCoord[1].xy);\n"
- " crc = texture2DRect(texD, gl_TexCoord[2].xy);\n"
- " ccd = texture2DRect(texD, gl_TexCoord[3].xy);\n"
- " ccu = texture2DRect(texD, gl_TexCoord[4].xy);\n"
- " cld = texture2DRect(texD, gl_TexCoord[5].xy);\n"
- " clu = texture2DRect(texD, gl_TexCoord[6].xy);\n"
- " crd = texture2DRect(texD, gl_TexCoord[7].xy);\n"
- " cru = texture2DRect(texD, TexRU.xy);\n"
- " vec4 cd = ccc;\n"
- " v5[0] = vec4(clc.g, ccc.g, ccd.b, ccc.b);\n"
- " v5[1] = vec4(ccc.r, crc.r, ccd.a, ccc.a);\n"
- " v5[2] = vec4(clc.a, ccc.a, ccc.r, ccu.r);\n"
- " v5[3] = vec4(ccc.b, crc.b, ccc.g, ccu.g);\n"
- " v6[0] = vec4(cld.a, clc.a, ccd.a, ccc.a);\n"
- " v6[1] = vec4(ccd.b, ccc.b, crd.b, crc.b);\n"
- " v6[2] = vec4(clc.g, clu.g, ccc.g, ccu.g);\n"
- " v6[3] = vec4(ccc.r, ccu.r, crc.r, cru.r);\n"
- <<
- " #define KEYTEST_STEP2(i)\\\n"
- " if(key[i] == 1.0)\\\n"
- " {\\\n"
- " bvec4 test = lessThan(vec4(cc[i]), max(v5[i], v6[i]));\\\n"
- " if(cc[i] < cd[i] || any(test))key[i] = 0.0; \\\n"
- " }else if(key[i] == -1.0)\\\n"
- " {\\\n"
- " bvec4 test = greaterThan(vec4(cc[i]), min(v5[i], v6[i]));\\\n"
- " if(cc[i] > cd[i] || any(test))key[i] = 0.0; \\\n"
- " }\n"
- " REPEAT4(KEYTEST_STEP2);\n"
- " float keysum = dot(abs(key), vec4(1, 1, 1, 1)) ;\n"
- " //assume there is only one keypoint in the four. \n"
- " if(keysum==1.0) {\n";
-
- //////////////////////////////////////////////////////////////////////
- if(GlobalUtil::_SubpixelLocalization)
-
- out <<
- " vec3 offset = vec3(0.0, 0.0, 0.0); \n"
- " #define TESTMOVE_KEYPOINT(idx) \\\n"
- " if(key[idx] != 0.0) \\\n"
- " {\\\n"
- " cu[0] = cu[idx]; cd[0] = cd[idx]; cc[0] = cc[idx]; \\\n"
- " v4[0] = v4[idx]; v5[0] = v5[idx]; \\\n"
- " fxy[0] = fxy[idx]; fxx[0] = fxx[idx]; fyy[0] = fyy[idx]; \\\n"
- " fx[0] = fx[idx]; fy[0] = fy[idx]; MOVE_EXTRA(idx); \\\n"
- " }\n"
- " TESTMOVE_KEYPOINT(1);\n"
- " TESTMOVE_KEYPOINT(2);\n"
- " TESTMOVE_KEYPOINT(3);\n"
- <<
-
- " float fs = 0.5*( cu[0] - cd[0] ); \n"
- " float fss = cu[0] + cd[0] - cc[0] - cc[0];\n"
- " float fxs = 0.25 * (v4[0].y + v5[0].x - v4[0].x - v5[0].y);\n"
- " float fys = 0.25 * (v4[0].w + v5[0].z - v4[0].z - v5[0].w);\n"
- " vec4 A0, A1, A2 ; \n"
- " A0 = vec4(fxx[0], fxy[0], fxs, -fx[0]); \n"
- " A1 = vec4(fxy[0], fyy[0], fys, -fy[0]); \n"
- " A2 = vec4(fxs, fys, fss, -fs); \n"
- " vec3 x3 = abs(vec3(fxx[0], fxy[0], fxs)); \n"
- " float maxa = max(max(x3.x, x3.y), x3.z); \n"
- " if(maxa >= 1e-10 ) \n"
- " { \n"
- " if(x3.y ==maxa ) \n"
- " { \n"
- " vec4 TEMP = A1; A1 = A0; A0 = TEMP; \n"
- " }else if( x3.z == maxa ) \n"
- " { \n"
- " vec4 TEMP = A2; A2 = A0; A0 = TEMP; \n"
- " } \n"
- " A0 /= A0.x; \n"
- " A1 -= A1.x * A0; \n"
- " A2 -= A2.x * A0; \n"
- " vec2 x2 = abs(vec2(A1.y, A2.y)); \n"
- " if( x2.y > x2.x ) \n"
- " { \n"
- " vec3 TEMP = A2.yzw; \n"
- " A2.yzw = A1.yzw; \n"
- " A1.yzw = TEMP; \n"
- " x2.x = x2.y; \n"
- " } \n"
- " if(x2.x >= 1e-10) { \n"
- " A1.yzw /= A1.y; \n"
- " A2.yzw -= A2.y * A1.yzw; \n"
- " if(abs(A2.z) >= 1e-10) {\n"
- " offset.z = A2.w /A2.z; \n"
- " offset.y = A1.w - offset.z*A1.z; \n"
- " offset.x = A0.w - offset.z*A0.z - offset.y*A0.y; \n"
- " bool test = (abs(cc[0] + 0.5*dot(vec3(fx[0], fy[0], fs), offset ))>float(THRESHOLD1)) ;\n"
- " if(!test || any( greaterThan(abs(offset), vec3(1.0)))) key = vec4(0.0);\n"
- " }\n"
- " }\n"
- " }\n"
- <<"\n"
- " float keyv = dot(key, vec4(1.0, 2.0, 3.0, 4.0));\n"
- " gl_FragColor = vec4(keyv, offset);\n"
- " }}}}\n"
- "}\n" <<'\0';
-
- else out << "\n"
- " float keyv = dot(key, vec4(1.0, 2.0, 3.0, 4.0));\n"
- " gl_FragColor = vec4(keyv, 0.0, 0.0, 0.0);\n"
- " }}}}\n"
- "}\n" <<'\0';
-
- ProgramGLSL * program = new ProgramGLSL(out.str().c_str());
- s_keypoint = program ;
-
- //parameter
- _param_dog_texu = glGetUniformLocation(*program, "texU");
- _param_dog_texd = glGetUniformLocation(*program, "texD");
- if(GlobalUtil::_DarknessAdaption) _param_dog_texi = glGetUniformLocation(*program, "texI");
-}
-void ShaderBagPKSL::SetDogTexParam(int texU, int texD)
-{
- glUniform1i(_param_dog_texu, 1);
- glUniform1i(_param_dog_texd, 2);
- if(GlobalUtil::_DarknessAdaption)glUniform1i(_param_dog_texi, 3);
-}
-void ShaderBagPKSL::SetGenListStepParam(int tex, int tex0)
-{
- glUniform1i(_param_genlist_step_tex0, 1);
-}
-
-void ShaderBagPKSL::SetGenVBOParam(float width, float fwidth,float size)
-{
- float sizes[4] = {size*3.0f, fwidth, width, 1.0f/width};
- glUniform4fv(_param_genvbo_size, 1, sizes);
-}
-void ShaderBagPKSL::SetGradPassParam(int texP)
-{
- glUniform1i(_param_grad_pass_texp, 1);
-}
-
-void ShaderBagPKSL::LoadDescriptorShader()
-{
- GlobalUtil::_DescriptorPPT = 16;
- LoadDescriptorShaderF2();
- s_rect_description = LoadDescriptorProgramRECT();
-}
-
-ProgramGLSL* ShaderBagPKSL::LoadDescriptorProgramRECT()
-{
- //one shader outpout 128/8 = 16 , each fragout encodes 4
- //const double twopi = 2.0*3.14159265358979323846;
- //const double rpi = 8.0/twopi;
- ostringstream out;
- out<IsNative())
- {
- return program;
- }
- else
- {
- delete program;
- return NULL;
- }
-}
-
-ProgramGLSL* ShaderBagPKSL::LoadDescriptorProgramPKSL()
-{
- //one shader outpout 128/8 = 16 , each fragout encodes 4
- //const double twopi = 2.0*3.14159265358979323846;
- //const double rpi = 8.0/twopi;
- ostringstream out;
- out< M_PI) anglef -= TWO_PI;\n"
- " float sigma = texture2DRect(tex, coord).w; \n"
- " float spt = abs(sigma * WF); //default to be 3*sigma \n";
- //rotation
- out<<
- " vec4 cscs, rots; \n"
- " cscs.x = cos(anglef); cscs.y = sin(anglef); \n"
- " cscs.zw = - cscs.xy; \n"
- " rots = cscs /spt; \n"
- " cscs *= spt; \n";
-
- //here cscs is actually (cos, sin, -cos, -sin) * (factor: 3)*sigma
- //and rots is (cos, sin, -cos, -sin ) /(factor*sigma)
- //devide the 4x4 sift grid into 16 1x1 block, and each corresponds to a shader thread
- //To use linear interoplation, 1x1 is increased to 2x2, by adding 0.5 to each side
- out<<
- " vec4 temp; vec2 pt, offsetpt; \n"
- " /*the fraction part of idx is .5*/ \n"
- " offsetpt.x = 4.0* fract(idx*0.25) - 2.0; \n"
- " offsetpt.y = floor(idx*0.25) - 1.5; \n"
- " temp = cscs.xwyx*offsetpt.xyxy; \n"
- " pt = pos + temp.xz + temp.yw; \n";
-
- //get a horizontal bounding box of the rotated rectangle
- out<<
- " vec2 bwin = abs(cscs.xy); \n"
- " float bsz = bwin.x + bwin.y; \n"
- " vec4 sz; \n"
- " sz.xy = max(pt - vec2(bsz), vec2(2,2));\n"
- " sz.zw = min(pt + vec2(bsz), dim - vec2(3)); \n"
- " sz = floor(sz * 0.5)+0.5;"; //move sample point to pixel center
- //get voting for two box
-
- out<<"\n"
- " vec4 DA, DB; vec2 spos; \n"
- " DA = DB = vec4(0.0, 0.0, 0.0, 0.0); \n"
- " vec4 nox = vec4(0.0, rots.xy, rots.x + rots.y); \n"
- " vec4 noy = vec4(0.0, rots.wx, rots.w + rots.x); \n"
- " for(spos.y = sz.y; spos.y <= sz.w; spos.y+=1.0) \n"
- " { \n"
- " for(spos.x = sz.x; spos.x <= sz.z; spos.x+=1.0) \n"
- " { \n"
- " vec2 tpt = spos * 2.0 - pt - 0.5; \n"
- " vec4 temp = rots.xywx * tpt.xyxy; \n"
- " vec2 temp2 = temp.xz + temp.yw; \n"
- " vec4 nx = temp2.x + nox; \n"
- " vec4 ny = temp2.y + noy; \n"
- " vec4 nxn = abs(nx), nyn = abs(ny); \n"
- " bvec4 inside = lessThan(max(nxn, nyn) , vec4(1.0)); \n"
- " if(any(inside))\n"
- " {\n"
- " vec4 gg = texture2DRect(gtex, spos);\n"
- " vec4 oo = texture2DRect(otex, spos);\n"
- " vec4 theta0 = (anglef - oo)*RPI;\n"
- " vec4 theta = 8.0 * fract(1.0 + 0.125 * theta0); \n"
- " vec4 theta1 = floor(theta); \n"
- " vec4 diffx = nx + offsetpt.x, diffy = ny + offsetpt.y; \n"
- " vec4 ww = exp(-0.125 * (diffx * diffx + diffy * diffy )); \n"
- " vec4 weight = (vec4(1) - nxn) * (vec4(1) - nyn) * gg * ww; \n"
- " vec4 weight2 = (theta - theta1) * weight; \n"
- " vec4 weight1 = weight - weight2; \n"
- " #define ADD_DESCRIPTOR(i) \\\n"
- " if(inside[i])\\\n"
- " {\\\n"
- " DA += vec4(equal(vec4(theta1[i]), vec4(0, 1, 2, 3)))*weight1[i]; \\\n"
- " DA += vec4(equal(vec4(theta1[i]), vec4(7, 0, 1, 2)))*weight2[i]; \\\n"
- " DB += vec4(equal(vec4(theta1[i]), vec4(4, 5, 6, 7)))*weight1[i]; \\\n"
- " DB += vec4(equal(vec4(theta1[i]), vec4(3, 4, 5, 6)))*weight2[i]; \\\n"
- " }\n"
- " REPEAT4(ADD_DESCRIPTOR);\n"
- " }\n"
- " }\n"
- " }\n";
- out<<
- " gl_FragData[0] = DA; gl_FragData[1] = DB;\n"
- "}\n"<<'\0';
-
- ProgramGLSL * program = new ProgramGLSL(out.str().c_str());
- if(program->IsNative())
- {
- return program;
- }
- else
- {
- delete program;
- return NULL;
- }
-}
-
-void ShaderBagPKSL::LoadDescriptorShaderF2()
-{
-
- ProgramGLSL * program = LoadDescriptorProgramPKSL();
- if( program )
- {
- s_descriptor_fp = program;
- _param_descriptor_gtex = glGetUniformLocation(*program, "gtex");
- _param_descriptor_otex = glGetUniformLocation(*program, "otex");
- _param_descriptor_size = glGetUniformLocation(*program, "size");
- _param_descriptor_dsize = glGetUniformLocation(*program, "dsize");
- }
-}
-
-
-
-void ShaderBagPKSL::SetSimpleOrientationInput(int oTex, float sigma, float sigma_step)
-{
- glUniform1i(_param_orientation_gtex, 1);
- glUniform2f(_param_orientation_size, sigma, sigma_step);
-}
-
-
-void ShaderBagPKSL::SetFeatureOrientationParam(int gtex, int width, int height, float sigma, int otex, float step)
-{
- ///
- glUniform1i(_param_orientation_gtex, 1);
- glUniform1i(_param_orientation_otex, 2);
-
- float size[4];
- size[0] = (float)width;
- size[1] = (float)height;
- size[2] = sigma;
- size[3] = step;
- glUniform4fv(_param_orientation_size, 1, size);
-}
-
-void ShaderBagPKSL::SetFeatureDescirptorParam(int gtex, int otex, float dwidth, float fwidth, float width, float height, float sigma)
-{
- if(sigma == 0 && s_rect_description)
- {
- //rectangle description mode
- s_rect_description->UseProgram();
- GLint param_descriptor_gtex = glGetUniformLocation(*s_rect_description, "gtex");
- GLint param_descriptor_otex = glGetUniformLocation(*s_rect_description, "otex");
- GLint param_descriptor_size = glGetUniformLocation(*s_rect_description, "size");
- GLint param_descriptor_dsize = glGetUniformLocation(*s_rect_description, "dsize");
- ///
- glUniform1i(param_descriptor_gtex, 1);
- glUniform1i(param_descriptor_otex, 2);
-
- float dsize[4] ={dwidth, 1.0f/dwidth, fwidth, 1.0f/fwidth};
- glUniform4fv(param_descriptor_dsize, 1, dsize);
- float size[3];
- size[0] = width;
- size[1] = height;
- size[2] = GlobalUtil::_DescriptorWindowFactor;
- glUniform3fv(param_descriptor_size, 1, size);
- }else
- {
- ///
- glUniform1i(_param_descriptor_gtex, 1);
- glUniform1i(_param_descriptor_otex, 2);
-
-
- float dsize[4] ={dwidth, 1.0f/dwidth, fwidth, 1.0f/fwidth};
- glUniform4fv(_param_descriptor_dsize, 1, dsize);
- float size[3];
- size[0] = width;
- size[1] = height;
- size[2] = GlobalUtil::_DescriptorWindowFactor;
- glUniform3fv(_param_descriptor_size, 1, size);
- }
-
-}
-
-
-void ShaderBagPKSL::SetGenListEndParam(int ktex)
-{
- glUniform1i(_param_genlist_end_ktex, 1);
-}
-void ShaderBagPKSL::SetGenListInitParam(int w, int h)
-{
- float bbox[4] = {(w -1.0f) * 0.5f +0.25f, (w-1.0f) * 0.5f - 0.25f, (h - 1.0f) * 0.5f + 0.25f, (h-1.0f) * 0.5f - 0.25f};
- glUniform4fv(_param_genlist_init_bbox, 1, bbox);
-}
-
-void ShaderBagPKSL::SetMarginCopyParam(int xmax, int ymax)
-{
- float truncate[4];
- truncate[0] = (xmax - 0.5f) * 0.5f; //((xmax + 1) >> 1) - 0.5f;
- truncate[1] = (ymax - 0.5f) * 0.5f; //((ymax + 1) >> 1) - 0.5f;
- truncate[2] = (xmax %2 == 1)? 0.0f: 1.0f;
- truncate[3] = truncate[2] + (((ymax % 2) == 1)? 0.0f : 2.0f);
- glUniform4fv(_param_margin_copy_truncate, 1, truncate);
-}
diff --git a/3rdparty/SiftGPU/src/SiftGPU/ProgramGLSL.h b/3rdparty/SiftGPU/src/SiftGPU/ProgramGLSL.h
deleted file mode 100644
index cc949539..00000000
--- a/3rdparty/SiftGPU/src/SiftGPU/ProgramGLSL.h
+++ /dev/null
@@ -1,267 +0,0 @@
-////////////////////////////////////////////////////////////////////////////
-// File: ProgramGLSL.h
-// Author: Changchang Wu
-// Description : Interface for ProgramGLSL classes
-// ProgramGLSL: Glsl Program
-// FilterGLSL: Glsl Gaussian Filters
-// ShaderBag: base class of ShaderBagPKSL and ShaderBagGLSL
-//
-// Copyright (c) 2007 University of North Carolina at Chapel Hill
-// All Rights Reserved
-//
-// Permission to use, copy, modify and distribute this software and its
-// documentation for educational, research and non-profit purposes, without
-// fee, and without a written agreement is hereby granted, provided that the
-// above copyright notice and the following paragraph appear in all copies.
-//
-// The University of North Carolina at Chapel Hill make no representations
-// about the suitability of this software for any purpose. It is provided
-// 'as is' without express or implied warranty.
-//
-// Please send BUG REPORTS to ccwu@cs.unc.edu
-//
-////////////////////////////////////////////////////////////////////////////
-
-
-#ifndef _PROGRAM_GLSL_H
-#define _PROGRAM_GLSL_H
-
-
-#include "ProgramGPU.h"
-
-class ProgramGLSL:public ProgramGPU
-{
- class ShaderObject
- {
- GLuint _shaderID;
- int _type;
- int _compiled;
- static int ReadShaderFile(const char * source, char *& code);
- void CheckCompileLog();
- public:
- void PrintCompileLog(ostream & os );
- int inline IsValidShaderObject(){ return _shaderID && _compiled;}
- int IsValidVertexShader();
- int IsValidFragmentShader();
- GLuint GetShaderID(){return _shaderID;}
- ~ShaderObject();
- ShaderObject(int shadertype, const char * source, int filesource =0);
- };
-
-protected:
- int _linked;
- GLint _TextureParam0;
- GLuint _programID;
-private:
- void AttachShaderObject(ShaderObject& shader);
- void DetachShaderObject(ShaderObject& shader);
-
-public:
- void ReLink();
- int IsNative();
- int UseProgram();
- void PrintLinkLog(std::ostream&os);
- int ValidateProgram();
- void CheckLinkLog();
- int LinkProgram();
- operator GLuint (){return _programID;}
- virtual void * GetProgramID() { return (void*) _programID; }
-public:
- ProgramGLSL();
- ~ProgramGLSL();
- ProgramGLSL(const char* frag_source);
-};
-
-
-class GLTexImage;
-class FilterGLSL : public FilterProgram
-{
-private:
- ProgramGPU* CreateFilterH(float kernel[], int width);
- ProgramGPU* CreateFilterV(float kernel[], int height);
- ProgramGPU* CreateFilterHPK(float kernel[], int width);
- ProgramGPU* CreateFilterVPK(float kernel[], int height);
-public:
- void MakeFilterProgram(float kernel[], int width);
-public:
- FilterGLSL(float sigma) ;
-};
-
-class SiftParam;
-
-/////////////////////////////////////////////////////////////////////////////////
-//class ShaderBag
-//desciption: pure virtual class
-// provides storage and usage interface of all the shaders for SIFT
-// two implementations are ShaderBagPKSL and ShaderBagGLSL
-/////////////////////////////////////////////////////////////////////////////////
-class ShaderBag
-{
-public:
- //shader: rgb to gray
- ProgramGPU * s_gray;
- //shader: copy keypoint to PBO
- ProgramGPU * s_copy_key;
- //shader: debug view
- ProgramGPU * s_debug;
- //shader: orientation
- //shader: assign simple orientation to keypoints if hardware is low
- ProgramGPU * s_orientation;
- //shader: display gaussian levels
- ProgramGPU * s_display_gaussian;
- //shader: display difference of gassian
- ProgramGPU * s_display_dog;
- //shader: display gradient
- ProgramGPU * s_display_grad;
- //shader: display keypoints as red(maximum) and blue (minimum)
- ProgramGPU * s_display_keys;
- //shader: up/down-sample
- ProgramGPU * s_sampling;
- //shader: compute gradient/dog
- ProgramGPU * s_grad_pass;
- ProgramGPU * s_dog_pass;
- //shader: keypoint detection in one pass
- ProgramGPU * s_keypoint;
- ProgramGPU * s_seperate_sp;
- //shader: feature list generations..
- ProgramGPU * s_genlist_init_tight;
- ProgramGPU * s_genlist_init_ex;
- ProgramGPU * s_genlist_histo;
- ProgramGPU * s_genlist_start;
- ProgramGPU * s_genlist_step;
- ProgramGPU * s_genlist_end;
- ProgramGPU * s_zero_pass;
- //shader: generate vertex to display SIFT as a square
- ProgramGPU * s_vertex_list;
- //shader: descriptor
- ProgramGPU * s_descriptor_fp;
- //shader: copy pixels to margin
- ProgramGPU * s_margin_copy;
-public:
- FilterProgram * f_gaussian_skip0;
- vector f_gaussian_skip0_v;
- FilterProgram * f_gaussian_skip1;
- FilterProgram ** f_gaussian_step;
- int _gaussian_step_num;
-public:
- virtual void SetGenListInitParam(int w, int h){};
- virtual void SetGenListEndParam(int ktex){};
- virtual void SetMarginCopyParam(int xmax, int ymax){};
- virtual void LoadDescriptorShader(){};
- virtual void SetFeatureDescirptorParam(int gtex, int otex, float dwidth, float fwidth, float width, float height, float sigma){};
- virtual void SetFeatureOrientationParam(int gtex, int width, int height, float sigma, int stex, float step){};
- virtual void SetSimpleOrientationInput(int oTex, float sigma, float sigma_step){};
- virtual void LoadOrientationShader() =0;
- virtual void SetGenListStartParam(float width, int tex0) =0;
- virtual void LoadGenListShader(int ndoglev, int nlev)=0;
- virtual void UnloadProgram()=0;
- virtual void LoadKeypointShader(float threshold, float edgeTrheshold) = 0;
- virtual void LoadFixedShaders()=0;
- virtual void LoadDisplayShaders() = 0;
- virtual void SetDogTexParam(int texU, int texD)=0;
- virtual void SetGradPassParam(int texP=0){}
- virtual void SetGenListStepParam(int tex, int tex0) = 0;
- virtual void SetGenVBOParam( float width, float fwidth, float size)=0;
-public:
- void CreateGaussianFilters(SiftParam¶m);
- void SelectInitialSmoothingFilter(int octave_min, SiftParam¶m);
- void LoadDynamicShaders(SiftParam& param);
- ShaderBag();
- virtual ~ShaderBag();
-};
-
-
-class ShaderBagGLSL:public ShaderBag
-{
- GLint _param_dog_texu;
- GLint _param_dog_texd;
- GLint _param_ftex_width;
- GLint _param_genlist_start_tex0;
- GLint _param_genlist_step_tex0;
- GLint _param_genvbo_size;
- GLint _param_orientation_gtex;
- GLint _param_orientation_size;
- GLint _param_orientation_stex;
- GLint _param_margin_copy_truncate;
- GLint _param_genlist_init_bbox;
- GLint _param_descriptor_gtex;
- GLint _param_descriptor_size;
- GLint _param_descriptor_dsize;
-public:
- virtual void SetMarginCopyParam(int xmax, int ymax);
- void SetSimpleOrientationInput(int oTex, float sigma, float sigma_step);
- void LoadOrientationShader();
- void LoadDescriptorShaderF2();
- virtual void LoadDescriptorShader();
- virtual void SetFeatureOrientationParam(int gtex, int width, int height, float sigma, int stex = 0, float step = 1.0f);
- virtual void SetFeatureDescirptorParam(int gtex, int otex, float dwidth, float fwidth, float width, float height, float sigma);
- static void WriteOrientationCodeToStream(ostream& out);
- static ProgramGLSL* LoadGenListStepShader(int start, int step);
- virtual void SetGenListInitParam(int w, int h);
- virtual void SetGenListStartParam(float width, int tex0);
- virtual void LoadGenListShader(int ndoglev, int nlev);
- virtual void UnloadProgram();
- virtual void LoadKeypointShader(float threshold, float edgeTrheshold);
- virtual void LoadFixedShaders();
- virtual void LoadDisplayShaders();
- virtual void SetDogTexParam(int texU, int texD);
- virtual void SetGenListStepParam(int tex, int tex0);
- virtual void SetGenVBOParam( float width, float fwidth, float size);
- virtual ~ShaderBagGLSL(){}
-};
-
-
-class ShaderBagPKSL:public ShaderBag
-{
-private:
- GLint _param_dog_texu;
- GLint _param_dog_texd;
- GLint _param_dog_texi;
- GLint _param_margin_copy_truncate;
- GLint _param_grad_pass_texp;
- GLint _param_genlist_init_bbox;
- GLint _param_genlist_start_tex0;
- GLint _param_ftex_width;
- GLint _param_genlist_step_tex0;
- GLint _param_genlist_end_ktex;
- GLint _param_genvbo_size;
- GLint _param_orientation_gtex;
- GLint _param_orientation_otex;
- GLint _param_orientation_size;
- GLint _param_descriptor_gtex;
- GLint _param_descriptor_otex;
- GLint _param_descriptor_size;
- GLint _param_descriptor_dsize;
-
- //
- ProgramGLSL* s_rect_description;
-public:
- ShaderBagPKSL () {s_rect_description = NULL; }
- virtual ~ShaderBagPKSL() {if(s_rect_description) delete s_rect_description; }
- virtual void LoadFixedShaders();
- virtual void LoadDisplayShaders();
- virtual void LoadOrientationShader() ;
- virtual void SetGenListStartParam(float width, int tex0) ;
- virtual void LoadGenListShader(int ndoglev, int nlev);
- virtual void UnloadProgram();
- virtual void LoadKeypointShader(float threshold, float edgeTrheshold) ;
- virtual void LoadDescriptorShader();
- virtual void LoadDescriptorShaderF2();
- static ProgramGLSL* LoadDescriptorProgramRECT();
- static ProgramGLSL* LoadDescriptorProgramPKSL();
-/////////////////
- virtual void SetDogTexParam(int texU, int texD);
- virtual void SetGradPassParam(int texP);
- virtual void SetGenListStepParam(int tex, int tex0);
- virtual void SetGenVBOParam( float width, float fwidth, float size);
- virtual void SetFeatureDescirptorParam(int gtex, int otex, float dwidth, float fwidth, float width, float height, float sigma);
- virtual void SetFeatureOrientationParam(int gtex, int width, int height, float sigma, int stex, float step);
- virtual void SetSimpleOrientationInput(int oTex, float sigma, float sigma_step);
- virtual void SetGenListEndParam(int ktex);
- virtual void SetGenListInitParam(int w, int h);
- virtual void SetMarginCopyParam(int xmax, int ymax);
-};
-
-
-#endif
-
diff --git a/3rdparty/SiftGPU/src/SiftGPU/ProgramGPU.cpp b/3rdparty/SiftGPU/src/SiftGPU/ProgramGPU.cpp
deleted file mode 100644
index c5a03ec8..00000000
--- a/3rdparty/SiftGPU/src/SiftGPU/ProgramGPU.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-////////////////////////////////////////////////////////////////////////////
-// File: ProgramGPU.cpp
-// Author: Changchang Wu
-// Description : Implementation of ProgramGPU and FilterProgram
-// This part is independent of GPU language
-//
-//
-//
-// Copyright (c) 2007 University of North Carolina at Chapel Hill
-// All Rights Reserved
-//
-// Permission to use, copy, modify and distribute this software and its
-// documentation for educational, research and non-profit purposes, without
-// fee, and without a written agreement is hereby granted, provided that the
-// above copyright notice and the following paragraph appear in all copies.
-//
-// The University of North Carolina at Chapel Hill make no representations
-// about the suitability of this software for any purpose. It is provided
-// 'as is' without express or implied warranty.
-//
-// Please send BUG REPORTS to ccwu@cs.unc.edu
-//
-////////////////////////////////////////////////////////////////////////////
-
-
-#include "GL/glew.h"
-#include
-#include
-#include
-using namespace std;
-
-#include "GlobalUtil.h"
-#include "GLTexImage.h"
-#include "ShaderMan.h"
-#include "ProgramGPU.h"
-#include "ProgramGLSL.h"
-#include "SiftGPU.h"
-
diff --git a/3rdparty/SiftGPU/src/SiftGPU/ProgramGPU.h b/3rdparty/SiftGPU/src/SiftGPU/ProgramGPU.h
deleted file mode 100644
index 203e52db..00000000
--- a/3rdparty/SiftGPU/src/SiftGPU/ProgramGPU.h
+++ /dev/null
@@ -1,59 +0,0 @@
-////////////////////////////////////////////////////////////////////////////
-// File: ProgramGPU.h
-// Author: Changchang Wu
-// Description : Based class for GPU programs
-// ProgramGPU: base class of ProgramGLSL
-// FilterProgram: base class of FilterGLSL, FilterPKSL
-//
-// Copyright (c) 2007 University of North Carolina at Chapel Hill
-// All Rights Reserved
-//
-// Permission to use, copy, modify and distribute this software and its
-// documentation for educational, research and non-profit purposes, without
-// fee, and without a written agreement is hereby granted, provided that the
-// above copyright notice and the following paragraph appear in all copies.
-//
-// The University of North Carolina at Chapel Hill make no representations
-// about the suitability of this software for any purpose. It is provided
-// 'as is' without express or implied warranty.
-//
-// Please send BUG REPORTS to ccwu@cs.unc.edu
-//
-////////////////////////////////////////////////////////////////////////////
-
-
-#ifndef _PROGRAM_GPU_H
-#define _PROGRAM_GPU_H
-
-////////////////////////////////////////////////////////////////////////////
-//class ProgramGPU
-//description: pure virtual class
-// provides a common interface for shader programs
-///////////////////////////////////////////////////////////////////////////
-class ProgramGPU
-{
-public:
- //use a gpu program
- virtual int UseProgram() = 0;
- virtual void* GetProgramID() = 0;
- //not used
- virtual ~ProgramGPU(){};
-};
-
-///////////////////////////////////////////////////////////////////////////
-//class FilterProgram
-///////////////////////////////////////////////////////////////////////////
-class FilterProgram
-{
-public:
- ProgramGPU* s_shader_h;
- ProgramGPU* s_shader_v;
- int _size;
- int _id;
-public:
- FilterProgram() { s_shader_h = s_shader_v = NULL; _size = _id = 0; }
- virtual ~FilterProgram() { if(s_shader_h) delete s_shader_h; if(s_shader_v) delete s_shader_v;}
-};
-
-#endif
-
diff --git a/3rdparty/SiftGPU/src/SiftGPU/PyramidCL.cpp b/3rdparty/SiftGPU/src/SiftGPU/PyramidCL.cpp
deleted file mode 100644
index 3d8d82ae..00000000
--- a/3rdparty/SiftGPU/src/SiftGPU/PyramidCL.cpp
+++ /dev/null
@@ -1,1132 +0,0 @@
-////////////////////////////////////////////////////////////////////////////
-// File: PyramidCL.cpp
-// Author: Changchang Wu
-// Description : implementation of the PyramidCL class.
-// OpenCL-based implementation of SiftPyramid
-//
-// Copyright (c) 2007 University of North Carolina at Chapel Hill
-// All Rights Reserved
-//
-// Permission to use, copy, modify and distribute this software and its
-// documentation for educational, research and non-profit purposes, without
-// fee, and without a written agreement is hereby granted, provided that the
-// above copyright notice and the following paragraph appear in all copies.
-//
-// The University of North Carolina at Chapel Hill make no representations
-// about the suitability of this software for any purpose. It is provided
-// 'as is' without express or implied warranty.
-//
-// Please send BUG REPORTS to ccwu@cs.unc.edu
-//
-////////////////////////////////////////////////////////////////////////////
-
-#if defined(CL_SIFTGPU_ENABLED)
-
-
-#include "GL/glew.h"
-#include
-#include
-#include
-#include
-#include
-#include
-using namespace std;
-
-#include "GlobalUtil.h"
-#include "GLTexImage.h"
-#include "CLTexImage.h"
-#include "SiftGPU.h"
-#include "SiftPyramid.h"
-#include "ProgramCL.h"
-#include "PyramidCL.h"
-
-
-#define USE_TIMING() double t, t0, tt;
-#define OCTAVE_START() if(GlobalUtil::_timingO){ t = t0 = CLOCK(); cout<<"#"<FinishCL(); tt = CLOCK();cout<<(tt-t)<<"\t"; t = CLOCK();}
-#define OCTAVE_FINISH() if(GlobalUtil::_timingO)cout<<"|\t"<<(CLOCK()-t0)<InitProgramBag(sp);
- _inputTex = new CLTexImage( _OpenCL->GetContextCL(),
- _OpenCL->GetCommandQueue());
- /////////////////////////
- InitializeContext();
-}
-
-PyramidCL::~PyramidCL()
-{
- DestroyPerLevelData();
- DestroySharedData();
- DestroyPyramidData();
- if(_OpenCL) delete _OpenCL;
- if(_inputTex) delete _inputTex;
- if(_bufferTEX) delete _bufferTEX;
-}
-
-void PyramidCL::InitializeContext()
-{
- GlobalUtil::InitGLParam(1);
-}
-
-void PyramidCL::InitPyramid(int w, int h, int ds)
-{
- int wp, hp, toobig = 0;
- if(ds == 0)
- {
- _down_sample_factor = 0;
- if(GlobalUtil::_octave_min_default>=0)
- {
- wp = w >> _octave_min_default;
- hp = h >> _octave_min_default;
- }else
- {
- //can't upsample by more than 8
- _octave_min_default = max(-3, _octave_min_default);
- //
- wp = w << (-_octave_min_default);
- hp = h << (-_octave_min_default);
- }
- _octave_min = _octave_min_default;
- }else
- {
- //must use 0 as _octave_min;
- _octave_min = 0;
- _down_sample_factor = ds;
- w >>= ds;
- h >>= ds;
- wp = w;
- hp = h;
- }
-
- while(wp > GlobalUtil::_texMaxDim || hp > GlobalUtil::_texMaxDim )
- {
- _octave_min ++;
- wp >>= 1;
- hp >>= 1;
- toobig = 1;
- }
- if(toobig && GlobalUtil::_verbose && _octave_min > 0)
- {
- std::cout<< "**************************************************************\n"
- "Image larger than allowed dimension, data will be downsampled!\n"
- "use -maxd to change the settings\n"
- "***************************************************************\n";
- }
-
- if( wp == _pyramid_width && hp == _pyramid_height && _allocated )
- {
- FitPyramid(wp, hp);
- }else if(GlobalUtil::_ForceTightPyramid || _allocated ==0)
- {
- ResizePyramid(wp, hp);
- }
- else if( wp > _pyramid_width || hp > _pyramid_height )
- {
- ResizePyramid(max(wp, _pyramid_width), max(hp, _pyramid_height));
- if(wp < _pyramid_width || hp < _pyramid_height) FitPyramid(wp, hp);
- }
- else
- {
- //try use the pyramid allocated for large image on small input images
- FitPyramid(wp, hp);
- }
-
- _OpenCL->SelectInitialSmoothingFilter(_octave_min + _down_sample_factor, param);
-}
-
-void PyramidCL::ResizePyramid(int w, int h)
-{
- //
- unsigned int totalkb = 0;
- int _octave_num_new, input_sz, i, j;
- //
-
- if(_pyramid_width == w && _pyramid_height == h && _allocated) return;
-
- if(w > GlobalUtil::_texMaxDim || h > GlobalUtil::_texMaxDim) return ;
-
- if(GlobalUtil::_verbose && GlobalUtil::_timingS) std::cout<<"[Allocate Pyramid]:\t" <0)
- {
- DestroyPerLevelData();
- DestroyPyramidData();
- }
- _pyramid_octave_num = _octave_num_new;
- }
-
- _octave_num = _pyramid_octave_num;
-
- int noct = _octave_num;
- int nlev = param._level_num;
- int texNum = noct* nlev * DATA_NUM;
-
- // //initialize the pyramid
- if(_allPyramid==NULL)
- {
- _allPyramid = new CLTexImage[ texNum];
- cl_context context = _OpenCL->GetContextCL();
- cl_command_queue queue = _OpenCL->GetCommandQueue();
- for(i = 0; i < texNum; ++i) _allPyramid[i].SetContext(context, queue);
- }
-
-
-
- CLTexImage * gus = GetBaseLevel(_octave_min, DATA_GAUSSIAN);
- CLTexImage * dog = GetBaseLevel(_octave_min, DATA_DOG);
- CLTexImage * grd = GetBaseLevel(_octave_min, DATA_GRAD);
- CLTexImage * rot = GetBaseLevel(_octave_min, DATA_ROT);
- CLTexImage * key = GetBaseLevel(_octave_min, DATA_KEYPOINT);
-
- ////////////there could be "out of memory" happening during the allocation
-
-
-
- for(i = 0; i< noct; i++)
- {
- for( j = 0; j< nlev; j++, gus++, dog++, grd++, rot++, key++)
- {
- gus->InitPackedTex(w, h, GlobalUtil::_usePackedTex);
- if(j==0)continue;
- dog->InitPackedTex(w, h, GlobalUtil::_usePackedTex);
- if(j < 1 + param._dog_level_num)
- {
- grd->InitPackedTex(w, h, GlobalUtil::_usePackedTex);
- rot->InitPackedTex(w, h, GlobalUtil::_usePackedTex);
- }
- if(j > 1 && j < nlev -1) key->InitPackedTex(w, h, GlobalUtil::_usePackedTex);
- }
- ////////////////////////////////////////
- int tsz = (gus -1)->GetTexPixelCount() * 16;
- totalkb += ((nlev *5 -6)* tsz / 1024);
- //several auxilary textures are not actually required
- w>>=1;
- h>>=1;
- }
-
- totalkb += ResizeFeatureStorage();
-
- _allocated = 1;
-
- if(GlobalUtil::_verbose && GlobalUtil::_timingS) std::cout<<"[Allocate Pyramid]:\t" <<(totalkb/1024)<<"MB\n";
-
-}
-
-void PyramidCL::FitPyramid(int w, int h)
-{
- _pyramid_octave_first = 0;
- //
- _octave_num = GlobalUtil::_octave_num_default;
-
- int _octave_num_max = GetRequiredOctaveNum(min(w, h));
-
- if(_octave_num < 1 || _octave_num > _octave_num_max)
- {
- _octave_num = _octave_num_max;
- }
-
-
- int pw = _pyramid_width>>1, ph = _pyramid_height>>1;
- while(_pyramid_octave_first + _octave_num < _pyramid_octave_num &&
- pw >= w && ph >= h)
- {
- _pyramid_octave_first++;
- pw >>= 1;
- ph >>= 1;
- }
-
- //////////////////
- for(int i = 0; i < _octave_num; i++)
- {
- CLTexImage * tex = GetBaseLevel(i + _octave_min);
- CLTexImage * dog = GetBaseLevel(i + _octave_min, DATA_DOG);
- CLTexImage * grd = GetBaseLevel(i + _octave_min, DATA_GRAD);
- CLTexImage * rot = GetBaseLevel(i + _octave_min, DATA_ROT);
- CLTexImage * key = GetBaseLevel(i + _octave_min, DATA_KEYPOINT);
- for(int j = param._level_min; j <= param._level_max; j++, tex++, dog++, grd++, rot++, key++)
- {
- tex->SetPackedSize(w, h, GlobalUtil::_usePackedTex);
- if(j == param._level_min) continue;
- dog->SetPackedSize(w, h, GlobalUtil::_usePackedTex);
- if(j < param._level_max - 1)
- {
- grd->SetPackedSize(w, h, GlobalUtil::_usePackedTex);
- rot->SetPackedSize(w, h, GlobalUtil::_usePackedTex);
- }
- if(j > param._level_min + 1 && j < param._level_max) key->SetPackedSize(w, h, GlobalUtil::_usePackedTex);
- }
- w>>=1;
- h>>=1;
- }
-}
-
-
-void PyramidCL::SetLevelFeatureNum(int idx, int fcount)
-{
- _featureTex[idx].InitBufferTex(fcount, 1, 4);
- _levelFeatureNum[idx] = fcount;
-}
-
-int PyramidCL::ResizeFeatureStorage()
-{
- int totalkb = 0;
- if(_levelFeatureNum==NULL) _levelFeatureNum = new int[_octave_num * param._dog_level_num];
- std::fill(_levelFeatureNum, _levelFeatureNum+_octave_num * param._dog_level_num, 0);
-
- cl_context context = _OpenCL->GetContextCL();
- cl_command_queue queue = _OpenCL->GetCommandQueue();
- int wmax = GetBaseLevel(_octave_min)->GetImgWidth() * 2;
- int hmax = GetBaseLevel(_octave_min)->GetImgHeight() * 2;
- int whmax = max(wmax, hmax);
- int w, i;
-
- //
- int num = (int)ceil(log(double(whmax))/log(4.0));
-
- if( _hpLevelNum != num)
- {
- _hpLevelNum = num;
- if(_histoPyramidTex ) delete [] _histoPyramidTex;
- _histoPyramidTex = new CLTexImage[_hpLevelNum];
- for(i = 0; i < _hpLevelNum; ++i) _histoPyramidTex[i].SetContext(context, queue);
- }
-
- for(i = 0, w = 1; i < _hpLevelNum; i++)
- {
- _histoPyramidTex[i].InitBufferTex(w, whmax, 4);
- w<<=2;
- }
-
- // (4 ^ (_hpLevelNum) -1 / 3) pixels
- totalkb += (((1 << (2 * _hpLevelNum)) -1) / 3 * 16 / 1024);
-
- //initialize the feature texture
- int idx = 0, n = _octave_num * param._dog_level_num;
- if(_featureTex==NULL)
- {
- _featureTex = new CLTexImage[n];
- for(i = 0; i 1 && GlobalUtil::_OrientationPack2==0 && _orientationTex== NULL)
- {
- _orientationTex = new CLTexImage[n];
- for(i = 0; i < n; ++i) _orientationTex[i].SetContext(context, queue);
- }
-
-
- for(i = 0; i < _octave_num; i++)
- {
- CLTexImage * tex = GetBaseLevel(i+_octave_min);
- int fmax = int(4 * tex->GetTexWidth() * tex->GetTexHeight()*GlobalUtil::_MaxFeaturePercent);
- //
- if(fmax > GlobalUtil::_MaxLevelFeatureNum) fmax = GlobalUtil::_MaxLevelFeatureNum;
- else if(fmax < 32) fmax = 32; //give it at least a space of 32 feature
-
- for(int j = 0; j < param._dog_level_num; j++, idx++)
- {
- _featureTex[idx].InitBufferTex(fmax, 1, 4);
- totalkb += fmax * 16 /1024;
- //
- if(GlobalUtil::_MaxOrientation>1 && GlobalUtil::_OrientationPack2 == 0)
- {
- _orientationTex[idx].InitBufferTex(fmax, 1, 4);
- totalkb += fmax * 16 /1024;
- }
- }
- }
-
- //this just need be initialized once
- if(_descriptorTex==NULL)
- {
- //initialize feature texture pyramid
- int fmax = _featureTex->GetImgWidth();
- _descriptorTex = new CLTexImage(context, queue);
- totalkb += ( fmax /2);
- _descriptorTex->InitBufferTex(fmax *128, 1, 1);
- }else
- {
- totalkb += _descriptorTex->GetDataSize()/1024;
- }
- return totalkb;
-}
-
-void PyramidCL::GetFeatureDescriptors()
-{
- //descriptors...
- /*float* pd = &_descriptor_buffer[0];
- vector descriptor_buffer2;
-
- //use another buffer if we need to re-order the descriptors
- if(_keypoint_index.size() > 0)
- {
- descriptor_buffer2.resize(_descriptor_buffer.size());
- pd = &descriptor_buffer2[0];
- }
-
- CLTexImage * got, * ftex= _featureTex;
- for(int i = 0, idx = 0; i < _octave_num; i++)
- {
- got = GetBaseLevel(i + _octave_min, DATA_GRAD) + 1;
- for(int j = 0; j < param._dog_level_num; j++, ftex++, idx++, got++)
- {
- if(_levelFeatureNum[idx]==0) continue;
- ProgramCL::ComputeDescriptor(ftex, got, _descriptorTex);//process
- _descriptorTex->CopyToHost(pd); //readback descriptor
- pd += 128*_levelFeatureNum[idx];
- }
- }
-
- if(GlobalUtil::_timingS) _OpenCL->FinishCL();
-
- if(_keypoint_index.size() > 0)
- {
- //put the descriptor back to the original order for keypoint list.
- for(int i = 0; i < _featureNum; ++i)
- {
- int index = _keypoint_index[i];
- memcpy(&_descriptor_buffer[index*128], &descriptor_buffer2[i*128], 128 * sizeof(float));
- }
- }*/
-}
-
-void PyramidCL::GenerateFeatureListTex()
-{
-
- vector list;
- int idx = 0;
- const double twopi = 2.0*3.14159265358979323846;
- float sigma_half_step = powf(2.0f, 0.5f / param._dog_level_num);
- float octave_sigma = _octave_min>=0? float(1<<_octave_min): 1.0f/(1<<(-_octave_min));
- float offset = GlobalUtil::_LoweOrigin? 0 : 0.5f;
- if(_down_sample_factor>0) octave_sigma *= float(1<<_down_sample_factor);
-
- _keypoint_index.resize(0); // should already be 0
- for(int i = 0; i < _octave_num; i++, octave_sigma*= 2.0f)
- {
- for(int j = 0; j < param._dog_level_num; j++, idx++)
- {
- list.resize(0);
- float level_sigma = param.GetLevelSigma(j + param._level_min + 1) * octave_sigma;
- float sigma_min = level_sigma / sigma_half_step;
- float sigma_max = level_sigma * sigma_half_step;
- int fcount = 0 ;
- for(int k = 0; k < _featureNum; k++)
- {
- float * key = &_keypoint_buffer[k*4];
- if( (key[2] >= sigma_min && key[2] < sigma_max)
- ||(key[2] < sigma_min && i ==0 && j == 0)
- ||(key[2] > sigma_max && i == _octave_num -1 && j == param._dog_level_num - 1))
- {
- //add this keypoint to the list
- list.push_back((key[0] - offset) / octave_sigma + 0.5f);
- list.push_back((key[1] - offset) / octave_sigma + 0.5f);
- list.push_back(key[2] / octave_sigma);
- list.push_back((float)fmod(twopi-key[3], twopi));
- fcount ++;
- //save the index of keypoints
- _keypoint_index.push_back(k);
- }
-
- }
-
- _levelFeatureNum[idx] = fcount;
- if(fcount==0)continue;
- CLTexImage * ftex = _featureTex+idx;
-
- SetLevelFeatureNum(idx, fcount);
- ftex->CopyFromHost(&list[0]);
- }
- }
-
- if(GlobalUtil::_verbose)
- {
- std::cout<<"#Features:\t"<<_featureNum<<"\n";
- }
-
-}
-
-void PyramidCL::ReshapeFeatureListCPU()
-{
- int i, szmax =0, sz;
- int n = param._dog_level_num*_octave_num;
- for( i = 0; i < n; i++)
- {
- sz = _levelFeatureNum[i];
- if(sz > szmax ) szmax = sz;
- }
- float * buffer = new float[szmax*16];
- float * buffer1 = buffer;
- float * buffer2 = buffer + szmax*4;
-
-
-
- _featureNum = 0;
-
-#ifdef NO_DUPLICATE_DOWNLOAD
- const double twopi = 2.0*3.14159265358979323846;
- _keypoint_buffer.resize(0);
- float os = _octave_min>=0? float(1<<_octave_min): 1.0f/(1<<(-_octave_min));
- if(_down_sample_factor>0) os *= float(1<<_down_sample_factor);
- float offset = GlobalUtil::_LoweOrigin? 0 : 0.5f;
-#endif
-
-
- for(i = 0; i < n; i++)
- {
- if(_levelFeatureNum[i]==0)continue;
-
- _featureTex[i].CopyToHost(buffer1);
-
- int fcount =0;
- float * src = buffer1;
- float * des = buffer2;
- const static double factor = 2.0*3.14159265358979323846/65535.0;
- for(int j = 0; j < _levelFeatureNum[i]; j++, src+=4)
- {
- unsigned short * orientations = (unsigned short*) (&src[3]);
- if(orientations[0] != 65535)
- {
- des[0] = src[0];
- des[1] = src[1];
- des[2] = src[2];
- des[3] = float( factor* orientations[0]);
- fcount++;
- des += 4;
- if(orientations[1] != 65535 && orientations[1] != orientations[0])
- {
- des[0] = src[0];
- des[1] = src[1];
- des[2] = src[2];
- des[3] = float(factor* orientations[1]);
- fcount++;
- des += 4;
- }
- }
- }
- //texture size
- SetLevelFeatureNum(i, fcount);
- _featureTex[i].CopyFromHost(buffer2);
-
- if(fcount == 0) continue;
-
-#ifdef NO_DUPLICATE_DOWNLOAD
- float oss = os * (1 << (i / param._dog_level_num));
- _keypoint_buffer.resize((_featureNum + fcount) * 4);
- float* ds = &_keypoint_buffer[_featureNum * 4];
- float* fs = buffer2;
- for(int k = 0; k < fcount; k++, ds+=4, fs+=4)
- {
- ds[0] = oss*(fs[0]-0.5f) + offset; //x
- ds[1] = oss*(fs[1]-0.5f) + offset; //y
- ds[2] = oss*fs[2]; //scale
- ds[3] = (float)fmod(twopi-fs[3], twopi); //orientation, mirrored
- }
-#endif
- _featureNum += fcount;
- }
- delete[] buffer;
- if(GlobalUtil::_verbose)
- {
- std::cout<<"#Features MO:\t"<<_featureNum<DisplayKeyBox(ftex, &texPBO1);
- _OpenCL->DisplayKeyPoint(ftex, &texPBO2);
- }*/
-}
-
-void PyramidCL::DestroySharedData()
-{
- //histogram reduction
- if(_histoPyramidTex)
- {
- delete[] _histoPyramidTex;
- _hpLevelNum = 0;
- _histoPyramidTex = NULL;
- }
- //descriptor storage shared by all levels
- if(_descriptorTex)
- {
- delete _descriptorTex;
- _descriptorTex = NULL;
- }
- //cpu reduction buffer.
- if(_histo_buffer)
- {
- delete[] _histo_buffer;
- _histo_buffer = 0;
- }
-}
-
-void PyramidCL::DestroyPerLevelData()
-{
- //integers vector to store the feature numbers.
- if(_levelFeatureNum)
- {
- delete [] _levelFeatureNum;
- _levelFeatureNum = NULL;
- }
- //texture used to store features
- if( _featureTex)
- {
- delete [] _featureTex;
- _featureTex = NULL;
- }
- //texture used for multi-orientation
- if(_orientationTex)
- {
- delete [] _orientationTex;
- _orientationTex = NULL;
- }
- int no = _octave_num* param._dog_level_num;
-
- //two sets of vbos used to display the features
- if(_featureDisplayVBO)
- {
- glDeleteBuffers(no, _featureDisplayVBO);
- delete [] _featureDisplayVBO;
- _featureDisplayVBO = NULL;
- }
- if( _featurePointVBO)
- {
- glDeleteBuffers(no, _featurePointVBO);
- delete [] _featurePointVBO;
- _featurePointVBO = NULL;
- }
-}
-
-void PyramidCL::DestroyPyramidData()
-{
- if(_allPyramid)
- {
- delete [] _allPyramid;
- _allPyramid = NULL;
- }
-}
-
-void PyramidCL::DownloadKeypoints()
-{
- const double twopi = 2.0*3.14159265358979323846;
- int idx = 0;
- float * buffer = &_keypoint_buffer[0];
- vector keypoint_buffer2;
- //use a different keypoint buffer when processing with an exisint features list
- //without orientation information.
- if(_keypoint_index.size() > 0)
- {
- keypoint_buffer2.resize(_keypoint_buffer.size());
- buffer = &keypoint_buffer2[0];
- }
- float * p = buffer, *ps;
- CLTexImage * ftex = _featureTex;
- /////////////////////
- float os = _octave_min>=0? float(1<<_octave_min): 1.0f/(1<<(-_octave_min));
- if(_down_sample_factor>0) os *= float(1<<_down_sample_factor);
- float offset = GlobalUtil::_LoweOrigin? 0 : 0.5f;
- /////////////////////
- for(int i = 0; i < _octave_num; i++, os *= 2.0f)
- {
-
- for(int j = 0; j < param._dog_level_num; j++, idx++, ftex++)
- {
-
- if(_levelFeatureNum[idx]>0)
- {
- ftex->CopyToHost(ps = p);
- for(int k = 0; k < _levelFeatureNum[idx]; k++, ps+=4)
- {
- ps[0] = os*(ps[0]-0.5f) + offset; //x
- ps[1] = os*(ps[1]-0.5f) + offset; //y
- ps[2] = os*ps[2];
- ps[3] = (float)fmod(twopi-ps[3], twopi); //orientation, mirrored
- }
- p+= 4* _levelFeatureNum[idx];
- }
- }
- }
-
- //put the feature into their original order for existing keypoint
- if(_keypoint_index.size() > 0)
- {
- for(int i = 0; i < _featureNum; ++i)
- {
- int index = _keypoint_index[i];
- memcpy(&_keypoint_buffer[index*4], &keypoint_buffer2[i*4], 4 * sizeof(float));
- }
- }
-}
-
-void PyramidCL::GenerateFeatureListCPU()
-{
- //no cpu version provided
- GenerateFeatureList();
-}
-
-void PyramidCL::GenerateFeatureList(int i, int j, int reduction_count, vector& hbuffer)
-{
- /*int fcount = 0, idx = i * param._dog_level_num + j;
- int hist_level_num = _hpLevelNum - _pyramid_octave_first /2;
- int ii, k, len;
-
- CLTexImage * htex, * ftex, * tex, *got;
- ftex = _featureTex + idx;
- htex = _histoPyramidTex + hist_level_num -1;
- tex = GetBaseLevel(_octave_min + i, DATA_KEYPOINT) + 2 + j;
- got = GetBaseLevel(_octave_min + i, DATA_GRAD) + 2 + j;
-
- _OpenCL->InitHistogram(tex, htex);
-
- for(k = 0; k < reduction_count - 1; k++, htex--)
- {
- ProgramCL::ReduceHistogram(htex, htex -1);
- }
-
- //htex has the row reduction result
- len = htex->GetImgHeight() * 4;
- hbuffer.resize(len);
- _OpenCL->FinishCL();
- htex->CopyToHost(&hbuffer[0]);
- //
- for(ii = 0; ii < len; ++ii) fcount += hbuffer[ii];
- SetLevelFeatureNum(idx, fcount);
-
- //build the feature list
- if(fcount > 0)
- {
- _featureNum += fcount;
- _keypoint_buffer.resize(fcount * 4);
- //vector ikbuf(fcount*4);
- int* ibuf = (int*) (&_keypoint_buffer[0]);
-
- for(ii = 0; ii < len; ++ii)
- {
- int x = ii%4, y = ii / 4;
- for(int jj = 0 ; jj < hbuffer[ii]; ++jj, ibuf+=4)
- {
- ibuf[0] = x; ibuf[1] = y; ibuf[2] = jj; ibuf[3] = 0;
- }
- }
- _featureTex[idx].CopyFromHost(&_keypoint_buffer[0]);
-
- ////////////////////////////////////////////
- ProgramCL::GenerateList(_featureTex + idx, ++htex);
- for(k = 2; k < reduction_count; k++)
- {
- ProgramCL::GenerateList(_featureTex + idx, ++htex);
- }
- }*/
-}
-
-void PyramidCL::GenerateFeatureList()
-{
- /*double t1, t2;
- int ocount = 0, reduction_count;
- int reverse = (GlobalUtil::_TruncateMethod == 1);
-
- vector hbuffer;
- _featureNum = 0;
-
- //for(int i = 0, idx = 0; i < _octave_num; i++)
- FOR_EACH_OCTAVE(i, reverse)
- {
- CLTexImage* tex = GetBaseLevel(_octave_min + i, DATA_KEYPOINT) + 2;
- reduction_count = FitHistogramPyramid(tex);
-
- if(GlobalUtil::_timingO)
- {
- t1 = CLOCK();
- ocount = 0;
- std::cout<<"#"< 0 && _featureNum > GlobalUtil::_FeatureCountThreshold) continue;
-
- GenerateFeatureList(i, j, reduction_count, hbuffer);
-
- /////////////////////////////
- if(GlobalUtil::_timingO)
- {
- int idx = i * param._dog_level_num + j;
- ocount += _levelFeatureNum[idx];
- std::cout<< _levelFeatureNum[idx] <<"\t";
- }
- }
- if(GlobalUtil::_timingO)
- {
- t2 = CLOCK();
- std::cout << "| \t" << int(ocount) << " :\t(" << (t2 - t1) << ")\n";
- }
- }
- /////
- CopyGradientTex();
- /////
- if(GlobalUtil::_timingS)_OpenCL->FinishCL();
-
- if(GlobalUtil::_verbose)
- {
- std::cout<<"#Features:\t"<<_featureNum<<"\n";
- }*/
-}
-
-GLTexImage* PyramidCL::GetLevelTexture(int octave, int level)
-{
- return GetLevelTexture(octave, level, DATA_GAUSSIAN);
-}
-
-GLTexImage* PyramidCL::ConvertTexCL2GL(CLTexImage* tex, int dataName)
-{
-
- if(_bufferTEX == NULL) _bufferTEX = new GLTexImage;
-
- ///////////////////////////////////////////
- int ratio = GlobalUtil::_usePackedTex ? 2 : 1;
- int width = tex->GetImgWidth() * ratio;
- int height = tex->GetImgHeight() * ratio;
- int tw = max(width, _bufferTEX->GetTexWidth());
- int th = max(height, _bufferTEX->GetTexHeight());
- _bufferTEX->InitTexture(tw, th, 1, GL_RGBA);
- _bufferTEX->SetImageSize(width, height);
-
- //////////////////////////////////
- CLTexImage texCL(_OpenCL->GetContextCL(), _OpenCL->GetCommandQueue());
- texCL.InitTextureGL(*_bufferTEX, width, height, 4);
-
- switch(dataName)
- {
- case DATA_GAUSSIAN: _OpenCL->UnpackImage(tex, &texCL); break;
- case DATA_DOG:_OpenCL->UnpackImageDOG(tex, &texCL); break;
- case DATA_GRAD:_OpenCL->UnpackImageGRD(tex, &texCL); break;
- case DATA_KEYPOINT:_OpenCL->UnpackImageKEY(tex,
- tex - param._level_num * _pyramid_octave_num, &texCL);break;
- default:
- break;
- }
-
-
- return _bufferTEX;
-}
-
-GLTexImage* PyramidCL::GetLevelTexture(int octave, int level, int dataName)
-{
- CLTexImage* tex = GetBaseLevel(octave, dataName) + (level - param._level_min);
- return ConvertTexCL2GL(tex, dataName);
-}
-
-void PyramidCL::ConvertInputToCL(GLTexInput* input, CLTexImage* output)
-{
- int ws = input->GetImgWidth(), hs = input->GetImgHeight();
- //copy the input image to pixel buffer object
- if(input->_pixel_data)
- {
- output->InitTexture(ws, hs, 1);
- output->CopyFromHost(input->_pixel_data);
- }else /*if(input->_rgb_converted && input->CopyToPBO(_bufferPBO, ws, hs, GL_LUMINANCE))
- {
- output->InitTexture(ws, hs, 1);
- output->CopyFromPBO(ws, hs, _bufferPBO);
- }else if(input->CopyToPBO(_bufferPBO, ws, hs))
- {
- CLTexImage texPBO(ws, hs, 4, _bufferPBO);
- output->InitTexture(ws, hs, 1);
- ProgramCL::ReduceToSingleChannel(output, &texPBO, !input->_rgb_converted);
- }else*/
- {
- std::cerr<< "Unable To Convert Intput\n";
- }
-}
-
-void PyramidCL::BuildPyramid(GLTexInput * input)
-{
-
- USE_TIMING();
-
- int i, j;
-
- for ( i = _octave_min; i < _octave_min + _octave_num; i++)
- {
-
- CLTexImage *tex = GetBaseLevel(i);
- CLTexImage *buf = GetBaseLevel(i, DATA_DOG) +2;
- FilterCL ** filter = _OpenCL->f_gaussian_step;
- j = param._level_min + 1;
-
- OCTAVE_START();
-
- if( i == _octave_min )
- {
- if(GlobalUtil::_usePackedTex)
- {
- ConvertInputToCL(input, _inputTex);
- if(i < 0) _OpenCL->SampleImageU(tex, _inputTex, -i- 1);
- else _OpenCL->SampleImageD(tex, _inputTex, i + 1);
- }else
- {
- if(i == 0) ConvertInputToCL(input, tex);
- else
- {
- ConvertInputToCL(input, _inputTex);
- if(i < 0) _OpenCL->SampleImageU(tex, _inputTex, -i);
- else _OpenCL->SampleImageD(tex, _inputTex, i);
- }
- }
- _OpenCL->FilterInitialImage(tex, buf);
- }else
- {
- _OpenCL->SampleImageD(tex, GetBaseLevel(i - 1) + param._level_ds - param._level_min);
- _OpenCL->FilterSampledImage(tex, buf);
- }
- LEVEL_FINISH();
- for( ; j <= param._level_max ; j++, tex++, filter++)
- {
- // filtering
- _OpenCL->FilterImage(*filter, tex + 1, tex, buf);
- LEVEL_FINISH();
- }
- OCTAVE_FINISH();
- }
- if(GlobalUtil::_timingS) _OpenCL->FinishCL();
-}
-
-void PyramidCL::DetectKeypointsEX()
-{
- int i, j;
- double t0, t, ts, t1, t2;
-
- if(GlobalUtil::_timingS && GlobalUtil::_verbose) ts = CLOCK();
-
- for(i = _octave_min; i < _octave_min + _octave_num; i++)
- {
- CLTexImage * gus = GetBaseLevel(i) + 1;
- CLTexImage * dog = GetBaseLevel(i, DATA_DOG) + 1;
- CLTexImage * grd = GetBaseLevel(i, DATA_GRAD) + 1;
- CLTexImage * rot = GetBaseLevel(i, DATA_ROT) + 1;
- //compute the gradient
- for(j = param._level_min +1; j <= param._level_max ; j++, gus++, dog++, grd++, rot++)
- {
- //input: gus and gus -1
- //output: gradient, dog, orientation
- _OpenCL->ComputeDOG(gus, gus - 1, dog, grd, rot);
- }
- }
- if(GlobalUtil::_timingS && GlobalUtil::_verbose)
- {
- _OpenCL->FinishCL();
- t1 = CLOCK();
- }
- //if(GlobalUtil::_timingS) _OpenCL->FinishCL();
- //if(!GlobalUtil::_usePackedTex) return; //not finished
- //return;
-
- for ( i = _octave_min; i < _octave_min + _octave_num; i++)
- {
- if(GlobalUtil::_timingO)
- {
- t0 = CLOCK();
- std::cout<<"#"<<(i + _down_sample_factor)<<"\t";
- }
- CLTexImage * dog = GetBaseLevel(i, DATA_DOG) + 2;
- CLTexImage * key = GetBaseLevel(i, DATA_KEYPOINT) +2;
-
-
- for( j = param._level_min +2; j < param._level_max ; j++, dog++, key++)
- {
- if(GlobalUtil::_timingL)t = CLOCK();
- //input, dog, dog + 1, dog -1
- //output, key
- _OpenCL->ComputeKEY(dog, key, param._dog_threshold, param._edge_threshold);
- if(GlobalUtil::_timingL)
- {
- std::cout<<(CLOCK()-t)<<"\t";
- }
- }
- if(GlobalUtil::_timingO)
- {
- std::cout<<"|\t"<<(CLOCK()-t0)<<"\n";
- }
- }
-
- if(GlobalUtil::_timingS)
- {
- _OpenCL->FinishCL();
- if(GlobalUtil::_verbose)
- {
- t2 = CLOCK();
- std::cout <<"\t"<<(t1-ts)<<"\n"
- <<"\t"<<(t2-t1)<<"\n";
- }
- }
-}
-
-void PyramidCL::CopyGradientTex()
-{
- /*double ts, t1;
-
- if(GlobalUtil::_timingS && GlobalUtil::_verbose)ts = CLOCK();
-
- for(int i = 0, idx = 0; i < _octave_num; i++)
- {
- CLTexImage * got = GetBaseLevel(i + _octave_min, DATA_GRAD) + 1;
- //compute the gradient
- for(int j = 0; j < param._dog_level_num ; j++, got++, idx++)
- {
- if(_levelFeatureNum[idx] > 0) got->CopyToTexture2D();
- }
- }
- if(GlobalUtil::_timingS)
- {
- ProgramCL::FinishCLDA();
- if(GlobalUtil::_verbose)
- {
- t1 = CLOCK();
- std::cout <<"\t"<<(t1-ts)<<"\n";
- }
- }*/
-}
-
-void PyramidCL::ComputeGradient()
-{
-
- /*int i, j;
- double ts, t1;
-
- if(GlobalUtil::_timingS && GlobalUtil::_verbose)ts = CLOCK();
-
- for(i = _octave_min; i < _octave_min + _octave_num; i++)
- {
- CLTexImage * gus = GetBaseLevel(i) + 1;
- CLTexImage * dog = GetBaseLevel(i, DATA_DOG) + 1;
- CLTexImage * got = GetBaseLevel(i, DATA_GRAD) + 1;
-
- //compute the gradient
- for(j = 0; j < param._dog_level_num ; j++, gus++, dog++, got++)
- {
- ProgramCL::ComputeDOG(gus, dog, got);
- }
- }
- if(GlobalUtil::_timingS)
- {
- ProgramCL::FinishCLDA();
- if(GlobalUtil::_verbose)
- {
- t1 = CLOCK();
- std::cout <<"\t"<<(t1-ts)<<"\n";
- }
- }*/
-}
-
-int PyramidCL::FitHistogramPyramid(CLTexImage* tex)
-{
- CLTexImage *htex;
- int hist_level_num = _hpLevelNum - _pyramid_octave_first / 2;
- htex = _histoPyramidTex + hist_level_num - 1;
- int w = (tex->GetImgWidth() + 2) >> 2;
- int h = tex->GetImgHeight();
- int count = 0;
- for(int k = 0; k < hist_level_num; k++, htex--)
- {
- //htex->SetImageSize(w, h);
- htex->InitTexture(w, h, 4);
- ++count;
- if(w == 1)
- break;
- w = (w + 3)>>2;
- }
- return count;
-}
-
-void PyramidCL::GetFeatureOrientations()
-{
-
-/*
- CLTexImage * ftex = _featureTex;
- int * count = _levelFeatureNum;
- float sigma, sigma_step = powf(2.0f, 1.0f/param._dog_level_num);
-
- for(int i = 0; i < _octave_num; i++)
- {
- CLTexImage* got = GetBaseLevel(i + _octave_min, DATA_GRAD) + 1;
- CLTexImage* key = GetBaseLevel(i + _octave_min, DATA_KEYPOINT) + 2;
-
- for(int j = 0; j < param._dog_level_num; j++, ftex++, count++, got++, key++)
- {
- if(*count<=0)continue;
-
- //if(ftex->GetImgWidth() < *count) ftex->InitTexture(*count, 1, 4);
-
- sigma = param.GetLevelSigma(j+param._level_min+1);
-
- ProgramCL::ComputeOrientation(ftex, got, key, sigma, sigma_step, _existing_keypoints);
- }
- }
-
- if(GlobalUtil::_timingS)ProgramCL::FinishCL();
- */
-
-
-}
-
-void PyramidCL::GetSimplifiedOrientation()
-{
- //no simplified orientation
- GetFeatureOrientations();
-}
-
-CLTexImage* PyramidCL::GetBaseLevel(int octave, int dataName)
-{
- if(octave <_octave_min || octave > _octave_min + _octave_num) return NULL;
- int offset = (_pyramid_octave_first + octave - _octave_min) * param._level_num;
- int num = param._level_num * _pyramid_octave_num;
- return _allPyramid + num * dataName + offset;
-}
-
-#endif
-
diff --git a/3rdparty/SiftGPU/src/SiftGPU/PyramidCL.h b/3rdparty/SiftGPU/src/SiftGPU/PyramidCL.h
deleted file mode 100644
index 1ff6b181..00000000
--- a/3rdparty/SiftGPU/src/SiftGPU/PyramidCL.h
+++ /dev/null
@@ -1,83 +0,0 @@
-////////////////////////////////////////////////////////////////////////////
-// File: PyramidCL.h
-// Author: Changchang Wu
-// Description : interface for the PyramdCL
-//
-// Copyright (c) 2007 University of North Carolina at Chapel Hill
-// All Rights Reserved
-//
-// Permission to use, copy, modify and distribute this software and its
-// documentation for educational, research and non-profit purposes, without
-// fee, and without a written agreement is hereby granted, provided that the
-// above copyright notice and the following paragraph appear in all copies.
-//
-// The University of North Carolina at Chapel Hill make no representations
-// about the suitability of this software for any purpose. It is provided
-// 'as is' without express or implied warranty.
-//
-// Please send BUG REPORTS to ccwu@cs.unc.edu
-//
-////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef _PYRAMID_CL_H
-#define _PYRAMID_CL_H
-#if defined(CL_SIFTGPU_ENABLED)
-
-class CLTexImage;
-class SiftPyramid;
-class ProgramBagCL;
-class PyramidCL: public SiftPyramid
-{
- CLTexImage* _inputTex;
- CLTexImage* _allPyramid;
- CLTexImage* _histoPyramidTex;
- CLTexImage* _featureTex;
- CLTexImage* _descriptorTex;
- CLTexImage* _orientationTex;
- ProgramBagCL* _OpenCL;
- GLTexImage* _bufferTEX;
-public:
- virtual void GetFeatureDescriptors();
- virtual void GenerateFeatureListTex();
- virtual void ReshapeFeatureListCPU();
- virtual void GenerateFeatureDisplayVBO();
- virtual void DestroySharedData();
- virtual void DestroyPerLevelData();
- virtual void DestroyPyramidData();
- virtual void DownloadKeypoints();
- virtual void GenerateFeatureListCPU();
- virtual void GenerateFeatureList();
- virtual GLTexImage* GetLevelTexture(int octave, int level);
- virtual GLTexImage* GetLevelTexture(int octave, int level, int dataName);
- virtual void BuildPyramid(GLTexInput * input);
- virtual void DetectKeypointsEX();
- virtual void ComputeGradient();
- virtual void GetFeatureOrientations();
- virtual void GetSimplifiedOrientation();
- virtual void InitPyramid(int w, int h, int ds = 0);
- virtual void ResizePyramid(int w, int h);
-
- //////////
- void CopyGradientTex();
- void FitPyramid(int w, int h);
-
- void InitializeContext();
- int ResizeFeatureStorage();
- int FitHistogramPyramid(CLTexImage* tex);
- void SetLevelFeatureNum(int idx, int fcount);
- void ConvertInputToCL(GLTexInput* input, CLTexImage* output);
- GLTexImage* ConvertTexCL2GL(CLTexImage* tex, int dataName);
- CLTexImage* GetBaseLevel(int octave, int dataName = DATA_GAUSSIAN);
-private:
- void GenerateFeatureList(int i, int j, int reduction_count, vector& hbuffer);
-public:
- PyramidCL(SiftParam& sp);
- virtual ~PyramidCL();
-};
-
-
-#endif
-#endif
-
diff --git a/3rdparty/SiftGPU/src/SiftGPU/PyramidCU.cpp b/3rdparty/SiftGPU/src/SiftGPU/PyramidCU.cpp
deleted file mode 100644
index 368b6fe6..00000000
--- a/3rdparty/SiftGPU/src/SiftGPU/PyramidCU.cpp
+++ /dev/null
@@ -1,1190 +0,0 @@
-////////////////////////////////////////////////////////////////////////////
-// File: PyramidCU.cpp
-// Author: Changchang Wu
-// Description : implementation of the PyramidCU class.
-// CUDA-based implementation of SiftPyramid
-//
-// Copyright (c) 2007 University of North Carolina at Chapel Hill
-// All Rights Reserved
-//
-// Permission to use, copy, modify and distribute this software and its
-// documentation for educational, research and non-profit purposes, without
-// fee, and without a written agreement is hereby granted, provided that the
-// above copyright notice and the following paragraph appear in all copies.
-//
-// The University of North Carolina at Chapel Hill make no representations
-// about the suitability of this software for any purpose. It is provided
-// 'as is' without express or implied warranty.
-//
-// Please send BUG REPORTS to ccwu@cs.unc.edu
-//
-////////////////////////////////////////////////////////////////////////////
-
-#if defined(CUDA_SIFTGPU_ENABLED)
-
-
-#include "GL/glew.h"
-#include
-#include
-#include
-#include
-#include
-#include
-using namespace std;
-
-#include "GlobalUtil.h"
-#include "GLTexImage.h"
-#include "CuTexImage.h"
-#include "SiftGPU.h"
-#include "SiftPyramid.h"
-#include "ProgramCU.h"
-#include "PyramidCU.h"
-
-
-//#include "imdebug/imdebuggl.h"
-//#pragma comment (lib, "../lib/imdebug.lib")
-
-
-
-#define USE_TIMING() double t, t0, tt;
-#define OCTAVE_START() if(GlobalUtil::_timingO){ t = t0 = CLOCK(); cout<<"#"<=0)
- {
- wp = w >> _octave_min_default;
- hp = h >> _octave_min_default;
- }else
- {
- //can't upsample by more than 8
- _octave_min_default = max(-3, _octave_min_default);
- //
- wp = w << (-_octave_min_default);
- hp = h << (-_octave_min_default);
- }
- _octave_min = _octave_min_default;
- }else
- {
- //must use 0 as _octave_min;
- _octave_min = 0;
- _down_sample_factor = ds;
- w >>= ds;
- h >>= ds;
- /////
-
- TruncateWidth(w);
-
- wp = w;
- hp = h;
-
- }
-
- while(wp > GlobalUtil::_texMaxDim || hp > GlobalUtil::_texMaxDim )
- {
- _octave_min ++;
- wp >>= 1;
- hp >>= 1;
- toobig = 1;
- }
-
- while(GlobalUtil::_MemCapGPU > 0 && GlobalUtil::_FitMemoryCap && (wp >_pyramid_width || hp > _pyramid_height)&&
- max(max(wp, hp), max(_pyramid_width, _pyramid_height)) > 1024 * sqrt(GlobalUtil::_MemCapGPU / 110.0))
- {
- _octave_min ++;
- wp >>= 1;
- hp >>= 1;
- toobig = 2;
- }
-
-
- if(toobig && GlobalUtil::_verbose && _octave_min > 0)
- {
- std::cout<<(toobig == 2 ? "[**SKIP OCTAVES**]:\tExceeding Memory Cap (-nomc)\n" :
- "[**SKIP OCTAVES**]:\tReaching the dimension limit(-maxd)!\n");
- }
- //ResizePyramid(wp, hp);
- if( wp == _pyramid_width && hp == _pyramid_height && _allocated )
- {
- FitPyramid(wp, hp);
- }else if(GlobalUtil::_ForceTightPyramid || _allocated ==0)
- {
- ResizePyramid(wp, hp);
- }
- else if( wp > _pyramid_width || hp > _pyramid_height )
- {
- ResizePyramid(max(wp, _pyramid_width), max(hp, _pyramid_height));
- if(wp < _pyramid_width || hp < _pyramid_height) FitPyramid(wp, hp);
- }
- else
- {
- //try use the pyramid allocated for large image on small input images
- FitPyramid(wp, hp);
- }
-}
-
-void PyramidCU::ResizePyramid(int w, int h)
-{
- //
- unsigned int totalkb = 0;
- int _octave_num_new, input_sz, i, j;
- //
-
- if(_pyramid_width == w && _pyramid_height == h && _allocated) return;
-
- if(w > GlobalUtil::_texMaxDim || h > GlobalUtil::_texMaxDim) return ;
-
- if(GlobalUtil::_verbose && GlobalUtil::_timingS) std::cout<<"[Allocate Pyramid]:\t" <0)
- {
- DestroyPerLevelData();
- DestroyPyramidData();
- }
- _pyramid_octave_num = _octave_num_new;
- }
-
- _octave_num = _pyramid_octave_num;
-
- int noct = _octave_num;
- int nlev = param._level_num;
-
- // //initialize the pyramid
- if(_allPyramid==NULL) _allPyramid = new CuTexImage[ noct* nlev * DATA_NUM];
-
- CuTexImage * gus = GetBaseLevel(_octave_min, DATA_GAUSSIAN);
- CuTexImage * dog = GetBaseLevel(_octave_min, DATA_DOG);
- CuTexImage * got = GetBaseLevel(_octave_min, DATA_GRAD);
- CuTexImage * key = GetBaseLevel(_octave_min, DATA_KEYPOINT);
-
- ////////////there could be "out of memory" happening during the allocation
-
- for(i = 0; i< noct; i++)
- {
- int wa = ((w + 3) / 4) * 4;
-
- totalkb += ((nlev *8 -19)* (wa * h) * 4 / 1024);
- for( j = 0; j< nlev; j++, gus++, dog++, got++, key++)
- {
- gus->InitTexture(wa, h); //nlev
- if(j==0)continue;
- dog->InitTexture(wa, h); //nlev -1
- if( j >= 1 && j < 1 + param._dog_level_num)
- {
- got->InitTexture(wa, h, 2); //2 * nlev - 6
- got->InitTexture2D();
- }
- if(j > 1 && j < nlev -1) key->InitTexture(wa, h, 4); // nlev -3 ; 4 * nlev - 12
- }
- w>>=1;
- h>>=1;
- }
-
- totalkb += ResizeFeatureStorage();
-
- if(ProgramCU::CheckErrorCUDA("ResizePyramid")) SetFailStatus();
-
- _allocated = 1;
-
- if(GlobalUtil::_verbose && GlobalUtil::_timingS) std::cout<<"[Allocate Pyramid]:\t" <<(totalkb/1024)<<"MB\n";
-
-}
-
-void PyramidCU::FitPyramid(int w, int h)
-{
- _pyramid_octave_first = 0;
- //
- _octave_num = GlobalUtil::_octave_num_default;
-
- int _octave_num_max = max(1, (int) floor (log ( double(min(w, h)))/log(2.0)) -3 );
-
- if(_octave_num < 1 || _octave_num > _octave_num_max)
- {
- _octave_num = _octave_num_max;
- }
-
-
- int pw = _pyramid_width>>1, ph = _pyramid_height>>1;
- while(_pyramid_octave_first + _octave_num < _pyramid_octave_num &&
- pw >= w && ph >= h)
- {
- _pyramid_octave_first++;
- pw >>= 1;
- ph >>= 1;
- }
-
- //////////////////
- int nlev = param._level_num;
- CuTexImage * gus = GetBaseLevel(_octave_min, DATA_GAUSSIAN);
- CuTexImage * dog = GetBaseLevel(_octave_min, DATA_DOG);
- CuTexImage * got = GetBaseLevel(_octave_min, DATA_GRAD);
- CuTexImage * key = GetBaseLevel(_octave_min, DATA_KEYPOINT);
- for(int i = 0; i< _octave_num; i++)
- {
- int wa = ((w + 3) / 4) * 4;
-
- for(int j = 0; j< nlev; j++, gus++, dog++, got++, key++)
- {
- gus->InitTexture(wa, h); //nlev
- if(j==0)continue;
- dog->InitTexture(wa, h); //nlev -1
- if( j >= 1 && j < 1 + param._dog_level_num)
- {
- got->InitTexture(wa, h, 2); //2 * nlev - 6
- got->InitTexture2D();
- }
- if(j > 1 && j < nlev -1) key->InitTexture(wa, h, 4); // nlev -3 ; 4 * nlev - 12
- }
- w>>=1;
- h>>=1;
- }
-}
-
-int PyramidCU::CheckCudaDevice(int device)
-{
- return ProgramCU::CheckCudaDevice(device);
-}
-
-void PyramidCU::SetLevelFeatureNum(int idx, int fcount)
-{
- _featureTex[idx].InitTexture(fcount, 1, 4);
- _levelFeatureNum[idx] = fcount;
-}
-
-int PyramidCU::ResizeFeatureStorage()
-{
- int totalkb = 0;
- if(_levelFeatureNum==NULL) _levelFeatureNum = new int[_octave_num * param._dog_level_num];
- std::fill(_levelFeatureNum, _levelFeatureNum+_octave_num * param._dog_level_num, 0);
-
- int wmax = GetBaseLevel(_octave_min)->GetImgWidth();
- int hmax = GetBaseLevel(_octave_min)->GetImgHeight();
- int whmax = max(wmax, hmax);
- int w, i;
-
- //
- int num = (int)ceil(log(double(whmax))/log(4.0));
-
- if( _hpLevelNum != num)
- {
- _hpLevelNum = num;
- if(_histoPyramidTex ) delete [] _histoPyramidTex;
- _histoPyramidTex = new CuTexImage[_hpLevelNum];
- }
-
- for(i = 0, w = 1; i < _hpLevelNum; i++)
- {
- _histoPyramidTex[i].InitTexture(w, whmax, 4);
- w<<=2;
- }
-
- // (4 ^ (_hpLevelNum) -1 / 3) pixels
- totalkb += (((1 << (2 * _hpLevelNum)) -1) / 3 * 16 / 1024);
-
- //initialize the feature texture
- int idx = 0, n = _octave_num * param._dog_level_num;
- if(_featureTex==NULL) _featureTex = new CuTexImage[n];
- if(GlobalUtil::_MaxOrientation >1 && GlobalUtil::_OrientationPack2==0 && _orientationTex== NULL)
- _orientationTex = new CuTexImage[n];
-
-
- for(i = 0; i < _octave_num; i++)
- {
- CuTexImage * tex = GetBaseLevel(i+_octave_min);
- int fmax = int(tex->GetImgWidth() * tex->GetImgHeight()*GlobalUtil::_MaxFeaturePercent);
- //
- if(fmax > GlobalUtil::_MaxLevelFeatureNum) fmax = GlobalUtil::_MaxLevelFeatureNum;
- else if(fmax < 32) fmax = 32; //give it at least a space of 32 feature
-
- for(int j = 0; j < param._dog_level_num; j++, idx++)
- {
- _featureTex[idx].InitTexture(fmax, 1, 4);
- totalkb += fmax * 16 /1024;
- //
- if(GlobalUtil::_MaxOrientation>1 && GlobalUtil::_OrientationPack2 == 0)
- {
- _orientationTex[idx].InitTexture(fmax, 1, 4);
- totalkb += fmax * 16 /1024;
- }
- }
- }
-
-
- //this just need be initialized once
- if(_descriptorTex==NULL)
- {
- //initialize feature texture pyramid
- int fmax = _featureTex->GetImgWidth();
- _descriptorTex = new CuTexImage;
- totalkb += ( fmax /2);
- _descriptorTex->InitTexture(fmax *128, 1, 1);
- }else
- {
- totalkb += _descriptorTex->GetDataSize()/1024;
- }
- return totalkb;
-}
-
-void PyramidCU::GetFeatureDescriptors()
-{
- //descriptors...
- float* pd = &_descriptor_buffer[0];
- vector descriptor_buffer2;
-
- //use another buffer if we need to re-order the descriptors
- if(_keypoint_index.size() > 0)
- {
- descriptor_buffer2.resize(_descriptor_buffer.size());
- pd = &descriptor_buffer2[0];
- }
-
- CuTexImage * got, * ftex= _featureTex;
- for(int i = 0, idx = 0; i < _octave_num; i++)
- {
- got = GetBaseLevel(i + _octave_min, DATA_GRAD) + 1;
- for(int j = 0; j < param._dog_level_num; j++, ftex++, idx++, got++)
- {
- if(_levelFeatureNum[idx]==0) continue;
- ProgramCU::ComputeDescriptor(ftex, got, _descriptorTex, IsUsingRectDescription());//process
- _descriptorTex->CopyToHost(pd); //readback descriptor
- pd += 128*_levelFeatureNum[idx];
- }
- }
-
- if(GlobalUtil::_timingS) ProgramCU::FinishCUDA();
-
- if(_keypoint_index.size() > 0)
- {
- //put the descriptor back to the original order for keypoint list.
- for(int i = 0; i < _featureNum; ++i)
- {
- int index = _keypoint_index[i];
- memcpy(&_descriptor_buffer[index*128], &descriptor_buffer2[i*128], 128 * sizeof(float));
- }
- }
-
- if(ProgramCU::CheckErrorCUDA("PyramidCU::GetFeatureDescriptors")) SetFailStatus();
-}
-
-void PyramidCU::GenerateFeatureListTex()
-{
-
- vector list;
- int idx = 0;
- const double twopi = 2.0*3.14159265358979323846;
- float sigma_half_step = powf(2.0f, 0.5f / param._dog_level_num);
- float octave_sigma = _octave_min>=0? float(1<<_octave_min): 1.0f/(1<<(-_octave_min));
- float offset = GlobalUtil::_LoweOrigin? 0 : 0.5f;
- if(_down_sample_factor>0) octave_sigma *= float(1<<_down_sample_factor);
-
- _keypoint_index.resize(0); // should already be 0
- for(int i = 0; i < _octave_num; i++, octave_sigma*= 2.0f)
- {
- for(int j = 0; j < param._dog_level_num; j++, idx++)
- {
- list.resize(0);
- float level_sigma = param.GetLevelSigma(j + param._level_min + 1) * octave_sigma;
- float sigma_min = level_sigma / sigma_half_step;
- float sigma_max = level_sigma * sigma_half_step;
- int fcount = 0 ;
- for(int k = 0; k < _featureNum; k++)
- {
- float * key = &_keypoint_buffer[k*4];
- float sigmak = key[2];
- //////////////////////////////////////
- if(IsUsingRectDescription()) sigmak = min(key[2], key[3]) / 12.0f;
-
- if( (sigmak >= sigma_min && sigmak < sigma_max)
- ||(sigmak < sigma_min && i ==0 && j == 0)
- ||(sigmak > sigma_max && i == _octave_num -1 && j == param._dog_level_num - 1))
- {
- //add this keypoint to the list
- list.push_back((key[0] - offset) / octave_sigma + 0.5f);
- list.push_back((key[1] - offset) / octave_sigma + 0.5f);
- if(IsUsingRectDescription())
- {
- list.push_back(key[2] / octave_sigma);
- list.push_back(key[3] / octave_sigma);
- }else
- {
- list.push_back(key[2] / octave_sigma);
- list.push_back((float)fmod(twopi-key[3], twopi));
- }
- fcount ++;
- //save the index of keypoints
- _keypoint_index.push_back(k);
- }
-
- }
-
- _levelFeatureNum[idx] = fcount;
- if(fcount==0)continue;
- CuTexImage * ftex = _featureTex+idx;
-
- SetLevelFeatureNum(idx, fcount);
- ftex->CopyFromHost(&list[0]);
- }
- }
-
- if(GlobalUtil::_verbose)
- {
- std::cout<<"#Features:\t"<<_featureNum<<"\n";
- }
-
-}
-
-void PyramidCU::ReshapeFeatureListCPU()
-{
- int i, szmax =0, sz;
- int n = param._dog_level_num*_octave_num;
- for( i = 0; i < n; i++)
- {
- sz = _levelFeatureNum[i];
- if(sz > szmax ) szmax = sz;
- }
- float * buffer = new float[szmax*16];
- float * buffer1 = buffer;
- float * buffer2 = buffer + szmax*4;
-
-
-
- _featureNum = 0;
-
-#ifdef NO_DUPLICATE_DOWNLOAD
- const double twopi = 2.0*3.14159265358979323846;
- _keypoint_buffer.resize(0);
- float os = _octave_min>=0? float(1<<_octave_min): 1.0f/(1<<(-_octave_min));
- if(_down_sample_factor>0) os *= float(1<<_down_sample_factor);
- float offset = GlobalUtil::_LoweOrigin? 0 : 0.5f;
-#endif
-
-
- for(i = 0; i < n; i++)
- {
- if(_levelFeatureNum[i]==0)continue;
-
- _featureTex[i].CopyToHost(buffer1);
-
- int fcount =0;
- float * src = buffer1;
- float * des = buffer2;
- const static double factor = 2.0*3.14159265358979323846/65535.0;
- for(int j = 0; j < _levelFeatureNum[i]; j++, src+=4)
- {
- unsigned short * orientations = (unsigned short*) (&src[3]);
- if(orientations[0] != 65535)
- {
- des[0] = src[0];
- des[1] = src[1];
- des[2] = src[2];
- des[3] = float( factor* orientations[0]);
- fcount++;
- des += 4;
- if(orientations[1] != 65535 && orientations[1] != orientations[0])
- {
- des[0] = src[0];
- des[1] = src[1];
- des[2] = src[2];
- des[3] = float(factor* orientations[1]);
- fcount++;
- des += 4;
- }
- }
- }
- //texture size
- SetLevelFeatureNum(i, fcount);
- _featureTex[i].CopyFromHost(buffer2);
-
- if(fcount == 0) continue;
-
-#ifdef NO_DUPLICATE_DOWNLOAD
- float oss = os * (1 << (i / param._dog_level_num));
- _keypoint_buffer.resize((_featureNum + fcount) * 4);
- float* ds = &_keypoint_buffer[_featureNum * 4];
- float* fs = buffer2;
- for(int k = 0; k < fcount; k++, ds+=4, fs+=4)
- {
- ds[0] = oss*(fs[0]-0.5f) + offset; //x
- ds[1] = oss*(fs[1]-0.5f) + offset; //y
- ds[2] = oss*fs[2]; //scale
- ds[3] = (float)fmod(twopi-fs[3], twopi); //orientation, mirrored
- }
-#endif
- _featureNum += fcount;
- }
- delete[] buffer;
- if(GlobalUtil::_verbose)
- {
- std::cout<<"#Features MO:\t"<<_featureNum< keypoint_buffer2;
- //use a different keypoint buffer when processing with an exisint features list
- //without orientation information.
- if(_keypoint_index.size() > 0)
- {
- keypoint_buffer2.resize(_keypoint_buffer.size());
- buffer = &keypoint_buffer2[0];
- }
- float * p = buffer, *ps;
- CuTexImage * ftex = _featureTex;
- /////////////////////
- float os = _octave_min>=0? float(1<<_octave_min): 1.0f/(1<<(-_octave_min));
- if(_down_sample_factor>0) os *= float(1<<_down_sample_factor);
- float offset = GlobalUtil::_LoweOrigin? 0 : 0.5f;
- /////////////////////
- for(int i = 0; i < _octave_num; i++, os *= 2.0f)
- {
-
- for(int j = 0; j < param._dog_level_num; j++, idx++, ftex++)
- {
-
- if(_levelFeatureNum[idx]>0)
- {
- ftex->CopyToHost(ps = p);
- for(int k = 0; k < _levelFeatureNum[idx]; k++, ps+=4)
- {
- ps[0] = os*(ps[0]-0.5f) + offset; //x
- ps[1] = os*(ps[1]-0.5f) + offset; //y
- ps[2] = os*ps[2];
- ps[3] = (float)fmod(twopi-ps[3], twopi); //orientation, mirrored
- }
- p+= 4* _levelFeatureNum[idx];
- }
- }
- }
-
- //put the feature into their original order for existing keypoint
- if(_keypoint_index.size() > 0)
- {
- for(int i = 0; i < _featureNum; ++i)
- {
- int index = _keypoint_index[i];
- memcpy(&_keypoint_buffer[index*4], &keypoint_buffer2[i*4], 4 * sizeof(float));
- }
- }
-}
-
-void PyramidCU::GenerateFeatureListCPU()
-{
- //no cpu version provided
- GenerateFeatureList();
-}
-
-void PyramidCU::GenerateFeatureList(int i, int j, int reduction_count, vector& hbuffer)
-{
- int fcount = 0, idx = i * param._dog_level_num + j;
- int hist_level_num = _hpLevelNum - _pyramid_octave_first /2;
- int ii, k, len;
-
- CuTexImage * htex, * ftex, * tex, *got;
- ftex = _featureTex + idx;
- htex = _histoPyramidTex + hist_level_num -1;
- tex = GetBaseLevel(_octave_min + i, DATA_KEYPOINT) + 2 + j;
- got = GetBaseLevel(_octave_min + i, DATA_GRAD) + 2 + j;
-
- ProgramCU::InitHistogram(tex, htex);
-
- for(k = 0; k < reduction_count - 1; k++, htex--)
- {
- ProgramCU::ReduceHistogram(htex, htex -1);
- }
-
- //htex has the row reduction result
- len = htex->GetImgHeight() * 4;
- hbuffer.resize(len);
- ProgramCU::FinishCUDA();
- htex->CopyToHost(&hbuffer[0]);
-
- ////TO DO: track the error found here..
- for(ii = 0; ii < len; ++ii) {if(!(hbuffer[ii]>= 0)) hbuffer[ii] = 0; }//?
-
-
- for(ii = 0; ii < len; ++ii) fcount += hbuffer[ii];
- SetLevelFeatureNum(idx, fcount);
-
- //build the feature list
- if(fcount > 0)
- {
- _featureNum += fcount;
- _keypoint_buffer.resize(fcount * 4);
- //vector ikbuf(fcount*4);
- int* ibuf = (int*) (&_keypoint_buffer[0]);
-
- for(ii = 0; ii < len; ++ii)
- {
- int x = ii%4, y = ii / 4;
- for(int jj = 0 ; jj < hbuffer[ii]; ++jj, ibuf+=4)
- {
- ibuf[0] = x; ibuf[1] = y; ibuf[2] = jj; ibuf[3] = 0;
- }
- }
- _featureTex[idx].CopyFromHost(&_keypoint_buffer[0]);
-
- ////////////////////////////////////////////
- ProgramCU::GenerateList(_featureTex + idx, ++htex);
- for(k = 2; k < reduction_count; k++)
- {
- ProgramCU::GenerateList(_featureTex + idx, ++htex);
- }
- }
-}
-
-void PyramidCU::GenerateFeatureList()
-{
- double t1, t2;
- int ocount = 0, reduction_count;
- int reverse = (GlobalUtil::_TruncateMethod == 1);
-
- vector