├── third_party ├── Eigen │ ├── src │ │ ├── Sparse │ │ │ ├── SparseAssign.h │ │ │ ├── CMakeLists.txt │ │ │ ├── SparseFuzzy.h │ │ │ ├── SparseRedux.h │ │ │ ├── SparseTranspose.h │ │ │ ├── CoreIterators.h │ │ │ ├── SparseDot.h │ │ │ ├── SparseView.h │ │ │ └── SparseTriangularView.h │ │ ├── Core │ │ │ ├── arch │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── SSE │ │ │ │ │ └── CMakeLists.txt │ │ │ │ ├── NEON │ │ │ │ │ └── CMakeLists.txt │ │ │ │ ├── AltiVec │ │ │ │ │ └── CMakeLists.txt │ │ │ │ └── Default │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ └── Settings.h │ │ │ ├── util │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── ReenableStupidWarnings.h │ │ │ │ └── DisableStupidWarnings.h │ │ │ ├── products │ │ │ │ └── CMakeLists.txt │ │ │ ├── CMakeLists.txt │ │ │ ├── GlobalFunctions.h │ │ │ ├── ReturnByValue.h │ │ │ └── NestByValue.h │ │ ├── QR │ │ │ └── CMakeLists.txt │ │ ├── SVD │ │ │ └── CMakeLists.txt │ │ ├── misc │ │ │ ├── CMakeLists.txt │ │ │ ├── Solve.h │ │ │ ├── Kernel.h │ │ │ └── Image.h │ │ ├── Jacobi │ │ │ └── CMakeLists.txt │ │ ├── LU │ │ │ ├── arch │ │ │ │ └── CMakeLists.txt │ │ │ ├── CMakeLists.txt │ │ │ └── Determinant.h │ │ ├── plugins │ │ │ ├── CMakeLists.txt │ │ │ ├── CommonCwiseBinaryOps.h │ │ │ └── MatrixCwiseUnaryOps.h │ │ ├── Cholesky │ │ │ └── CMakeLists.txt │ │ ├── StlSupport │ │ │ ├── CMakeLists.txt │ │ │ └── details.h │ │ ├── Eigenvalues │ │ │ ├── CMakeLists.txt │ │ │ └── EigenvaluesCommon.h │ │ ├── Householder │ │ │ ├── CMakeLists.txt │ │ │ └── BlockHouseholder.h │ │ ├── Geometry │ │ │ ├── arch │ │ │ │ └── CMakeLists.txt │ │ │ ├── CMakeLists.txt │ │ │ └── EulerAngles.h │ │ ├── Eigen2Support │ │ │ ├── Geometry │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── All.h │ │ │ ├── CMakeLists.txt │ │ │ ├── Macros.h │ │ │ ├── TriangularSolver.h │ │ │ ├── Memory.h │ │ │ ├── QR.h │ │ │ ├── Lazy.h │ │ │ ├── MathFunctions.h │ │ │ ├── VectorBlock.h │ │ │ └── Meta.h │ │ └── CMakeLists.txt │ ├── Eigen │ ├── Dense │ ├── README.ipol │ ├── Array │ ├── CMakeLists.txt │ ├── Householder │ ├── QtAlignedMalloc │ ├── Jacobi │ ├── Cholesky │ ├── LeastSquares │ ├── SVD │ ├── QR │ ├── LU │ ├── Eigenvalues │ ├── StdList │ ├── StdDeque │ ├── StdVector │ ├── Geometry │ ├── Sparse │ └── Eigen2Support └── flimage.h ├── feature.c ├── sift ├── numerics1.cpp ├── frot.h ├── fproj.h ├── splines.h ├── domain.h ├── filter.h ├── numerics1.h ├── frot.cpp └── domain.cpp ├── crc32.h ├── cythreading.pxd_bad ├── crc64.pxd ├── crc64.h ├── crc32.pxd ├── image.pxd ├── orsa.pxd ├── surf ├── surf_match.h ├── match.h ├── surf_match.cpp ├── descriptor.h ├── integral.cpp ├── lib.h ├── keypoint.h ├── integral.h ├── image.h └── descriptor.cpp ├── orsa_cpp.pxd ├── orsa ├── match.h ├── match.cpp └── orsa.h ├── MANIFEST.in ├── libNumerics ├── rodrigues.h ├── rodrigues.cpp ├── homography.cpp ├── numerics.h └── homography.h ├── crc64.cpp ├── test_numpy.py ├── asift ├── log.txt ├── compute_asift_matches.h ├── compute_asift_keypoints.h └── LICENSE.txt ├── README ├── asift.pxd ├── image ├── image.cpp.nogood ├── flimage.h └── flimage.cpp ├── test2.py ├── crc32.cpp ├── surf.pxd ├── test_numpy2.py ├── sift.pxd ├── setup.py └── orsa.pyx /third_party/Eigen/src/Sparse/SparseAssign.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /third_party/Eigen/Eigen: -------------------------------------------------------------------------------- 1 | #include "Dense" 2 | //#include "Sparse" 3 | -------------------------------------------------------------------------------- /feature.c: -------------------------------------------------------------------------------- 1 | #error Do not use this file, it is the result of a failed Cython compilation. 2 | -------------------------------------------------------------------------------- /sift/numerics1.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kif/imageAlignment/HEAD/sift/numerics1.cpp -------------------------------------------------------------------------------- /crc32.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | uint32_t crc32(char *str, uint32_t len); 5 | -------------------------------------------------------------------------------- /cythreading.pxd_bad: -------------------------------------------------------------------------------- 1 | 2 | cdef class FastRLock: 3 | pass 4 | cdef class Condition: 5 | pass 6 | cdef class Semaphore: 7 | pass 8 | -------------------------------------------------------------------------------- /crc64.pxd: -------------------------------------------------------------------------------- 1 | from libc.stdint cimport uint64_t 2 | cdef extern from "crc64.h": 3 | uint64_t crc64(char * seq, unsigned int lg_seq) 4 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Core/arch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_SUBDIRECTORY(SSE) 2 | ADD_SUBDIRECTORY(AltiVec) 3 | ADD_SUBDIRECTORY(NEON) 4 | ADD_SUBDIRECTORY(Default) 5 | -------------------------------------------------------------------------------- /third_party/Eigen/Dense: -------------------------------------------------------------------------------- 1 | #include "Core" 2 | #include "LU" 3 | #include "Cholesky" 4 | #include "QR" 5 | #include "SVD" 6 | #include "Geometry" 7 | #include "Eigenvalues" 8 | -------------------------------------------------------------------------------- /crc64.h: -------------------------------------------------------------------------------- 1 | #include 2 | #define POLY64REV 0x95AC9329AC4BC9B5 3 | #define INITIALCRC 0xFFFFFFFFFFFFFFFF 4 | 5 | uint64_t crc64(char *seq, unsigned int lg_seq); 6 | -------------------------------------------------------------------------------- /third_party/Eigen/src/QR/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_QR_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_QR_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/QR COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/Eigen/src/SVD/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_SVD_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_SVD_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/SVD COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/Eigen/src/misc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_misc_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_misc_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/misc COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Jacobi/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Jacobi_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Jacobi_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Jacobi COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/Eigen/src/LU/arch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_LU_arch_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_LU_arch_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/LU/arch COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Sparse/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Sparse_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Sparse_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Sparse COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/Eigen/src/plugins/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_plugins_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_plugins_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/plugins COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Cholesky/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Cholesky_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Cholesky_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Cholesky COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Core/util/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_util_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_util_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/util COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/Eigen/src/LU/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_LU_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_LU_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/LU COMPONENT Devel 6 | ) 7 | 8 | ADD_SUBDIRECTORY(arch) 9 | -------------------------------------------------------------------------------- /third_party/Eigen/src/StlSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_StlSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_StlSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/StlSupport COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Eigenvalues/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_EIGENVALUES_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_EIGENVALUES_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Eigenvalues COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Householder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Householder_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Householder_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Householder COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Core/arch/SSE/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_arch_SSE_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_arch_SSE_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/arch/SSE COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Core/products/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_Product_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_Product_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/products COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Geometry/arch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Geometry_arch_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Geometry_arch_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Geometry/arch COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Core/arch/NEON/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_arch_NEON_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_arch_NEON_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/arch/NEON COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /crc32.pxd: -------------------------------------------------------------------------------- 1 | from libc.stdint cimport uint32_t 2 | cdef extern from "crc32.h": 3 | void slowcrc_init() 4 | uint32_t slowcrc(char * str, uint32_t len) 5 | uint32_t fastcrc(char * str, uint32_t len) 6 | uint32_t crc32(char * str, uint32_t len) 7 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Core/arch/AltiVec/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_arch_AltiVec_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_arch_AltiVec_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/arch/AltiVec COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Core/arch/Default/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_arch_Default_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_arch_Default_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/arch/Default COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Geometry/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Geometry_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Geometry_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Geometry COMPONENT Devel 6 | ) 7 | 8 | ADD_SUBDIRECTORY(arch) 9 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Eigen2Support/Geometry/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Eigen2Support_Geometry_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Eigen2Support_Geometry_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Eigen2Support/Geometry 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Eigen2Support/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Eigen2Support_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Eigen2Support_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Eigen2Support COMPONENT Devel 6 | ) 7 | 8 | ADD_SUBDIRECTORY(Geometry) -------------------------------------------------------------------------------- /image.pxd: -------------------------------------------------------------------------------- 1 | 2 | cdef extern from "image/flimage.h": 3 | cdef cppclass flimage: 4 | flimage() 5 | flimage(int w, int h) 6 | flimage(int w, int h, float v) 7 | flimage(int w, int h, float * v) 8 | int nwidth() nogil 9 | int nheight() nogil 10 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core COMPONENT Devel 6 | ) 7 | 8 | ADD_SUBDIRECTORY(products) 9 | ADD_SUBDIRECTORY(util) 10 | ADD_SUBDIRECTORY(arch) 11 | -------------------------------------------------------------------------------- /third_party/Eigen/README.ipol: -------------------------------------------------------------------------------- 1 | Project: EIGEN 2 | URL: http://eigen.tuxfamily.org/ 3 | License: GPL/LGPL 4 | Upstream version: Eigen 3.0 released on March 19, 2011. 5 | 6 | Local modifications: 7 | 8 | * Use only the Eigen directory 9 | * Copy *.GPL and *.LGPL licence file 10 | * Add this readme file 11 | -------------------------------------------------------------------------------- /third_party/Eigen/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB Eigen_src_subdirectories "*") 2 | escape_string_as_regex(ESCAPED_CMAKE_CURRENT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") 3 | foreach(f ${Eigen_src_subdirectories}) 4 | if(NOT f MATCHES "\\.txt" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/[.].+" ) 5 | add_subdirectory(${f}) 6 | endif() 7 | endforeach() 8 | -------------------------------------------------------------------------------- /third_party/Eigen/Array: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_ARRAY_MODULE_H 2 | #define EIGEN_ARRAY_MODULE_H 3 | 4 | // include Core first to handle Eigen2 support macros 5 | #include "Core" 6 | 7 | #ifndef EIGEN2_SUPPORT 8 | #error The Eigen/Array header does no longer exist in Eigen3. All that functionality has moved to Eigen/Core. 9 | #endif 10 | 11 | #endif // EIGEN_ARRAY_MODULE_H 12 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Core/util/ReenableStupidWarnings.h: -------------------------------------------------------------------------------- 1 | #ifdef EIGEN_WARNINGS_DISABLED 2 | #undef EIGEN_WARNINGS_DISABLED 3 | 4 | #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS 5 | #ifdef _MSC_VER 6 | #pragma warning( pop ) 7 | #elif defined __INTEL_COMPILER 8 | #pragma warning pop 9 | #elif defined __clang__ 10 | #pragma clang diagnostic pop 11 | #endif 12 | #endif 13 | 14 | #endif // EIGEN_WARNINGS_DISABLED 15 | -------------------------------------------------------------------------------- /orsa.pxd: -------------------------------------------------------------------------------- 1 | # Cython header for keypoint comparison using Orsa algorithm 2 | 3 | from libcpp.vector cimport vector 4 | 5 | cdef extern from "orsa/match.h": 6 | struct Match: 7 | float x1, y1, x2, y2 8 | 9 | cdef extern from "orsa/orsa.h": 10 | float orsa(int width, int height, vector[Match] match, vector[float] index, int t_value, int verb_value, int n_flag_value, int mode_value, int stop_value)nogil 11 | 12 | ctypedef vector[ Match ] MatchList 13 | -------------------------------------------------------------------------------- /surf/surf_match.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file surf.h 3 | * \brief Header for SURF tools 4 | * 5 | * The only one you have to include. 6 | * 7 | */ 8 | 9 | 10 | #ifndef SURF 11 | #define SURF 12 | #include "integral.h" 13 | #include "descriptor.h" 14 | #include "keypoint.h" 15 | #include "match.h" 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | void get_points(listMatch* m,float* out); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /orsa_cpp.pxd: -------------------------------------------------------------------------------- 1 | # Cython header for keypoint comparison using Orsa algorithm 2 | 3 | from libcpp.vector cimport vector 4 | 5 | cdef extern from "orsa/match.h": 6 | struct Match: 7 | float x1, y1, x2, y2 8 | 9 | cdef extern from "orsa/orsa.h": 10 | float orsa(int width, int height, vector[Match] match, vector[float] index, int t_value, int verb_value, int n_flag_value, int mode_value, int stop_value)nogil 11 | 12 | ctypedef vector[ Match ] MatchList 13 | -------------------------------------------------------------------------------- /sift/frot.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007 Lionel Moisan 2 | 3 | #include "library.h" 4 | #include 5 | using namespace std; 6 | 7 | 8 | /*void frot(float *in, float *out, int nx, int ny, int *nx_out, int *ny_out, float *a, float *b, char *k_flag)*/ 9 | //void frot(float *, float (*)[], int, int, int *, int *, float *, float *, char *); 10 | void frot(vector&, vector&, int, int, int *, int *, float *, float *, char *); 11 | -------------------------------------------------------------------------------- /orsa/match.h: -------------------------------------------------------------------------------- 1 | // Authors: Unknown. Please, if you are the author of this file, or if you 2 | // know who are the authors of this file, let us know, so we can give the 3 | // adequate credits and/or get the adequate authorizations. 4 | 5 | #ifndef MATCH_H 6 | #define MATCH_H 7 | 8 | #include 9 | 10 | struct Match { 11 | float x1, y1, x2, y2; 12 | }; 13 | 14 | bool loadMatch(const char* nameFile, std::vector& match); 15 | bool saveMatch(const char* nameFile, const std::vector& match); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | # file GENERATED by distutils, do NOT edit 2 | include README 3 | include crc32.cpp 4 | include crc32.h 5 | include feature.pyx 6 | include setup.py 7 | include asift.pxd 8 | include crc32.pxd 9 | #include crc64.pxd 10 | include image.pxd 11 | include orsa_cpp.pxd 12 | include orsa.pxd 13 | include sift.pxd 14 | include surf.pxd 15 | recursive-include asift * 16 | recursive-include image * 17 | recursive-include orsa * 18 | recursive-include sift * 19 | recursive-include surf * 20 | recursive-include libNumerics * 21 | recursive-include third_party * 22 | -------------------------------------------------------------------------------- /sift/fproj.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007 Lionel Moisan 2 | 3 | #include "library.h" 4 | #include 5 | using namespace std; 6 | 7 | //void fproj(float *in, float *out, int nx, int ny, int *sx, int *sy, float *bg, int *o, float *p, char *i, float X1, float Y1, float X2, float Y2, float X3, float Y3, float *x4, float *y4); 8 | void fproj(vector& in, vector& out, int nx, int ny, int *sx, int *sy, float *bg, int *o, float *p, char *i, float X1, float Y1, float X2, float Y2, float X3, float Y3, float *x4, float *y4); 9 | 10 | -------------------------------------------------------------------------------- /surf/match.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file correspondances.h 3 | * \brief Header for matching 4 | * 5 | * Empty. 6 | * 7 | */ 8 | 9 | #ifndef MATCH 10 | #define MATCH 11 | #include 12 | 13 | #include "descriptor.h" 14 | 15 | /// A vector of descriptor for matching 16 | typedef std::pair pairMatch; 17 | typedef std::vector listMatch; 18 | float euclideanDistance(descriptor *a,descriptor* b); 19 | 20 | image* showDescriptors(image* img1,listDescriptor* listeDesc,bool afficher); 21 | void lign(image *img,float xa,float ya,float xb, float yb,float intensite); 22 | listMatch* matchDescriptor(listDescriptor * l1, listDescriptor * l2); 23 | 24 | #endif -------------------------------------------------------------------------------- /third_party/Eigen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(RegexUtils) 2 | test_escape_string_as_regex() 3 | 4 | file(GLOB Eigen_directory_files "*") 5 | 6 | escape_string_as_regex(ESCAPED_CMAKE_CURRENT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") 7 | 8 | foreach(f ${Eigen_directory_files}) 9 | if(NOT f MATCHES "\\.txt" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/[.].+" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/src") 10 | list(APPEND Eigen_directory_files_to_install ${f}) 11 | endif() 12 | endforeach(f ${Eigen_directory_files}) 13 | 14 | install(FILES 15 | ${Eigen_directory_files_to_install} 16 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen COMPONENT Devel 17 | ) 18 | 19 | add_subdirectory(src) 20 | -------------------------------------------------------------------------------- /surf/surf_match.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * surf_matching.cpp 3 | * Extract a serie of matching point from surf comparison 4 | * 5 | * Created by Jerome Kieffer (kieffer@esrf.fr). 6 | * Copyright 2012 ESRF. 7 | * Licenced under the GPL 8 | */ 9 | #define ABS(x) (((x) > 0) ? (x) : (-(x))) 10 | 11 | #include "surf_match.h" 12 | 13 | 14 | using namespace std; 15 | 16 | //Extract matching points 17 | void get_points(listMatch* m,float* out){ 18 | for(int i=0;isize();i++) 19 | { 20 | out[4*i] = ((((*m)[i]).first)->kP)->y; 21 | out[4*i+1] = ((((*m)[i]).first)->kP)->x; 22 | out[4*i+2] = ((((*m)[i]).second)->kP)->y; 23 | out[4*i+3] = ((((*m)[i]).second)->kP)->x; 24 | } 25 | } 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /third_party/Eigen/Householder: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_HOUSEHOLDER_MODULE_H 2 | #define EIGEN_HOUSEHOLDER_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | namespace Eigen { 9 | 10 | /** \defgroup Householder_Module Householder module 11 | * This module provides Householder transformations. 12 | * 13 | * \code 14 | * #include 15 | * \endcode 16 | */ 17 | 18 | #include "src/Householder/Householder.h" 19 | #include "src/Householder/HouseholderSequence.h" 20 | #include "src/Householder/BlockHouseholder.h" 21 | 22 | } // namespace Eigen 23 | 24 | #include "src/Core/util/ReenableStupidWarnings.h" 25 | 26 | #endif // EIGEN_HOUSEHOLDER_MODULE_H 27 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 28 | -------------------------------------------------------------------------------- /libNumerics/rodrigues.h: -------------------------------------------------------------------------------- 1 | // Authors: Unknown. Please, if you are the author of this file, or if you 2 | // know who are the authors of this file, let us know, so we can give the 3 | // adequate credits and/or get the adequate authorizations. 4 | 5 | #ifndef RODRIGUES_H 6 | #define RODRIGUES_H 7 | 8 | #include "matrix.h" 9 | #include 10 | 11 | namespace libNumerics { 12 | 13 | /// Skew-symmetric matrix of 3-vector v. 14 | template matrix skew(const vector& v); 15 | /// Rodrigues's rotation: exp(w_x). 16 | template matrix rotation(vector w); 17 | /// Inverse Rodrigues's formula: w s.t. R=exp(w_x). 18 | template vector rotationAxis(const matrix& R); 19 | 20 | } // libNumerics 21 | 22 | #include "rodrigues.cpp" 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /crc64.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define POLY64REV 0x95AC9329AC4BC9B5 4 | #define INITIALCRC 0xFFFFFFFFFFFFFFFF 5 | uint64_t crc64(char *seq, unsigned int lg_seq) 6 | { 7 | unsigned short i; 8 | unsigned char j; 9 | uint64_t crc = INITIALCRC; 10 | uint64_t part; 11 | static bool init = false; 12 | static uint64_t CRCTable[256]; 13 | 14 | if (!init) 15 | { 16 | init = true; 17 | for (i = 0; i < 256; i++) 18 | { 19 | part = i; 20 | for (j = 0; j < 8; j++) 21 | { 22 | if (part & 1) 23 | part = (part >> 1) ^ POLY64REV; 24 | else 25 | part >>= 1; 26 | } 27 | CRCTable[i] = part; 28 | } 29 | } 30 | 31 | while (lg_seq-- > 0) 32 | crc = CRCTable[(crc ^ *seq++) & 0xff] ^ (crc >> 8); 33 | 34 | return crc; 35 | } 36 | -------------------------------------------------------------------------------- /third_party/Eigen/QtAlignedMalloc: -------------------------------------------------------------------------------- 1 | 2 | #ifndef EIGEN_QTMALLOC_MODULE_H 3 | #define EIGEN_QTMALLOC_MODULE_H 4 | 5 | #include "Core" 6 | 7 | #if (!EIGEN_MALLOC_ALREADY_ALIGNED) 8 | 9 | #include "src/Core/util/DisableStupidWarnings.h" 10 | 11 | void *qMalloc(size_t size) 12 | { 13 | return Eigen::internal::aligned_malloc(size); 14 | } 15 | 16 | void qFree(void *ptr) 17 | { 18 | Eigen::internal::aligned_free(ptr); 19 | } 20 | 21 | void *qRealloc(void *ptr, size_t size) 22 | { 23 | void* newPtr = Eigen::internal::aligned_malloc(size); 24 | memcpy(newPtr, ptr, size); 25 | Eigen::internal::aligned_free(ptr); 26 | return newPtr; 27 | } 28 | 29 | #include "src/Core/util/ReenableStupidWarnings.h" 30 | 31 | #endif 32 | 33 | #endif // EIGEN_QTMALLOC_MODULE_H 34 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 35 | -------------------------------------------------------------------------------- /third_party/Eigen/Jacobi: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_JACOBI_MODULE_H 2 | #define EIGEN_JACOBI_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | namespace Eigen { 9 | 10 | /** \defgroup Jacobi_Module Jacobi module 11 | * This module provides Jacobi and Givens rotations. 12 | * 13 | * \code 14 | * #include 15 | * \endcode 16 | * 17 | * In addition to listed classes, it defines the two following MatrixBase methods to apply a Jacobi or Givens rotation: 18 | * - MatrixBase::applyOnTheLeft() 19 | * - MatrixBase::applyOnTheRight(). 20 | */ 21 | 22 | #include "src/Jacobi/Jacobi.h" 23 | 24 | } // namespace Eigen 25 | 26 | #include "src/Core/util/ReenableStupidWarnings.h" 27 | 28 | #endif // EIGEN_JACOBI_MODULE_H 29 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 30 | 31 | -------------------------------------------------------------------------------- /test_numpy.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | from math import sin, cos, pi 3 | import numpy 4 | import matplotlib 5 | from matplotlib import pylab 6 | import scipy 7 | import feature 8 | 9 | l = scipy.misc.lena().astype(numpy.float32) 10 | fig = pylab.figure() 11 | sp = fig.add_subplot(1, 1, 1) 12 | sp.imshow(l, interpolation="nearest", cmap="gray") 13 | siftalignement = feature.SiftAlignment() 14 | kp = siftalignement.sift(l) 15 | print kp[:, :4] 16 | print kp[:, :4].max(axis=0) 17 | print kp.shape[0] 18 | 19 | for i in range(kp.shape[0]): 20 | x = kp[i, 0] 21 | y = kp[i, 1] 22 | scale = kp[i, 2] 23 | angle = kp[i, 3] 24 | sp.annotate("", xy=(x, y), xytext=(x + scale * cos(angle), y + scale * sin(angle)), color="blue", 25 | arrowprops=dict(facecolor='blue', edgecolor='blue', width=1),) 26 | fig.show() 27 | raw_input("enter to quit") 28 | -------------------------------------------------------------------------------- /third_party/Eigen/Cholesky: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_CHOLESKY_MODULE_H 2 | #define EIGEN_CHOLESKY_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | namespace Eigen { 9 | 10 | /** \defgroup Cholesky_Module Cholesky module 11 | * 12 | * 13 | * 14 | * This module provides two variants of the Cholesky decomposition for selfadjoint (hermitian) matrices. 15 | * Those decompositions are accessible via the following MatrixBase methods: 16 | * - MatrixBase::llt(), 17 | * - MatrixBase::ldlt() 18 | * 19 | * \code 20 | * #include 21 | * \endcode 22 | */ 23 | 24 | #include "src/misc/Solve.h" 25 | #include "src/Cholesky/LLT.h" 26 | #include "src/Cholesky/LDLT.h" 27 | 28 | } // namespace Eigen 29 | 30 | #include "src/Core/util/ReenableStupidWarnings.h" 31 | 32 | #endif // EIGEN_CHOLESKY_MODULE_H 33 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 34 | -------------------------------------------------------------------------------- /asift/log.txt: -------------------------------------------------------------------------------- 1 | - 2010.04.08, Pierre Moulon 2 | Use Eigen matrix library in order to compute the SVD in ORSA. 3 | Add a Cmake based build, for easier compilation on Windows. 4 | 5 | - 2010.11.08, Guoshen Yu 6 | Remove a few minor bugs in orsa.cpp. 7 | Code compiled with Intel C++ and Visual C++ compilers under Windows (32 bits). Both OpenMP and vectorization work with Intel C++. OpenMP but vectorization withs with Visual C++. 8 | 9 | - 2010.08.17, Guoshen Yu 10 | In compute_asift_matches.c, change the nfa_max value from 0 to -2 to reduce false matching. 11 | 12 | - 2010.08.28, Guoshen Yu 13 | In demo_lib_sift.cpp, change par.MatchRatio from 0.75 to 0.73 to reduce et number of false matches. 14 | In demo_ASIFT.cpp, change the image resize target dimension from 640x480 to 800x600. 15 | In demo_ASIFT.cpp, add a white band between the images in the output image for better visibility. 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /third_party/Eigen/LeastSquares: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_REGRESSION_MODULE_H 2 | #define EIGEN_REGRESSION_MODULE_H 3 | 4 | #ifndef EIGEN2_SUPPORT 5 | #error LeastSquares is only available in Eigen2 support mode (define EIGEN2_SUPPORT) 6 | #endif 7 | 8 | // exclude from normal eigen3-only documentation 9 | #ifdef EIGEN2_SUPPORT 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include "Eigenvalues" 16 | #include "Geometry" 17 | 18 | namespace Eigen { 19 | 20 | /** \defgroup LeastSquares_Module LeastSquares module 21 | * This module provides linear regression and related features. 22 | * 23 | * \code 24 | * #include 25 | * \endcode 26 | */ 27 | 28 | #include "src/Eigen2Support/LeastSquares.h" 29 | 30 | } // namespace Eigen 31 | 32 | #include "src/Core/util/ReenableStupidWarnings.h" 33 | 34 | #endif // EIGEN2_SUPPORT 35 | 36 | #endif // EIGEN_REGRESSION_MODULE_H 37 | -------------------------------------------------------------------------------- /third_party/Eigen/SVD: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_SVD_MODULE_H 2 | #define EIGEN_SVD_MODULE_H 3 | 4 | #include "QR" 5 | #include "Householder" 6 | #include "Jacobi" 7 | 8 | #include "src/Core/util/DisableStupidWarnings.h" 9 | 10 | namespace Eigen { 11 | 12 | /** \defgroup SVD_Module SVD module 13 | * 14 | * 15 | * 16 | * This module provides SVD decomposition for (currently) real matrices. 17 | * This decomposition is accessible via the following MatrixBase method: 18 | * - MatrixBase::svd() 19 | * 20 | * \code 21 | * #include 22 | * \endcode 23 | */ 24 | 25 | #include "src/misc/Solve.h" 26 | #include "src/SVD/JacobiSVD.h" 27 | #include "src/SVD/UpperBidiagonalization.h" 28 | 29 | #ifdef EIGEN2_SUPPORT 30 | #include "src/Eigen2Support/SVD.h" 31 | #endif 32 | 33 | } // namespace Eigen 34 | 35 | #include "src/Core/util/ReenableStupidWarnings.h" 36 | 37 | #endif // EIGEN_SVD_MODULE_H 38 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 39 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | imageAlignement is a python wrapper for various algorithm described in IPOL and doing image alignment: 2 | http://www.ipol.im/ 3 | 4 | Wrapper made by Jerome Kieffer (jerome.kieffer@esrf.fr) and released under the LGPL. 5 | Copyright: 2012 ESRF Grenoble 6 | 7 | 1) Installation 8 | 9 | python setup.py build_ext --inplace 10 | 11 | 2) Test 12 | 13 | python test.py 14 | 15 | This wrapper relies on code published in IPOL: 16 | SURF & SIFT: 17 | * Webpage: http://www.ipol.im/pub/algo/or_speeded_up_robust_features/ 18 | * Authors: edouard.oyallon@ens-cachan.fr, for CMLA & IPOL, under the direction of julien.rabin@cmla.ens-cachan.fr 19 | ORSA: 20 | * Webpage: http://www.ipol.im/pub/algo/mmm_orsa_homography/ 21 | * Authors: Lionel Moisan , Pierre Moulon , Pascal Monasse 22 | ASIFT: 23 | * Webpage: http://dx.doi.org/10.5201/ipol.2011.my-asift 24 | * Authors: Guoshen Yu , Jean-Michel Morel 25 | -------------------------------------------------------------------------------- /third_party/Eigen/QR: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_QR_MODULE_H 2 | #define EIGEN_QR_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include "Cholesky" 9 | #include "Jacobi" 10 | #include "Householder" 11 | 12 | namespace Eigen { 13 | 14 | /** \defgroup QR_Module QR module 15 | * 16 | * 17 | * 18 | * This module provides various QR decompositions 19 | * This module also provides some MatrixBase methods, including: 20 | * - MatrixBase::qr(), 21 | * 22 | * \code 23 | * #include 24 | * \endcode 25 | */ 26 | 27 | #include "src/misc/Solve.h" 28 | #include "src/QR/HouseholderQR.h" 29 | #include "src/QR/FullPivHouseholderQR.h" 30 | #include "src/QR/ColPivHouseholderQR.h" 31 | 32 | #ifdef EIGEN2_SUPPORT 33 | #include "src/Eigen2Support/QR.h" 34 | #endif 35 | 36 | } // namespace Eigen 37 | 38 | #include "src/Core/util/ReenableStupidWarnings.h" 39 | 40 | #ifdef EIGEN2_SUPPORT 41 | #include "Eigenvalues" 42 | #endif 43 | 44 | #endif // EIGEN_QR_MODULE_H 45 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 46 | -------------------------------------------------------------------------------- /third_party/Eigen/LU: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_LU_MODULE_H 2 | #define EIGEN_LU_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | namespace Eigen { 9 | 10 | /** \defgroup LU_Module LU module 11 | * This module includes %LU decomposition and related notions such as matrix inversion and determinant. 12 | * This module defines the following MatrixBase methods: 13 | * - MatrixBase::inverse() 14 | * - MatrixBase::determinant() 15 | * 16 | * \code 17 | * #include 18 | * \endcode 19 | */ 20 | 21 | #include "src/misc/Solve.h" 22 | #include "src/misc/Kernel.h" 23 | #include "src/misc/Image.h" 24 | #include "src/LU/FullPivLU.h" 25 | #include "src/LU/PartialPivLU.h" 26 | #include "src/LU/Determinant.h" 27 | #include "src/LU/Inverse.h" 28 | 29 | #if defined EIGEN_VECTORIZE_SSE 30 | #include "src/LU/arch/Inverse_SSE.h" 31 | #endif 32 | 33 | #ifdef EIGEN2_SUPPORT 34 | #include "src/Eigen2Support/LU.h" 35 | #endif 36 | 37 | } // namespace Eigen 38 | 39 | #include "src/Core/util/ReenableStupidWarnings.h" 40 | 41 | #endif // EIGEN_LU_MODULE_H 42 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 43 | -------------------------------------------------------------------------------- /asift.pxd: -------------------------------------------------------------------------------- 1 | from libcpp cimport bool 2 | from libcpp.pair cimport pair 3 | from libcpp.vector cimport vector 4 | from sift cimport keypointslist, siftPar, matchingslist 5 | cdef extern from "asift/compute_asift_keypoints.h": 6 | int compute_asift_keypoints(vector[float] image, 7 | int width, 8 | int height, 9 | int num_of_tilts, 10 | int verb, 11 | vector[ vector[ keypointslist ]] & keys_all, 12 | siftPar siftparameters) nogil 13 | cdef extern from "asift/compute_asift_matches.h": 14 | int compute_asift_matches(int num_of_tilts1, 15 | int num_of_tilts2, 16 | int w1, int h1, 17 | int w2, int h2, 18 | int verb, 19 | vector[vector[keypointslist]] keys1, 20 | vector[vector[keypointslist]] keys2, 21 | matchingslist matchings, 22 | siftPar siftparameters) nogil 23 | -------------------------------------------------------------------------------- /image/image.cpp.nogood: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | class Image{ 5 | public: 6 | Image(){ 7 | std::cout<<"Image::Image() default constructor"< v; 37 | //v.reserve(100); 38 | Image i; 39 | std::cout <<"pass 1"< 12 | using namespace std; 13 | 14 | 15 | //float v(float *in,int x,int y,float bg, int width, int height); 16 | 17 | // Guoshen Yu, 2010.09.21, Windows version 18 | float v(vector& in,int x,int y,float bg, int width, int height); 19 | //float v(float *in, int x,int y,float bg, int width, int height); 20 | 21 | void keys(float *c,float t,float a); 22 | void spline3(float *c,float t); 23 | void init_splinen(float *a,int n); 24 | void splinen(float *c,float t,float *a,int n); 25 | 26 | //void finvspline(float *in,int order,float *out, int width, int height); 27 | 28 | // Guoshen Yu, 2010.09.22, Windows versions 29 | void finvspline(vector& in,int order,vector& out, int width, int height); 30 | // void finvspline(float *in,int order,float *out, int width, int height); 31 | 32 | 33 | #endif 34 | 35 | -------------------------------------------------------------------------------- /test2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import fabio, feature, time 3 | print feature.__file__ 4 | ref0 = 1.6923630028440242 5 | ref1 = 0.67084262245579773 6 | img1 = fabio.open("Ti_slow_data_0000_0011_0000_norm.edf").data 7 | img2 = fabio.open("Ti_slow_data_0002_0055_0000_norm.edf").data 8 | #out = feature.sift2(img1, img2 , True) 9 | #assert abs((out[:, 2] - out[:, 0]).mean() - ref0) < 0.01 10 | #assert abs((out[:, 3] - out[:, 1]).mean() - ref1) < 0.01 11 | 12 | import threading 13 | dico = {} 14 | sift = feature.SiftAlignment() 15 | def oneImg(name): 16 | img1 = fabio.open(name).data 17 | dico[name] = sift.sift(img1) 18 | th1 = threading.Thread(target=oneImg, args=["Ti_slow_data_0000_0011_0000_norm.edf"]) 19 | th2 = threading.Thread(target=oneImg, args=["Ti_slow_data_0002_0055_0000_norm.edf"]) 20 | t0 = time.time() 21 | th1.start();th2.start() 22 | th1.join();th2.join() 23 | 24 | print time.time() - t0, dico 25 | t0 = time.time() 26 | out = sift.match(dico["Ti_slow_data_0000_0011_0000_norm.edf"], dico["Ti_slow_data_0002_0055_0000_norm.edf"]) 27 | print time.time() - t0 28 | assert abs((out[:, 2] - out[:, 0]).mean() - ref0) < 0.01 29 | assert abs((out[:, 3] - out[:, 1]).mean() - ref1) < 0.01 30 | 31 | -------------------------------------------------------------------------------- /orsa/match.cpp: -------------------------------------------------------------------------------- 1 | // Authors: Unknown. Please, if you are the author of this file, or if you 2 | // know who are the authors of this file, let us know, so we can give the 3 | // adequate credits and/or get the adequate authorizations. 4 | 5 | #include "match.h" 6 | #include 7 | #include 8 | 9 | bool loadMatch(const char* nameFile, std::vector& match) { 10 | match.clear(); 11 | std::ifstream f(nameFile); 12 | while( f.good() ) { 13 | std::string str; 14 | std::getline(f, str); 15 | if( f.good() ) { 16 | std::istringstream s(str); 17 | Match m; 18 | s >> m.x1 >> m.y1 >> m.x2 >> m.y2; 19 | if(!s.fail() ) 20 | match.push_back(m); 21 | } 22 | } 23 | return !match.empty(); 24 | } 25 | 26 | bool saveMatch(const char* nameFile, const std::vector& match) { 27 | std::ofstream f(nameFile); 28 | if( f.is_open() ) { 29 | std::vector::const_iterator it = match.begin(); 30 | for(; it != match.end(); ++it) 31 | f << it->x1 << " " << it->y1 << " " 32 | << it->x2 << " " << it->y2 << std::endl; 33 | } 34 | return f.is_open(); 35 | } 36 | -------------------------------------------------------------------------------- /third_party/Eigen/Eigenvalues: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_EIGENVALUES_MODULE_H 2 | #define EIGEN_EIGENVALUES_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include "Cholesky" 9 | #include "Jacobi" 10 | #include "Householder" 11 | #include "LU" 12 | 13 | namespace Eigen { 14 | 15 | /** \defgroup Eigenvalues_Module Eigenvalues module 16 | * 17 | * 18 | * 19 | * This module mainly provides various eigenvalue solvers. 20 | * This module also provides some MatrixBase methods, including: 21 | * - MatrixBase::eigenvalues(), 22 | * - MatrixBase::operatorNorm() 23 | * 24 | * \code 25 | * #include 26 | * \endcode 27 | */ 28 | 29 | #include "src/Eigenvalues/Tridiagonalization.h" 30 | #include "src/Eigenvalues/RealSchur.h" 31 | #include "src/Eigenvalues/EigenSolver.h" 32 | #include "src/Eigenvalues/SelfAdjointEigenSolver.h" 33 | #include "src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h" 34 | #include "src/Eigenvalues/HessenbergDecomposition.h" 35 | #include "src/Eigenvalues/ComplexSchur.h" 36 | #include "src/Eigenvalues/ComplexEigenSolver.h" 37 | #include "src/Eigenvalues/MatrixBaseEigenvalues.h" 38 | 39 | } // namespace Eigen 40 | 41 | #include "src/Core/util/ReenableStupidWarnings.h" 42 | 43 | #endif // EIGEN_EIGENVALUES_MODULE_H 44 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 45 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Eigenvalues/EigenvaluesCommon.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2010 Jitse Niesen 5 | // 6 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_EIGENVALUES_COMMON_H 26 | #define EIGEN_EIGENVALUES_COMMON_H 27 | 28 | 29 | 30 | #endif // EIGEN_EIGENVALUES_COMMON_H 31 | 32 | -------------------------------------------------------------------------------- /libNumerics/rodrigues.cpp: -------------------------------------------------------------------------------- 1 | // Authors: Unknown. Please, if you are the author of this file, or if you 2 | // know who are the authors of this file, let us know, so we can give the 3 | // adequate credits and/or get the adequate authorizations. 4 | 5 | #ifdef RODRIGUES_H 6 | 7 | namespace libNumerics { 8 | 9 | template 10 | matrix skew(const vector& v) 11 | { 12 | assert(v.nrow() == 3); 13 | matrix M(3,3); 14 | M(0,0) = M(1,1) = M(2,2) = 0; 15 | M(1,2) = -(M(2,1)=v(0)); 16 | M(2,0) = -(M(0,2)=v(1)); 17 | M(0,1) = -(M(1,0)=v(2)); 18 | return M; 19 | } 20 | 21 | template 22 | matrix rotation(vector w) 23 | { 24 | assert(w.nrow() == 3); 25 | T n = sqrt(w.qnorm()); 26 | T c = cos(n); 27 | matrix R = c*matrix::eye(3); 28 | if(n) { 29 | w /= n; 30 | R += skew(sin(n)*w); 31 | R += (1-c)*w*w.t(); 32 | } 33 | return R; 34 | } 35 | 36 | template 37 | vector rotationAxis(const matrix& R) 38 | { 39 | assert(R.nrow() == 3 && R.ncol() == 3); 40 | vector w(3); 41 | T n = acos(0.5*(R.tr()-1)); 42 | if(n == 0) 43 | w = 0; 44 | else { 45 | w(0) = R(2,1)-R(1,2); 46 | w(1) = R(0,2)-R(2,0); 47 | w(2) = R(1,0)-R(0,1); 48 | w *= n/(2*sin(n)); 49 | } 50 | return w; 51 | } 52 | 53 | } // libNumerics 54 | 55 | #endif // RODRIGUES_H 56 | -------------------------------------------------------------------------------- /surf/descriptor.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file descriptor.h 3 | * \brief Header for SURF descriptors 4 | * 5 | * All functions required are there. 6 | * 7 | */ 8 | /// \class descriptor 9 | /** \brief The descriptor itself 10 | */ 11 | #ifndef DESCRIPTOR 12 | 13 | #define DESCRIPTOR 14 | #include 15 | #include "image.h" 16 | #include "keypoint.h" 17 | 18 | #include "integral.h" 19 | #include "descriptor.h" 20 | 21 | #include "lib.h" 22 | 23 | 24 | 25 | /// \class vectorDescriptor 26 | /** \brief A descriptor */ 27 | class vectorDescriptor{ 28 | public : 29 | float sumDx; 30 | float sumDy; 31 | float sumAbsDx; 32 | float sumAbsDy; 33 | vectorDescriptor(float a,float b,float c, float d); 34 | ~vectorDescriptor(); 35 | vectorDescriptor(); 36 | }; 37 | 38 | 39 | 40 | 41 | class descriptor{ 42 | public:vectorDescriptor* list;///Will be the 16 elements of the descriptor 43 | keyPoint* kP;/// Keypoint linked to the descriptor. 44 | descriptor(); 45 | descriptor(descriptor* a); 46 | 47 | ~descriptor(); 48 | descriptor(const descriptor & des); 49 | 50 | }; 51 | 52 | typedef std::vector listDescriptor; 53 | 54 | 55 | 56 | descriptor* makeDescriptor(imageIntegral* imgInt,keyPoint* pC); 57 | listDescriptor* getDescriptor(imageIntegral* imgInt,listKeyPoints* lPC); 58 | listDescriptor* getKeyPoints(image *img,int numberOctave,int numberInterval,listKeyPoints* lKP,bool verbose); 59 | 60 | #endif -------------------------------------------------------------------------------- /image/flimage.h: -------------------------------------------------------------------------------- 1 | // Authors: Unknown. Please, if you are the author of this file, or if you 2 | // know who are the authors of this file, let us know, so we can give the 3 | // adequate credits and/or get the adequate authorizations. 4 | 5 | 6 | #ifndef _FLIMAGE_H_ 7 | #define _FLIMAGE_H_ 8 | 9 | #include 10 | #include 11 | 12 | class flimage { 13 | 14 | private: 15 | 16 | int width, height; // image size 17 | float* p; // array of color levels: level of pixel (x,y) is p[y*width+x] 18 | 19 | public: 20 | 21 | 22 | //// Construction 23 | flimage(); 24 | flimage(int w, int h); 25 | flimage(int w, int h, float v); 26 | flimage(int w, int h, float* v); 27 | flimage(const flimage& im); 28 | flimage& operator= (const flimage& im); 29 | 30 | 31 | void create(int w, int h); 32 | void create(int w, int h, float *v); 33 | 34 | //// Destruction 35 | void erase(); 36 | ~flimage(); 37 | 38 | //// Get Basic Data 39 | int nwidth() const {return width;} // image size 40 | int nheight() const {return height;} 41 | 42 | /// Access values 43 | float* getPlane() {return p;} // return the adress of the array of values 44 | 45 | float operator()(int x, int y) const {return p[ y*width + x ];} // acces to the (x,y) value 46 | float& operator()(int x, int y) {return p[ y*width + x ];} // by value (for const images) and by reference 47 | 48 | 49 | }; 50 | 51 | 52 | #endif 53 | 54 | -------------------------------------------------------------------------------- /crc32.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | bool initialized(false); 6 | uint32_t slowcrc_table[1<<8]; 7 | 8 | void slowcrc_init() { 9 | uint32_t i, j, a; 10 | 11 | for (i=0;i<(1<<8);i++) { 12 | a=((uint32_t)i)<<24; 13 | for (j=0;j<8;j++) { 14 | if (a&0x80000000) 15 | a=(a<<1)^0x11EDC6F41; 16 | else 17 | a=(a<<1); 18 | } 19 | slowcrc_table[i]=a; 20 | } 21 | initialized=true; 22 | } 23 | 24 | uint32_t slowcrc(char *str, uint32_t len) { 25 | uint32_t lcrc=~0; 26 | char *p, *e; 27 | 28 | e=str+len; 29 | for (p=str;p < e;++p) 30 | lcrc=(lcrc>>8)^slowcrc_table[(lcrc^(*p))&0xff]; 31 | return ~lcrc; 32 | } 33 | 34 | uint32_t fastcrc(const char *str, uint32_t len) { 35 | uint64_t q=len/sizeof(uint64_t), 36 | r=len%sizeof(uint64_t), 37 | *p=(uint64_t*)str, 38 | crc64=0; 39 | uint32_t crc=0; 40 | 41 | while (q--) { 42 | crc64 = _mm_crc32_u64(crc64,*p); 43 | p++; 44 | } 45 | 46 | str=(char*)p; 47 | crc=crc64; 48 | while (r--) { 49 | crc = _mm_crc32_u8(crc,*str); 50 | str++; 51 | } 52 | 53 | return crc; 54 | } 55 | 56 | uint32_t crc32(char *str, uint32_t len) { 57 | uint32_t eax, ebx, ecx, edx; 58 | __get_cpuid(1, &eax, &ebx, &ecx, &edx); 59 | 60 | if (ecx & bit_SSE4_2){ 61 | return fastcrc(str,len); 62 | }else{ 63 | if (!initialized){ 64 | slowcrc_init(); 65 | } 66 | return slowcrc(str,len); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /surf.pxd: -------------------------------------------------------------------------------- 1 | from libcpp cimport bool 2 | from libcpp.pair cimport pair 3 | from libcpp.vector cimport vector 4 | 5 | cdef extern from "surf/image.h": 6 | cdef cppclass image: 7 | image(int , int) 8 | int idImage 9 | int width, height 10 | float * img 11 | 12 | cdef extern from "surf/keypoint.h": 13 | cdef cppclass keyPoint: 14 | # keyPoint() # 15 | keypoint(float, float, float, float, bool) 16 | float x, y, scale, orientation 17 | bool signLaplacian 18 | # typedef std::vector < keyPoint *> listKeyPoints 19 | ctypedef vector[ keyPoint * ] listKeyPoints 20 | 21 | cdef extern from "surf/descriptor.h": 22 | cdef cppclass descriptor: 23 | descriptor() 24 | descriptor(descriptor *) 25 | keyPoint * kP 26 | #std::vector listDescriptor; 27 | ctypedef vector[ descriptor * ] listDescriptor 28 | listDescriptor * getKeyPoints(image * , int , int , listKeyPoints * , bool)nogil 29 | 30 | cdef extern from "surf/match.h": 31 | #typedef std::pair pairMatch; 32 | ctypedef pair[ descriptor , descriptor ] pairMatch 33 | #typedef std::vector listMatch; 34 | ctypedef vector[ pairMatch ] listMatch 35 | listMatch * matchDescriptor(listDescriptor * , listDescriptor *)nogil 36 | 37 | cdef extern from "surf/lib.h": 38 | int octave 39 | int interval 40 | 41 | cdef extern from "surf/surf_match.h": 42 | void get_points(listMatch * , float *)nogil 43 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Eigen2Support/Macros.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2011 Benoit Jacob 5 | // 6 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN2_MACROS_H 26 | #define EIGEN2_MACROS_H 27 | 28 | #define ei_assert eigen_assert 29 | #define ei_internal_assert eigen_internal_assert 30 | 31 | #define EIGEN_ALIGN_128 EIGEN_ALIGN16 32 | 33 | #define EIGEN_ARCH_WANTS_ALIGNMENT EIGEN_ALIGN_STATICALLY 34 | 35 | #endif // EIGEN2_MACROS_H 36 | -------------------------------------------------------------------------------- /surf/integral.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file integrale.h 3 | * \brief {File concerning calculus of integral image, convolution, haarwavelet, etc} 4 | * 5 | */ 6 | 7 | 8 | #include "integral.h" 9 | 10 | 11 | 12 | /// Compute integrale image 13 | /** Take in argument the image, symetrize it and then calculate. 14 | */ 15 | imageIntegral* computeIntegralImage(image* img,bool verbose) 16 | { 17 | int starter=3*(3+pow(2.0f,octave)*(interval+2)); 18 | image* stamp=new image(img->w()+2*starter,img->h()+2*starter); 19 | int i2,j2; 20 | for(int j=-starter;jh()+starter;j++) 21 | for(int i=-starter;iw()+starter;i++) 22 | 23 | { 24 | i2=i; 25 | j2=j; 26 | if(i<0) 27 | i2=-i; 28 | else if(i>img->w()-1) 29 | i2=2*(img->w()-1)-i; 30 | if(j<0) 31 | j2=-j; 32 | 33 | else if(j>img->h()-1) 34 | 35 | j2=2*(img->h()-1)-j; 36 | 37 | 38 | 39 | 40 | (*stamp)(i+starter,j+starter)=(*img)(i2,j2); 41 | } 42 | //Now we use the stamp to compute its integral image. 43 | imageIntegral* imgInt=new imageIntegral(stamp); 44 | (*imgInt)(0,0)=(*stamp)(0,0); 45 | for(int i=1;iw();i++) 46 | (*imgInt)(i,0)=(*imgInt)(i-1,0)+(*stamp)(i,0); 47 | 48 | 49 | for(int j=1;jh();j++) 50 | { 51 | float h=0.f; 52 | for(int i=0;iw();i++) 53 | { 54 | h+=(*stamp)(i,j); 55 | (*imgInt)(i,j)=(*imgInt)(i,j-1)+h; 56 | } 57 | } 58 | delete stamp; 59 | if(verbose) 60 | imgInt->printImage((char*)"imInt.png"); 61 | imgInt->center(starter,img); 62 | 63 | return imgInt; 64 | 65 | } 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /third_party/Eigen/StdList: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Hauke Heibel 5 | // 6 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_STDLIST_MODULE_H 26 | #define EIGEN_STDLIST_MODULE_H 27 | 28 | #include "Core" 29 | #include 30 | 31 | #if (defined(_MSC_VER) && defined(_WIN64)) /* MSVC auto aligns in 64 bit builds */ 32 | 33 | #define EIGEN_DEFINE_STL_LIST_SPECIALIZATION(...) 34 | 35 | #else 36 | 37 | #include "src/StlSupport/StdList.h" 38 | 39 | #endif 40 | 41 | #endif // EIGEN_STDLIST_MODULE_H 42 | -------------------------------------------------------------------------------- /libNumerics/homography.cpp: -------------------------------------------------------------------------------- 1 | // Authors: Unknown. Please, if you are the author of this file, or if you 2 | // know who are the authors of this file, let us know, so we can give the 3 | // adequate credits and/or get the adequate authorizations. 4 | 5 | #include "homography.h" 6 | 7 | namespace libNumerics { 8 | 9 | /// Constructor. 10 | Homography::Homography() 11 | : m_H( matrix::eye(3) ) 12 | {} 13 | 14 | /// Put to identity. 15 | void Homography::setId() 16 | { 17 | m_H = matrix::eye(3); 18 | } 19 | 20 | /// Set to translation. 21 | void Homography::setTrans(double dx, double dy) 22 | { 23 | setId(); 24 | m_H(0,2) = dx; 25 | m_H(1,2) = dy; 26 | } 27 | 28 | /// Set to zoom. 29 | void Homography::setZoom(double zx, double zy) 30 | { 31 | setId(); 32 | m_H(0,0) = zx; 33 | m_H(1,1) = zy; 34 | } 35 | 36 | /// Apply homography. 37 | void Homography::operator()(double& x, double& y) const 38 | { 39 | vector m(3); 40 | m(0) = x; 41 | m(1) = y; 42 | m(2) = 1.0f; 43 | m = m_H * m; 44 | double z_1 = 1.0 / m(2); 45 | x = m(0) * z_1; 46 | y = m(1) * z_1; 47 | } 48 | 49 | /// Compose homographies. 50 | Homography Homography::operator*(const Homography& rhs) const 51 | { 52 | Homography h; 53 | h.m_H = m_H * rhs.m_H; 54 | h.normalize(); 55 | return h; 56 | } 57 | 58 | /// Inverse homography. 59 | Homography Homography::inverse() const 60 | { 61 | Homography h; 62 | h.m_H = m_H.inv(); 63 | h.normalize(); 64 | return h; 65 | } 66 | 67 | /// Put coef(2,2) to 1. 68 | void Homography::normalize() 69 | { 70 | m_H /= m_H(2,2); 71 | } 72 | 73 | } // libNumerics 74 | -------------------------------------------------------------------------------- /third_party/Eigen/StdDeque: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // Eigen is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU Lesser General Public 9 | // License as published by the Free Software Foundation; either 10 | // version 3 of the License, or (at your option) any later version. 11 | // 12 | // Alternatively, you can redistribute it and/or 13 | // modify it under the terms of the GNU General Public License as 14 | // published by the Free Software Foundation; either version 2 of 15 | // the License, or (at your option) any later version. 16 | // 17 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 18 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public 23 | // License and a copy of the GNU General Public License along with 24 | // Eigen. If not, see . 25 | 26 | #ifndef EIGEN_STDDEQUE_MODULE_H 27 | #define EIGEN_STDDEQUE_MODULE_H 28 | 29 | #include "Core" 30 | #include 31 | 32 | #if (defined(_MSC_VER) && defined(_WIN64)) /* MSVC auto aligns in 64 bit builds */ 33 | 34 | #define EIGEN_DEFINE_STL_DEQUE_SPECIALIZATION(...) 35 | 36 | #else 37 | 38 | #include "src/StlSupport/StdDeque.h" 39 | 40 | #endif 41 | 42 | #endif // EIGEN_STDDEQUE_MODULE_H 43 | -------------------------------------------------------------------------------- /third_party/Eigen/StdVector: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // Eigen is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU Lesser General Public 9 | // License as published by the Free Software Foundation; either 10 | // version 3 of the License, or (at your option) any later version. 11 | // 12 | // Alternatively, you can redistribute it and/or 13 | // modify it under the terms of the GNU General Public License as 14 | // published by the Free Software Foundation; either version 2 of 15 | // the License, or (at your option) any later version. 16 | // 17 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 18 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public 23 | // License and a copy of the GNU General Public License along with 24 | // Eigen. If not, see . 25 | 26 | #ifndef EIGEN_STDVECTOR_MODULE_H 27 | #define EIGEN_STDVECTOR_MODULE_H 28 | 29 | #include "Core" 30 | #include 31 | 32 | #if (defined(_MSC_VER) && defined(_WIN64)) /* MSVC auto aligns in 64 bit builds */ 33 | 34 | #define EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...) 35 | 36 | #else 37 | 38 | #include "src/StlSupport/StdVector.h" 39 | 40 | #endif 41 | 42 | #endif // EIGEN_STDVECTOR_MODULE_H 43 | -------------------------------------------------------------------------------- /sift/domain.h: -------------------------------------------------------------------------------- 1 | // Authors: Unknown. Please, if you are the author of this file, or if you 2 | // know who are the authors of this file, let us know, so we can give the 3 | // adequate credits and/or get the adequate authorizations. 4 | 5 | 6 | #ifndef _DOMAIN_H_ 7 | #define _DOMAIN_H_ 8 | 9 | 10 | #include "numerics1.h" 11 | #include "library.h" 12 | #include "splines.h" 13 | 14 | 15 | /// Compute homography from n points using svd 16 | void compute_planar_homography_n_points(float *x0, float *y0, float *x1, float *y1, int n, float **H); 17 | 18 | 19 | /// Compute homography using svd + Ransac 20 | void compute_ransac_planar_homography_n_points(float *x0, float *y0, float *x1, float *y1, int n, int niter, float tolerance, float **H); 21 | 22 | /// Compute homography by using Lionel Code 23 | void compute_moisan_planar_homography_n_points(float *x0, float *y0, float *x1, float *y1, int n, int niter, float &epsilon, float **H, int &counter, int recursivity); 24 | 25 | 26 | /// Apply planar homography to image 27 | void compute_planar_homography_bounding_box(int width, int height, float **H, float *x0, float *y0, int *nwidth, int *nheight); 28 | 29 | 30 | void apply_planar_homography(float *input, int width, int height, float **H, float bg, int order, float *out, float x0, float y0, int nwidth, int nheight); 31 | 32 | 33 | /// Apply zoom of factor z 34 | void apply_zoom(float *input, float *out, float zoom, int order, int width, int height); 35 | 36 | /// Apply general transformation 37 | void apply_general_transformation(float *input, float *transformx, float* transformy, float *out, float bg, int order, int width, int height, int nwidth,int nheight); 38 | 39 | #endif 40 | 41 | 42 | 43 | #define DEBUG 0 44 | 45 | 46 | -------------------------------------------------------------------------------- /test_numpy2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | from math import sin, cos, pi 3 | import numpy 4 | import matplotlib 5 | from matplotlib import pylab 6 | import scipy 7 | import feature 8 | 9 | l = scipy.misc.lena().astype(numpy.float32) 10 | #l1 = l[5:, 6:] 11 | #l2 = l[:-5, :-6] 12 | l1=l2=l 13 | fig = pylab.figure() 14 | sp1 = fig.add_subplot(1, 2, 1) 15 | sp2 = fig.add_subplot(1, 2, 2) 16 | sp1.imshow(l1, interpolation="nearest", cmap="gray") 17 | sp2.imshow(l2, interpolation="nearest", cmap="gray") 18 | siftalignement = feature.SiftAlignment() 19 | kp1 = siftalignement.sift(l1) 20 | print("") 21 | kp2 = siftalignement.sift(l2) 22 | print kp1[:, :4], kp2[:, :4] 23 | print kp1.shape[0], kp2.shape[0] 24 | match = siftalignement.match(kp1, kp2) 25 | 26 | for i in range(kp1.shape[0]): 27 | x = kp1[i, 0] 28 | y = kp1[i, 1] 29 | scale = kp1[i, 2] 30 | angle = kp1[i, 3] 31 | if ((match[:, 1] == x) * (match[:, 0] == y)).sum() > 0: 32 | color = "blue" 33 | else: 34 | color = "red" 35 | sp1.annotate("", xy=(x, y), xytext=(x + scale * cos(angle), y + scale * sin(angle)), color=color, 36 | arrowprops=dict(facecolor=color, edgecolor=color, width=1),) 37 | for i in range(kp2.shape[0]): 38 | x = kp2[i, 0] 39 | y = kp2[i, 1] 40 | scale = kp2[i, 2] 41 | angle = kp2[i, 3] 42 | if ((match[:, 3] == x) * (match[:, 2] == y)).sum() > 0: 43 | color = "blue" 44 | else: 45 | color = "red" 46 | sp2.annotate("", xy=(x, y), xytext=(x + scale * cos(angle), y + scale * sin(angle)), color=color, 47 | arrowprops=dict(facecolor=color, edgecolor=color, width=1),) 48 | 49 | print match.shape[0] 50 | 51 | fig.show() 52 | raw_input("enter to quit") 53 | -------------------------------------------------------------------------------- /surf/lib.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib.h 3 | * SURF 4 | * 5 | * Created by Edouard Oyallon on 19/06/11. 6 | * Copyright 2011 __MyCompanyName__. All rights reserved. 7 | * 8 | */ 9 | #ifndef LIB 10 | #define LIB 11 | #include 12 | inline int fround(float flt); 13 | inline float gaussian(float x, float y, float sig); 14 | inline float absval(float x); 15 | inline int absval(int x); 16 | 17 | /** \def pi 18 | * \brief What else ? 19 | */ 20 | #define pi 3.14159265358979323846 /// Constante pi... 21 | /** \def threshold 22 | * \brief Threshold for which a point of the Hessian is compute as a maxima. 23 | */ 24 | #define threshold_maximum 4000 25 | 26 | /** \def nombreSecteur 27 | * \brief Nombre de secteur qu'on considère pour la fonction d'orientation 28 | */ 29 | #define number_sector 16 30 | /** \def rate 31 | * \brief Rate between the last and previous last minimum in euclidean norm for matching 32 | */ 33 | #define rate 0.8 34 | /** \def octave 35 | * \brief Clear 36 | */ 37 | #define octave 4 38 | /** \def intervall 39 | * \brief Clear 40 | */ 41 | #define interval 4 42 | 43 | /** \def iteration_interpolation 44 | * \brief Number of interpolation possible.(recursrive) 45 | */ 46 | #define iteration_interpolation 5 47 | 48 | 49 | /// Compute a gaussian 50 | /** Empty.. 51 | */ 52 | inline float gaussian(float x, float y, float sig) 53 | { 54 | return 1/(2*pi*sig*sig)*expf( -(x*x+y*y)/(2*sig*sig)); 55 | } 56 | 57 | /// Round function... 58 | /** Set inline... */ 59 | inline int fround(float flt) 60 | { 61 | return (int) (flt+0.5f); 62 | } 63 | /// Absolute value int 64 | inline int absval(int x) 65 | { 66 | return ((x>0)?x:-x); 67 | } 68 | 69 | /// Absolute value float 70 | inline float absval(float x) 71 | { 72 | return ((x>0)?x:-x); 73 | } 74 | #endif -------------------------------------------------------------------------------- /sift.pxd: -------------------------------------------------------------------------------- 1 | from libcpp cimport bool 2 | from libcpp.pair cimport pair 3 | from libcpp.vector cimport vector 4 | 5 | from image cimport flimage 6 | 7 | cdef extern from "sift/sift.h": 8 | struct keypoint: 9 | float x 10 | float y 11 | float scale 12 | float angle 13 | float * vec 14 | #typedef std::vector keypointslist; 15 | ctypedef vector[ keypoint ] keypointslist 16 | struct siftPar: 17 | int OctaveMax 18 | int DoubleImSize 19 | int order 20 | float InitSigma 21 | int BorderDist 22 | int Scales 23 | float PeakThresh 24 | float EdgeThresh 25 | float EdgeThresh1 26 | int OriBins 27 | float OriSigma 28 | float OriHistThresh 29 | float MaxIndexVal 30 | int MagFactor 31 | float IndexSigma 32 | int IgnoreGradSign 33 | float MatchRatio 34 | float MatchXradius 35 | float MatchYradius 36 | int noncorrectlylocalized 37 | void default_sift_parameters(siftPar par) nogil 38 | void compute_sift_keypoints(float * input, keypointslist keypoints, int width, int height, siftPar par) nogil 39 | void compute_sift_keypoints_flimage(flimage img, keypointslist keypoints, siftPar par) nogil 40 | 41 | #typedef std::pair matching; 42 | ctypedef pair[ keypoint , keypoint ] matching 43 | #typedef std::vector matchingslist; 44 | ctypedef vector[ matching ] matchingslist 45 | void compute_sift_matches(keypointslist keys1, keypointslist keys2, matchingslist matchings, siftPar par) nogil 46 | void imgblur(float *, float* , int , int , float) 47 | 48 | cdef extern from "sift/library.h": 49 | void sample ( float *,float *, float ,int , int) nogil 50 | -------------------------------------------------------------------------------- /surf/keypoint.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file keypoint.h 3 | * \brief Get SURF Key Points 4 | * 5 | * Involved functions 6 | * 7 | */ 8 | 9 | #ifndef KEYPOINT 10 | 11 | #define KEYPOINT 12 | #include 13 | #include 14 | #include "lib.h" 15 | #include "image.h" 16 | #include 17 | 18 | 19 | /** 20 | \class keyPoint For the keypoint. 21 | \brief Has the key point with natural notations. 22 | */ 23 | class keyPoint { 24 | public: 25 | float x,y,scale,orientation; 26 | bool signLaplacian; 27 | keyPoint(float a, float b, float c, float e, bool f); 28 | 29 | keyPoint(keyPoint* a); 30 | keyPoint(); 31 | 32 | }; 33 | 34 | /// The vector of keypoint 35 | typedef std::vector listKeyPoints; 36 | 37 | 38 | 39 | #include "descriptor.h" 40 | #include "integral.h" 41 | 42 | 43 | //inline bool isMaximum(image** imageStamp,int x,int y,int sigma); 44 | void addKeyPoint(imageIntegral* img,float i,float j,bool signeLapl,float scale,listKeyPoints* listePointsClefs,bool verbose); 45 | float getOrientation(imageIntegral* imgInt,int x,int y,int nombreSecteurs,float scale,bool verbose); 46 | bool interpolationSpaceScale(image** img,int x, int y,int sig,float &scale,float &x2,float &y2, int iteration); 47 | /// True if maxima STRICT 48 | /** Compute 26 pixels & check it is more than the fixed threshold 49 | */ 50 | inline bool isMaximum(image** imageStamp,int x,int y,int scale) 51 | { 52 | float tmp=(*(imageStamp[scale]))(x,y); 53 | if(absval(tmp)>threshold_maximum ) 54 | { 55 | for(int j=-1+y;j<2+y;j++) 56 | for(int i=-1+x;i<2+x;i++) 57 | if((*(imageStamp[scale-1]))(i,j)>tmp or (*(imageStamp[scale]))(i,j)>tmp or (*(imageStamp[scale+1]))(i,j)>tmp ) 58 | return false; 59 | 60 | 61 | return true; 62 | } 63 | else 64 | return false; 65 | } 66 | 67 | 68 | 69 | 70 | 71 | 72 | #endif 73 | 74 | -------------------------------------------------------------------------------- /sift/filter.h: -------------------------------------------------------------------------------- 1 | // Authors: Unknown. Please, if you are the author of this file, or if you 2 | // know who are the authors of this file, let us know, so we can give the 3 | // adequate credits and/or get the adequate authorizations. 4 | 5 | 6 | #ifndef _FILTER_H_ 7 | #define _FILTER_H_ 8 | 9 | 10 | #include "library.h" 11 | 12 | 13 | float * directional_gauss_filter(float xsigma, float ysigma, float angle, int *kwidth, int *kheight); 14 | 15 | 16 | void median(float *u,float *v, float radius, int niter, int width,int height); 17 | void remove_outliers(float *igray,float *ogray,int width, int height); 18 | 19 | /// Convolution with a separable kernel, boundary condition: 0=zero, 1=symmetry 20 | void separable_convolution(float *u, float *v, int width, int height, float *xkernel, int xsize, float *ykernel, int ysize,int boundary); 21 | 22 | void buffer_convolution(float *buffer,float *kernel,int size,int ksize); 23 | void horizontal_convolution(float *u, float *v, int width, int height, float *kernel, int ksize, int boundary); 24 | void vertical_convolution(float *u, float *v, int width, int height, float *kernel,int ksize, int boundary); 25 | 26 | void fast_separable_convolution(float *u, float *v, int width, int height,float * xkernel, int xsize,float *ykernel,int ysize,int boundary); 27 | 28 | /// Can be called with u=v 29 | void gaussian_convolution(float *u, float *v, int width, int height, float sigma); 30 | void gaussian_convolution(float *u, float *v, int width, int height, float sigma, int ksize); 31 | 32 | void convol(float *u, float *v, int width, int height, float *kernel, int kwidth, int kheight); /// Convolution with a kernel, No padding applied to the image 33 | 34 | void heat(float *u, float *v, float step, int niter, float sigma, int width, int height); 35 | 36 | 37 | #endif // _FILTER_H_ 38 | 39 | 40 | 41 | 42 | /////////////////////////////////////////////////////////////// Build Gaussian filters -------------------------------------------------------------------------------- /third_party/Eigen/src/Sparse/SparseFuzzy.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // 6 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_SPARSE_FUZZY_H 26 | #define EIGEN_SPARSE_FUZZY_H 27 | 28 | // template 29 | // template 30 | // bool SparseMatrixBase::isApprox( 31 | // const OtherDerived& other, 32 | // typename NumTraits::Real prec 33 | // ) const 34 | // { 35 | // const typename internal::nested::type nested(derived()); 36 | // const typename internal::nested::type otherNested(other.derived()); 37 | // return (nested - otherNested).cwise().abs2().sum() 38 | // <= prec * prec * std::min(nested.cwise().abs2().sum(), otherNested.cwise().abs2().sum()); 39 | // } 40 | 41 | #endif // EIGEN_SPARSE_FUZZY_H 42 | -------------------------------------------------------------------------------- /third_party/Eigen/Geometry: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_GEOMETRY_MODULE_H 2 | #define EIGEN_GEOMETRY_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include "SVD" 9 | #include "LU" 10 | #include 11 | 12 | #ifndef M_PI 13 | #define M_PI 3.14159265358979323846 14 | #endif 15 | 16 | namespace Eigen { 17 | 18 | /** \defgroup Geometry_Module Geometry module 19 | * 20 | * 21 | * 22 | * This module provides support for: 23 | * - fixed-size homogeneous transformations 24 | * - translation, scaling, 2D and 3D rotations 25 | * - quaternions 26 | * - \ref MatrixBase::cross() "cross product" 27 | * - \ref MatrixBase::unitOrthogonal() "orthognal vector generation" 28 | * - some linear components: parametrized-lines and hyperplanes 29 | * 30 | * \code 31 | * #include 32 | * \endcode 33 | */ 34 | 35 | #include "src/Geometry/OrthoMethods.h" 36 | #include "src/Geometry/EulerAngles.h" 37 | 38 | #if EIGEN2_SUPPORT_STAGE > STAGE20_RESOLVE_API_CONFLICTS 39 | #include "src/Geometry/Homogeneous.h" 40 | #include "src/Geometry/RotationBase.h" 41 | #include "src/Geometry/Rotation2D.h" 42 | #include "src/Geometry/Quaternion.h" 43 | #include "src/Geometry/AngleAxis.h" 44 | #include "src/Geometry/Transform.h" 45 | #include "src/Geometry/Translation.h" 46 | #include "src/Geometry/Scaling.h" 47 | #include "src/Geometry/Hyperplane.h" 48 | #include "src/Geometry/ParametrizedLine.h" 49 | #include "src/Geometry/AlignedBox.h" 50 | #include "src/Geometry/Umeyama.h" 51 | 52 | #if defined EIGEN_VECTORIZE_SSE 53 | #include "src/Geometry/arch/Geometry_SSE.h" 54 | #endif 55 | #endif 56 | 57 | #ifdef EIGEN2_SUPPORT 58 | #include "src/Eigen2Support/Geometry/All.h" 59 | #endif 60 | 61 | } // namespace Eigen 62 | 63 | #include "src/Core/util/ReenableStupidWarnings.h" 64 | 65 | #endif // EIGEN_GEOMETRY_MODULE_H 66 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 67 | 68 | -------------------------------------------------------------------------------- /surf/integral.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file integrale.h 3 | * \brief {File concerning calculus of integral image, convolution, haarwavelet, etc} 4 | * 5 | */ 6 | 7 | /** \def m 8 | * \brief get min between a and b 9 | */ 10 | #ifndef INTEGRAL 11 | #define INTEGRAL 12 | #include "lib.h" 13 | #include "image.h" 14 | 15 | 16 | imageIntegral* computeIntegralImage(image* img,bool verbose); 17 | //float squareConvolutionXY(image* imgInt,int a,int c,int b,int d,int x,int y); 18 | 19 | 20 | 21 | inline float squareConvolutionXY(imageIntegral* imgInt,int a,int b,int c,int d,int x,int y) 22 | { 23 | int a1=x-a; 24 | int a2=y-b; 25 | int b1=a1-c; 26 | int b2=a2-d; 27 | 28 | return (*imgInt)(b1,b2)+(*imgInt)(a1,a2)-(*imgInt)(b1,a2)-(*imgInt)(a1,b2);// ((A+D)-(B+C)); 29 | 30 | } 31 | /*----------------------------------------------------*/ 32 | /// Compute convolution by a square 33 | /** Compute image in the point (x,y) 34 | * \param (a,b) inferior side of the square 35 | * \param (c,d) weight and height 36 | */ 37 | inline float squareConvolutionXY2(float* img,int w,int a,int b,int c,int d,int x,int y) 38 | { 39 | int a1=x-a; 40 | int a2=y-b; 41 | int b1=a1-c; 42 | int b2=a2-d; 43 | return img[ b2*w + b1 ]+img[ a2*w + a1 ]-img[ a2*w + b1 ]-img[ b2*w + a1 ]; 44 | 45 | } 46 | 47 | 48 | 49 | 50 | 51 | 52 | /// Haar belong X 53 | /** Compute in (x,y) 54 | */ 55 | inline float haarX(imageIntegral* img,int x,int y,int tailleFiltre) 56 | { 57 | 58 | return -(squareConvolutionXY(img,1,-tailleFiltre-1,-tailleFiltre-1,tailleFiltre*2+1, x, y)+ 59 | squareConvolutionXY(img, 0,-tailleFiltre-1, tailleFiltre+1,tailleFiltre*2+1, x, y)); 60 | 61 | 62 | } 63 | 64 | 65 | 66 | /// Haar belong Y 67 | /** Compute in (x,y) 68 | */ 69 | 70 | inline float haarY(imageIntegral* img,int x,int y,int tailleFiltre) 71 | {return -(squareConvolutionXY(img, -tailleFiltre-1,1, 2*tailleFiltre+1,-tailleFiltre-1, x, y)+ 72 | squareConvolutionXY(img, -tailleFiltre-1,0, 2*tailleFiltre+1,tailleFiltre+1, x, y)); 73 | } 74 | 75 | #endif 76 | 77 | -------------------------------------------------------------------------------- /image/flimage.cpp: -------------------------------------------------------------------------------- 1 | // Authors: Unknown. Please, if you are the author of this file, or if you 2 | // know who are the authors of this file, let us know, so we can give the 3 | // adequate credits and/or get the adequate authorizations. 4 | 5 | #include "flimage.h" 6 | 7 | 8 | 9 | //////////////////////////////////////////////// Class flimage 10 | //// Construction 11 | flimage::flimage() : width(0), height(0), p(0) 12 | { 13 | } 14 | 15 | flimage::flimage(int w, int h) : width(w), height(h), p(new float[w*h]) 16 | { 17 | for (int j=width*height-1; j>=0 ; j--) p[j] = 0.0; 18 | } 19 | 20 | 21 | flimage::flimage(int w, int h, float v) : width(w), height(h), p(new float[w*h]) 22 | { 23 | for (int j=width*height-1; j>=0 ; j--) p[j] = v; 24 | } 25 | 26 | 27 | flimage::flimage(int w, int h, float* v) : width(w), height(h), p(new float[w*h]) 28 | { 29 | for (int j=width*height-1; j>=0 ; j--) p[j] = v[j]; 30 | } 31 | 32 | 33 | void flimage::create(int w, int h) 34 | { 35 | erase(); 36 | width = w; height = h; 37 | p = new float[w*h]; 38 | for (int j=width*height-1; j>=0 ; j--) p[j] = 0.0; 39 | } 40 | 41 | void flimage::create(int w, int h, float* v) 42 | { 43 | erase(); 44 | width = w; height = h; p = new float[w*h]; 45 | for (int j=width*height-1; j>=0 ; j--) p[j] = v[j]; 46 | } 47 | 48 | 49 | flimage::flimage(const flimage& im) : width(im.width), height(im.height), p(new float[im.width*im.height]) 50 | { 51 | for (int j=width*height-1; j>=0 ; j--) p[j] = im.p[j]; 52 | } 53 | 54 | flimage& flimage::operator= (const flimage& im) 55 | { 56 | if (&im == this) { 57 | return *this; 58 | } 59 | 60 | if (width != im.width || height != im.height) 61 | { 62 | erase(); 63 | width = im.width; height=im.height; p = new float[width*height]; 64 | } 65 | 66 | for (int j=width*height-1; j>=0 ; j--) p[j] = im.p[j]; 67 | return *this; 68 | } 69 | 70 | 71 | //// Destruction 72 | void flimage::erase() 73 | { 74 | width = height = 0; 75 | if (p) delete[] p; 76 | p=0; 77 | } 78 | 79 | flimage::~flimage() 80 | { 81 | erase(); 82 | } 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /third_party/Eigen/Sparse: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_SPARSE_MODULE_H 2 | #define EIGEN_SPARSE_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #ifdef EIGEN2_SUPPORT 15 | #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET 16 | #endif 17 | 18 | #ifndef EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET 19 | #error The sparse module API is not stable yet. To use it anyway, please define the EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET preprocessor token. 20 | #endif 21 | 22 | namespace Eigen { 23 | 24 | /** \defgroup Sparse_Module Sparse module 25 | * 26 | * 27 | * 28 | * See the \ref TutorialSparse "Sparse tutorial" 29 | * 30 | * \code 31 | * #include 32 | * \endcode 33 | */ 34 | 35 | /** The type used to identify a general sparse storage. */ 36 | struct Sparse {}; 37 | 38 | #include "src/Sparse/SparseUtil.h" 39 | #include "src/Sparse/SparseMatrixBase.h" 40 | #include "src/Sparse/CompressedStorage.h" 41 | #include "src/Sparse/AmbiVector.h" 42 | #include "src/Sparse/SparseMatrix.h" 43 | #include "src/Sparse/DynamicSparseMatrix.h" 44 | #include "src/Sparse/MappedSparseMatrix.h" 45 | #include "src/Sparse/SparseVector.h" 46 | #include "src/Sparse/CoreIterators.h" 47 | #include "src/Sparse/SparseBlock.h" 48 | #include "src/Sparse/SparseTranspose.h" 49 | #include "src/Sparse/SparseCwiseUnaryOp.h" 50 | #include "src/Sparse/SparseCwiseBinaryOp.h" 51 | #include "src/Sparse/SparseDot.h" 52 | #include "src/Sparse/SparseAssign.h" 53 | #include "src/Sparse/SparseRedux.h" 54 | #include "src/Sparse/SparseFuzzy.h" 55 | #include "src/Sparse/SparseProduct.h" 56 | #include "src/Sparse/SparseSparseProduct.h" 57 | #include "src/Sparse/SparseDenseProduct.h" 58 | #include "src/Sparse/SparseDiagonalProduct.h" 59 | #include "src/Sparse/SparseTriangularView.h" 60 | #include "src/Sparse/SparseSelfAdjointView.h" 61 | #include "src/Sparse/TriangularSolver.h" 62 | #include "src/Sparse/SparseView.h" 63 | 64 | } // namespace Eigen 65 | 66 | #include "src/Core/util/ReenableStupidWarnings.h" 67 | 68 | #endif // EIGEN_SPARSE_MODULE_H 69 | 70 | -------------------------------------------------------------------------------- /sift/numerics1.h: -------------------------------------------------------------------------------- 1 | // Authors: Unknown. Please, if you are the author of this file, or if you 2 | // know who are the authors of this file, let us know, so we can give the 3 | // adequate credits and/or get the adequate authorizations. 4 | 5 | 6 | #ifndef _NUMERICS_H_ 7 | #define _NUMERICS_H_ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | 16 | #include "library.h" 17 | 18 | #define NRMAX(i,j) ( (i)<(j) ? (j):(i) ) 19 | #define NRMIN(i,j) ( (i)<(j) ? (i):(j) ) 20 | #define NRTINY 1.0e-10 21 | 22 | 23 | // ********************************************** 24 | // float ** basic functions 25 | // ********************************************** 26 | 27 | float ** allocate_float_matrix(int nrows, int ncols); 28 | 29 | void desallocate_float_matrix(float **matrix, int nrows, int ncols); 30 | 31 | // ********************************************** 32 | // LU based algorithms 33 | // ********************************************** 34 | 35 | // Solves Ax=b by using lu decomposition 36 | // a matrix a[1..n][1..n] is replaced by the LU decompositions of a rowwise permutation of itself 37 | // b[1..n] and x[1..n] 38 | int lusolve(float **a, float *x, float *b, int n); 39 | 40 | 41 | /*-- LU decomposition */ 42 | /* Given a matrix a[1..n][1..n] this routine replacess it by the LU decompositions of a rowwise permutation of itself. */ 43 | /* a and n are input, a is output, arranged as in equation (2.3.14) above; indx[1..n] in an output vector that records */ 44 | /* the row permutation effected by the partial pivoting; d is output as +-1 depending on whether the number of row */ 45 | /* interchanges was even or odd respectively. */ 46 | int ludcmp(float **a, int n, int *indx, float *d); /* LU decomposition */ 47 | 48 | /* Solves the set of n linear equations Ax=b. Here a[0..n-1][0..n-1] as input, not as the matrix A but rather as its LU decomposition,*/ 49 | /* determined by the routine ludcmp. indx[0..n-1] is input as the permutation vector returned by ludcmp. b[0..n-1] is input as the */ 50 | /* right hand side vector and returns with the solution vector x. */ 51 | void lubksb(float **a, int n, int *indx, float *b); /* LU linear solution */ 52 | 53 | 54 | 55 | 56 | #endif 57 | 58 | -------------------------------------------------------------------------------- /libNumerics/numerics.h: -------------------------------------------------------------------------------- 1 | // Authors: Unknown. Please, if you are the author of this file, or if you 2 | // know who are the authors of this file, let us know, so we can give the 3 | // adequate credits and/or get the adequate authorizations. 4 | 5 | #ifndef NUMERICS_H 6 | #define NUMERICS_H 7 | 8 | #include "matrix.h" 9 | #include 10 | 11 | namespace libNumerics { 12 | class NumericsException {}; 13 | class SvdConvergenceError : public NumericsException {}; 14 | typedef double flnum; 15 | 16 | /// Solve system AX = B. 17 | bool solveLU(const matrix& A, const vector& B, 18 | vector& X); 19 | bool solveLU(matrix A, vector& B); 20 | 21 | /// Singular Value Decomposition 22 | class SVD { 23 | public: 24 | SVD(const matrix& A); 25 | matrix& U() { return m_U; } 26 | vector& W() { return m_W; } 27 | matrix& V() { return m_V; } 28 | matrix compose() const; 29 | 30 | private: 31 | matrix m_U, m_V; 32 | vector m_W; 33 | static flnum withSignOf(flnum a, flnum b); 34 | static flnum hypot(flnum a, flnum b); 35 | static void rotate(flnum& a, flnum& b, flnum c, flnum s); 36 | void compute(); 37 | void sort(); 38 | }; 39 | 40 | /// Levenberg-Marquardt minimization. 41 | class MinLM { 42 | static const flnum DEFAULT_RELATIVE_TOL; 43 | static const flnum DEFAULT_LAMBDA_INIT; 44 | static const flnum DEFAULT_LAMBDA_FACT; 45 | static const flnum EPSILON_KERNEL; 46 | public: 47 | MinLM(); 48 | flnum minimize(vector& P, const vector& ydata, 49 | flnum targetRMSE=0.1, int maxIters=300); 50 | virtual void modelData(const vector& P, 51 | vector& ymodel) const = 0; 52 | virtual void modelJacobian(const vector& P, 53 | matrix& J) const = 0; 54 | int iterations; 55 | flnum relativeTol; 56 | flnum lambdaInit; 57 | flnum lambdaFact; 58 | private: 59 | std::vector m_nullCols; 60 | void compress(matrix& JtJ, vector& B); 61 | void uncompress(vector& B); 62 | }; 63 | 64 | } // namespace libNumerics 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /surf/image.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef IMAGE 4 | 5 | #define IMAGE 6 | 7 | #include 8 | #include 9 | 10 | 11 | //#include "io_png.h" 12 | #include 13 | #include "lib.h" 14 | 15 | /** \class image image.h 16 | * Here we stock an image 17 | */ 18 | 19 | /** \class image image.h 20 | * Here we stock an image 21 | */ 22 | 23 | 24 | class image { 25 | public: 26 | /// pointeur vers l'image 27 | int idImage;/// This is put only in order to name images. 28 | 29 | 30 | 31 | 32 | int width,height; /// image size ; trueWidth contains the real width for image integral 33 | float* img; 34 | /// Give the array. 35 | int returnIdImage(); 36 | inline float* array(){return img;} 37 | /// Weight 38 | inline int w() {return width;} 39 | /// Height 40 | inline int h(){return height;} 41 | 42 | 43 | /// Affiche l'image tout en préfixant son nom par l'id. 44 | void printImage( char nomFichier[]); 45 | 46 | void printImagePara( char nomFichier[],image* para,image* orsa,image* line); 47 | 48 | /// Operator (x,y) give the matrix in x,y point. 49 | inline float operator()(int x, int y) const { 50 | 51 | 52 | return img[ y*width + x ]; 53 | 54 | 55 | } 56 | 57 | /// cf supra 58 | inline float& operator()(int x, int y) { 59 | 60 | 61 | 62 | return img[ y*width+ x ]; 63 | } 64 | 65 | ///Affiche l'image avec des seuils. 66 | void afficher_minimaliste( char nomFichier[],float minSeuil,float maxSeuil); 67 | 68 | /// First constructor 69 | /** black image, 0 ID 70 | */ image(int x,int y); 71 | 72 | /// Second constructor 73 | /** Black image, n ID 74 | */ 75 | image(int x,int y,int n); 76 | /// Last constructor 77 | /** Black image, similar to im(same size) 78 | */ 79 | image(image* im); 80 | 81 | ~image(); 82 | image(const image &img); 83 | }; 84 | 85 | class imageIntegral : public image { 86 | 87 | public: int trueWidth; 88 | 89 | imageIntegral(image* im); 90 | ~imageIntegral(); 91 | float& operator()(int x, int y) { 92 | 93 | return img[ y*trueWidth+ x ];} 94 | float operator()(int x, int y) const { 95 | return img[ y*trueWidth+ x ];} 96 | /// Center for the integrale image(put the pointer at the good position because of symetrization) 97 | void center(int begin,image* im); 98 | 99 | 100 | }; 101 | 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Core/util/DisableStupidWarnings.h: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_WARNINGS_DISABLED 2 | #define EIGEN_WARNINGS_DISABLED 3 | 4 | #ifdef _MSC_VER 5 | // 4100 - unreferenced formal parameter (occurred e.g. in aligned_allocator::destroy(pointer p)) 6 | // 4101 - unreferenced local variable 7 | // 4127 - conditional expression is constant 8 | // 4181 - qualifier applied to reference type ignored 9 | // 4211 - nonstandard extension used : redefined extern to static 10 | // 4244 - 'argument' : conversion from 'type1' to 'type2', possible loss of data 11 | // 4273 - QtAlignedMalloc, inconsistent DLL linkage 12 | // 4324 - structure was padded due to declspec(align()) 13 | // 4512 - assignment operator could not be generated 14 | // 4522 - 'class' : multiple assignment operators specified 15 | // 4700 - uninitialized local variable 'xyz' used 16 | // 4717 - 'function' : recursive on all control paths, function will cause runtime stack overflow 17 | #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS 18 | #pragma warning( push ) 19 | #endif 20 | #pragma warning( disable : 4100 4101 4127 4181 4211 4244 4273 4324 4512 4522 4700 4717 ) 21 | #elif defined __INTEL_COMPILER 22 | // 2196 - routine is both "inline" and "noinline" ("noinline" assumed) 23 | // ICC 12 generates this warning even without any inline keyword, when defining class methods 'inline' i.e. inside of class body 24 | // 2536 - type qualifiers are meaningless here 25 | // ICC 12 generates this warning when a function return type is const qualified, even if that type is a template-parameter-dependent 26 | // typedef that may be a reference type. 27 | // 279 - controlling expression is constant 28 | // ICC 12 generates this warning on assert(constant_expression_depending_on_template_params) and frankly this is a legitimate use case. 29 | #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS 30 | #pragma warning push 31 | #endif 32 | #pragma warning disable 2196 2536 279 33 | #elif defined __clang__ 34 | // -Wconstant-logical-operand - warning: use of logical && with constant operand; switch to bitwise & or remove constant 35 | // this is really a stupid warning as it warns on compile-time expressions involving enums 36 | #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS 37 | #pragma clang diagnostic push 38 | #endif 39 | #pragma clang diagnostic ignored "-Wconstant-logical-operand" 40 | #endif 41 | 42 | #endif // not EIGEN_WARNINGS_DISABLED 43 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Eigen2Support/TriangularSolver.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2010 Gael Guennebaud 5 | // 6 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_TRIANGULAR_SOLVER2_H 26 | #define EIGEN_TRIANGULAR_SOLVER2_H 27 | 28 | const unsigned int UnitDiagBit = UnitDiag; 29 | const unsigned int SelfAdjointBit = SelfAdjoint; 30 | const unsigned int UpperTriangularBit = Upper; 31 | const unsigned int LowerTriangularBit = Lower; 32 | 33 | const unsigned int UpperTriangular = Upper; 34 | const unsigned int LowerTriangular = Lower; 35 | const unsigned int UnitUpperTriangular = UnitUpper; 36 | const unsigned int UnitLowerTriangular = UnitLower; 37 | 38 | template 39 | template 40 | typename ExpressionType::PlainObject 41 | Flagged::solveTriangular(const MatrixBase& other) const 42 | { 43 | return m_matrix.template triangularView().solve(other.derived()); 44 | } 45 | 46 | template 47 | template 48 | void Flagged::solveTriangularInPlace(const MatrixBase& other) const 49 | { 50 | m_matrix.template triangularView().solveInPlace(other.derived()); 51 | } 52 | 53 | #endif // EIGEN_TRIANGULAR_SOLVER2_H 54 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Sparse/SparseRedux.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // 6 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_SPARSEREDUX_H 26 | #define EIGEN_SPARSEREDUX_H 27 | 28 | template 29 | typename internal::traits::Scalar 30 | SparseMatrixBase::sum() const 31 | { 32 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 33 | Scalar res = 0; 34 | for (Index j=0; j 41 | typename internal::traits >::Scalar 42 | SparseMatrix<_Scalar,_Options,_Index>::sum() const 43 | { 44 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 45 | return Matrix::Map(&m_data.value(0), m_data.size()).sum(); 46 | } 47 | 48 | template 49 | typename internal::traits >::Scalar 50 | SparseVector<_Scalar,_Options,_Index>::sum() const 51 | { 52 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 53 | return Matrix::Map(&m_data.value(0), m_data.size()).sum(); 54 | } 55 | 56 | #endif // EIGEN_SPARSEREDUX_H 57 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf8 3 | # 4 | # Project: Image Alignment 5 | # 6 | # Copyright (C) European Synchrotron Radiation Facility, Grenoble, France 7 | # 8 | # Principal author: Jérôme Kieffer (Jerome.Kieffer@ESRF.eu) 9 | # 10 | # This program is free software: you can redistribute it and/or modify 11 | # it under the terms of the GNU Lesser General Public License as published by 12 | # the Free Software Foundation, either version 3 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU Lesser General Public License 21 | # along with this program. If not, see . 22 | # 23 | 24 | __author__ = "Jérôme Kieffer" 25 | __copyright__ = "2012, ESRF" 26 | __license__ = "LGPL" 27 | 28 | import sys 29 | from distutils.core import setup 30 | import glob 31 | from numpy.distutils.misc_util import get_numpy_include_dirs 32 | 33 | cython_src = ["feature"] 34 | 35 | if sys.version_info < (2, 6): 36 | src = [i + ".cpp" for i in cython_src] 37 | from distutils.core import Extension 38 | build_ext = None 39 | else: 40 | src = [i + ".pyx" for i in cython_src] 41 | from Cython.Distutils.extension import Extension 42 | from Cython.Distutils import build_ext 43 | 44 | feature_ext = Extension(name="feature", 45 | sources=src + glob.glob("surf/*.cpp") + glob.glob("sift/*.cpp") + glob.glob("asift/*.cpp") + glob.glob("orsa/*.cpp") + glob.glob("image/*.cpp") + ["crc32.cpp"], 46 | include_dirs=get_numpy_include_dirs(), 47 | language="c++", 48 | extra_compile_args=['-fopenmp', "-msse4.2"], 49 | extra_link_args=['-fopenmp'], 50 | ) 51 | 52 | rlock_ext = Extension(name="cythreading", 53 | sources=["cythreading.pyx"], 54 | language="c++", 55 | ) 56 | 57 | setup(name='feature', 58 | version="0.6.1", 59 | author="Jerome Kieffer", 60 | author_email="jerome.kieffer@esrf.eu", 61 | description='test for feature extraction algorithm like sift, surf, ...', 62 | ext_modules=[feature_ext ], 63 | cmdclass={'build_ext': build_ext} 64 | ) 65 | -------------------------------------------------------------------------------- /asift/compute_asift_matches.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2008-2011, Guoshen Yu 2 | // Copyright (c) 2008-2011, Jean-Michel Morel 3 | // 4 | // WARNING: 5 | // This file implements an algorithm possibly linked to the patent 6 | // 7 | // Jean-Michel Morel and Guoshen Yu, Method and device for the invariant 8 | // affine recognition recognition of shapes (WO/2009/150361), patent pending. 9 | // 10 | // This file is made available for the exclusive aim of serving as 11 | // scientific tool to verify of the soundness and 12 | // completeness of the algorithm description. Compilation, 13 | // execution and redistribution of this file may violate exclusive 14 | // patents rights in certain countries. 15 | // The situation being different for every country and changing 16 | // over time, it is your responsibility to determine which patent 17 | // rights restrictions apply to you before you compile, use, 18 | // modify, or redistribute this file. A patent lawyer is qualified 19 | // to make this determination. 20 | // If and only if they don't conflict with any patent terms, you 21 | // can benefit from the following license terms attached to this 22 | // file. 23 | // 24 | // This program is provided for scientific and educational only: 25 | // you can use and/or modify it for these purposes, but you are 26 | // not allowed to redistribute this work or derivative works in 27 | // source or executable form. A license must be obtained from the 28 | // patent right holders for any other use. 29 | // 30 | // 31 | //*------------------------ compute_asift_matches-- -------------------------*/ 32 | // Match the ASIFT keypoints. 33 | // 34 | // Please report bugs and/or send comments to Guoshen Yu yu@cmap.polytechnique.fr 35 | // 36 | // Reference: J.M. Morel and G.Yu, ASIFT: A New Framework for Fully Affine Invariant Image 37 | // Comparison, SIAM Journal on Imaging Sciences, vol. 2, issue 2, pp. 438-469, 2009. 38 | // Reference: ASIFT online demo (You can try ASIFT with your own images online.) 39 | // http://www.ipol.im/pub/algo/my_affine_sift/ 40 | /*---------------------------------------------------------------------------*/ 41 | 42 | #include "../sift/library.h" 43 | #include "../sift/sift.h" 44 | #include "../sift/frot.h" 45 | #include "../sift/fproj.h" 46 | #include 47 | using namespace std; 48 | 49 | 50 | int compute_asift_matches(int num_of_tilts1, int num_of_tilts2, int w1, int h1, int w2, int h2, int verb, vector< vector< keypointslist > >& keys1, vector< vector< keypointslist > >& keys2, matchingslist &matchings, siftPar &siftparameters); 51 | 52 | -------------------------------------------------------------------------------- /orsa/orsa.h: -------------------------------------------------------------------------------- 1 | // 2 | // C++ Implementation: stereomatch 3 | // 4 | // Description: eliminate the false matches with epipolar geometry constraint. 5 | // See http://www.math-info.univ-paris5.fr/~moisan/epipolar/ 6 | // 7 | // Copyright (c) 2007 Lionel Moisan 8 | // Changelog : 2011 Use Eigen SVD 9 | // 10 | // Copyright: See COPYING file that comes with this distribution 11 | // 12 | // 13 | 14 | #ifndef STEREOMATCH_H 15 | #define STEREOMATCH_H 16 | 17 | #include 18 | 19 | #include "../libNumerics/numerics.h" 20 | #include "match.h" 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | /*-------------------- GENERAL PURPOSE ROUTINES --------------------*/ 31 | 32 | /* routines for vectors and matrices */ 33 | 34 | //float *vector(int nl, int nh); 35 | 36 | float **matrix(int nrl, int nrh, int ncl, int nch); 37 | 38 | void free_vector(float *v, int nl, int nh); 39 | 40 | void free_matrix(float **m, int nrl, int nrh, int ncl, int nch); 41 | 42 | /* Singular Value Decomposition routine */ 43 | void svdcmp(float **a, int m, int n, float *w, float **v); 44 | 45 | /* Compute the real roots of a third order polynomial */ 46 | /* returns 1 or 3, the number of roots found */ 47 | int FindCubicRoots(float coeff[4], float x[3]); 48 | 49 | /* logarithm (base 10) of binomial coefficient */ 50 | float logcombi(int k, int n); 51 | 52 | /* tabulate logcombi(.,n) */ 53 | float *makelogcombi_n(int n); 54 | 55 | 56 | /* tabulate logcombi(k,.) */ 57 | float *makelogcombi_k(int k, int nmax); 58 | 59 | 60 | /* get a (sorted) random 7-uple of 0..n-1 */ 61 | void random_p7(int *k, int n); 62 | 63 | /*-------------------- END OF GENERAL PURPOSE ROUTINES --------------------*/ 64 | 65 | 66 | /* float comparison for qsort() */ 67 | //According to http://www.cplusplus.com/reference/clibrary/cstdlib/qsort/, 68 | //we should have: void qsort ( void * base, size_t num, size_t size, int ( * comparator ) ( const void *, const void * ) ); that means, for "qsort", the "comparator" has two constant void* type input parameters 69 | int compf(const void *i, const void *j); 70 | 71 | void matcherrorn(float **F, const std::vector& p1, const std::vector& p2, float *e); 72 | 73 | int epipolar(std::vector& m1, std::vector& m2, int *k, float *z, float **F1, float **F2); 74 | 75 | float orsa(int width, int height, std::vector& match, std::vector& index, int t_value, int verb_value, int n_flag_value, int mode_value, int stop_value); 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Eigen2Support/Memory.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2011 Benoit Jacob 5 | // 6 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN2_MEMORY_H 26 | #define EIGEN2_MEMORY_H 27 | 28 | inline void* ei_aligned_malloc(size_t size) { return internal::aligned_malloc(size); } 29 | inline void ei_aligned_free(void *ptr) { internal::aligned_free(ptr); } 30 | inline void* ei_aligned_realloc(void *ptr, size_t new_size, size_t old_size) { return internal::aligned_realloc(ptr, new_size, old_size); } 31 | inline void* ei_handmade_aligned_malloc(size_t size) { return internal::handmade_aligned_malloc(size); } 32 | inline void ei_handmade_aligned_free(void *ptr) { internal::handmade_aligned_free(ptr); } 33 | 34 | template inline void* ei_conditional_aligned_malloc(size_t size) 35 | { 36 | return internal::conditional_aligned_malloc(size); 37 | } 38 | template inline void ei_conditional_aligned_free(void *ptr) 39 | { 40 | internal::conditional_aligned_free(ptr); 41 | } 42 | template inline void* ei_conditional_aligned_realloc(void* ptr, size_t new_size, size_t old_size) 43 | { 44 | return internal::conditional_aligned_realloc(ptr, new_size, old_size); 45 | } 46 | 47 | template inline T* ei_aligned_new(size_t size) 48 | { 49 | return internal::aligned_new(size); 50 | } 51 | template inline void ei_aligned_delete(T *ptr, size_t size) 52 | { 53 | return internal::aligned_delete(ptr, size); 54 | } 55 | 56 | 57 | 58 | #endif // EIGEN2_MACROS_H 59 | -------------------------------------------------------------------------------- /asift/compute_asift_keypoints.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2008-2011, Guoshen Yu 2 | // Copyright (c) 2008-2011, Jean-Michel Morel 3 | // 4 | // WARNING: 5 | // This file implements an algorithm possibly linked to the patent 6 | // 7 | // Jean-Michel Morel and Guoshen Yu, Method and device for the invariant 8 | // affine recognition recognition of shapes (WO/2009/150361), patent pending. 9 | // 10 | // This file is made available for the exclusive aim of serving as 11 | // scientific tool to verify of the soundness and 12 | // completeness of the algorithm description. Compilation, 13 | // execution and redistribution of this file may violate exclusive 14 | // patents rights in certain countries. 15 | // The situation being different for every country and changing 16 | // over time, it is your responsibility to determine which patent 17 | // rights restrictions apply to you before you compile, use, 18 | // modify, or redistribute this file. A patent lawyer is qualified 19 | // to make this determination. 20 | // If and only if they don't conflict with any patent terms, you 21 | // can benefit from the following license terms attached to this 22 | // file. 23 | // 24 | // This program is provided for scientific and educational only: 25 | // you can use and/or modify it for these purposes, but you are 26 | // not allowed to redistribute this work or derivative works in 27 | // source or executable form. A license must be obtained from the 28 | // patent right holders for any other use. 29 | // 30 | // 31 | //*------------------------ compute_asift_keypoints -------------------------*/ 32 | // Compute the ASIFT keypoints on the input image. 33 | // 34 | // Please report bugs and/or send comments to Guoshen Yu yu@cmap.polytechnique.fr 35 | // 36 | // Reference: J.M. Morel and G.Yu, ASIFT: A New Framework for Fully Affine Invariant Image 37 | // Comparison, SIAM Journal on Imaging Sciences, vol. 2, issue 2, pp. 438-469, 2009. 38 | // Reference: ASIFT online demo (You can try ASIFT with your own images online.) 39 | // http://www.ipol.im/pub/algo/my_affine_sift/ 40 | /*---------------------------------------------------------------------------*/ 41 | 42 | 43 | #include "../sift/library.h" 44 | #include "../sift/sift.h" 45 | #include "../sift/frot.h" 46 | #include "../sift/fproj.h" 47 | #include 48 | using namespace std; 49 | 50 | 51 | int compute_asift_keypoints(vector& image, int width, int height, int num_of_tilts, int verb, vector< vector< keypointslist > >& keys_all, siftPar &siftparameters); 52 | 53 | void GaussianBlur1D(vector& image, int width, int height, float sigma, int flag_dir); 54 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Core/arch/Default/Settings.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2010 Gael Guennebaud 5 | // Copyright (C) 2006-2008 Benoit Jacob 6 | // 7 | // Eigen is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU Lesser General Public 9 | // License as published by the Free Software Foundation; either 10 | // version 3 of the License, or (at your option) any later version. 11 | // 12 | // Alternatively, you can redistribute it and/or 13 | // modify it under the terms of the GNU General Public License as 14 | // published by the Free Software Foundation; either version 2 of 15 | // the License, or (at your option) any later version. 16 | // 17 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 18 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public 23 | // License and a copy of the GNU General Public License along with 24 | // Eigen. If not, see . 25 | 26 | 27 | /* All the parameters defined in this file can be specialized in the 28 | * architecture specific files, and/or by the user. 29 | * More to come... */ 30 | 31 | #ifndef EIGEN_DEFAULT_SETTINGS_H 32 | #define EIGEN_DEFAULT_SETTINGS_H 33 | 34 | /** Defines the maximal loop size to enable meta unrolling of loops. 35 | * Note that the value here is expressed in Eigen's own notion of "number of FLOPS", 36 | * it does not correspond to the number of iterations or the number of instructions 37 | */ 38 | #ifndef EIGEN_UNROLLING_LIMIT 39 | #define EIGEN_UNROLLING_LIMIT 100 40 | #endif 41 | 42 | /** Defines the threshold between a "small" and a "large" matrix. 43 | * This threshold is mainly used to select the proper product implementation. 44 | */ 45 | #ifndef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 46 | #define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 8 47 | #endif 48 | 49 | /** Defines the maximal width of the blocks used in the triangular product and solver 50 | * for vectors (level 2 blas xTRMV and xTRSV). The default is 8. 51 | */ 52 | #ifndef EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH 53 | #define EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH 8 54 | #endif 55 | 56 | 57 | /** Defines the default number of registers available for that architecture. 58 | * Currently it must be 8 or 16. Other values will fail. 59 | */ 60 | #ifndef EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS 61 | #define EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS 8 62 | #endif 63 | 64 | #endif // EIGEN_DEFAULT_SETTINGS_H 65 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Eigen2Support/QR.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // Copyright (C) 2011 Benoit Jacob 6 | // 7 | // Eigen is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU Lesser General Public 9 | // License as published by the Free Software Foundation; either 10 | // version 3 of the License, or (at your option) any later version. 11 | // 12 | // Alternatively, you can redistribute it and/or 13 | // modify it under the terms of the GNU General Public License as 14 | // published by the Free Software Foundation; either version 2 of 15 | // the License, or (at your option) any later version. 16 | // 17 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 18 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public 23 | // License and a copy of the GNU General Public License along with 24 | // Eigen. If not, see . 25 | 26 | #ifndef EIGEN2_QR_H 27 | #define EIGEN2_QR_H 28 | 29 | template 30 | class QR : public HouseholderQR 31 | { 32 | public: 33 | 34 | typedef HouseholderQR Base; 35 | typedef Block MatrixRBlockType; 36 | 37 | QR() : Base() {} 38 | 39 | template 40 | explicit QR(const T& t) : Base(t) {} 41 | 42 | template 43 | bool solve(const MatrixBase& b, ResultType *result) const 44 | { 45 | *result = static_cast(this)->solve(b); 46 | return true; 47 | } 48 | 49 | MatrixType matrixQ(void) const { 50 | MatrixType ret = MatrixType::Identity(this->rows(), this->cols()); 51 | ret = this->householderQ() * ret; 52 | return ret; 53 | } 54 | 55 | bool isFullRank() const { 56 | return true; 57 | } 58 | 59 | const TriangularView 60 | matrixR(void) const 61 | { 62 | int cols = this->cols(); 63 | return MatrixRBlockType(this->matrixQR(), 0, 0, cols, cols).template triangularView(); 64 | } 65 | }; 66 | 67 | /** \return the QR decomposition of \c *this. 68 | * 69 | * \sa class QR 70 | */ 71 | template 72 | const QR::PlainObject> 73 | MatrixBase::qr() const 74 | { 75 | return QR(eval()); 76 | } 77 | 78 | 79 | #endif // EIGEN2_QR_H 80 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Sparse/SparseTranspose.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2009 Gael Guennebaud 5 | // 6 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_SPARSETRANSPOSE_H 26 | #define EIGEN_SPARSETRANSPOSE_H 27 | 28 | template class TransposeImpl 29 | : public SparseMatrixBase > 30 | { 31 | typedef typename internal::remove_all::type _MatrixTypeNested; 32 | public: 33 | 34 | EIGEN_SPARSE_PUBLIC_INTERFACE(Transpose) 35 | 36 | class InnerIterator; 37 | class ReverseInnerIterator; 38 | 39 | inline Index nonZeros() const { return derived().nestedExpression().nonZeros(); } 40 | }; 41 | 42 | template class TransposeImpl::InnerIterator 43 | : public _MatrixTypeNested::InnerIterator 44 | { 45 | typedef typename _MatrixTypeNested::InnerIterator Base; 46 | public: 47 | 48 | EIGEN_STRONG_INLINE InnerIterator(const TransposeImpl& trans, Index outer) 49 | : Base(trans.derived().nestedExpression(), outer) 50 | {} 51 | inline Index row() const { return Base::col(); } 52 | inline Index col() const { return Base::row(); } 53 | }; 54 | 55 | template class TransposeImpl::ReverseInnerIterator 56 | : public _MatrixTypeNested::ReverseInnerIterator 57 | { 58 | typedef typename _MatrixTypeNested::ReverseInnerIterator Base; 59 | public: 60 | 61 | EIGEN_STRONG_INLINE ReverseInnerIterator(const TransposeImpl& xpr, Index outer) 62 | : Base(xpr.derived().nestedExpression(), outer) 63 | {} 64 | inline Index row() const { return Base::col(); } 65 | inline Index col() const { return Base::row(); } 66 | }; 67 | 68 | #endif // EIGEN_SPARSETRANSPOSE_H 69 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Sparse/CoreIterators.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2010 Gael Guennebaud 5 | // 6 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_COREITERATORS_H 26 | #define EIGEN_COREITERATORS_H 27 | 28 | /* This file contains the respective InnerIterator definition of the expressions defined in Eigen/Core 29 | */ 30 | 31 | /** \class InnerIterator 32 | * \brief An InnerIterator allows to loop over the element of a sparse (or dense) matrix or expression 33 | * 34 | * todo 35 | */ 36 | 37 | // generic version for dense matrix and expressions 38 | template class DenseBase::InnerIterator 39 | { 40 | protected: 41 | typedef typename Derived::Scalar Scalar; 42 | typedef typename Derived::Index Index; 43 | 44 | enum { IsRowMajor = (Derived::Flags&RowMajorBit)==RowMajorBit }; 45 | public: 46 | EIGEN_STRONG_INLINE InnerIterator(const Derived& expr, Index outer) 47 | : m_expression(expr), m_inner(0), m_outer(outer), m_end(expr.innerSize()) 48 | {} 49 | 50 | EIGEN_STRONG_INLINE Scalar value() const 51 | { 52 | return (IsRowMajor) ? m_expression.coeff(m_outer, m_inner) 53 | : m_expression.coeff(m_inner, m_outer); 54 | } 55 | 56 | EIGEN_STRONG_INLINE InnerIterator& operator++() { m_inner++; return *this; } 57 | 58 | EIGEN_STRONG_INLINE Index index() const { return m_inner; } 59 | inline Index row() const { return IsRowMajor ? m_outer : index(); } 60 | inline Index col() const { return IsRowMajor ? index() : m_outer; } 61 | 62 | EIGEN_STRONG_INLINE operator bool() const { return m_inner < m_end && m_inner>=0; } 63 | 64 | protected: 65 | const Derived& m_expression; 66 | Index m_inner; 67 | const Index m_outer; 68 | const Index m_end; 69 | }; 70 | 71 | #endif // EIGEN_COREITERATORS_H 72 | -------------------------------------------------------------------------------- /third_party/Eigen/src/plugins/CommonCwiseBinaryOps.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2009 Gael Guennebaud 5 | // Copyright (C) 2006-2008 Benoit Jacob 6 | // 7 | // Eigen is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU Lesser General Public 9 | // License as published by the Free Software Foundation; either 10 | // version 3 of the License, or (at your option) any later version. 11 | // 12 | // Alternatively, you can redistribute it and/or 13 | // modify it under the terms of the GNU General Public License as 14 | // published by the Free Software Foundation; either version 2 of 15 | // the License, or (at your option) any later version. 16 | // 17 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 18 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public 23 | // License and a copy of the GNU General Public License along with 24 | // Eigen. If not, see . 25 | 26 | // This file is a base class plugin containing common coefficient wise functions. 27 | 28 | /** \returns an expression of the difference of \c *this and \a other 29 | * 30 | * \note If you want to substract a given scalar from all coefficients, see Cwise::operator-(). 31 | * 32 | * \sa class CwiseBinaryOp, operator-=() 33 | */ 34 | EIGEN_MAKE_CWISE_BINARY_OP(operator-,internal::scalar_difference_op) 35 | 36 | /** \returns an expression of the sum of \c *this and \a other 37 | * 38 | * \note If you want to add a given scalar to all coefficients, see Cwise::operator+(). 39 | * 40 | * \sa class CwiseBinaryOp, operator+=() 41 | */ 42 | EIGEN_MAKE_CWISE_BINARY_OP(operator+,internal::scalar_sum_op) 43 | 44 | /** \returns an expression of a custom coefficient-wise operator \a func of *this and \a other 45 | * 46 | * The template parameter \a CustomBinaryOp is the type of the functor 47 | * of the custom operator (see class CwiseBinaryOp for an example) 48 | * 49 | * Here is an example illustrating the use of custom functors: 50 | * \include class_CwiseBinaryOp.cpp 51 | * Output: \verbinclude class_CwiseBinaryOp.out 52 | * 53 | * \sa class CwiseBinaryOp, operator+(), operator-(), cwiseProduct() 54 | */ 55 | template 56 | EIGEN_STRONG_INLINE const CwiseBinaryOp 57 | binaryExpr(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other, const CustomBinaryOp& func = CustomBinaryOp()) const 58 | { 59 | return CwiseBinaryOp(derived(), other.derived(), func); 60 | } 61 | 62 | -------------------------------------------------------------------------------- /third_party/Eigen/Eigen2Support: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // 6 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN2SUPPORT_H 26 | #define EIGEN2SUPPORT_H 27 | 28 | #if (!defined(EIGEN2_SUPPORT)) || (!defined(EIGEN_CORE_H)) 29 | #error Eigen2 support must be enabled by defining EIGEN2_SUPPORT before including any Eigen header 30 | #endif 31 | 32 | #include "src/Core/util/DisableStupidWarnings.h" 33 | 34 | namespace Eigen { 35 | 36 | /** \defgroup Eigen2Support_Module Eigen2 support module 37 | * This module provides a couple of deprecated functions improving the compatibility with Eigen2. 38 | * 39 | * To use it, define EIGEN2_SUPPORT before including any Eigen header 40 | * \code 41 | * #define EIGEN2_SUPPORT 42 | * \endcode 43 | * 44 | */ 45 | 46 | #include "src/Eigen2Support/Macros.h" 47 | #include "src/Eigen2Support/Memory.h" 48 | #include "src/Eigen2Support/Meta.h" 49 | #include "src/Eigen2Support/Lazy.h" 50 | #include "src/Eigen2Support/Cwise.h" 51 | #include "src/Eigen2Support/CwiseOperators.h" 52 | #include "src/Eigen2Support/TriangularSolver.h" 53 | #include "src/Eigen2Support/Block.h" 54 | #include "src/Eigen2Support/VectorBlock.h" 55 | #include "src/Eigen2Support/Minor.h" 56 | #include "src/Eigen2Support/MathFunctions.h" 57 | 58 | 59 | } // namespace Eigen 60 | 61 | #include "src/Core/util/ReenableStupidWarnings.h" 62 | 63 | // Eigen2 used to include iostream 64 | #include 65 | 66 | #define USING_PART_OF_NAMESPACE_EIGEN \ 67 | EIGEN_USING_MATRIX_TYPEDEFS \ 68 | using Eigen::Matrix; \ 69 | using Eigen::MatrixBase; \ 70 | using Eigen::ei_random; \ 71 | using Eigen::ei_real; \ 72 | using Eigen::ei_imag; \ 73 | using Eigen::ei_conj; \ 74 | using Eigen::ei_abs; \ 75 | using Eigen::ei_abs2; \ 76 | using Eigen::ei_sqrt; \ 77 | using Eigen::ei_exp; \ 78 | using Eigen::ei_log; \ 79 | using Eigen::ei_sin; \ 80 | using Eigen::ei_cos; 81 | 82 | #endif // EIGEN2SUPPORT_H 83 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Eigen2Support/Lazy.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Benoit Jacob 5 | // 6 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_LAZY_H 26 | #define EIGEN_LAZY_H 27 | 28 | /** \deprecated it is only used by lazy() which is deprecated 29 | * 30 | * \returns an expression of *this with added flags 31 | * 32 | * Example: \include MatrixBase_marked.cpp 33 | * Output: \verbinclude MatrixBase_marked.out 34 | * 35 | * \sa class Flagged, extract(), part() 36 | */ 37 | template 38 | template 39 | inline const Flagged 40 | MatrixBase::marked() const 41 | { 42 | return derived(); 43 | } 44 | 45 | /** \deprecated use MatrixBase::noalias() 46 | * 47 | * \returns an expression of *this with the EvalBeforeAssigningBit flag removed. 48 | * 49 | * Example: \include MatrixBase_lazy.cpp 50 | * Output: \verbinclude MatrixBase_lazy.out 51 | * 52 | * \sa class Flagged, marked() 53 | */ 54 | template 55 | inline const Flagged 56 | MatrixBase::lazy() const 57 | { 58 | return derived(); 59 | } 60 | 61 | 62 | /** \internal 63 | * Overloaded to perform an efficient C += (A*B).lazy() */ 64 | template 65 | template 66 | Derived& MatrixBase::operator+=(const Flagged, 0, 67 | EvalBeforeAssigningBit>& other) 68 | { 69 | other._expression().derived().addTo(derived()); return derived(); 70 | } 71 | 72 | /** \internal 73 | * Overloaded to perform an efficient C -= (A*B).lazy() */ 74 | template 75 | template 76 | Derived& MatrixBase::operator-=(const Flagged, 0, 77 | EvalBeforeAssigningBit>& other) 78 | { 79 | other._expression().derived().subTo(derived()); return derived(); 80 | } 81 | 82 | #endif // EIGEN_LAZY_H 83 | -------------------------------------------------------------------------------- /orsa.pyx: -------------------------------------------------------------------------------- 1 | #!/usr/bin/cython 2 | 3 | __author__ = "Jerome Kieffer" 4 | __date__ = "13/11/2013" 5 | __doc__ = """ 6 | Cython binding for ORSA: Optimized Ransac 7 | """ 8 | import time 9 | import numpy 10 | cimport numpy 11 | import cython 12 | from libcpp.vector cimport vector 13 | from orsa_cpp cimport Match, MatchList, orsa 14 | 15 | dtype_kp = numpy.dtype([('x', numpy.float32), 16 | ('y', numpy.float32), 17 | ('scale', numpy.float32), 18 | ('angle', numpy.float32), 19 | ('desc', (numpy.uint8, 128)) 20 | ]) 21 | 22 | cdef packed struct dtype_kp_t: 23 | numpy.float32_t x, y, scale, angle 24 | unsigned char desc[128] 25 | 26 | @cython.cdivision(True) 27 | @cython.boundscheck(False) 28 | @cython.wraparound(False) 29 | def sift_orsa(inp not None, shape=None, bint verbose=0): 30 | """ 31 | Call ORSA (keypoint checking) on sift matched keypoints 32 | 33 | @param inp: n*2 array representing of keypoints. 34 | @param shape: shape of the input images (unless guessed) 35 | @type shape: 2-tuple of integers 36 | @return: 2D array with n control points and 4 coordinates: in1_0,in1_1,in2_0,in2_1 37 | """ 38 | 39 | cdef int i, num_matchings 40 | cdef float[:,:] data_x = inp.x 41 | cdef float[:,:] data_y = inp.y 42 | cdef int insize = inp.shape[0] 43 | if insize < 10: 44 | return inp 45 | cdef vector [ Match ] match_coor = vector [ Match ](< size_t > insize) 46 | cdef int t_value_orsa = 10000 47 | cdef int verb_value_orsa = verbose 48 | cdef int n_flag_value_orsa = 0 49 | cdef int mode_value_orsa = 2 50 | cdef int stop_value_orsa = 0 51 | cdef float nfa 52 | cdef int width, heigh 53 | if shape is None: 54 | # keypoints are at least a 5 pixels of the border 55 | width = int(5 + max(inp[:, 0].x.max(), inp[:, 1].x.max())) 56 | heigh = int(5 + max(inp[:, 0].y.max(), inp[:, 1].y.max())) 57 | elif hasattr(shape, "__len__") and len(shape) >= 2: 58 | width = int(shape[1]) 59 | heigh = int(shape[0]) 60 | else: 61 | width = heigh = int(shape) 62 | cdef vector [ float ] index = vector [ float ](< size_t > insize) 63 | tmatch = time.time() 64 | with nogil: 65 | for i in range(insize): 66 | match_coor[i].x1 = data_x[i,0] 67 | match_coor[i].y1 = data_y[i,0] 68 | match_coor[i].x2 = data_x[i,1] 69 | match_coor[i].y2 = data_y[i,1] 70 | 71 | # epipolar filtering with the Moisan - Stival ORSA algorithm. 72 | nfa = orsa(width, heigh, match_coor, index, t_value_orsa, verb_value_orsa, n_flag_value_orsa, mode_value_orsa, stop_value_orsa) 73 | tend = time.time() 74 | num_matchings = index.size() 75 | if verbose: 76 | print("Matching with ORSA: %s => %s, took %.3fs, nfs=%s" % (insize, num_matchings, tend - tmatch, nfa)) 77 | # cdef numpy.ndarray[numpy.int64_t, ndim=1] out_index = numpy.zeros(num_matchings, dtype=numpy.int64) 78 | # with nogil: 79 | # for i in range(num_matchings): 80 | # out_index[i] = < int > index[i] 81 | out_index = numpy.array(index, dtype=numpy.int32) 82 | out = inp[out_index] 83 | return out 84 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Eigen2Support/Geometry/All.h: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN2_GEOMETRY_MODULE_H 2 | #define EIGEN2_GEOMETRY_MODULE_H 3 | 4 | #include 5 | 6 | #ifndef M_PI 7 | #define M_PI 3.14159265358979323846 8 | #endif 9 | 10 | #if EIGEN2_SUPPORT_STAGE < STAGE20_RESOLVE_API_CONFLICTS 11 | #include "RotationBase.h" 12 | #include "Rotation2D.h" 13 | #include "Quaternion.h" 14 | #include "AngleAxis.h" 15 | #include "Transform.h" 16 | #include "Translation.h" 17 | #include "Scaling.h" 18 | #include "AlignedBox.h" 19 | #include "Hyperplane.h" 20 | #include "ParametrizedLine.h" 21 | #endif 22 | 23 | 24 | #define RotationBase eigen2_RotationBase 25 | #define Rotation2D eigen2_Rotation2D 26 | #define Rotation2Df eigen2_Rotation2Df 27 | #define Rotation2Dd eigen2_Rotation2Dd 28 | 29 | #define Quaternion eigen2_Quaternion 30 | #define Quaternionf eigen2_Quaternionf 31 | #define Quaterniond eigen2_Quaterniond 32 | 33 | #define AngleAxis eigen2_AngleAxis 34 | #define AngleAxisf eigen2_AngleAxisf 35 | #define AngleAxisd eigen2_AngleAxisd 36 | 37 | #define Transform eigen2_Transform 38 | #define Transform2f eigen2_Transform2f 39 | #define Transform2d eigen2_Transform2d 40 | #define Transform3f eigen2_Transform3f 41 | #define Transform3d eigen2_Transform3d 42 | 43 | #define Translation eigen2_Translation 44 | #define Translation2f eigen2_Translation2f 45 | #define Translation2d eigen2_Translation2d 46 | #define Translation3f eigen2_Translation3f 47 | #define Translation3d eigen2_Translation3d 48 | 49 | #define Scaling eigen2_Scaling 50 | #define Scaling2f eigen2_Scaling2f 51 | #define Scaling2d eigen2_Scaling2d 52 | #define Scaling3f eigen2_Scaling3f 53 | #define Scaling3d eigen2_Scaling3d 54 | 55 | #define AlignedBox eigen2_AlignedBox 56 | 57 | #define Hyperplane eigen2_Hyperplane 58 | #define ParametrizedLine eigen2_ParametrizedLine 59 | 60 | #define ei_toRotationMatrix eigen2_ei_toRotationMatrix 61 | #define ei_quaternion_assign_impl eigen2_ei_quaternion_assign_impl 62 | #define ei_transform_product_impl eigen2_ei_transform_product_impl 63 | 64 | #include "RotationBase.h" 65 | #include "Rotation2D.h" 66 | #include "Quaternion.h" 67 | #include "AngleAxis.h" 68 | #include "Transform.h" 69 | #include "Translation.h" 70 | #include "Scaling.h" 71 | #include "AlignedBox.h" 72 | #include "Hyperplane.h" 73 | #include "ParametrizedLine.h" 74 | 75 | #undef ei_toRotationMatrix 76 | #undef ei_quaternion_assign_impl 77 | #undef ei_transform_product_impl 78 | 79 | #undef RotationBase 80 | #undef Rotation2D 81 | #undef Rotation2Df 82 | #undef Rotation2Dd 83 | 84 | #undef Quaternion 85 | #undef Quaternionf 86 | #undef Quaterniond 87 | 88 | #undef AngleAxis 89 | #undef AngleAxisf 90 | #undef AngleAxisd 91 | 92 | #undef Transform 93 | #undef Transform2f 94 | #undef Transform2d 95 | #undef Transform3f 96 | #undef Transform3d 97 | 98 | #undef Translation 99 | #undef Translation2f 100 | #undef Translation2d 101 | #undef Translation3f 102 | #undef Translation3d 103 | 104 | #undef Scaling 105 | #undef Scaling2f 106 | #undef Scaling2d 107 | #undef Scaling3f 108 | #undef Scaling3d 109 | 110 | #undef AlignedBox 111 | 112 | #undef Hyperplane 113 | #undef ParametrizedLine 114 | 115 | #endif // EIGEN2_GEOMETRY_MODULE_H -------------------------------------------------------------------------------- /libNumerics/homography.h: -------------------------------------------------------------------------------- 1 | #ifndef HOMOGRAPHY_H 2 | #define HOMOGRAPHY_H 3 | 4 | #include "matrix.h" 5 | 6 | namespace libNumerics { 7 | 8 | /// 2-D homography transform. 9 | class Homography { 10 | public: 11 | Homography(); 12 | 13 | void setId(); 14 | void setTrans(double dx, double dy); 15 | void setZoom(double zx, double zy); 16 | 17 | matrix& mat() { return m_H; } 18 | const matrix& mat() const { return m_H; } 19 | 20 | void operator()(double& x, double& y) const; 21 | Homography operator*(const Homography& rhs) const; 22 | Homography inverse() const; 23 | private: 24 | matrix m_H; 25 | void normalize(); 26 | }; 27 | 28 | /// Homography (and more restricted transforms) estimation. 29 | class ComputeH { 30 | public: 31 | enum Type { Translation, // (2 parameters) 32 | Rotation, // Rotation/Translation (3 parameters) 33 | Zoom, // Zoom/Translation (3 parameters) 34 | GeneralZoom, // Non uniform zoom/Translation (4 parameters) 35 | Similarity, // Zoom/Rotation/Translation (4 parameters) 36 | Affine, // (6 parameters) 37 | Projective // (8 parameters) 38 | }; 39 | static Type restrict(Type t); // Return less general motion 40 | public: 41 | ComputeH(Type type); 42 | ~ComputeH(); 43 | 44 | Type type() const { return _type; } 45 | void clear(); 46 | 47 | /// Add corresponding points (x1,y1) and (x2,y2) 48 | void add(float x1, float y1, float x2, float y2, float w = 1.0f); 49 | /// Add corresponding lines of equation u x + v y + w = 0 50 | void add(float a1, float b1, float c1, 51 | float a2, float b2, float c2, float w = 1.0f); 52 | 53 | float weight() const; ///< Sum of weights (=#correspondences) 54 | float q_error(const Homography& map) const; ///< Quadratic error 55 | float compute(Homography& map) const; ///< LSE motion, return support weight 56 | private: 57 | Type _type; 58 | int n; ///< Dimension of matrix = # unknown parameters 59 | double Ann[64], Bn[8], b; // Min (X 1) (A B) (X 1)^T is X^T = Ann^-1 Bn 60 | 61 | static int size(Type type); 62 | void add_4parameters(float x1, float y1, float x2, float y2, float w); 63 | void add_4parameters(float a1, float b1, float c1, 64 | float a2, float b2, float c2, float w); 65 | void wrap(Homography& map, const vector& v) const; 66 | void unwrap(const Homography& map, vector& v) const; 67 | float q_error(const vector& v) const; // Quadratic error 68 | 69 | bool compute_rotation(vector& B) const; 70 | 71 | /// For Projective, data normalization is required 72 | class Normalization { public: double x, y, s; }; 73 | bool normalize(Normalization& left, 74 | matrix& A, vector& B, 75 | Normalization& right) const; 76 | static bool de_normalize(const Normalization& left, 77 | vector& B, 78 | const Normalization& right); 79 | }; 80 | 81 | } // libNumerics 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /third_party/flimage.h: -------------------------------------------------------------------------------- 1 | // Authors: Unknown. Please, if you are the author of this file, or if you 2 | // know who are the authors of this file, let us know, so we can give the 3 | // adequate credits and/or get the adequate authorizations. 4 | 5 | 6 | #ifndef _FLIMAGE_H_ 7 | #define _FLIMAGE_H_ 8 | 9 | #include 10 | #include 11 | 12 | class flimage { 13 | 14 | private: 15 | 16 | int width, height; // image size 17 | float* p; // array of color levels: level of pixel (x,y) is p[y*width+x] 18 | 19 | public: 20 | 21 | 22 | //// Construction 23 | flimage(); 24 | flimage(int w, int h); 25 | flimage(int w, int h, float v); 26 | flimage(int w, int h, float* v); 27 | flimage(const flimage& im); 28 | flimage& operator= (const flimage& im); 29 | 30 | 31 | void create(int w, int h); 32 | void create(int w, int h, float *v); 33 | 34 | //// Destruction 35 | void erase(); 36 | ~flimage(); 37 | 38 | //// Get Basic Data 39 | int nwidth() const {return width;} // image size 40 | int nheight() const {return height;} 41 | 42 | /// Access values 43 | float* getPlane() {return p;} // return the adress of the array of values 44 | 45 | float operator()(int x, int y) const {return p[ y*width + x ];} // acces to the (x,y) value 46 | float& operator()(int x, int y) {return p[ y*width + x ];} // by value (for const images) and by reference 47 | 48 | 49 | }; 50 | 51 | 52 | #endif 53 | 54 | 55 | //////////////////////////////////////////////// Class flimage 56 | //// Construction 57 | flimage::flimage() : width(0), height(0), p(0) 58 | { 59 | } 60 | 61 | flimage::flimage(int w, int h) : width(w), height(h), p(new float[w*h]) 62 | { 63 | for (int j=width*height-1; j>=0 ; j--) p[j] = 0.0; 64 | } 65 | 66 | 67 | flimage::flimage(int w, int h, float v) : width(w), height(h), p(new float[w*h]) 68 | { 69 | for (int j=width*height-1; j>=0 ; j--) p[j] = v; 70 | } 71 | 72 | 73 | flimage::flimage(int w, int h, float* v) : width(w), height(h), p(new float[w*h]) 74 | { 75 | for (int j=width*height-1; j>=0 ; j--) p[j] = v[j]; 76 | } 77 | 78 | 79 | void flimage::create(int w, int h) 80 | { 81 | erase(); 82 | width = w; height = h; 83 | p = new float[w*h]; 84 | for (int j=width*height-1; j>=0 ; j--) p[j] = 0.0; 85 | } 86 | 87 | void flimage::create(int w, int h, float* v) 88 | { 89 | erase(); 90 | width = w; height = h; p = new float[w*h]; 91 | for (int j=width*height-1; j>=0 ; j--) p[j] = v[j]; 92 | } 93 | 94 | 95 | flimage::flimage(const flimage& im) : width(im.width), height(im.height), p(new float[im.width*im.height]) 96 | { 97 | for (int j=width*height-1; j>=0 ; j--) p[j] = im.p[j]; 98 | } 99 | 100 | flimage& flimage::operator= (const flimage& im) 101 | { 102 | if (&im == this) { 103 | return *this; 104 | } 105 | 106 | if (width != im.width || height != im.height) 107 | { 108 | erase(); 109 | width = im.width; height=im.height; p = new float[width*height]; 110 | } 111 | 112 | for (int j=width*height-1; j>=0 ; j--) p[j] = im.p[j]; 113 | return *this; 114 | } 115 | 116 | 117 | //// Destruction 118 | void flimage::erase() 119 | { 120 | width = height = 0; 121 | if (p) delete[] p; 122 | p=0; 123 | } 124 | 125 | flimage::~flimage() 126 | { 127 | erase(); 128 | } 129 | 130 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /third_party/Eigen/src/misc/Solve.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Benoit Jacob 5 | // 6 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_MISC_SOLVE_H 26 | #define EIGEN_MISC_SOLVE_H 27 | 28 | namespace internal { 29 | 30 | /** \class solve_retval_base 31 | * 32 | */ 33 | template 34 | struct traits > 35 | { 36 | typedef typename DecompositionType::MatrixType MatrixType; 37 | typedef Matrix ReturnType; 43 | }; 44 | 45 | template struct solve_retval_base 46 | : public ReturnByValue > 47 | { 48 | typedef typename remove_all::type RhsNestedCleaned; 49 | typedef _DecompositionType DecompositionType; 50 | typedef ReturnByValue Base; 51 | typedef typename Base::Index Index; 52 | 53 | solve_retval_base(const DecompositionType& dec, const Rhs& rhs) 54 | : m_dec(dec), m_rhs(rhs) 55 | {} 56 | 57 | inline Index rows() const { return m_dec.cols(); } 58 | inline Index cols() const { return m_rhs.cols(); } 59 | inline const DecompositionType& dec() const { return m_dec; } 60 | inline const RhsNestedCleaned& rhs() const { return m_rhs; } 61 | 62 | template inline void evalTo(Dest& dst) const 63 | { 64 | static_cast*>(this)->evalTo(dst); 65 | } 66 | 67 | protected: 68 | const DecompositionType& m_dec; 69 | const typename Rhs::Nested m_rhs; 70 | }; 71 | 72 | } // end namespace internal 73 | 74 | #define EIGEN_MAKE_SOLVE_HELPERS(DecompositionType,Rhs) \ 75 | typedef typename DecompositionType::MatrixType MatrixType; \ 76 | typedef typename MatrixType::Scalar Scalar; \ 77 | typedef typename MatrixType::RealScalar RealScalar; \ 78 | typedef typename MatrixType::Index Index; \ 79 | typedef Eigen::internal::solve_retval_base Base; \ 80 | using Base::dec; \ 81 | using Base::rhs; \ 82 | using Base::rows; \ 83 | using Base::cols; \ 84 | solve_retval(const DecompositionType& dec, const Rhs& rhs) \ 85 | : Base(dec, rhs) {} 86 | 87 | #endif // EIGEN_MISC_SOLVE_H 88 | -------------------------------------------------------------------------------- /third_party/Eigen/src/plugins/MatrixCwiseUnaryOps.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2009 Gael Guennebaud 5 | // Copyright (C) 2006-2008 Benoit Jacob 6 | // 7 | // Eigen is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU Lesser General Public 9 | // License as published by the Free Software Foundation; either 10 | // version 3 of the License, or (at your option) any later version. 11 | // 12 | // Alternatively, you can redistribute it and/or 13 | // modify it under the terms of the GNU General Public License as 14 | // published by the Free Software Foundation; either version 2 of 15 | // the License, or (at your option) any later version. 16 | // 17 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 18 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public 23 | // License and a copy of the GNU General Public License along with 24 | // Eigen. If not, see . 25 | 26 | // This file is a base class plugin containing matrix specifics coefficient wise functions. 27 | 28 | /** \returns an expression of the coefficient-wise absolute value of \c *this 29 | * 30 | * Example: \include MatrixBase_cwiseAbs.cpp 31 | * Output: \verbinclude MatrixBase_cwiseAbs.out 32 | * 33 | * \sa cwiseAbs2() 34 | */ 35 | EIGEN_STRONG_INLINE const CwiseUnaryOp, const Derived> 36 | cwiseAbs() const { return derived(); } 37 | 38 | /** \returns an expression of the coefficient-wise squared absolute value of \c *this 39 | * 40 | * Example: \include MatrixBase_cwiseAbs2.cpp 41 | * Output: \verbinclude MatrixBase_cwiseAbs2.out 42 | * 43 | * \sa cwiseAbs() 44 | */ 45 | EIGEN_STRONG_INLINE const CwiseUnaryOp, const Derived> 46 | cwiseAbs2() const { return derived(); } 47 | 48 | /** \returns an expression of the coefficient-wise square root of *this. 49 | * 50 | * Example: \include MatrixBase_cwiseSqrt.cpp 51 | * Output: \verbinclude MatrixBase_cwiseSqrt.out 52 | * 53 | * \sa cwisePow(), cwiseSquare() 54 | */ 55 | inline const CwiseUnaryOp, const Derived> 56 | cwiseSqrt() const { return derived(); } 57 | 58 | /** \returns an expression of the coefficient-wise inverse of *this. 59 | * 60 | * Example: \include MatrixBase_cwiseInverse.cpp 61 | * Output: \verbinclude MatrixBase_cwiseInverse.out 62 | * 63 | * \sa cwiseProduct() 64 | */ 65 | inline const CwiseUnaryOp, const Derived> 66 | cwiseInverse() const { return derived(); } 67 | 68 | /** \returns an expression of the coefficient-wise == operator of \c *this and a scalar \a s 69 | * 70 | * \warning this performs an exact comparison, which is generally a bad idea with floating-point types. 71 | * In order to check for equality between two vectors or matrices with floating-point coefficients, it is 72 | * generally a far better idea to use a fuzzy comparison as provided by isApprox() and 73 | * isMuchSmallerThan(). 74 | * 75 | * \sa cwiseEqual(const MatrixBase &) const 76 | */ 77 | inline const CwiseUnaryOp >, const Derived> 78 | cwiseEqual(const Scalar& s) const 79 | { 80 | return CwiseUnaryOp >,const Derived> 81 | (derived(), std::bind1st(std::equal_to(), s)); 82 | } 83 | -------------------------------------------------------------------------------- /sift/frot.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007 Lionel Moisan 2 | 3 | 4 | 5 | #include "frot.h" 6 | 7 | #ifndef M_PI 8 | #define M_PI 3.14159265358979323846 9 | #endif 10 | 11 | 12 | void bound(int x, int y, float ca, float sa, int *xmin, int *xmax, int *ymin, int *ymax); 13 | 14 | 15 | /* NB : calling this module with out=in is nonsense */ 16 | 17 | /* void frot(in,out,a,b,k_flag) 18 | Fimage in,out; 19 | float *a,*b; 20 | char *k_flag; */ 21 | 22 | void frot(vector& in, vector& out, int nx, int ny, int *nx_out, int *ny_out, float *a, float *b, char *k_flag) 23 | //void frot(float *in, float *out, int nx, int ny, int *nx_out, int *ny_out, float *a, float *b, char *k_flag) 24 | { 25 | /* int nx,ny,x,y,x1,y1,adr; */ 26 | int x,y,x1,y1,adr; 27 | float ca,sa,xp,yp,a11,a12,a21,a22,ux,uy,xtrans,ytrans; 28 | int tx1,ty1,tx2,ty2,xmin,xmax,ymin,ymax,sx,sy; 29 | 30 | /* nx = in->ncol; 31 | ny = in->nrow; */ 32 | 33 | ca = (float)cos((double)(*a)*M_PI/180.0); 34 | sa = (float)sin((double)(*a)*M_PI/180.0); 35 | 36 | 37 | 38 | /********** Compute new image location **********/ 39 | if (k_flag) { 40 | /* crop image and fix center */ 41 | xmin = ymin = 0; 42 | xmax = nx-1; 43 | ymax = ny-1; 44 | xtrans = 0.5*( (float)(nx-1)*(1.0-ca)+(float)(ny-1)*sa ); 45 | ytrans = 0.5*( (float)(ny-1)*(1.0-ca)-(float)(nx-1)*sa ); 46 | } else { 47 | /* extend image size to include the whole input image */ 48 | xmin = xmax = ymin = ymax = 0; 49 | bound(nx-1,0,ca,sa,&xmin,&xmax,&ymin,&ymax); 50 | bound(0,ny-1,ca,sa,&xmin,&xmax,&ymin,&ymax); 51 | bound(nx-1,ny-1,ca,sa,&xmin,&xmax,&ymin,&ymax); 52 | xtrans = ytrans = 0.0; 53 | } 54 | sx = xmax-xmin+1; 55 | sy = ymax-ymin+1; 56 | 57 | /* out = mw_change_fimage(out,sy,sx); 58 | if (!out) mwerror(FATAL,1,"not enough memory\n"); */ 59 | 60 | *nx_out = sx; 61 | *ny_out = sy; 62 | 63 | // printf("Hello sx=%d, sy=%d\n", sx, sy); 64 | 65 | // out = new float[sy*sx]; 66 | out = std::vector(sx*sy); 67 | 68 | /********** Rotate image **********/ 69 | for (x=xmin;x<=xmax;x++) 70 | for (y=ymin;y<=ymax;y++) { 71 | xp = ca*(float)x-sa*(float)y + xtrans; 72 | yp = sa*(float)x+ca*(float)y + ytrans; 73 | x1 = (int)floor(xp); 74 | y1 = (int)floor(yp); 75 | ux = xp-(float)x1; 76 | uy = yp-(float)y1; 77 | adr = y1*nx+x1; 78 | tx1 = (x1>=0 && x1=0 && x1+1=0 && y1=0 && y1+1gray[adr]:*b); 84 | a12 = (tx1 && ty2? in->gray[adr+nx]:*b); 85 | a21 = (tx2 && ty1? in->gray[adr+1]:*b); 86 | a22 = (tx2 && ty2? in->gray[adr+nx+1]:*b); */ 87 | 88 | a11 = (tx1 && ty1? in[adr]:*b); 89 | a12 = (tx1 && ty2? in[adr+nx]:*b); 90 | a21 = (tx2 && ty1? in[adr+1]:*b); 91 | a22 = (tx2 && ty2? in[adr+nx+1]:*b); 92 | 93 | 94 | /* out->gray[(y-ymin)*sx+x-xmin] = 95 | (1.0-uy)*((1.0-ux)*a11+ux*a21)+uy*((1.0-ux)*a12+ux*a22);*/ 96 | 97 | out[(y-ymin)*sx+x-xmin] = 98 | (1.0-uy)*((1.0-ux)*a11+ux*a21)+uy*((1.0-ux)*a12+ux*a22); 99 | 100 | } 101 | } 102 | 103 | 104 | void bound(int x, int y, float ca, float sa, int *xmin, int *xmax, int *ymin, int *ymax) 105 | /* int x,y; 106 | float ca,sa; 107 | int *xmin,*xmax,*ymin,*ymax;*/ 108 | { 109 | int rx,ry; 110 | 111 | rx = (int)floor(ca*(float)x+sa*(float)y); 112 | ry = (int)floor(-sa*(float)x+ca*(float)y); 113 | if (rx<*xmin) *xmin=rx; if (rx>*xmax) *xmax=rx; 114 | if (ry<*ymin) *ymin=ry; if (ry>*ymax) *ymax=ry; 115 | } 116 | 117 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Geometry/EulerAngles.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // 6 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_EULERANGLES_H 26 | #define EIGEN_EULERANGLES_H 27 | 28 | /** \geometry_module \ingroup Geometry_Module 29 | * 30 | * 31 | * \returns the Euler-angles of the rotation matrix \c *this using the convention defined by the triplet (\a a0,\a a1,\a a2) 32 | * 33 | * Each of the three parameters \a a0,\a a1,\a a2 represents the respective rotation axis as an integer in {0,1,2}. 34 | * For instance, in: 35 | * \code Vector3f ea = mat.eulerAngles(2, 0, 2); \endcode 36 | * "2" represents the z axis and "0" the x axis, etc. The returned angles are such that 37 | * we have the following equality: 38 | * \code 39 | * mat == AngleAxisf(ea[0], Vector3f::UnitZ()) 40 | * * AngleAxisf(ea[1], Vector3f::UnitX()) 41 | * * AngleAxisf(ea[2], Vector3f::UnitZ()); \endcode 42 | * This corresponds to the right-multiply conventions (with right hand side frames). 43 | */ 44 | template 45 | inline Matrix::Scalar,3,1> 46 | MatrixBase::eulerAngles(Index a0, Index a1, Index a2) const 47 | { 48 | /* Implemented from Graphics Gems IV */ 49 | EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Derived,3,3) 50 | 51 | Matrix res; 52 | typedef Matrix Vector2; 53 | const Scalar epsilon = NumTraits::dummy_precision(); 54 | 55 | const Index odd = ((a0+1)%3 == a1) ? 0 : 1; 56 | const Index i = a0; 57 | const Index j = (a0 + 1 + odd)%3; 58 | const Index k = (a0 + 2 - odd)%3; 59 | 60 | if (a0==a2) 61 | { 62 | Scalar s = Vector2(coeff(j,i) , coeff(k,i)).norm(); 63 | res[1] = internal::atan2(s, coeff(i,i)); 64 | if (s > epsilon) 65 | { 66 | res[0] = internal::atan2(coeff(j,i), coeff(k,i)); 67 | res[2] = internal::atan2(coeff(i,j),-coeff(i,k)); 68 | } 69 | else 70 | { 71 | res[0] = Scalar(0); 72 | res[2] = (coeff(i,i)>0?1:-1)*internal::atan2(-coeff(k,j), coeff(j,j)); 73 | } 74 | } 75 | else 76 | { 77 | Scalar c = Vector2(coeff(i,i) , coeff(i,j)).norm(); 78 | res[1] = internal::atan2(-coeff(i,k), c); 79 | if (c > epsilon) 80 | { 81 | res[0] = internal::atan2(coeff(j,k), coeff(k,k)); 82 | res[2] = internal::atan2(coeff(i,j), coeff(i,i)); 83 | } 84 | else 85 | { 86 | res[0] = Scalar(0); 87 | res[2] = (coeff(i,k)>0?1:-1)*internal::atan2(-coeff(k,j), coeff(j,j)); 88 | } 89 | } 90 | if (!odd) 91 | res = -res; 92 | return res; 93 | } 94 | 95 | 96 | #endif // EIGEN_EULERANGLES_H 97 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Eigen2Support/MathFunctions.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2010 Gael Guennebaud 5 | // 6 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN2_MATH_FUNCTIONS_H 26 | #define EIGEN2_MATH_FUNCTIONS_H 27 | 28 | template inline typename NumTraits::Real ei_real(const T& x) { return internal::real(x); } 29 | template inline typename NumTraits::Real ei_imag(const T& x) { return internal::imag(x); } 30 | template inline T ei_conj(const T& x) { return internal::conj(x); } 31 | template inline typename NumTraits::Real ei_abs (const T& x) { return internal::abs(x); } 32 | template inline typename NumTraits::Real ei_abs2(const T& x) { return internal::abs2(x); } 33 | template inline T ei_sqrt(const T& x) { return internal::sqrt(x); } 34 | template inline T ei_exp (const T& x) { return internal::exp(x); } 35 | template inline T ei_log (const T& x) { return internal::log(x); } 36 | template inline T ei_sin (const T& x) { return internal::sin(x); } 37 | template inline T ei_cos (const T& x) { return internal::cos(x); } 38 | template inline T ei_atan2(const T& x,const T& y) { return internal::atan2(x,y); } 39 | template inline T ei_pow (const T& x,const T& y) { return internal::pow(x,y); } 40 | template inline T ei_random () { return internal::random(); } 41 | template inline T ei_random (const T& x, const T& y) { return internal::random(x, y); } 42 | 43 | template inline T precision () { return NumTraits::dummy_precision(); } 44 | template inline T machine_epsilon () { return NumTraits::epsilon(); } 45 | 46 | 47 | template 48 | inline bool ei_isMuchSmallerThan(const Scalar& x, const OtherScalar& y, 49 | typename NumTraits::Real precision = NumTraits::dummy_precision()) 50 | { 51 | return internal::isMuchSmallerThan(x, y, precision); 52 | } 53 | 54 | template 55 | inline bool ei_isApprox(const Scalar& x, const Scalar& y, 56 | typename NumTraits::Real precision = NumTraits::dummy_precision()) 57 | { 58 | return internal::isApprox(x, y, precision); 59 | } 60 | 61 | template 62 | inline bool ei_isApproxOrLessThan(const Scalar& x, const Scalar& y, 63 | typename NumTraits::Real precision = NumTraits::dummy_precision()) 64 | { 65 | return internal::isApproxOrLessThan(x, y, precision); 66 | } 67 | 68 | #endif // EIGEN2_MATH_FUNCTIONS_H 69 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Householder/BlockHouseholder.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2010 Vincent Lejeune 5 | // Copyright (C) 2010 Gael Guennebaud 6 | // 7 | // Eigen is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU Lesser General Public 9 | // License as published by the Free Software Foundation; either 10 | // version 3 of the License, or (at your option) any later version. 11 | // 12 | // Alternatively, you can redistribute it and/or 13 | // modify it under the terms of the GNU General Public License as 14 | // published by the Free Software Foundation; either version 2 of 15 | // the License, or (at your option) any later version. 16 | // 17 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 18 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public 23 | // License and a copy of the GNU General Public License along with 24 | // Eigen. If not, see . 25 | 26 | #ifndef EIGEN_BLOCK_HOUSEHOLDER_H 27 | #define EIGEN_BLOCK_HOUSEHOLDER_H 28 | 29 | // This file contains some helper function to deal with block householder reflectors 30 | 31 | namespace internal { 32 | 33 | /** \internal */ 34 | template 35 | void make_block_householder_triangular_factor(TriangularFactorType& triFactor, const VectorsType& vectors, const CoeffsType& hCoeffs) 36 | { 37 | typedef typename TriangularFactorType::Index Index; 38 | typedef typename VectorsType::Scalar Scalar; 39 | const Index nbVecs = vectors.cols(); 40 | eigen_assert(triFactor.rows() == nbVecs && triFactor.cols() == nbVecs && vectors.rows()>=nbVecs); 41 | 42 | for(Index i = 0; i < nbVecs; i++) 43 | { 44 | Index rs = vectors.rows() - i; 45 | Scalar Vii = vectors(i,i); 46 | vectors.const_cast_derived().coeffRef(i,i) = Scalar(1); 47 | triFactor.col(i).head(i).noalias() = -hCoeffs(i) * vectors.block(i, 0, rs, i).adjoint() 48 | * vectors.col(i).tail(rs); 49 | vectors.const_cast_derived().coeffRef(i, i) = Vii; 50 | // FIXME add .noalias() once the triangular product can work inplace 51 | triFactor.col(i).head(i) = triFactor.block(0,0,i,i).template triangularView() 52 | * triFactor.col(i).head(i); 53 | triFactor(i,i) = hCoeffs(i); 54 | } 55 | } 56 | 57 | /** \internal */ 58 | template 59 | void apply_block_householder_on_the_left(MatrixType& mat, const VectorsType& vectors, const CoeffsType& hCoeffs) 60 | { 61 | typedef typename MatrixType::Index Index; 62 | enum { TFactorSize = MatrixType::ColsAtCompileTime }; 63 | Index nbVecs = vectors.cols(); 64 | Matrix T(nbVecs,nbVecs); 65 | make_block_householder_triangular_factor(T, vectors, hCoeffs); 66 | 67 | const TriangularView& V(vectors); 68 | 69 | // A -= V T V^* A 70 | Matrix tmp = V.adjoint() * mat; 72 | // FIXME add .noalias() once the triangular product can work inplace 73 | tmp = T.template triangularView().adjoint() * tmp; 74 | mat.noalias() -= V * tmp; 75 | } 76 | 77 | } // end namespace internal 78 | 79 | #endif // EIGEN_BLOCK_HOUSEHOLDER_H 80 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Sparse/SparseDot.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // 6 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_SPARSE_DOT_H 26 | #define EIGEN_SPARSE_DOT_H 27 | 28 | template 29 | template 30 | typename internal::traits::Scalar 31 | SparseMatrixBase::dot(const MatrixBase& other) const 32 | { 33 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 34 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived) 35 | EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived) 36 | EIGEN_STATIC_ASSERT((internal::is_same::value), 37 | YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) 38 | 39 | eigen_assert(size() == other.size()); 40 | eigen_assert(other.size()>0 && "you are using a non initialized vector"); 41 | 42 | typename Derived::InnerIterator i(derived(),0); 43 | Scalar res = 0; 44 | while (i) 45 | { 46 | res += internal::conj(i.value()) * other.coeff(i.index()); 47 | ++i; 48 | } 49 | return res; 50 | } 51 | 52 | template 53 | template 54 | typename internal::traits::Scalar 55 | SparseMatrixBase::dot(const SparseMatrixBase& other) const 56 | { 57 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 58 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived) 59 | EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived) 60 | EIGEN_STATIC_ASSERT((internal::is_same::value), 61 | YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) 62 | 63 | eigen_assert(size() == other.size()); 64 | 65 | typename Derived::InnerIterator i(derived(),0); 66 | typename OtherDerived::InnerIterator j(other.derived(),0); 67 | Scalar res = 0; 68 | while (i && j) 69 | { 70 | if (i.index()==j.index()) 71 | { 72 | res += internal::conj(i.value()) * j.value(); 73 | ++i; ++j; 74 | } 75 | else if (i.index() 84 | inline typename NumTraits::Scalar>::Real 85 | SparseMatrixBase::squaredNorm() const 86 | { 87 | return internal::real((*this).cwiseAbs2().sum()); 88 | } 89 | 90 | template 91 | inline typename NumTraits::Scalar>::Real 92 | SparseMatrixBase::norm() const 93 | { 94 | return internal::sqrt(squaredNorm()); 95 | } 96 | 97 | #endif // EIGEN_SPARSE_DOT_H 98 | -------------------------------------------------------------------------------- /asift/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011, Guoshen Yu and Jean-Michel Morel 2 | All rights reserved. 3 | 4 | The source code files in this directory implement as tightly as 5 | possible algorithms described in this IPOL article. They are made 6 | available to the exclusive aim of serving as scientific tools enabling 7 | the verification of the soundness and completeness of the algorithmic 8 | descriptions. 9 | 10 | These source codes implement an algorithm possibly linked to the patent 11 | [1][2]. Compiling or running this code may violate patents in certain 12 | countries. For this reason, the use of the source files 13 | - demo_ASIFT.cpp 14 | - compute_asift_keypoints.cpp 15 | - compute_asift_matches.cpp 16 | - demo_lib_sift.cpp 17 | may be restricted in certain countries to non profit research and non profit 18 | educational purposes. In certain countries, redistribution or commercial 19 | use of these source files may require the consent of the patent owner. 20 | 21 | [1] Jean-Michel Morel and Guoshen Yu, Method and device for the invariant 22 | affine recognition recognition of shapes (WO/2009/150361), patent pending. 23 | 24 | [2] David Lowe "Method and apparatus for identifying scale invariant 25 | features in an image and use of same for locating an object in an 26 | image", U.S. Patent 6,711,293. 27 | 28 | In short, be careful before you download, compile, use, modify, or 29 | redistribute these source codes. The situation being different for every 30 | country and changing over time, it is your responsibility to check that 31 | you are not infringing a patent by using this source code. IPOL therefore 32 | invites potential users to consult a patent lawyer. If and only if you are 33 | free from any patent restriction, then you can enjoy the BSD license terms. 34 | 35 | The source code in the subdirectory third_party comes from the Eigen 36 | library, which is LGPL-licensed. 37 | (see http://www.gnu.org/copyleft/lesser.html) 38 | 39 | fproj.cpp, frot.cpp, orsa.cpp, libMatch, libNumerics 40 | copyright (C) 2007-2010, Lionel Moisan , 41 | Universite Paris Descartes, distributed under the BSD license. 42 | 43 | With the exception of the files mentioned above, redistribution and use 44 | in source and binary forms, with or without modification, are permitted 45 | provided that the following conditions are met: the rest of usual BSD 46 | license follows. 47 | 48 | BSD LICENSE 49 | 50 | Redistribution and use in source and binary forms, with or without 51 | modification, are permitted provided that the following conditions are 52 | * Redistributions of source code must retain the above copyright 53 | notice, this list of conditions and the following disclaimer. 54 | * Redistributions in binary form must reproduce the above 55 | copyright notice, this list of conditions and the following 56 | disclaimer in the documentation and/or other materials provided 57 | with the distribution. 58 | 59 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 60 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 61 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 62 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 63 | HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 64 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 65 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 66 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 67 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 68 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 69 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 70 | 71 | This license file must be retained with all copies of the software, 72 | including any modified or derivative versions. 73 | -------------------------------------------------------------------------------- /third_party/Eigen/src/misc/Kernel.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Benoit Jacob 5 | // 6 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_MISC_KERNEL_H 26 | #define EIGEN_MISC_KERNEL_H 27 | 28 | namespace internal { 29 | 30 | /** \class kernel_retval_base 31 | * 32 | */ 33 | template 34 | struct traits > 35 | { 36 | typedef typename DecompositionType::MatrixType MatrixType; 37 | typedef Matrix< 38 | typename MatrixType::Scalar, 39 | MatrixType::ColsAtCompileTime, // the number of rows in the "kernel matrix" 40 | // is the number of cols of the original matrix 41 | // so that the product "matrix * kernel = zero" makes sense 42 | Dynamic, // we don't know at compile-time the dimension of the kernel 43 | MatrixType::Options, 44 | MatrixType::MaxColsAtCompileTime, // see explanation for 2nd template parameter 45 | MatrixType::MaxColsAtCompileTime // the kernel is a subspace of the domain space, 46 | // whose dimension is the number of columns of the original matrix 47 | > ReturnType; 48 | }; 49 | 50 | template struct kernel_retval_base 51 | : public ReturnByValue > 52 | { 53 | typedef _DecompositionType DecompositionType; 54 | typedef ReturnByValue Base; 55 | typedef typename Base::Index Index; 56 | 57 | kernel_retval_base(const DecompositionType& dec) 58 | : m_dec(dec), 59 | m_rank(dec.rank()), 60 | m_cols(m_rank==dec.cols() ? 1 : dec.cols() - m_rank) 61 | {} 62 | 63 | inline Index rows() const { return m_dec.cols(); } 64 | inline Index cols() const { return m_cols; } 65 | inline Index rank() const { return m_rank; } 66 | inline const DecompositionType& dec() const { return m_dec; } 67 | 68 | template inline void evalTo(Dest& dst) const 69 | { 70 | static_cast*>(this)->evalTo(dst); 71 | } 72 | 73 | protected: 74 | const DecompositionType& m_dec; 75 | Index m_rank, m_cols; 76 | }; 77 | 78 | } // end namespace internal 79 | 80 | #define EIGEN_MAKE_KERNEL_HELPERS(DecompositionType) \ 81 | typedef typename DecompositionType::MatrixType MatrixType; \ 82 | typedef typename MatrixType::Scalar Scalar; \ 83 | typedef typename MatrixType::RealScalar RealScalar; \ 84 | typedef typename MatrixType::Index Index; \ 85 | typedef Eigen::internal::kernel_retval_base Base; \ 86 | using Base::dec; \ 87 | using Base::rank; \ 88 | using Base::rows; \ 89 | using Base::cols; \ 90 | kernel_retval(const DecompositionType& dec) : Base(dec) {} 91 | 92 | #endif // EIGEN_MISC_KERNEL_H 93 | -------------------------------------------------------------------------------- /surf/descriptor.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file descripteur.h 3 | * \brief Header for SURF descriptors 4 | * 5 | * All functions required are there. 6 | * 7 | */ 8 | #include "descriptor.h" 9 | 10 | 11 | vectorDescriptor::vectorDescriptor(float a,float b,float c, float d) 12 | { 13 | this->sumDx=a; 14 | this->sumDy=b; 15 | this->sumAbsDx=c; 16 | this->sumAbsDx=d; 17 | } 18 | vectorDescriptor::~vectorDescriptor() 19 | { 20 | } 21 | vectorDescriptor::vectorDescriptor() 22 | {} 23 | descriptor::descriptor() 24 | { 25 | this->list=new vectorDescriptor[16]; 26 | } 27 | 28 | descriptor::descriptor(descriptor* a) 29 | { 30 | this->list=new vectorDescriptor[16]; 31 | for(int i=0;i<16;i++) 32 | this->list[i]=a->list[i]; 33 | this->kP=new keyPoint(a->kP); 34 | } 35 | 36 | 37 | descriptor::~descriptor() 38 | { 39 | 40 | 41 | delete kP; 42 | delete[] list; 43 | } 44 | descriptor::descriptor(const descriptor & des) 45 | { 46 | this->list=new vectorDescriptor[16]; 47 | this->kP=new keyPoint(); 48 | for(int i=0;i<16;i++) 49 | (this->list)[i]=(des.list)[i]; 50 | this->kP=(des.kP); 51 | } 52 | 53 | 54 | /// Create a list of descriptor 55 | /** Everything is stocked in a vector 56 | * \param *imgInt : l'image intégrale 57 | * \param *lPC : la liste de points clefs à passer en adresse 58 | */ 59 | listDescriptor* getDescriptor(imageIntegral* imgInt,listKeyPoints* lPC) 60 | { 61 | listDescriptor* lD=new listDescriptor(); 62 | for(int i=0;isize();i++) 63 | lD->push_back(makeDescriptor(imgInt, (*lPC)[i])); 64 | delete imgInt; 65 | return lD; 66 | } 67 | 68 | 69 | 70 | 71 | 72 | /// Compute the descriptor in 20*scale domain 73 | /** Use kP given 74 | */ 75 | descriptor* makeDescriptor(imageIntegral* imgInt,keyPoint* pC) 76 | { 77 | float scale=pC->scale; 78 | descriptor* desc=new descriptor(); 79 | // Let's divide in a 4x4 zone the space around the interest point 80 | float cosA=cosf(pC->orientation); 81 | float sinA=sinf(pC->orientation); 82 | float norm=0; 83 | float u,v; 84 | float gauss,responseU,responseV,responseX,responseY; 85 | //We divide in 16 sectors 86 | for(int i=0;i<4;i++) 87 | { 88 | for(int j=0;j<4;j++) 89 | { 90 | (desc->list[4*i+j]).sumDx=0; 91 | (desc->list[4*i+j]).sumAbsDx=0; 92 | (desc->list[4*i+j]).sumDy=0; 93 | (desc->list[4*i+j]).sumAbsDy=0; 94 | // Then each 4x4 becomes a 5x5 zone 95 | for(int k=0;k<5;k++) 96 | { 97 | for(int l=0;l<5;l++) 98 | { 99 | u=(pC->x+scale*(cosA*((i-2)*5+k+0.5)-sinA*((j-2)*5+l+0.5)));//-0.5 is here to center pixel 100 | v=(pC->y+scale*(sinA*((i-2)*5+k+0.5)+cosA*((j-2)*5+l+0.5))); 101 | responseX=haarX(imgInt,u,v,fround(scale) ); 102 | responseY=haarY(imgInt,u,v,fround(scale)); 103 | 104 | //We use a gaussian to weight 105 | gauss=gaussian(((i-2)*5+k+0.5),((j-2)*5+l+0.5),3.3f); 106 | responseU = gauss*( -responseX*sinA + responseY*cosA); 107 | responseV = gauss*(responseX*cosA + responseY*sinA); 108 | (desc->list[4*i+j]).sumDx+=responseU; 109 | (desc->list[4*i+j]).sumAbsDx+=absval(responseU); 110 | (desc->list[4*i+j]).sumDy+=responseV; 111 | (desc->list[4*i+j]).sumAbsDy+=absval(responseV); 112 | 113 | } 114 | } 115 | //We compute the norm of the vector 116 | norm+=(desc->list[4*i+j]).sumAbsDx*(desc->list[4*i+j]).sumAbsDx+(desc->list[4*i+j]).sumAbsDy*(desc->list[4*i+j]).sumAbsDy+((desc->list[4*i+j]).sumDx*(desc->list[4*i+j]).sumDx+(desc->list[4*i+j]).sumDy*(desc->list[4*i+j]).sumDy); 117 | 118 | } 119 | } 120 | //Then we normalized it. 121 | norm=sqrtf(norm); 122 | if(norm!=0) 123 | for(int i=0;i<16;i++) 124 | { 125 | (desc->list[i]).sumDx/=norm; 126 | (desc->list[i]).sumAbsDx/=norm; 127 | (desc->list[i]).sumDy/=norm; 128 | (desc->list[i]).sumAbsDy/=norm; 129 | } 130 | desc->kP=new keyPoint(pC); 131 | return desc; 132 | } 133 | 134 | 135 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Eigen2Support/VectorBlock.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2009 Gael Guennebaud 5 | // Copyright (C) 2006-2008 Benoit Jacob 6 | // 7 | // Eigen is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU Lesser General Public 9 | // License as published by the Free Software Foundation; either 10 | // version 3 of the License, or (at your option) any later version. 11 | // 12 | // Alternatively, you can redistribute it and/or 13 | // modify it under the terms of the GNU General Public License as 14 | // published by the Free Software Foundation; either version 2 of 15 | // the License, or (at your option) any later version. 16 | // 17 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 18 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public 23 | // License and a copy of the GNU General Public License along with 24 | // Eigen. If not, see . 25 | 26 | #ifndef EIGEN2_VECTORBLOCK_H 27 | #define EIGEN2_VECTORBLOCK_H 28 | 29 | /** \deprecated use DenseMase::head(Index) */ 30 | template 31 | inline VectorBlock 32 | MatrixBase::start(Index size) 33 | { 34 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 35 | return VectorBlock(derived(), 0, size); 36 | } 37 | 38 | /** \deprecated use DenseMase::head(Index) */ 39 | template 40 | inline const VectorBlock 41 | MatrixBase::start(Index size) const 42 | { 43 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 44 | return VectorBlock(derived(), 0, size); 45 | } 46 | 47 | /** \deprecated use DenseMase::tail(Index) */ 48 | template 49 | inline VectorBlock 50 | MatrixBase::end(Index size) 51 | { 52 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 53 | return VectorBlock(derived(), this->size() - size, size); 54 | } 55 | 56 | /** \deprecated use DenseMase::tail(Index) */ 57 | template 58 | inline const VectorBlock 59 | MatrixBase::end(Index size) const 60 | { 61 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 62 | return VectorBlock(derived(), this->size() - size, size); 63 | } 64 | 65 | /** \deprecated use DenseMase::head() */ 66 | template 67 | template 68 | inline VectorBlock 69 | MatrixBase::start() 70 | { 71 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 72 | return VectorBlock(derived(), 0); 73 | } 74 | 75 | /** \deprecated use DenseMase::head() */ 76 | template 77 | template 78 | inline const VectorBlock 79 | MatrixBase::start() const 80 | { 81 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 82 | return VectorBlock(derived(), 0); 83 | } 84 | 85 | /** \deprecated use DenseMase::tail() */ 86 | template 87 | template 88 | inline VectorBlock 89 | MatrixBase::end() 90 | { 91 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 92 | return VectorBlock(derived(), size() - Size); 93 | } 94 | 95 | /** \deprecated use DenseMase::tail() */ 96 | template 97 | template 98 | inline const VectorBlock 99 | MatrixBase::end() const 100 | { 101 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 102 | return VectorBlock(derived(), size() - Size); 103 | } 104 | 105 | #endif // EIGEN2_VECTORBLOCK_H 106 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Sparse/SparseView.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2010 Gael Guennebaud 5 | // Copyright (C) 2010 Daniel Lowengrub 6 | // 7 | // Eigen is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU Lesser General Public 9 | // License as published by the Free Software Foundation; either 10 | // version 3 of the License, or (at your option) any later version. 11 | // 12 | // Alternatively, you can redistribute it and/or 13 | // modify it under the terms of the GNU General Public License as 14 | // published by the Free Software Foundation; either version 2 of 15 | // the License, or (at your option) any later version. 16 | // 17 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 18 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public 23 | // License and a copy of the GNU General Public License along with 24 | // Eigen. If not, see . 25 | 26 | #ifndef EIGEN_SPARSEVIEW_H 27 | #define EIGEN_SPARSEVIEW_H 28 | 29 | namespace internal { 30 | 31 | template 32 | struct traits > : traits 33 | { 34 | typedef int Index; 35 | typedef Sparse StorageKind; 36 | enum { 37 | Flags = int(traits::Flags) & (RowMajorBit) 38 | }; 39 | }; 40 | 41 | } // end namespace internal 42 | 43 | template 44 | class SparseView : public SparseMatrixBase > 45 | { 46 | typedef typename MatrixType::Nested MatrixTypeNested; 47 | typedef typename internal::remove_all::type _MatrixTypeNested; 48 | public: 49 | EIGEN_SPARSE_PUBLIC_INTERFACE(SparseView) 50 | 51 | SparseView(const MatrixType& mat, const Scalar& m_reference = Scalar(0), 52 | typename NumTraits::Real m_epsilon = NumTraits::dummy_precision()) : 53 | m_matrix(mat), m_reference(m_reference), m_epsilon(m_epsilon) {} 54 | 55 | class InnerIterator; 56 | 57 | inline Index rows() const { return m_matrix.rows(); } 58 | inline Index cols() const { return m_matrix.cols(); } 59 | 60 | inline Index innerSize() const { return m_matrix.innerSize(); } 61 | inline Index outerSize() const { return m_matrix.outerSize(); } 62 | 63 | protected: 64 | const MatrixTypeNested m_matrix; 65 | Scalar m_reference; 66 | typename NumTraits::Real m_epsilon; 67 | }; 68 | 69 | template 70 | class SparseView::InnerIterator : public _MatrixTypeNested::InnerIterator 71 | { 72 | public: 73 | typedef typename _MatrixTypeNested::InnerIterator IterBase; 74 | InnerIterator(const SparseView& view, Index outer) : 75 | IterBase(view.m_matrix, outer), m_view(view) 76 | { 77 | incrementToNonZero(); 78 | } 79 | 80 | EIGEN_STRONG_INLINE InnerIterator& operator++() 81 | { 82 | IterBase::operator++(); 83 | incrementToNonZero(); 84 | return *this; 85 | } 86 | 87 | using IterBase::value; 88 | 89 | protected: 90 | const SparseView& m_view; 91 | 92 | private: 93 | void incrementToNonZero() 94 | { 95 | while(internal::isMuchSmallerThan(value(), m_view.m_reference, m_view.m_epsilon) && (bool(*this))) 96 | { 97 | IterBase::operator++(); 98 | } 99 | } 100 | }; 101 | 102 | template 103 | const SparseView MatrixBase::sparseView(const Scalar& m_reference, 104 | typename NumTraits::Real m_epsilon) const 105 | { 106 | return SparseView(derived(), m_reference, m_epsilon); 107 | } 108 | 109 | #endif 110 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Eigen2Support/Meta.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2011 Benoit Jacob 5 | // 6 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN2_META_H 26 | #define EIGEN2_META_H 27 | 28 | template 29 | struct ei_traits : internal::traits 30 | {}; 31 | 32 | struct ei_meta_true { enum { ret = 1 }; }; 33 | struct ei_meta_false { enum { ret = 0 }; }; 34 | 35 | template 36 | struct ei_meta_if { typedef Then ret; }; 37 | 38 | template 39 | struct ei_meta_if { typedef Else ret; }; 40 | 41 | template struct ei_is_same_type { enum { ret = 0 }; }; 42 | template struct ei_is_same_type { enum { ret = 1 }; }; 43 | 44 | template struct ei_unref { typedef T type; }; 45 | template struct ei_unref { typedef T type; }; 46 | 47 | template struct ei_unpointer { typedef T type; }; 48 | template struct ei_unpointer { typedef T type; }; 49 | template struct ei_unpointer { typedef T type; }; 50 | 51 | template struct ei_unconst { typedef T type; }; 52 | template struct ei_unconst { typedef T type; }; 53 | template struct ei_unconst { typedef T & type; }; 54 | template struct ei_unconst { typedef T * type; }; 55 | 56 | template struct ei_cleantype { typedef T type; }; 57 | template struct ei_cleantype { typedef typename ei_cleantype::type type; }; 58 | template struct ei_cleantype { typedef typename ei_cleantype::type type; }; 59 | template struct ei_cleantype { typedef typename ei_cleantype::type type; }; 60 | template struct ei_cleantype { typedef typename ei_cleantype::type type; }; 61 | template struct ei_cleantype { typedef typename ei_cleantype::type type; }; 62 | 63 | /** \internal In short, it computes int(sqrt(\a Y)) with \a Y an integer. 64 | * Usage example: \code ei_meta_sqrt<1023>::ret \endcode 65 | */ 66 | template Y))) > 70 | // use ?: instead of || just to shut up a stupid gcc 4.3 warning 71 | class ei_meta_sqrt 72 | { 73 | enum { 74 | MidX = (InfX+SupX)/2, 75 | TakeInf = MidX*MidX > Y ? 1 : 0, 76 | NewInf = int(TakeInf) ? InfX : int(MidX), 77 | NewSup = int(TakeInf) ? int(MidX) : SupX 78 | }; 79 | public: 80 | enum { ret = ei_meta_sqrt::ret }; 81 | }; 82 | 83 | template 84 | class ei_meta_sqrt { public: enum { ret = (SupX*SupX <= Y) ? SupX : InfX }; }; 85 | 86 | #endif // EIGEN2_META_H 87 | -------------------------------------------------------------------------------- /third_party/Eigen/src/StlSupport/details.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // Eigen is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU Lesser General Public 9 | // License as published by the Free Software Foundation; either 10 | // version 3 of the License, or (at your option) any later version. 11 | // 12 | // Alternatively, you can redistribute it and/or 13 | // modify it under the terms of the GNU General Public License as 14 | // published by the Free Software Foundation; either version 2 of 15 | // the License, or (at your option) any later version. 16 | // 17 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 18 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public 23 | // License and a copy of the GNU General Public License along with 24 | // Eigen. If not, see . 25 | 26 | #ifndef EIGEN_STL_DETAILS_H 27 | #define EIGEN_STL_DETAILS_H 28 | 29 | #ifndef EIGEN_ALIGNED_ALLOCATOR 30 | #define EIGEN_ALIGNED_ALLOCATOR Eigen::aligned_allocator 31 | #endif 32 | 33 | namespace Eigen { 34 | 35 | // This one is needed to prevent reimplementing the whole std::vector. 36 | template 37 | class aligned_allocator_indirection : public EIGEN_ALIGNED_ALLOCATOR 38 | { 39 | public: 40 | typedef size_t size_type; 41 | typedef ptrdiff_t difference_type; 42 | typedef T* pointer; 43 | typedef const T* const_pointer; 44 | typedef T& reference; 45 | typedef const T& const_reference; 46 | typedef T value_type; 47 | 48 | template 49 | struct rebind 50 | { 51 | typedef aligned_allocator_indirection other; 52 | }; 53 | 54 | aligned_allocator_indirection() {} 55 | aligned_allocator_indirection(const aligned_allocator_indirection& ) : EIGEN_ALIGNED_ALLOCATOR() {} 56 | aligned_allocator_indirection(const EIGEN_ALIGNED_ALLOCATOR& ) {} 57 | template 58 | aligned_allocator_indirection(const aligned_allocator_indirection& ) {} 59 | template 60 | aligned_allocator_indirection(const EIGEN_ALIGNED_ALLOCATOR& ) {} 61 | ~aligned_allocator_indirection() {} 62 | }; 63 | 64 | #ifdef _MSC_VER 65 | 66 | // sometimes, MSVC detects, at compile time, that the argument x 67 | // in std::vector::resize(size_t s,T x) won't be aligned and generate an error 68 | // even if this function is never called. Whence this little wrapper. 69 | #define EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T) \ 70 | typename Eigen::internal::conditional< \ 71 | Eigen::internal::is_arithmetic::value, \ 72 | T, \ 73 | Eigen::internal::workaround_msvc_stl_support \ 74 | >::type 75 | 76 | namespace internal { 77 | template struct workaround_msvc_stl_support : public T 78 | { 79 | inline workaround_msvc_stl_support() : T() {} 80 | inline workaround_msvc_stl_support(const T& other) : T(other) {} 81 | inline operator T& () { return *static_cast(this); } 82 | inline operator const T& () const { return *static_cast(this); } 83 | template 84 | inline T& operator=(const OtherT& other) 85 | { T::operator=(other); return *this; } 86 | inline workaround_msvc_stl_support& operator=(const workaround_msvc_stl_support& other) 87 | { T::operator=(other); return *this; } 88 | }; 89 | } 90 | 91 | #else 92 | 93 | #define EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T) T 94 | 95 | #endif 96 | 97 | } 98 | 99 | #endif // EIGEN_STL_DETAILS_H 100 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Sparse/SparseTriangularView.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // 6 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_SPARSE_TRIANGULARVIEW_H 26 | #define EIGEN_SPARSE_TRIANGULARVIEW_H 27 | 28 | namespace internal { 29 | 30 | template 31 | struct traits > 32 | : public traits 33 | {}; 34 | 35 | } // namespace internal 36 | 37 | template class SparseTriangularView 38 | : public SparseMatrixBase > 39 | { 40 | enum { SkipFirst = (Mode==Lower && !(MatrixType::Flags&RowMajorBit)) 41 | || (Mode==Upper && (MatrixType::Flags&RowMajorBit)) }; 42 | public: 43 | 44 | EIGEN_SPARSE_PUBLIC_INTERFACE(SparseTriangularView) 45 | 46 | class InnerIterator; 47 | 48 | inline Index rows() const { return m_matrix.rows(); } 49 | inline Index cols() const { return m_matrix.cols(); } 50 | 51 | typedef typename internal::conditional::ret, 52 | MatrixType, const MatrixType&>::type MatrixTypeNested; 53 | 54 | inline SparseTriangularView(const MatrixType& matrix) : m_matrix(matrix) {} 55 | 56 | /** \internal */ 57 | inline const MatrixType& nestedExpression() const { return m_matrix; } 58 | 59 | template 60 | typename internal::plain_matrix_type_column_major::type 61 | solve(const MatrixBase& other) const; 62 | 63 | template void solveInPlace(MatrixBase& other) const; 64 | template void solveInPlace(SparseMatrixBase& other) const; 65 | 66 | protected: 67 | MatrixTypeNested m_matrix; 68 | }; 69 | 70 | template 71 | class SparseTriangularView::InnerIterator : public MatrixType::InnerIterator 72 | { 73 | typedef typename MatrixType::InnerIterator Base; 74 | public: 75 | 76 | EIGEN_STRONG_INLINE InnerIterator(const SparseTriangularView& view, Index outer) 77 | : Base(view.nestedExpression(), outer) 78 | { 79 | if(SkipFirst) 80 | while((*this) && this->index()index() <= this->outer()); 89 | } 90 | }; 91 | 92 | template 93 | template 94 | inline const SparseTriangularView 95 | SparseMatrixBase::triangularView() const 96 | { 97 | return derived(); 98 | } 99 | 100 | #endif // EIGEN_SPARSE_TRIANGULARVIEW_H 101 | -------------------------------------------------------------------------------- /third_party/Eigen/src/misc/Image.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Benoit Jacob 5 | // 6 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_MISC_IMAGE_H 26 | #define EIGEN_MISC_IMAGE_H 27 | 28 | namespace internal { 29 | 30 | /** \class image_retval_base 31 | * 32 | */ 33 | template 34 | struct traits > 35 | { 36 | typedef typename DecompositionType::MatrixType MatrixType; 37 | typedef Matrix< 38 | typename MatrixType::Scalar, 39 | MatrixType::RowsAtCompileTime, // the image is a subspace of the destination space, whose 40 | // dimension is the number of rows of the original matrix 41 | Dynamic, // we don't know at compile time the dimension of the image (the rank) 42 | MatrixType::Options, 43 | MatrixType::MaxRowsAtCompileTime, // the image matrix will consist of columns from the original matrix, 44 | MatrixType::MaxColsAtCompileTime // so it has the same number of rows and at most as many columns. 45 | > ReturnType; 46 | }; 47 | 48 | template struct image_retval_base 49 | : public ReturnByValue > 50 | { 51 | typedef _DecompositionType DecompositionType; 52 | typedef typename DecompositionType::MatrixType MatrixType; 53 | typedef ReturnByValue Base; 54 | typedef typename Base::Index Index; 55 | 56 | image_retval_base(const DecompositionType& dec, const MatrixType& originalMatrix) 57 | : m_dec(dec), m_rank(dec.rank()), 58 | m_cols(m_rank == 0 ? 1 : m_rank), 59 | m_originalMatrix(originalMatrix) 60 | {} 61 | 62 | inline Index rows() const { return m_dec.rows(); } 63 | inline Index cols() const { return m_cols; } 64 | inline Index rank() const { return m_rank; } 65 | inline const DecompositionType& dec() const { return m_dec; } 66 | inline const MatrixType& originalMatrix() const { return m_originalMatrix; } 67 | 68 | template inline void evalTo(Dest& dst) const 69 | { 70 | static_cast*>(this)->evalTo(dst); 71 | } 72 | 73 | protected: 74 | const DecompositionType& m_dec; 75 | Index m_rank, m_cols; 76 | const MatrixType& m_originalMatrix; 77 | }; 78 | 79 | } // end namespace internal 80 | 81 | #define EIGEN_MAKE_IMAGE_HELPERS(DecompositionType) \ 82 | typedef typename DecompositionType::MatrixType MatrixType; \ 83 | typedef typename MatrixType::Scalar Scalar; \ 84 | typedef typename MatrixType::RealScalar RealScalar; \ 85 | typedef typename MatrixType::Index Index; \ 86 | typedef Eigen::internal::image_retval_base Base; \ 87 | using Base::dec; \ 88 | using Base::originalMatrix; \ 89 | using Base::rank; \ 90 | using Base::rows; \ 91 | using Base::cols; \ 92 | image_retval(const DecompositionType& dec, const MatrixType& originalMatrix) \ 93 | : Base(dec, originalMatrix) {} 94 | 95 | #endif // EIGEN_MISC_IMAGE_H 96 | -------------------------------------------------------------------------------- /sift/domain.cpp: -------------------------------------------------------------------------------- 1 | // Authors: Unknown. Please, if you are the author of this file, or if you 2 | // know who are the authors of this file, let us know, so we can give the 3 | // adequate credits and/or get the adequate authorizations. 4 | 5 | #include "domain.h" 6 | 7 | 8 | #define DEBUG 0 9 | 10 | 11 | 12 | 13 | void apply_zoom(float *input, float *out, float zoom, int order, int width, int height) 14 | { 15 | 16 | int nwidth = (int)( zoom * (float) width); 17 | int nheight = (int)( zoom * (float) height); 18 | 19 | float *coeffs; 20 | float *ref; 21 | 22 | float cx[12],cy[12],ak[13]; 23 | 24 | // Guoshen Yu, 2010.09.22, Windows versions 25 | vector input_vec, coeffs_vec, ref_vec; 26 | input_vec = vector(width*height); 27 | coeffs_vec = vector(width*height); 28 | ref_vec = vector(width*height); 29 | for (int i = 0; i < width*height; i++) 30 | input_vec[i] = input[i]; 31 | 32 | if (order!=0 && order!=1 && order!=-3 && 33 | order!=3 && order!=5 && order!=7 && order!=9 && order!=11) 34 | { 35 | printf("unrecognized interpolation order.\n"); 36 | exit(-1); 37 | } 38 | 39 | if (order>=3) { 40 | 41 | coeffs = new float[width*height]; 42 | 43 | // Guoshen Yu, 2010.09.21, Windows version 44 | //finvspline(input,order,coeffs,width,height); 45 | finvspline(input_vec,order,coeffs_vec,width,height); 46 | for (int i = 0; i < width*height; i++) 47 | coeffs[i] = coeffs_vec[i]; 48 | 49 | ref = coeffs; 50 | if (order>3) init_splinen(ak,order); 51 | 52 | } else 53 | { 54 | coeffs = NULL; 55 | ref = input; 56 | } 57 | 58 | int xi,yi; 59 | float xp,yp; 60 | float res; 61 | int n1,n2; 62 | float bg = 0.0f; 63 | float p=-0.5; 64 | for(int i=0; i < nwidth; i++) 65 | for(int j=0; j < nheight; j++) 66 | { 67 | 68 | xp = (float) i / zoom; 69 | yp = (float) j / zoom; 70 | 71 | if (order == 0) { 72 | 73 | xi = (int)floor((double)xp); 74 | yi = (int)floor((double)yp); 75 | 76 | if (xi<0 || xi>=width || yi<0 || yi>=height) 77 | res = bg; 78 | else res = input[yi*width+xi]; 79 | 80 | } else { 81 | 82 | 83 | if (xp<0. || xp>=(float)width || yp<0. || yp>=(float)height) res=bg; 84 | else { 85 | xp -= 0.5; yp -= 0.5; 86 | int xi = (int)floor((double)xp); 87 | int yi = (int)floor((double)yp); 88 | float ux = xp-(float)xi; 89 | float uy = yp-(float)yi; 90 | 91 | switch (order) 92 | { 93 | case 1: /* first order interpolation (bilinear) */ 94 | n2 = 1; 95 | cx[0]=ux; cx[1]=1.-ux; 96 | cy[0]=uy; cy[1]=1.-uy; 97 | break; 98 | 99 | case -3: /* third order interpolation (bicubic Keys' function) */ 100 | n2 = 2; 101 | keys(cx,ux,p); 102 | keys(cy,uy,p); 103 | break; 104 | 105 | case 3: /* spline of order 3 */ 106 | n2 = 2; 107 | spline3(cx,ux); 108 | spline3(cy,uy); 109 | break; 110 | 111 | default: /* spline of order >3 */ 112 | n2 = (1+order)/2; 113 | splinen(cx,ux,ak,order); 114 | splinen(cy,uy,ak,order); 115 | break; 116 | } 117 | 118 | res = 0.; n1 = 1-n2; 119 | if (xi+n1>=0 && xi+n2=0 && yi+n2 5 | // Copyright (C) 2010 Benoit Jacob 6 | // 7 | // Eigen is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU Lesser General Public 9 | // License as published by the Free Software Foundation; either 10 | // version 3 of the License, or (at your option) any later version. 11 | // 12 | // Alternatively, you can redistribute it and/or 13 | // modify it under the terms of the GNU General Public License as 14 | // published by the Free Software Foundation; either version 2 of 15 | // the License, or (at your option) any later version. 16 | // 17 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 18 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public 23 | // License and a copy of the GNU General Public License along with 24 | // Eigen. If not, see . 25 | 26 | #ifndef EIGEN_GLOBAL_FUNCTIONS_H 27 | #define EIGEN_GLOBAL_FUNCTIONS_H 28 | 29 | #define EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(NAME,FUNCTOR) \ 30 | template \ 31 | inline const Eigen::CwiseUnaryOp, const Derived> \ 32 | NAME(const Eigen::ArrayBase& x) { \ 33 | return x.derived(); \ 34 | } 35 | 36 | #define EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(NAME,FUNCTOR) \ 37 | \ 38 | template \ 39 | struct NAME##_retval > \ 40 | { \ 41 | typedef const Eigen::CwiseUnaryOp, const Derived> type; \ 42 | }; \ 43 | template \ 44 | struct NAME##_impl > \ 45 | { \ 46 | static inline typename NAME##_retval >::type run(const Eigen::ArrayBase& x) \ 47 | { \ 48 | return x.derived(); \ 49 | } \ 50 | }; 51 | 52 | 53 | namespace std 54 | { 55 | EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(real,scalar_real_op) 56 | EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(imag,scalar_imag_op) 57 | EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(sin,scalar_sin_op) 58 | EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(cos,scalar_cos_op) 59 | EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(asin,scalar_asin_op) 60 | EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(acos,scalar_acos_op) 61 | EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(tan,scalar_tan_op) 62 | EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(exp,scalar_exp_op) 63 | EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(log,scalar_log_op) 64 | EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(abs,scalar_abs_op) 65 | EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(sqrt,scalar_sqrt_op) 66 | 67 | template 68 | inline const Eigen::CwiseUnaryOp, const Derived> 69 | pow(const Eigen::ArrayBase& x, const typename Derived::Scalar& exponent) { \ 70 | return x.derived().pow(exponent); \ 71 | } 72 | } 73 | 74 | namespace Eigen 75 | { 76 | namespace internal 77 | { 78 | EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(real,scalar_real_op) 79 | EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(imag,scalar_imag_op) 80 | EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(sin,scalar_sin_op) 81 | EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(cos,scalar_cos_op) 82 | EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(asin,scalar_asin_op) 83 | EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(acos,scalar_acos_op) 84 | EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(tan,scalar_tan_op) 85 | EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(exp,scalar_exp_op) 86 | EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(log,scalar_log_op) 87 | EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(abs,scalar_abs_op) 88 | EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(abs2,scalar_abs2_op) 89 | EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(sqrt,scalar_sqrt_op) 90 | } 91 | } 92 | 93 | // TODO: cleanly disable those functions that are not supported on Array (internal::real_ref, internal::random, internal::isApprox...) 94 | 95 | #endif // EIGEN_GLOBAL_FUNCTIONS_H 96 | -------------------------------------------------------------------------------- /third_party/Eigen/src/LU/Determinant.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Benoit Jacob 5 | // 6 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_DETERMINANT_H 26 | #define EIGEN_DETERMINANT_H 27 | 28 | namespace internal { 29 | 30 | template 31 | inline const typename Derived::Scalar bruteforce_det3_helper 32 | (const MatrixBase& matrix, int a, int b, int c) 33 | { 34 | return matrix.coeff(0,a) 35 | * (matrix.coeff(1,b) * matrix.coeff(2,c) - matrix.coeff(1,c) * matrix.coeff(2,b)); 36 | } 37 | 38 | template 39 | const typename Derived::Scalar bruteforce_det4_helper 40 | (const MatrixBase& matrix, int j, int k, int m, int n) 41 | { 42 | return (matrix.coeff(j,0) * matrix.coeff(k,1) - matrix.coeff(k,0) * matrix.coeff(j,1)) 43 | * (matrix.coeff(m,2) * matrix.coeff(n,3) - matrix.coeff(n,2) * matrix.coeff(m,3)); 44 | } 45 | 46 | template struct determinant_impl 49 | { 50 | static inline typename traits::Scalar run(const Derived& m) 51 | { 52 | if(Derived::ColsAtCompileTime==Dynamic && m.rows()==0) 53 | return typename traits::Scalar(1); 54 | return m.partialPivLu().determinant(); 55 | } 56 | }; 57 | 58 | template struct determinant_impl 59 | { 60 | static inline typename traits::Scalar run(const Derived& m) 61 | { 62 | return m.coeff(0,0); 63 | } 64 | }; 65 | 66 | template struct determinant_impl 67 | { 68 | static inline typename traits::Scalar run(const Derived& m) 69 | { 70 | return m.coeff(0,0) * m.coeff(1,1) - m.coeff(1,0) * m.coeff(0,1); 71 | } 72 | }; 73 | 74 | template struct determinant_impl 75 | { 76 | static inline typename traits::Scalar run(const Derived& m) 77 | { 78 | return bruteforce_det3_helper(m,0,1,2) 79 | - bruteforce_det3_helper(m,1,0,2) 80 | + bruteforce_det3_helper(m,2,0,1); 81 | } 82 | }; 83 | 84 | template struct determinant_impl 85 | { 86 | static typename traits::Scalar run(const Derived& m) 87 | { 88 | // trick by Martin Costabel to compute 4x4 det with only 30 muls 89 | return bruteforce_det4_helper(m,0,1,2,3) 90 | - bruteforce_det4_helper(m,0,2,1,3) 91 | + bruteforce_det4_helper(m,0,3,1,2) 92 | + bruteforce_det4_helper(m,1,2,0,3) 93 | - bruteforce_det4_helper(m,1,3,0,2) 94 | + bruteforce_det4_helper(m,2,3,0,1); 95 | } 96 | }; 97 | 98 | } // end namespace internal 99 | 100 | /** \lu_module 101 | * 102 | * \returns the determinant of this matrix 103 | */ 104 | template 105 | inline typename internal::traits::Scalar MatrixBase::determinant() const 106 | { 107 | assert(rows() == cols()); 108 | typedef typename internal::nested::type Nested; 109 | return internal::determinant_impl::type>::run(derived()); 110 | } 111 | 112 | #endif // EIGEN_DETERMINANT_H 113 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Core/ReturnByValue.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009-2010 Gael Guennebaud 5 | // Copyright (C) 2009-2010 Benoit Jacob 6 | // 7 | // Eigen is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU Lesser General Public 9 | // License as published by the Free Software Foundation; either 10 | // version 3 of the License, or (at your option) any later version. 11 | // 12 | // Alternatively, you can redistribute it and/or 13 | // modify it under the terms of the GNU General Public License as 14 | // published by the Free Software Foundation; either version 2 of 15 | // the License, or (at your option) any later version. 16 | // 17 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 18 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public 23 | // License and a copy of the GNU General Public License along with 24 | // Eigen. If not, see . 25 | 26 | #ifndef EIGEN_RETURNBYVALUE_H 27 | #define EIGEN_RETURNBYVALUE_H 28 | 29 | /** \class ReturnByValue 30 | * \ingroup Core_Module 31 | * 32 | */ 33 | 34 | namespace internal { 35 | 36 | template 37 | struct traits > 38 | : public traits::ReturnType> 39 | { 40 | enum { 41 | // We're disabling the DirectAccess because e.g. the constructor of 42 | // the Block-with-DirectAccess expression requires to have a coeffRef method. 43 | // Also, we don't want to have to implement the stride stuff. 44 | Flags = (traits::ReturnType>::Flags 45 | | EvalBeforeNestingBit) & ~DirectAccessBit 46 | }; 47 | }; 48 | 49 | /* The ReturnByValue object doesn't even have a coeff() method. 50 | * So the only way that nesting it in an expression can work, is by evaluating it into a plain matrix. 51 | * So internal::nested always gives the plain return matrix type. 52 | * 53 | * FIXME: I don't understand why we need this specialization: isn't this taken care of by the EvalBeforeNestingBit ?? 54 | */ 55 | template 56 | struct nested, n, PlainObject> 57 | { 58 | typedef typename traits::ReturnType type; 59 | }; 60 | 61 | } // end namespace internal 62 | 63 | template class ReturnByValue 64 | : public internal::dense_xpr_base< ReturnByValue >::type 65 | { 66 | public: 67 | typedef typename internal::traits::ReturnType ReturnType; 68 | 69 | typedef typename internal::dense_xpr_base::type Base; 70 | EIGEN_DENSE_PUBLIC_INTERFACE(ReturnByValue) 71 | 72 | template 73 | inline void evalTo(Dest& dst) const 74 | { static_cast(this)->evalTo(dst); } 75 | inline Index rows() const { return static_cast(this)->rows(); } 76 | inline Index cols() const { return static_cast(this)->cols(); } 77 | 78 | #ifndef EIGEN_PARSED_BY_DOXYGEN 79 | #define Unusable YOU_ARE_TRYING_TO_ACCESS_A_SINGLE_COEFFICIENT_IN_A_SPECIAL_EXPRESSION_WHERE_THAT_IS_NOT_ALLOWED_BECAUSE_THAT_WOULD_BE_INEFFICIENT 80 | class Unusable{ 81 | Unusable(const Unusable&) {} 82 | Unusable& operator=(const Unusable&) {return *this;} 83 | }; 84 | const Unusable& coeff(Index) const { return *reinterpret_cast(this); } 85 | const Unusable& coeff(Index,Index) const { return *reinterpret_cast(this); } 86 | Unusable& coeffRef(Index) { return *reinterpret_cast(this); } 87 | Unusable& coeffRef(Index,Index) { return *reinterpret_cast(this); } 88 | #endif 89 | }; 90 | 91 | template 92 | template 93 | Derived& DenseBase::operator=(const ReturnByValue& other) 94 | { 95 | other.evalTo(derived()); 96 | return derived(); 97 | } 98 | 99 | #endif // EIGEN_RETURNBYVALUE_H 100 | -------------------------------------------------------------------------------- /third_party/Eigen/src/Core/NestByValue.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // Copyright (C) 2006-2008 Benoit Jacob 6 | // 7 | // Eigen is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU Lesser General Public 9 | // License as published by the Free Software Foundation; either 10 | // version 3 of the License, or (at your option) any later version. 11 | // 12 | // Alternatively, you can redistribute it and/or 13 | // modify it under the terms of the GNU General Public License as 14 | // published by the Free Software Foundation; either version 2 of 15 | // the License, or (at your option) any later version. 16 | // 17 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 18 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public 23 | // License and a copy of the GNU General Public License along with 24 | // Eigen. If not, see . 25 | 26 | #ifndef EIGEN_NESTBYVALUE_H 27 | #define EIGEN_NESTBYVALUE_H 28 | 29 | /** \class NestByValue 30 | * \ingroup Core_Module 31 | * 32 | * \brief Expression which must be nested by value 33 | * 34 | * \param ExpressionType the type of the object of which we are requiring nesting-by-value 35 | * 36 | * This class is the return type of MatrixBase::nestByValue() 37 | * and most of the time this is the only way it is used. 38 | * 39 | * \sa MatrixBase::nestByValue() 40 | */ 41 | 42 | namespace internal { 43 | template 44 | struct traits > : public traits 45 | {}; 46 | } 47 | 48 | template class NestByValue 49 | : public internal::dense_xpr_base< NestByValue >::type 50 | { 51 | public: 52 | 53 | typedef typename internal::dense_xpr_base::type Base; 54 | EIGEN_DENSE_PUBLIC_INTERFACE(NestByValue) 55 | 56 | inline NestByValue(const ExpressionType& matrix) : m_expression(matrix) {} 57 | 58 | inline Index rows() const { return m_expression.rows(); } 59 | inline Index cols() const { return m_expression.cols(); } 60 | inline Index outerStride() const { return m_expression.outerStride(); } 61 | inline Index innerStride() const { return m_expression.innerStride(); } 62 | 63 | inline const CoeffReturnType coeff(Index row, Index col) const 64 | { 65 | return m_expression.coeff(row, col); 66 | } 67 | 68 | inline Scalar& coeffRef(Index row, Index col) 69 | { 70 | return m_expression.const_cast_derived().coeffRef(row, col); 71 | } 72 | 73 | inline const CoeffReturnType coeff(Index index) const 74 | { 75 | return m_expression.coeff(index); 76 | } 77 | 78 | inline Scalar& coeffRef(Index index) 79 | { 80 | return m_expression.const_cast_derived().coeffRef(index); 81 | } 82 | 83 | template 84 | inline const PacketScalar packet(Index row, Index col) const 85 | { 86 | return m_expression.template packet(row, col); 87 | } 88 | 89 | template 90 | inline void writePacket(Index row, Index col, const PacketScalar& x) 91 | { 92 | m_expression.const_cast_derived().template writePacket(row, col, x); 93 | } 94 | 95 | template 96 | inline const PacketScalar packet(Index index) const 97 | { 98 | return m_expression.template packet(index); 99 | } 100 | 101 | template 102 | inline void writePacket(Index index, const PacketScalar& x) 103 | { 104 | m_expression.const_cast_derived().template writePacket(index, x); 105 | } 106 | 107 | operator const ExpressionType&() const { return m_expression; } 108 | 109 | protected: 110 | const ExpressionType m_expression; 111 | }; 112 | 113 | /** \returns an expression of the temporary version of *this. 114 | */ 115 | template 116 | inline const NestByValue 117 | DenseBase::nestByValue() const 118 | { 119 | return NestByValue(derived()); 120 | } 121 | 122 | #endif // EIGEN_NESTBYVALUE_H 123 | --------------------------------------------------------------------------------