flann-lib / flann Goto Github PK
View Code? Open in Web Editor NEWFast Library for Approximate Nearest Neighbors
Home Page: http://people.cs.ubc.ca/~mariusm/flann
License: Other
Fast Library for Approximate Nearest Neighbors
Home Page: http://people.cs.ubc.ca/~mariusm/flann
License: Other
Marius,
There is a small mistake at the FindTBB.cmake file over at line 44.
I think
set(TBB_INCLUDE_DIRS ${PC_TBB_INCLUDEDIR})
should be
set(TBB_INCLUDE_DIRS ${TBB_INCLUDE_DIR})
otherwise its left as an empty string :)
Also while you are at it you might wanna correct an accidental paste over at line 20
find_path(TBB_INCLUDE_DIR tbb/task_scheduler_init.h
That task_scheduler_init.h does not look right to me hehe
Last, was there any reason of not using something like this ?
if(TBB_FOUND AND TBB_DEBUG_FOUND)
target_link_libraries(flann_cpp ${TBB_LIBRARIES})
set_property(TARGET flann_cpp PROPERTY COMPILE_DEFINITIONS FLANN_STATIC TBB)
else()
set_property(TARGET flann_cpp PROPERTY COMPILE_DEFINITIONS FLANN_STATIC)
endif(TBB_FOUND AND TBB_DEBUG_FOUND)
If TBB is found why not just add the definition ?
I guess it limits the options but why would not you wanna use TBB.
Why dont you also add TBB to the static linking in the cmake as in also for flann_cpp_s
Dear, Marius.
Now, saved index file that made by linux (x64 machine) and by my android phone(SO-01C) are not compatible.
Because, in save process flann library uses environment depended types.
For example,
typeof(size_t) equals 8 in linux64 and win7 64. But in android, this size is 4.
Can you use environment independent type like uint64_t instead of size_t.
Index building on android phone is slow, So I plan to put pre-build index file into android pkg file.
Thank you.
This bug prevents linking more than one file including flann.h.
It is caused by those 2 lines in general.h:
const int FLANN_CHECKS_UNLIMITED = -1;
const int FLANN_CHECKS_AUTOTUNED = -2;
To reproduce:
echo '#include <flann/flann.h>' >a.c
cp a.c b.c
echo 'int main() {return 0;}' >c.c
gcc *.c
Result:
/tmp/ccJKEBkl.o:(.rodata+0x0): multiple definition of FLANN_CHECKS_UNLIMITED' /tmp/ccPsyg0P.o:(.rodata+0x0): first defined here /tmp/ccJKEBkl.o:(.rodata+0x4): multiple definition of
FLANN_CHECKS_AUTOTUNED'
/tmp/ccPsyg0P.o:(.rodata+0x4): first defined here
collect2: ld returned 1 exit status
Fix:
enum { FLANN_CHECKS_UNLIMITED = -1,
FLANN_CHECKS_AUTOTUNED = -2};
I get the following 2 'no matching function for call to...' errors when compiling a slightly modified version of the flann_example.cpp included with the source and described in the user guide:
flann_example.cpp:76: error: no matching function for call to ‘flann::Index<flann::L2<float> >::Index(flann::Matrix<unsigned char>&, flann::KDTreeIndexParams)’
/flann/flann.hpp:107: note: candidates are: flann::Index<Distance>::Index(const flann::Matrix<typename Distance::ElementType>&, const flann::IndexParams&, Distance) [with Distance = flann::L2<float>]
/flann/flann.hpp:102: note: flann::Index<flann::L2<float> >::Index(const flann::Index<flann::L2<float> >&)
flann_example.cpp:80: error: no matching function for call to ‘flann::Index<flann::L2<float> >::knnSearch(flann::Matrix<unsigned char>&, flann::Matrix<int>&, flann::Matrix<float>&, int&, flann::SearchParams)’
/flann/flann.hpp:215: note: candidates are: void flann::Index<Distance>::knnSearch(const flann::Matrix<typename Distance::ElementType>&, flann::Matrix<int>&, flann::Matrix<typename Distance::ResultType>&, int, const flann::SearchParams&) [with Distance = flann::L2<float>]
The only modification I made to the example code deals with how the data is read in. Instead of using the hdf5 interface, I've read the data in from a binary file. The code is as follows:
Matrix<uint8_t> dataset(new uint8_t[num_bytes], num_features, dimensions);
Matrix<uint8_t> query(new uint8_t[num_bytes], num_features, dimensions);
//dataset and query were read in from a binary file...
int nn = 3;
Matrix<int> indices(new int[query.rows*nn], query.rows, nn);
Matrix<float> dists(new float[query.rows*nn], query.rows, nn);
// construct an randomized kd-tree index using 4 kd-trees
Index<L2<float> > index(dataset, flann::KDTreeIndexParams(4));
index.buildIndex();
// do a knn search, using 128 checks
index.knnSearch(query, indices, dists, nn, flann::SearchParams(128));
flann::save_to_file(indices,"result.hdf5","result");
delete[] dataset.data;
delete[] query.data;
delete[] indices.data;
delete[] dists.data;
return 0;
The variable HDF5_IS_PARALLEL is not set by the method find_hdf5.
Deleting lines 79 to 89 in CMakeLists.txt
https://github.com/mariusmuja/flann/blob/master/CMakeLists.txt#L79
resolves the problem.
Hello, Marius.
I met segmentation fault at reading saved HierarchicalClusteringIndex.
Using May 18 2012 code (f320d4b) my code was worked in good.
But, current code (8d87f4b) throws segmentation fault.
Both android and linux environment, error occurs at the same line.
And, I use 512 bits binary data.
My code and line of error are shown as below.
Thanks.
Hello,
I have successfully downloaded and compiled flann on ubuntu.
I'm just trying to play with the code to know whether it fits my needs. I'm just recoding a simple version of nlmeans with flann.
however, I cannot compile my code and get the following error:
"pierre@pierre-VirtualBox:~/dev/ContentAwareProcessing$ make
[ 50%] Built target ImageAnalogies
[100%] Building CXX object CMakeFiles/NLMeans.dir/NLMeans.cpp.o
In file included from /home/pierre/third-party/flann-1.7.1-src/build/include/flann/flann.hpp:42:0,
from /home/pierre/dev/ContentAwareProcessing/NLMeans.cpp:12:
/home/pierre/third-party/flann-1.7.1-src/build/include/flann/util/saving.h:72:40: error: ‘NNIndex’ is not a template
/home/pierre/third-party/flann-1.7.1-src/build/include/flann/util/saving.h: In function ‘void flann::save_header(FILE*, const NNIndex&)’:
/home/pierre/third-party/flann-1.7.1-src/build/include/flann/util/saving.h:80:30: error: invalid use of incomplete type ‘const struct NNIndex’
/home/pierre/third-party/flann-1.7.1-src/build/include/flann/util/saving.h:45:7: error: forward declaration of ‘const struct NNIndex’
/home/pierre/third-party/flann-1.7.1-src/build/include/flann/util/saving.h:81:24: error: invalid use of incomplete type ‘const struct NNIndex’
/home/pierre/third-party/flann-1.7.1-src/build/include/flann/util/saving.h:45:7: error: forward declaration of ‘const struct NNIndex’
/home/pierre/third-party/flann-1.7.1-src/build/include/flann/util/saving.h:82:24: error: invalid use of incomplete type ‘const struct NNIndex’
"
Followed by pages of errors. I have tried to look into the error, but cannot find why, since the class NNIndex is obviously defined in nn_index.hpp
Have I missed something obvious?
Thanks, pierre
As far as I could tell, there is no CUDA and multicore support using the Python bindings. That would be pretty cool :)
Hi,
I just cloned src from latest repository, then compiled.
but compile error massage printed as follows,
/home/trairia/tmp/flann/src/cpp/flann/util/random.h:81:5: error: 'ptrdiff_t' does not name a type
In file included from /usr/include/c++/4.6/algorithm:63:0,
from /home/trairia/tmp/flann/src/cpp/flann/util/result_set.h:34,
from /home/trairia/tmp/flann/src/cpp/flann/algorithms/nn_index.h:46,
from /home/trairia/tmp/flann/src/cpp/flann/util/saving.h:37,
from /home/trairia/tmp/flann/src/cpp/flann/flann.hpp:42,
from /home/trairia/tmp/flann/src/cpp/flann/flann.h:468,
from /home/trairia/tmp/flann/src/cpp/flann/flann.cpp:29:
My environment are,
System : Debian Linux unstable
Linux Kernel:3.2.6-20120215
gcc-version:4.6.3
I inserted "#include" into src/cpp/flann/util/random.h, then compile succeeded.
Thanks.
trairia
Hello,
I am trying to build flann from git. However, I run into some trouble on:
Building NVCC (Device) object src/cpp/./flann_cuda_s_generated_kdtree_cuda_3d_index.cu.o
The first error occurs:
flann/src/cpp/flann/algorithms/kdtree_cuda_3d_index.h(56): error: identifier "FLANN_INDEX_KDTREE_CUDA" is undefined
I got a look at defines, where "FLANN_INDEX_KDTREE_CUDA" is commented out.
thanks and regards,
avo
[ 66%] Building NVCC (Device) object src/cpp/./flann_cuda_s_generated_kdtree_cuda_3d_index.cu.o
/home/avo/libs/flanngit/flann/src/cpp/flann/general.h(54): warning: statement is unreachable
/home/avo/libs/flanngit/flann/src/cpp/flann/general.h(57): warning: statement is unreachable
/home/avo/libs/flanngit/flann/src/cpp/flann/general.h(60): warning: statement is unreachable
/home/avo/libs/flanngit/flann/src/cpp/flann/general.h(63): warning: statement is unreachable
/home/avo/libs/flanngit/flann/src/cpp/flann/general.h(66): warning: statement is unreachable
/home/avo/libs/flanngit/flann/src/cpp/flann/general.h(69): warning: statement is unreachable
/home/avo/libs/flanngit/flann/src/cpp/flann/general.h(72): warning: statement is unreachable
/home/avo/libs/flanngit/flann/src/cpp/flann/general.h(75): warning: statement is unreachable
/home/avo/libs/flanngit/flann/src/cpp/flann/general.h(78): warning: statement is unreachable
/home/avo/libs/flanngit/flann/src/cpp/flann/general.h(81): warning: statement is unreachable
/home/avo/libs/flanngit/flann/src/cpp/flann/algorithms/kdtree_cuda_3d_index.h(56): error: identifier "FLANN_INDEX_KDTREE_CUDA" is undefined
/home/avo/libs/flanngit/flann/src/cpp/flann/algorithms/dist.h(567): warning: integer conversion resulted in a change of sign
/home/avo/libs/flanngit/flann/src/cpp/flann/algorithms/kdtree_cuda_3d_index.cu(734): error: identifier "dataset_" is undefined
/home/avo/libs/flanngit/flann/src/cpp/flann/algorithms/kdtree_cuda_3d_index.cu(734): error: no instance of overloaded function "thrust::device_pointer_cast" matches the argument list
argument types are: (<error-type>)
/home/avo/libs/flanngit/flann/src/cpp/flann/algorithms/kdtree_cuda_3d_index.cu(734): error: no instance of overloaded function "thrust::device_pointer_cast" matches the argument list
argument types are: (<error-type>)
/home/avo/libs/flanngit/flann/src/cpp/flann/algorithms/kdtree_cuda_3d_index.cu(746): error: identifier "dataset_" is undefined
5 errors detected in the compilation of "/tmp/tmpxft_00003512_00000000-6_kdtree_cuda_3d_index.cpp1.ii".
CMake Error at CMakeFiles/flann_cuda_s_generated_kdtree_cuda_3d_index.cu.o.cmake:258 (message):
Error generating file
/home/avo/libs/flanngit/flann/build/src/cpp/./flann_cuda_s_generated_kdtree_cuda_3d_index.cu.o
make[2]: *** [src/cpp/./flann_cuda_s_generated_kdtree_cuda_3d_index.cu.o] Error 1
make[1]: *** [src/cpp/CMakeFiles/flann_cuda_s.dir/all] Error 2
make: *** [all] Error 2
It would be nice if the documentation would suggest a recommended way to attach meta-data to the points (feature vectors) stored in memory.
I am surprised to see that the data input is handled as a Matrix, had it been a vector of a datatype defined as a Distance:: element, then defining the application specific type (e.g. struct { point_t point; data_t data; } ) and reusing the FLANN distances over "element.point" would have been the way to go.
With the current code base, what is the recommend approach ?
Hi,
I have a set of points and a set of indices already built for my dataset. (where indices is a subset of the full dataset).
I'd like to be able to use KDTreeSingleIndex() while minimising memory usage.
Currently, the constructor would make a copy of the points used, as it assumes all the points would be used.
Thus, I'd like to add a constructor like this:
KDTreeSingleIndex(const Matrix<ElementType>& inputData,
const std::vector<int>& inputIndices,
const IndexParams& params = KDTreeSingleIndexParams(),
Distance d = Distance() ) :
dataset_(inputData), index_params_(params), distance_(d)
{
size_ = inputIndices.size();
dim_ = dataset_.cols;
leaf_max_size_ = get_param(params,"leaf_max_size",10);
reorder_ = get_param(params,"reorder",true);
// Create a permutable array of indices to the input vectors.
// Copy from the passed input indices.
vind_ = inputIndices;
}
If I pass reorder=false, then the only memory required is for the vind_ copy and the tree.
I have already done so on my copy, I was wondering if you would perhaps add it to your mainstream version?
Note that I was not able to inherit from the class to implement my change, due to private members.
thanks,
Paul
ps there is no documentation on the 'reorder' flag.
Is it known to improve search speed significantly?
Hello,
I use in my code flann_set_distance_type to set the distance type to ChiSquareDistance. Unfortunatly, the algorithm seems not to compute using this distance. It use only the square euclidean distance. Where is my mistake please? What do i have to do to use ChiSquareDistance?
Thanks,
Marzieh
Hi,
Thanks for this fine piece of software.
I'm trying to build flann but i am encountering some problems both with version 1.6.10 and the git repository. Here is the output:
davide@mizar ~/Programs $:git clone git://github.com/mariusmuja/flann.git
Cloning into flann...
remote: Counting objects: 6720, done.
remote: Compressing objects: 100% (2559/2559), done.
remote: Total 6720 (delta 4074), reused 6642 (delta 4008)
Receiving objects: 100% (6720/6720), 78.48 MiB | 875 KiB/s, done.
Resolving deltas: 100% (4074/4074), done.
davide@mizar ~/Programs $:cd flann
davide@mizar ~/Programs/flann $:mkdir tmp
davide@mizar ~/Programs/flann $:cd tmp
davide@mizar ~/Programs/flann/tmp $:cmake ../src/ -DCMAKE_BUILD_TYPE=release
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMake Warning (dev) at cpp/CMakeLists.txt:3 (add_definitions):
Policy CMP0005 is not set: Preprocessor definition values are now escaped
automatically. Run "cmake --help-policy CMP0005" for policy details. Use
the cmake_policy command to set the policy and suppress this warning.
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Error at cpp/CMakeLists.txt:79 (install):
install TARGETS given no LIBRARY DESTINATION for shared library target
"flann_cpp".
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as
cmake_minimum_required(VERSION 2.8)
should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring incomplete, errors occurred!
What could be the problem?
Regards,
Davide
cd build && cmake -DCMAKE_BUILD_TYPE='Release' -DCMAKE_INSTALL_PREFIX=/usr/local -DPYTHON_INSTALL_PREFIX=false -DBUILD_C_BINDINGS=true -DBUILD_MATLAB_BINDINGS=false -DBUILD_PYTHON_BINDINGS=true -DUSE_MPI=false .. && make all
Install prefix: /usr/local
Build type: Release
Building C bindings: true
Building python bindings: true
Building matlab bindings: false
USE_MPI: false
CMake Error: find_package could not find module FindHDF5.cmake or a configuration file for package HDF5.
Adjust CMAKE_MODULE_PATH to find FindHDF5.cmake or set HDF5_DIR to the directory containing a CMake configuration file for HDF5. The file will have one of the following names:
HDF5Config.cmake
hdf5-config.cmake
hdf5 library not found, not compiling flann_example.cpp
CMake Error: find_package could not find module FindGTest.cmake or a configuration file for package GTest.
Adjust CMAKE_MODULE_PATH to find FindGTest.cmake or set GTest_DIR to the directory containing a CMake configuration file for GTest. The file will have one of the following names:
GTestConfig.cmake
gtest-config.cmake
gtest library not found, some tests will not be run
hdf5 library not found, some tests will not be run
-- Configuring done
make: *** [all] Error 1
I'm having trouble saving and loading an lsh index. I save the index and when I try to load it I get an error in the load_value call which tries to deserialize the Matrix of the index: the number of bytes read is less than the one specified before:
read_cnt = fread(value.data, sizeof(T), value.rows_value.cols, stream);
if (read_cnt != (size_t)(value.rows_value.cols)) {
throw FLANNException("Cannot read from file");
}
Hi,
What is the purpose of FLANN_FIRST_MATCH?
Is it for ensuring that the same point is not added to the result set twice?
Should it be defined at all times?
It is defined in flann.cpp but not anywhere else, meaning if I use flann C++ by creating KNNResultSet<> manually, my code will not have it defined, and the behaviour will be different.
thanks,
Paul
Hi, thank you to the author for this library. I have successfully built the latest version of FLANN in VS2008 with the BUILD_CUDA_LIB flag on.
I first wrote a simple program to try NN search on the CPU. This worked great without any errors.
I then wanted to try flann::KDTreeCuda3dIndexParams. I defined the #define FLANN_USE_CUDA in my source file. I also specified flann_cuda_s.lib in my TARGET_LINK_LIBRARIES in my CMakeLists.txt file.
When I tried to compile, I get the following error:
1>flann_cuda_s.lib(flann_cuda_s_generated_kdtree_cuda_3d_index.cu.obj) : error LNK2019: unresolved external symbol __cudaUnregisterFatBinary referenced in function "void __cdecl __cudaUnregisterBinaryUtil(void)" (?__cudaUnregisterBinaryUtil@@yaxxz)
1>flann_cuda_s.lib(flann_cuda_s_generated_kdtree_cuda_3d_index.cu.obj) : error LNK2019: unresolved external symbol cudaLaunch referenced in function "enum cudaError __cdecl cudaLaunch(char _)" (??$cudaLaunch@D@@ya?AW4cudaError@@pead@Z)
1>flann_cuda_s.lib(flann_cuda_s_generated_kdtree_cuda_3d_index.cu.obj) : error LNK2019: unresolved external symbol cudaFuncGetAttributes referenced in function "enum cudaError __cdecl cudaFuncGetAttributes<void __cdecl(void)>(struct cudaFuncAttributes *,void (_cdecl)(void))" (??$cudaFuncGetAttributes@$$A6AXXZ@@ya?AW4cudaError@@PEAUcudaFuncAttributes@@P6AXXZ@Z)
1>flann_cuda_s.lib(flann_cuda_s_generated_kdtree_cuda_3d_index.cu.obj) : error LNK2019: unresolved external symbol cudaGetErrorString referenced in function "public: virtual class std::basic_string<char,struct std::char_traits,class std::allocator > __cdecl thrust::system::detail::cuda_error_category::message(int)const " (?message@cuda_error_category@detail@system@thrust@@ueba?AV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@h@Z)
1>flann_cuda_s.lib(flann_cuda_s_generated_kdtree_cuda_3d_index.cu.obj) : error LNK2019: unresolved external symbol cudaGetDeviceProperties referenced in function "void __cdecl thrust::detail::backend::cuda::arch::detail::get_device_properties(struct thrust::detail::backend::cuda::arch::device_properties_t &,int)" (?get_device_properties@detail@arch@cuda@backend@1thrust@@YAXAEAUdevice_properties_t@23415@H@Z)
1>flann_cuda_s.lib(flann_cuda_s_generated_kdtree_cuda_3d_index.cu.obj) : error LNK2019: unresolved external symbol cudaGetDevice referenced in function "struct thrust::detail::backend::cuda::arch::device_properties_t __cdecl thrust::detail::backend::cuda::arch::device_properties(void)" (?device_properties@arch@cuda@backend@detail@thrust@@ya?AUdevice_properties_t@12345@XZ)
1>flann_cuda_s.lib(flann_cuda_s_generated_kdtree_cuda_3d_index.cu.obj) : error LNK2019: unresolved external symbol cudaMemcpy referenced in function "void __cdecl thrust::detail::backend::cuda::detail::checked_cudaMemcpy(void *,void const *,unsigned __int64,enum cudaMemcpyKind)" (?checked_cudaMemcpy@detail@cuda@backend@1thrust@@YAXPEAXPEBX_KW4cudaMemcpyKind@@@z)
1>flann_cuda_s.lib(flann_cuda_s_generated_kdtree_cuda_3d_index.cu.obj) : error LNK2019: unresolved external symbol cudaSetupArgument referenced in function "void __cdecl _device_stub__ZN5flann17KdTreeCudaPrivate13nearestKernelINS_4cuda15SingleResultSetIfEENS_6CudaL2EEEvPKNS2_22kd_tree_builder_detail9SplitInfoEPKiSB_PK6float4SE_SE_PKfiiPiPfiT_T0(struct flann::cuda::kd_tree_builder_detail::SplitInfo const *,int const *,int const *,struct float4 const *,struct float4 const *,struct float4 const *,float const *,int,int,int *,float *,int,struct flann::cuda::SingleResultSet &,struct flann::CudaL2 &)" (?_device_stub__ZN5flann17KdTreeCudaPrivate13nearestKernelINS_4cuda15SingleResultSetIfEENS_6CudaL2EEEvPKNS2_22kd_tree_builder_detail9SplitInfoEPKiSB_PK6float4SE_SE_PKfiiPiPfiT_T0@@YAXPEBUSplitInfo@kd_tree_builder_detail@cuda@flann@@PEBH1PEBUfloat4@@22PEBMHHPEAHPEAMHAEAU?$SingleResultSet@M@34@AEAUCudaL2@4@@z)
1>flann_cuda_s.lib(flann_cuda_s_generated_kdtree_cuda_3d_index.cu.obj) : error LNK2019: unresolved external symbol cudaConfigureCall referenced in function "public: static void __cdecl thrust::detail::backend::cuda::detail::closure_launcher_base<struct thrust::detail::backend::cuda::unordered_reduce_closure<class thrust::detail::normal_iterator<class thrust::device_ptr >,__int64,int,class thrust::detail::normal_iterator<class thrust::device_ptr >,struct thrust::plus >,1>::launch<unsigned __int64,unsigned __int64,unsigned __int64>(struct thrust::detail::backend::cuda::unordered_reduce_closure<class thrust::detail::normal_iterator<class thrust::device_ptr >,__int64,int,class thrust::detail::normal_iterator<class thrust::device_ptr >,struct thrust::plus >,unsigned __int64,unsigned __int64,unsigned __int64)" (??$launch@_K_K_K@?$closure_launcher_base@U?$unordered_reduce_closure@V?$normal_iterator@V?$device_ptr@H@thrust@@@detail@thrust@@_JHV123@U?$plus@H@3@@cuda@backend@detail@thrust@@$00@detail@cuda@backend@1thrust@@saxu?$unordered_reduce_closure@V?$normal_iterator@V?$device_ptr@H@thrust@@@detail@thrust@@_JHV123@U?$plus@H@3@@2314@_K11@Z)
1>flann_cuda_s.lib(flann_cuda_s_generated_kdtree_cuda_3d_index.cu.obj) : error LNK2019: unresolved external symbol cudaMalloc referenced in function "public: enum cudaError __cdecl thrust::detail::backend::cuda::detail::b40c_thrust::BaseRadixSortingEnactor<float,int>::EnactSort(struct thrust::detail::backend::cuda::detail::b40c_thrust::RadixSortStorage<float,int> &)" (?EnactSort@?$BaseRadixSortingEnactor@MH@b40c_thrust@detail@cuda@backend@3thrust@@qeaa?AW4cudaError@@aeau?$RadixSortStorage@MH@234536@@z)
1>flann_cuda_s.lib(flann_cuda_s_generated_kdtree_cuda_3d_index.cu.obj) : error LNK2019: unresolved external symbol __cudaRegisterFunction referenced in function "void __cdecl __sti____cudaRegisterAll_55_tmpxft_00000c20_00000000_6_kdtree_cuda_3d_index_cpp1_ii_134f9e06(void)" (?__sti____cudaRegisterAll_55_tmpxft_00000c20_00000000_6_kdtree_cuda_3d_index_cpp1_ii_134f9e06@@yaxxz)
1>flann_cuda_s.lib(flann_cuda_s_generated_kdtree_cuda_3d_index.cu.obj) : error LNK2019: unresolved external symbol __cudaRegisterFatBinary referenced in function "void __cdecl __sti____cudaRegisterAll_55_tmpxft_00000c20_00000000_6_kdtree_cuda_3d_index_cpp1_ii_134f9e06(void)" (?__sti____cudaRegisterAll_55_tmpxft_00000c20_00000000_6_kdtree_cuda_3d_index_cpp1_ii_134f9e06@@yaxxz)
1>flann_cuda_s.lib(flann_cuda_s_generated_kdtree_cuda_3d_index.cu.obj) : error LNK2019: unresolved external symbol cudaFree referenced in function "void __cdecl thrust::detail::backend::cuda::free<0>(class thrust::device_ptr)" (??$free@$0A@@cuda@backend@detail@thrust@@yaxv?$device_ptr@X@3@@z)
Can you let me know what might be the problem?
Thank you.
Querying a hierarchical clustering index for the nearest neighbor with SearchParams.checks set to FLANN_CHECKS_UNLIMITED gives wrong results.
The problem can be solved by changing lines 431 and 618 of hierarchical_clustering_index.h.
Commit f02e2d4 on 3 July 2012 with check in log "Some X-MACRO changes" introduces a boost dependency in defines.h but the CMake system doesn't have any facility to point at the boost headers. So generating an Xcode project and trying to compile it fails since it can't find boost includes.
Back in May 2011 there's a check in that "removes all boost dependencies", so is boost going to be required again?
Just a quick fix for newer clang and gcc flavours
diff --git a/src/cpp/flann/util/random.h b/src/cpp/flann/util/random.h
index 8b8791b..b7b51b4 100644
--- a/src/cpp/flann/util/random.h
+++ b/src/cpp/flann/util/random.h
@@ -33,6 +33,7 @@
#include <algorithm>
#include <cstdlib>
+#include <cstddef>
#include <vector>
#include "flann/general.h"
Hello Marius,
I wanted to have a look at the performance increase of the CUDA version so i wanted to compile it in windows. However these are the errors that i get in cmake. Unfortunately i have no clue with CMake so i was wondering if you can help me a little bit.
Thank you in advance !
CMake Error at c:/Program Files/CMake 2.8/share/cmake-2.8/Modules/FindCUDA.cmake:1153 (add_library):
add_library cannot create target "flann_cpp" because another target with
the same name already exists. The existing target is a shared library
created in source directory "D:/dev/src/flann/src/cpp". See documentation
for policy CMP0002 for more details.
Call Stack (most recent call first):
src/cpp/CMakeLists.txt:50 (cuda_add_library)
CMake Error at src/cpp/CMakeLists.txt:64 (set_target_properties):
set_target_properties Can not find target to add properties to: flann_cuda
CMake Error at src/cpp/CMakeLists.txt:140 (install):
install TARGETS given target "flann_cuda" which does not exist in this
directory.
Hi,
The find_program command cannot find matlab on windows because mex and mexext are batch files. Changing
find_program(MEX_CMD mex)
find_program(MEXEXT_CMD mexext)
to
find_program(MEX_CMD mex.bat)
find_program(MEXEXT_CMD mexext.bat)
fixes the problem.
Could you please fix this in the next version?
Thanks
Dear Marius Muja,
I wonder that where I can get data to test FLANN? I have a set of vectors. How can I config them to be input for FLANN?
Thank you!
I'm packaging flann for Archlinux and need the contents of COPYING for the binaries. Would you mind adding it to your source distribution?
Hello,
I am trying to install flann with tbb library. I installed libtbb-dev, libtbb2 and libtbb2-dbg and added the -DTBB option in CMakeLists.txt.
This is the output I get by cmake ..:
-- Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY)
CMake Warning at CMakeLists.txt:95 (message):
gtest library not found, some tests will not be run
CUDA_TOOLKIT_ROOT_DIR not found or specified
-- Could NOT find CUDA (missing: CUDA_TOOLKIT_ROOT_DIR CUDA_NVCC_EXECUTABLE CUDA_INCLUDE_DIRS CUDA_CUDART_LIBRARY)
-- CUDA not found, CUDA library will not be built
-- Could NOT find tbb_debug (missing: TBB_DEBUG_LIBRARIES)
-- Only the Intel TBB (release) libraries were found
CMake Warning at src/matlab/CMakeLists.txt:72 (message):
Cannot find MATLAB or Octave instalation. Make sure that the 'bin'
directory from the MATLAB instalation or that mkoctfile is in PATH
-- Install prefix: /usr/local
-- Build type: RelWithDebInfo
-- Building C bindings: ON
-- Building python bindings: ON
-- Building matlab bindings: ON
-- Building CUDA library: OFF
-- Using MPI support: OFF
-- Configuring done
-- Generating done
-- Build files have been written to: /home/Praline/Downloads/flann-1.7.1-src/build
TBB_DEBUG_LIBRARIES are missing and Using MPI support is OFF. Do I need to install some additional tbb libraries or is there another solution?
Thanks,
Praline
Hi,
I cannot build flann on my debian machine. It fails with:
make[3]: Entering directory /tmp/buildd/flann-1.6.11/obj-x86_64-linux-gnu' /usr/bin/cmake -E cmake_progress_report /tmp/buildd/flann-1.6.11/obj-x86_64-linux-gnu/CMakeFiles 22 [ 92%] Building CXX object examples/CMakeFiles/flann_example_mpi.dir/flann_example_mpi.cpp.o cd /tmp/buildd/flann-1.6.11/obj-x86_64-linux-gnu/examples && /usr/bin/c++ -g -O2 -O3 -DNDEBUG -I/usr/lib/openmpi/include -I/usr/lib/openmpi/include/openmpi -I/tmp/buildd/flann-1.6.11/src/cpp -Wall -o CMakeFiles/flann_example_mpi.dir/flann_example_mpi.cpp.o -c /tmp/buildd/flann-1.6.11/examples/flann_example_mpi.cpp In file included from /tmp/buildd/flann-1.6.11/examples/flann_example_mpi.cpp:2:0: /tmp/buildd/flann-1.6.11/src/cpp/flann/flann_mpi.hpp: In constructor 'flann::mpi::Index<Distance>::Index(const string&, const string&, const flann::IndexParams&)': /tmp/buildd/flann-1.6.11/src/cpp/flann/flann_mpi.hpp:179:5: error: 'load_from_file' is not a member of 'flann::mpi' /tmp/buildd/flann-1.6.11/src/cpp/flann/flann_mpi.hpp:179:5: note: suggested alternative: /tmp/buildd/flann-1.6.11/src/cpp/flann/io/hdf5.h:111:6: note: 'flann::load_from_file' /tmp/buildd/flann-1.6.11/src/cpp/flann/flann_mpi.hpp: At global scope: /tmp/buildd/flann-1.6.11/src/cpp/flann/flann_mpi.hpp: In instantiation of 'flann::mpi::Index<float>': /tmp/buildd/flann-1.6.11/examples/flann_example_mpi.cpp:64:35: instantiated from here /tmp/buildd/flann-1.6.11/src/cpp/flann/flann_mpi.hpp:120:44: error: 'float' is not a class, struct, or union type /tmp/buildd/flann-1.6.11/src/cpp/flann/flann_mpi.hpp:121:43: error: 'float' is not a class, struct, or union type /tmp/buildd/flann-1.6.11/src/cpp/flann/flann_mpi.hpp:124:32: error: 'float' is not a class, struct, or union type /tmp/buildd/flann-1.6.11/src/cpp/flann/flann_mpi.hpp:201:6: error: 'float' is not a class, struct, or union type In file included from /tmp/buildd/flann-1.6.11/examples/flann_example_mpi.cpp:2:0: /tmp/buildd/flann-1.6.11/src/cpp/flann/flann_mpi.hpp:234:5: error: 'float' is not a class, struct, or union type /tmp/buildd/flann-1.6.11/examples/flann_example_mpi.cpp: In function 'int main(int, char**)': /tmp/buildd/flann-1.6.11/examples/flann_example_mpi.cpp:75:11: error: 'class flann::mpi::Index<float>' has no member named 'knnSearch' /tmp/buildd/flann-1.6.11/examples/flann_example_mpi.cpp:79:66: warning: format '%d' expects argument of type 'int', but argument 2 has type 'size_t {aka long unsigned int}' [-Wformat] /tmp/buildd/flann-1.6.11/examples/flann_example_mpi.cpp:79:66: warning: format '%d' expects argument of type 'int', but argument 3 has type 'size_t {aka long unsigned int}' [-Wformat] In file included from /tmp/buildd/flann-1.6.11/examples/flann_example_mpi.cpp:2:0: /tmp/buildd/flann-1.6.11/src/cpp/flann/flann_mpi.hpp: In constructor 'flann::mpi::Index<Distance>::Index(const string&, const string&, const flann::IndexParams&) [with Distance = float, std::string = std::basic_string<char>]': /tmp/buildd/flann-1.6.11/examples/flann_example_mpi.cpp:64:89: instantiated from here /tmp/buildd/flann-1.6.11/src/cpp/flann/flann_mpi.hpp:180:5: error: using invalid field 'flann::mpi::Index<Distance>::dataset' In file included from /tmp/buildd/flann-1.6.11/src/cpp/flann/flann_mpi.hpp:35:0, from /tmp/buildd/flann-1.6.11/examples/flann_example_mpi.cpp:2: /tmp/buildd/flann-1.6.11/src/cpp/flann/flann.hpp: At global scope: /tmp/buildd/flann-1.6.11/src/cpp/flann/flann.hpp: In instantiation of 'flann::Index<float>': /tmp/buildd/flann-1.6.11/src/cpp/flann/flann_mpi.hpp:180:5: instantiated from 'flann::mpi::Index<Distance>::Index(const string&, const string&, const flann::IndexParams&) [with Distance = float, std::string = std::basic_string<char>]' /tmp/buildd/flann-1.6.11/examples/flann_example_mpi.cpp:64:89: instantiated from here /tmp/buildd/flann-1.6.11/src/cpp/flann/flann.hpp:92:44: error: 'float' is not a class, struct, or union type /tmp/buildd/flann-1.6.11/src/cpp/flann/flann.hpp:93:43: error: 'float' is not a class, struct, or union type In file included from /tmp/buildd/flann-1.6.11/src/cpp/flann/flann_mpi.hpp:35:0, from /tmp/buildd/flann-1.6.11/examples/flann_example_mpi.cpp:2: /tmp/buildd/flann-1.6.11/src/cpp/flann/flann.hpp:154:1: error: 'float' is not a class, struct, or union type /tmp/buildd/flann-1.6.11/src/cpp/flann/flann.hpp:184:6: error: 'float' is not a class, struct, or union type /tmp/buildd/flann-1.6.11/src/cpp/flann/flann.hpp:206:5: error: 'float' is not a class, struct, or union type In file included from /tmp/buildd/flann-1.6.11/examples/flann_example_mpi.cpp:2:0: /tmp/buildd/flann-1.6.11/src/cpp/flann/flann_mpi.hpp: In constructor 'flann::mpi::Index<Distance>::Index(const string&, const string&, const flann::IndexParams&) [with Distance = float, std::string = std::basic_string<char>]': /tmp/buildd/flann-1.6.11/examples/flann_example_mpi.cpp:64:89: instantiated from here /tmp/buildd/flann-1.6.11/src/cpp/flann/flann_mpi.hpp:180:5: error: new initializer expression list treated as compound expression [-fpermissive] /tmp/buildd/flann-1.6.11/examples/flann_example_mpi.cpp:64:89: instantiated from here /tmp/buildd/flann-1.6.11/src/cpp/flann/flann_mpi.hpp:188:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] /tmp/buildd/flann-1.6.11/src/cpp/flann/flann_mpi.hpp: In destructor 'flann::mpi::Index<Distance>::~Index() [with Distance = float]': /tmp/buildd/flann-1.6.11/examples/flann_example_mpi.cpp:64:89: instantiated from here /tmp/buildd/flann-1.6.11/src/cpp/flann/flann_mpi.hpp:197:5: error: using invalid field 'flann::mpi::Index<Distance>::dataset' In file included from /tmp/buildd/flann-1.6.11/src/cpp/flann/nn/index_testing.h:39:0, from /tmp/buildd/flann-1.6.11/src/cpp/flann/flann.hpp:43, from /tmp/buildd/flann-1.6.11/src/cpp/flann/flann_mpi.hpp:35, from /tmp/buildd/flann-1.6.11/examples/flann_example_mpi.cpp:2: /tmp/buildd/flann-1.6.11/src/cpp/flann/algorithms/nn_index.h: At global scope: /tmp/buildd/flann-1.6.11/src/cpp/flann/algorithms/nn_index.h: In instantiation of 'flann::NNIndex<float>': /tmp/buildd/flann-1.6.11/src/cpp/flann/flann.hpp:257:26: instantiated from 'int flann::Index<Distance>::size() const [with Distance = float]' /tmp/buildd/flann-1.6.11/src/cpp/flann/flann_mpi.hpp:184:5: instantiated from 'flann::mpi::Index<Distance>::Index(const string&, const string&, const flann::IndexParams&) [with Distance = float, std::string = std::basic_string<char>]' /tmp/buildd/flann-1.6.11/examples/flann_example_mpi.cpp:64:89: instantiated from here /tmp/buildd/flann-1.6.11/src/cpp/flann/algorithms/nn_index.h:51:44: error: 'float' is not a class, struct, or union type /tmp/buildd/flann-1.6.11/src/cpp/flann/algorithms/nn_index.h:52:43: error: 'float' is not a class, struct, or union type make[3]: *** [examples/CMakeFiles/flann_example_mpi.dir/flann_example_mpi.cpp.o] Error 1 make[3]: Leaving directory
/tmp/buildd/flann-1.6.11/obj-x86_64-linux-gnu'
make[2]: *** [examples/CMakeFiles/flann_example_mpi.dir/all] Error 2
make[2]: *** Waiting for unfinished jobs....
Linking CXX static library ../../lib/libflann_s.a
cd /tmp/buildd/flann-1.6.11/obj-x86_64-linux-gnu/src/cpp && /usr/bin/cmake -P CMakeFiles/flann_s.dir/cmake_clean_target.cmake
cd /tmp/buildd/flann-1.6.11/obj-x86_64-linux-gnu/src/cpp && /usr/bin/cmake -E cmake_link_script CMakeFiles/flann_s.dir/link.txt --verbose=1
/usr/bin/ar cr ../../lib/libflann_s.a CMakeFiles/flann_s.dir/flann/util/random.cpp.o CMakeFiles/flann_s.dir/flann/util/saving.cpp.o CMakeFiles/flann_s.dir/flann/util/logger.cpp.o CMakeFiles/flann_s.dir/flann/flann.cpp.o CMakeFiles/flann_s.dir/flann/nn/index_testing.cpp.o
/usr/bin/ranlib ../../lib/libflann_s.a
make[3]: Leaving directory /tmp/buildd/flann-1.6.11/obj-x86_64-linux-gnu' /usr/bin/cmake -E cmake_progress_report /tmp/buildd/flann-1.6.11/obj-x86_64-linux-gnu/CMakeFiles 23 24 25 26 27 [ 92%] Built target flann_s make[2]: Leaving directory
/tmp/buildd/flann-1.6.11/obj-x86_64-linux-gnu'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/tmp/buildd/flann-1.6.11/obj-x86_64-linux-gnu'
dh_auto_build: make -j2 returned exit code 2
make: *** [build] Error 2
dpkg-buildpackage: error: debian/rules build gave error exit status 2
After cloning 72de077, and doing this:
cd flann;
mkdir build;
cd build;
cmake ..;
make
There's no pyflann directory in flann/build/src/python
, so python setup.py install
gives the error error: package directory 'pyflann' does not exist
. I copied pyflann:
cp -r ~/flann/src/python/pyflann ~/flann/build/src/python/pyflann
and the install worked properly.
This is just a test of how to create an issue.
Not sure if this duplicated with #21
Hi,
Please see if you can help on this issue
OS: ubuntu 11.10 x64
GCC version 4.4.6
CMake version 2.8.7
cmake command:
/usr/local/bin/cmake /opt/surfscan-dev/depend/source/flann-1.7.1 -DCMAKE_INSTALL_PREFIX=/opt/surfscan-dev/depend/install/flann-1.7.1 -DCMAKE_BUILD_TYPE=Release -DBUILD_CUDA_LIB=ON -DBUILD_C_BINDINGS=OFF -DBUILD_MATLAB_BINDINGS=OFF -DBUILD_PYTHON_BINDINGS=OFF
cmake output:
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/lib/ccache/gcc
-- Check for working C compiler: /usr/lib/ccache/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/lib/ccache/c++
-- Check for working CXX compiler: /usr/lib/ccache/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found PythonInterp: /usr/bin/python (found version "2.7.2+")
-- Found HDF5: debug;/usr/lib/libhdf5.so;debug;/usr/lib/x86_64-linux-gnu/libpthread.so;debug;/usr/lib/x86_64-linux-gnu/libz.so;debug;/usr/lib/x86_64-linux-gnu/libm.so;optimized;/usr/lib/libhdf5.so;optimized;/usr/lib/x86_64-linux-gnu/libpthread.so;optimized;/usr/lib/x86_64-linux-gnu/libz.so;optimized;/usr/lib/x86_64-linux-gnu/libm.so
-- Found GTest: /usr/lib/libgtest.a
-- Found CUDA: /usr/local/cuda (found version "4.0")
-- CUDA found (include: /usr/local/cuda/include, lib: /usr/local/cuda/lib64/libcudart.so)
-- checking for module 'tbb'
-- found tbb, version 3.0+r018
-- Found tbb: /usr/lib/libtbb.so
-- Could NOT find tbb_debug (missing: TBB_DEBUG_LIBRARIES)
-- Only the Intel TBB (release) libraries were found
You have called ADD_LIBRARY for library flann_cuda without any source files. This typically indicates a problem with your CMakeLists.txt file
-- Install prefix: /opt/surfscan-dev/depend/install/flann-1.7.1
-- Build type: Release
-- Building C bindings: OFF
-- Building python bindings: OFF
-- Building matlab bindings: OFF
-- Building CUDA library: ON
-- Using MPI support: OFF
-- Configuring done
-- Generating done
-- Build files have been written to: /opt/surfscan-dev/depend/build/flann-1.7.1
make install output:
[ 14%] Scanning dependencies of target flann_cpp_s
Building NVCC (Device) object src/cpp/CMakeFiles/flann_cuda_s.dir/flann/algorithms/./flann_cuda_s_generated_kdtree_cuda_3d_index.cu.o
Scanning dependencies of target flann_cpp-gd
Scanning dependencies of target flann_cpp_s-gd
[ 28%] Building CXX object src/cpp/CMakeFiles/flann_cpp_s.dir/flann/flann_cpp.cpp.o
[ 42%] Building CXX object src/cpp/CMakeFiles/flann_cpp-gd.dir/flann/flann_cpp.cpp.o
[ 57%] Linking CXX static library ../../lib/libflann_cpp_s.a
No such file or directory
Building CXX object src/cpp/CMakeFiles/flann_cpp_s-gd.dir/flann/flann_cpp.cpp.o
CMake Error at flann_cuda_s_generated_kdtree_cuda_3d_index.cu.o.cmake:198 (message):
Error generating
/opt/surfscan-dev/depend/build/flann-1.7.1/src/cpp/CMakeFiles/flann_cuda_s.dir/flann/algorithms/./flann_cuda_s_generated_kdtree_cuda_3d_index.cu.o
make[2]: *** [src/cpp/CMakeFiles/flann_cuda_s.dir/flann/algorithms/./flann_cuda_s_generated_kdtree_cuda_3d_index.cu.o] Error 1
Linking CXX shared library ../../lib/libflann_cpp-gd.so
make[1]: *** [src/cpp/CMakeFiles/flann_cuda_s.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 57%] Built target flann_cpp_s
Linking CXX static library ../../lib/libflann_cpp_s-gd.a
[ 57%] Built target flann_cpp_s-gd
[ 57%] Built target flann_cpp-gd
make: *** [all] Error 2
The assert in getNeighbors looks like a poor choice. I'm looking at the following location:
https://github.com/mariusmuja/flann/blob/master/src/cpp/flann/algorithms/kdtree_index.h#L458
Since this is an approximate KD-Tree, it's not totally wild that a query may produce no results. So that assert may happen in general use. An assert there is a bad choice, since the user can't do anything to prevent or catch that abort from happening.
I'd like to suggest that the highlighted line should just be deleted. The user has access to the ResultSet object, so they can query full() themselves to verify the results.
Hi again,
I am using KNNRadiusResultSet,
and I would like to be able to reuse the results instance (to minimise memory reallocs) while adjusting the radius for each search.
I was not able to inherit to reach my goal (due to private members), so I added this member directly:
/**
* Clears the result set and adjusts the search radius.
*/
void set_radius_and_clear( DistanceType r )
{
radius_ = r;
clear();
}
to use, I call it like so:
results.set_radius_and_clear( new_radius );
index.findNeighbors(results, query, params);
I submit this idea to you, perhaps you would in interested in incorporating the change.
thanks,
Paul
Marius,
I have a large dataset located (in ASCII) at http://www.pointcloud.org/files/autzen-colorized-1.2-3.txt.xz
When I attempt to create a 3D flann::Indexflann::L2 index with the XYZ data in this file, I get a segfault. It seems to crash on the same point all the time, but I'm unsure if it is due to the volume of data (there's 10 million points in the file), or the specific configuration of points. Here's some stack trace that might be helpful, but I suppose the only way to really test is to construct an example using the file.
#0 0x0000000100339b9b in flann::KDTreeIndex<flann::L2<float> >::meanSplit (this=0x102a26270, ind=0x1326ac000, count=10653336,
index=@0x7fff5fbfe6fc, cutfeat=@0x7fff5fbfe6f8, cutval=@0x7fff5fbfe6f4) at kdtree_index.h:319
#1 0x0000000100339a2d in flann::KDTreeIndex<flann::L2<float> >::divideTree (this=0x102a26270, ind=0x1326ac000, count=10653336)
at kdtree_index.h:290
#2 0x00000001003366ea in flann::KDTreeIndex<flann::L2<float> >::buildIndex (this=0x102a26270) at kdtree_index.h:130
#3 0x000000010030bd8f in flann::Index<flann::L2<float> >::buildIndex (this=0x102a26170) at flann.hpp:133
#4 0x000000010030b42e in pdal::filters::iterators::sequential::Index::readEndImpl (this=0x102a25000)
at /Users/hobu/dev/git/pdal/src/filters/Index.cpp:348
#5 0x000000010025c642 in pdal::StageIterator::readEnd (this=0x102a25000) at /Users/hobu/dev/git/pdal/src/StageIterator.cpp:198
#6 0x000000010025bd43 in pdal::StageIterator::read (this=0x102a25000, buffer=@0x7fff5fbff138)
at /Users/hobu/dev/git/pdal/src/StageIterator.cpp:106
#7 0x0000000100004401 in PcEqual::readPoints (this=0x7fff5fbff738, points=0x102a16350, iter=0x102a25000, data=@0x7fff5fbff138)
at pcequal.cpp:171
#8 0x0000000100005019 in PcEqual::execute (this=0x7fff5fbff738) at pcequal.cpp:245
#9 0x0000000100012b54 in Application::innerRun (this=0x7fff5fbff738) at Application.cpp:229
#10 0x00000001000125d1 in Application::do_execution (this=0x7fff5fbff738) at Application.cpp:128
#11 0x0000000100012ed1 in Application::run (this=0x7fff5fbff738) at Application.cpp:185
#12 0x000000010000641a in main (argc=3, argv=0x7fff5fbff8c0) at pcequal.cpp:336
(gdb) f 0
#0 0x0000000100339b9b in flann::KDTreeIndex<flann::L2<float> >::meanSplit (this=0x102a26270, ind=0x1326ac000, count=10653336,
index=@0x7fff5fbfe6fc, cutfeat=@0x7fff5fbfe6f8, cutval=@0x7fff5fbfe6f4) at kdtree_index.h:319
319 /**
(gdb) p count
$1 = 10653336
(gdb) p ind
$2 = (int *) 0x1326ac000
(gdb) p *ind
$3 = 4754599
I wanted to check if flann is using cuda, but I could not find a compiled version of flann_cuda_test.cu
or any of the other c(pp) test files. Flann itself is working, I tried pyflann. (It actually works quite nice!)
I am using cc0c061 and have installed GTest.
Here is the output of cmake ..
me@serv8:~/flann/build$ cmake ..
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /home/me/bin/gcc
-- Check for working C compiler: /home/me/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found PythonInterp: /usr/bin/python2.6
-- Found HDF5: debug;/usr/lib/libhdf5_hl.so;/usr/lib/libhdf5.so;optimized;/usr/lib/libhdf5_hl.so;/usr/lib/libhdf5.so
-- Found GTest: /usr/lib/libgtest.so
-- Found CUDA: /usr/local/cuda
-- CUDA found (include: /usr/local/cuda/include, lib: /usr/local/cuda/lib64/libcudart.so;/usr/lib/libcuda.so)
-- checking for module 'tbb'
-- found tbb, version 3.0+r018
-- Found tbb: /usr/lib/libtbb.so
-- Could NOT find tbb_debug (missing: TBB_DEBUG_LIBRARIES)
-- Only the Intel TBB (release) libraries were found
You have called ADD_LIBRARY for library flann_cuda without any source files. This typically indicates a problem with your CMakeLists.txt file
CMake Warning at src/matlab/CMakeLists.txt:72 (message):
Cannot find MATLAB or Octave instalation. Make sure that the 'bin'
directory from the MATLAB instalation or that mkoctfile is in PATH
-- I could not find the latex2html command.
-- Install prefix: /usr/local
-- Build type: RelWithDebInfo
-- Building C bindings: ON
-- Building python bindings: ON
-- Building matlab bindings: ON
-- Building CUDA library: ON
-- Using MPI support: OFF
-- Configuring done
-- Generating done
-- Build files have been written to: /home/me/flann/build
Dear Marius,
Could you please provide a brief example of using LSH or HierarchicalClustering with hamming distances. I did not get it work properly. When I called LSH or HierarchicalClustering , the build process will go to kdtree_single_index.h and ask for "accum_dist" function (which is not defined with hamming distances).
I think I am not doing this properly. Thanks for your help in advance.
Here is the code:
int nn = 1;
Matrix<unsigned char> query((unsigned char*)descriptors.data, descriptors.rows, descriptors.cols);
Matrix<unsigned char> dataset((unsigned char*)traindescriptors.data, traindescriptors.rows, traindescriptors.cols);
Matrix<unsigned int> indices(new unsigned int[query.rows*nn], query.rows, nn);
Matrix<unsigned char> dists(new unsigned char[query.rows*nn], query.rows, nn);
Index<HammingLUT> index(dataset, flann::HierarchicalClusteringIndexParams());
error message:
1>C:\flann-1.7.1-src\src\cpp\flann/algorithms/kdtree_single_index.h(500): error C2039: 'accum_dist' : is not a member of 'flann::HammingLUT'
1> C:\flann-1.7.1-src\src\cpp\flann/algorithms/dist.h(362) : see declaration of 'flann::HammingLUT'
1>C:\flann-1.7.1-src\src\cpp\flann/algorithms/kdtree_single_index.h(504): error C2039: 'accum_dist' : is not a member of 'flann::HammingLUT'
1> C:\flann-1.7.1-src\src\cpp\flann/algorithms/dist.h(362) : see declaration of 'flann::HammingLUT'
Kind regards
Yifei
Hi,
Thanks for providing this nice piece of software and being continuously trying to improve it.
I was following the instructions in the manual, and trying to compile flann_example.cpp, but I was not able to do it.
I tried rebuilding the program and I saw the following message:
-- Could NOT find HDF5 (missing: HDF5_LIBRARIES HDF5_INCLUDE_DIRS)
CMake Warning at CMakeLists.txt:64 (message):
hdf5 library not found, some tests will not be run
-- Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY)
CMake Warning at CMakeLists.txt:95 (message):
gtest library not found, some tests will not be run
is there a way I can fix this and be able to compile flann_example.cpp?
Sincerely,
Marco
Hi,
I have installed FLANN 1.6.11 on my Mac via MacPorts. It is working fine with its defalut settings,
but I cannot change the distance type by calling set_distance_type method. It fails as follows:
$ python
Python 2.6.7 (r267:88850, Jul 9 2011, 01:51:09)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
from pyflann import *
from numpy import *
from numpy.random import *dataset = rand(10000, 128)
flann = FLANN()
flann.set_distance_type('manhattan')
Traceback (most recent call last):
File "", line 1, in
AttributeError: FLANN instance has no attribute 'set_distance_type'
Is this already implemented?
__
takataka
Specifically, both calls to print_params here always print, and as far as I know, there's absolutely no way to disable them. (You can't hackily assign std::cout to something else in C++ as far as I know.)
This is particularly annoying for my application that does a lot of autotuning. If there is an easy workaround, of course, that's fine too.
One dumb but easy solution:
// in util/logger.h
static int Logger::getLevel() {
return instance().logLevel;
}
// in algorithms/autotuned_index.h
Logger::info("----------------------------------------------------\n");
Logger::info("Autotuned parameters:\n");
if (Logger::getLevel() <= FLANN_LOG_INFO)
print_params(bestParams_);
Logger::info("----------------------------------------------------\n");
A better but more-effort solution: have Logger
provide output streams for each log level, and add an optional stream argument to print_params
defaulting to std::cout
.
The deprecated LINEAR
constant in define.h
conflicts with the LINEAR
constant in libsvm's svm.h
. Obviously the reason why they're deprecated is because of the potential for conflicts like this, but this makes it impossible to include both headers in a pure-C file, and hence hard for me to write C bindings to my library that uses both flann and libsvm. :)
I might be able to work around this by manually including the parts of either flann.h
or svm.h
that I need, but it'd be nice to have some kind of preprocessor flag that determines whether those deprecated constants are defined (or just remove them, since they've been deprecated for a year).
This message appears when compiling flann on debian (with nvcc)
Hi,
I just wanted to give the cuda knn search a try and cloned the latest git repository.
However, it crashes when calling buildIndex.
According to a post [1] I found, it could be due to the float4 datatype.
Here is a minimal program to reproduce the crash:
void main(void){
const int size = 1000;
flann::Matrix dataset(new float[size*3], size, 3);
for(int i=0;i<1000;i++){
dataset[i][0]=i;
dataset[i][1]=i;
dataset[i][2]=i;
}
flann::Index<flann::L2> *m_Index
= new flann::Indexflann::L2 ( dataset, flann::KDTreeCuda3dIndexParams() );
m_Index->buildIndex();
}
Is this bug already known? Are there any workarounds/solutions?
using provided code to generate signatures
the result can be way bigger then 1 << key_size
UPDATED: sorry my bad. everything is OK
Can anyone reproduce this error? I tried it on two different Ubuntu installations (both Ubuntu 10.10).
I am using version: cc0c061
~/flann/build$ make test
[ 7%] Built target flann_s
[ 7%] Built target flann
Scanning dependencies of target pyunit_test_clustering.py
[ 7%] Running pyunit test(s) test_clustering.py
Clusters requested: 2, returning 2
Clusters requested: 2, returning 2
Clusters requested: 2, returning 2
.Clusters requested: 2, returning 2
Clusters requested: 2, returning 2
Clusters requested: 2, returning 2
.Clusters requested: 3, returning 3
Clusters requested: 3, returning 3
Clusters requested: 3, returning 3
.Clusters requested: 3, returning 3
Clusters requested: 3, returning 3
Clusters requested: 3, returning 3
.Clusters requested: 4, returning 4
Clusters requested: 4, returning 4
Clusters requested: 4, returning 4
.Clusters requested: 2, returning 2
Clusters requested: 2, returning 2
Clusters requested: 2, returning 2
.Clusters requested: 10, returning 10
.Clusters requested: 50, returning 50
Clusters requested: 50, returning 50
FClusters requested: 50, returning 50
Clusters requested: 50, returning 50
.
======================================================================
FAIL: testrandnumber_different (__main__.Test_PyFLANN_clustering)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/me/flann/test/test_clustering.py", line 90, in testrandnumber_different
self.assert_(any(cl1 != cl2))
AssertionError
----------------------------------------------------------------------
Ran 9 tests in 0.236s
FAILED (failures=1)
make[3]: *** [test/CMakeFiles/pyunit_test_clustering.py] Error 1
make[2]: *** [test/CMakeFiles/pyunit_test_clustering.py.dir/all] Error 2
make[1]: *** [test/CMakeFiles/test.dir/rule] Error 2
make: *** [test] Error 2
If you create a KDTreeSingleIndex with no data, it will segfault when you call buildIndex().
This assumes that you create the dataset matrix with the number of columns that it would have IF there were data,
but with zero rows.
Minimal example:
// empty dataset, with 3 columns if there were data.
Matrix dataset(NULL, 0, 3);
KDTreeSingleIndex< L2 > index(dataset);
index.buildIndex();
This also happens for findNeighbors() due to computeInitialDistances() segfault.
I would suggest either assert()ing that there is data, or doing an if (empty) return; or similar.
thanks again,
Paul
It will be great that you can define a distance functor that uses a minimization criterion instead a maximization criterion.
Best regards,
I'm not sure if I'm doing something incorrectly, but the nn_radius query available in the python bindings seems to be triggering an assertion. The following minimal example triggers the problem on my machine. FLANN 1.6.9, compiled with with gcc 4.4.3, and accessing the library from python 2.6.5.
from pyflann import *
from numpy import *
from numpy.random import *
dataset = rand(10000, 3)
testset = rand(3)
flann = FLANN()
flann = FLANN()
params = flann.build_index(dataset, target_precision=0.9, log_level = "info");
result, dists = flann.nn_radius(testset,0.2, checks=params["checks"])
Which results in the following assertion:
{'branching': 32, 'cb_index': 0.5, 'centers_init': 'default', 'log_level': 'info', 'algorithm': 'default', 'build_weight': 0.0099999997764825821, 'leaf_max_size': 4, 'eps': 0.0, 'trees': 1, 'speedup': 0.0, 'memory_weight': 0.0, 'target_precision': 0.89999997615814209, 'sample_fraction': 0.10000000149011612, 'iterations': 5, 'random_seed': 822048278, 'checks': 32}
python: /home/walkera/software/flann-1.6.9-src/src/cpp/flann/algorithms/kdtree_index.h:540: void flann::KDTreeIndex::getNeighbors(flann::ResultSet&, const typename Distance::ElementType*, int, float) [with Distance = flann::L2]: Assertion `result.full()' failed.
Command terminated
Hi again,
I am using KNNRadiusResultSet, and I often want to find the kth nearest item.
I could call results.copy(etc) and then grab the result from there, however that would add the overhead of a sort() or at least a copy() + max_element.
I was not able to inherit to achieve my goal, so instead, I added this method:
/**
* Find the worst result (furtherest neighbor) without copying or sorting
* Pre-conditions: size() > 0
*/
std::pair<int,double> worst_item() const
{
assert(not dist_index_.empty());
typedef typename std::vector<DistIndex>::const_iterator DistIt;
DistIt it = std::max_element(dist_index_.begin(), dist_index_.end());
return std::make_pair(it->index_, it->dist_);
}
Perhaps you would like to incorporate into the mainstream version?
thanks
Paul
Found Windows SDK v7.1: C:\Program Files\Microsoft SDKs\Windows\v7.1
Install prefix: C:/Program Files/flann
Build type: RelWithDebInfo
Building C bindings: true
Building python bindings: true
Building matlab bindings: true
USE_MPI:
Could NOT find HDF5 (missing: HDF5_LIBRARIES HDF5_INCLUDE_DIRS)
Cannot find MATLAB instalation. Make sure that the 'bin' directory from the MATLAB instalation is in PATH
hdf5 library not found, not compiling flann_example.cpp
Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY)
gtest library not found, some tests will not be run
hdf5 library not found, some tests will not be run
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:91 (MESSAGE):
Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE)
Call Stack (most recent call first):
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:252 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindPythonInterp.cmake:49 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
cmake/flann_utils.cmake:102 (find_package)
test/CMakeLists.txt:21 (flann_download_test_data)
Would it make sense to extend the method
int KMeansIndex::getClusterCenters(Matrix& centers)
to
int KMeansIndex::getClusterCenters(Matrix& centers, KMeansNodePtr* clustes)
?
Using this method it would be easy to visualize the group assignment.
Sorry to put this here as an issue. Is there another place, where one can post such messages?
Hey,
First off, thanks for a great library! You guys are providing an invaluable resource so please keep it.
That being said, I just want to bring to your attention a bug that I believe I found in the matlab interface. While using the mex interface I kept getting seg faults that would seemingly occur at random. It seemed like they would occur more frequently when working with larger amounts of data. I believe I have tracked the problem down to the improper use of pointers when building or loading and index. The functions _build_index and _load_index within the nearest_neighbors.cpp code both pass a pointer of the dataset to the API when constructing and index. However, I see that the FLANN code does not perform a copy of the dataset when constructing the index. This was probably intended behavior I imagine. However, this causes problems when trying to make the index persistent accross mex calls because that dataset memory can be deallocated after the flann_load_index or flann_build_index calls are completely. This is because the dataset memory is allocated for the arguments of these mex calls and after they are done will most likely be cleaned up by the memory manager after they finish.
I hope all that makes sense. The easiest way that I found to fix this is to modify nearest_neighbors.cpp such that it makes a copy of the dataset passed in via the input arguments to mexFunction. This copy must also be kept track of so that it can be free'd when flann_free_index is called. I have implemented this myself and it seems to resolve all segfaults that I was encountering. There is probably a better fix.
I just wanted to let you all know of the problem. As I said, this bug might be hard to reproduce as it doesn't always cause seg faults. I did not have any problems until I moved to larger datasets.
Just to note I am using
Matlab Version 7.12.0.635 (R2011a) 64-bit (glnxa64)
Thanks,
Dave
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.