pyflann | python bindings for FLANN - Fast Library | Machine Learning library
kandi X-RAY | pyflann Summary
kandi X-RAY | pyflann Summary
python bindings for FLANN - Fast Library for Approximate Nearest Neighbors.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Build an index
- Ensure the random_seed is set
- Compute k - means clustering
- Compute kmeans clustering
pyflann Key Features
pyflann Examples and Code Snippets
pip install pyflann-py3
sudo 2to3 -w D:\Anaconda3\lib\site-packages\pyflann
static void Main(string[] args)
{
int rows = 3, cols = 5;
int tCount = 2, nn = 3;
float[,] dataset2D = { { 1.0f, 1.0f, 1.0f, 2.0f, 3.0f},
{ 10.0f, 10.0f, 10.0f, 3
(nasa) [rovers@mars ~]# conda install -c conda-forge pyflann
(nasa) [rovers@mars ~]# python -c 'import pyflann; print pyflann.__path__'
['/conda/lib/python2.7/site-packages/pyflann']
Community Discussions
Trending Discussions on pyflann
QUESTION
I have some problems installing pyflann
in python 3.7.3, after execute:
ANSWER
Answered 2019-Oct-24 at 18:53pyflann
does not have support for python 3 yet, according to this GitHub issue. Your two options are:
Install the pyflann-py3
package:
QUESTION
Flann C++ library has wrappers for C, C++, Python, Matlab and Ruby but no C# wrapper available. I am trying to create a C# wrapper around flann.dll
32-bit unmanaged DLL downloaded from here.
Being new to PInvoke/marshalling, I am quite certain I am not doing the C# P/Invoke calls to the DLL correctly. I am basically trying to mirror the available Python wrapper in C#. Main areas of confusion are:
- I am not sure how to marshal (input) and unmarshal (output) between a 2D managed rectangular array in C# where the argument type is
float*
i.e. pointer to a query set stored in row major order (according to comments in flann.h). - I am also not sure how I am passing a structure reference to C is correct i.e.
struct FLANNParameters*
- Is
IntPtr
appropriate to referencetypedef void*
andint* indices
?
Public exported C++ methods from flann.h that I need to use are as follows:
...ANSWER
Answered 2017-Oct-30 at 09:05When you're working with p/invoke, you have to stop thinking "managed", and instead think physical binary layout, 32 vs 64 bit, etc. Also, when the called native binary always runs in-process (like here, but with COM servers it can be different) it's easier than out-of-process because you don't have to think too much about marshaling/serialization, ref vs out, etc.
Also, you don't need to tell .NET what it already knows. An array of float is an LPArray of R4, you don't have to specify it. The simpler the better.
So, first of all flann_index_t
. It's defined in C as void *
, so it must clearly be an IntPtr
(an opaque pointer on "something").
Then, structures. Structures passed as a simple pointer in C can just be passed as a ref
argument in C# if you define it as struct
. If you define it as a class
, don't use ref
. In general I prefer using struct for C structures.
You'll have to make sure the structure is well defined. In general, you use the LayoutKind.Sequential
because .NET p/invoke will pack arguments the same way that the C compiler does. So you don't have to use explicit, especially when arguments are standard (not bit things) like int, float, So you can remove all FieldOffset and use LayoutKind.Sequential if all members are properly declared... but this is not the case.
For types, like I said, you really have to think binary and ask yourself for each type you use, what's its binary layout, size? int
are (with 99.9% C compilers) 32-bit. float and double are IEEE standards, so there should never be issues about them. Enums are in general based on int
, but this may vary (in C and in .NET, to be able to match C). long
are (with 99.0% C compilers) 32-bit, not 64-bit. So the .NET equivalent is Int32 (int), not Int64 (long).
So you should correct your FlannParameters
structure and replace the long
by an int
. If you really want to make sure for a given struct, check Marshal.SizeOf(mystruct)
against C's sizeof(mystruct)
with the same C compiler than the one that was used to compile the library you're calling. They should be the same. If they're not, there's an error in the .NET definition (packing, member size, order, etc.).
Here are modified definitions and calling code that seem to work.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install pyflann
You can use pyflann like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page