Module Sift for calculating SIFT keypoint using PyOpenCL
Bases: dict
Simple class half way between a dict and a class, behaving as an enum
Contains a class for creating a plan, allocating arrays, compiling kernels and other things like that... to calculate SIFT keypoints and descriptors.
This algorithm is patented: U.S. Patent 6,711,293: “Method and apparatus for identifying scale invariant features in an image and use of same for locating an object in an image”, David Lowe’s patent for the SIFT algorithm, March 23, 2004
Bases: object
This class implements a way to calculate SIFT keypoints.
How to calculate a set of SIFT keypoint on an image:
siftp = sift.SiftPlan(img.shape,img.dtype,devicetype=”GPU”) kp = siftp.keypoints(img)
kp is a nx132 array. the second dimension is composed of x,y, scale and angle as well as 128 floats describing the keypoint
This SIFT algorithm is patented: U.S. Patent 6,711,293: “Method and apparatus for identifying scale invariant features in an image and use of same for locating an object in an image”,
Print the number of keypoint per octave
Calculates the keypoints of the image :param image: ndimage of 2D (or 3D if RGB)
If we are in debugging mode, prints out all timing for every single OpenCL call
Resets the profiling timers
Contains a class for creating a matching plan, allocating arrays, compiling kernels and other things like that
Bases: object
Plan to compare sets of SIFT keypoint
siftp = sift.MatchPlan(devicetype=”GPU”) kp = siftp.match(kp1,kp2)
kp is a nx132 array. the second dimension is composed of x,y, scale and angle as well as 128 floats describing the keypoint
calculate the matching of 2 keypoint list
Parameters: |
|
---|
TODO: implement the ROI ...
Resets the profiling timers
Defines the region of interest
Parameters: | roi – region of interest as 2D numpy array with non zero where |
---|
valid pixels are.
Unset the region of interest
Automatic selection of OpenCL devices
Bases: object
Simple class that contains the structure of an OpenCL device
Complete device description
Returns: | string |
---|
Bases: object
Simple class that wraps the structure ocl_tools_extended.h
This is a static class. ocl should be the only instance and shared among all python modules.
Choose a device and initiate a context.
Devicetypes can be GPU,gpu,CPU,cpu,DEF,ACC,ALL. Suggested are GPU,CPU. For each setting to work there must be such an OpenCL device and properly installed. E.g.: If Nvidia driver is installed, GPU will succeed but CPU will fail. The AMD SDK kit is required for CPU via OpenCL. :param devicetype: string in [“cpu”,”gpu”, “all”, “acc”] :param useFp64: boolean specifying if double precision will be used :param platformid: integer :param devid: integer :return: OpenCL context on the selected device
Return a platform according
Parameters: | key (int or str) – identifier for a platform, either an Id (int) or it’s name |
---|
Select a device based on few parameters (at the end, keep the one with most memory)
Parameters: |
|
---|
Bases: object
Simple class that contains the structure of an OpenCL platform
Return a device according to key
Parameters: | key (int or str) – identifier for a device, either it’s id (int) or it’s name |
---|
Parameters: | buffers – the buffers info use to create the pyopencl.Buffer |
---|---|
Returns: | a dict containing the instanciated pyopencl.Buffer |
Return type: | dict(str, pyopencl.Buffer) |
This method instanciate the pyopencl.Buffer from the buffers description.
Parameters: | cl_buffer (dict(str, pyopencl.Buffer)) – the buffer you want to release |
---|
This method release the memory of the buffers store in the dict
Contains classes for image alignment on a reference images.
Bases: object
Align images on a reference image based on an Afine transformation (bi-linear + offset)
Align image on reference image
Parameters: |
|
---|---|
Returns: | aligned image or all informations |
If we are in debugging mode, prints out all timing for every single OpenCL call
Perform a 2x2 binning of the image
Calculate the optimal size for a kernel according to the workgroup size
Calculate the optimal kernel size for a convolution with sigma
Parameters: |
|
---|
Given the matching between two list of keypoints, return the linear transformation to correct kp2 with respect to kp1
Calculate the number of bytes needed to allocate for a given structure
Parameters: |
|
---|
Automatic selection of OpenCL devices
Bases: object
Simple class that contains the structure of an OpenCL device
Complete device description
Returns: | string |
---|
Bases: object
Simple class that wraps the structure ocl_tools_extended.h
This is a static class. ocl should be the only instance and shared among all python modules.
Choose a device and initiate a context.
Devicetypes can be GPU,gpu,CPU,cpu,DEF,ACC,ALL. Suggested are GPU,CPU. For each setting to work there must be such an OpenCL device and properly installed. E.g.: If Nvidia driver is installed, GPU will succeed but CPU will fail. The AMD SDK kit is required for CPU via OpenCL. :param devicetype: string in [“cpu”,”gpu”, “all”, “acc”] :param useFp64: boolean specifying if double precision will be used :param platformid: integer :param devid: integer :return: OpenCL context on the selected device
Return a platform according
Parameters: | key (int or str) – identifier for a platform, either an Id (int) or it’s name |
---|
Select a device based on few parameters (at the end, keep the one with most memory)
Parameters: |
|
---|
Bases: object
Simple class that contains the structure of an OpenCL platform
Return a device according to key
Parameters: | key (int or str) – identifier for a device, either it’s id (int) or it’s name |
---|
Parameters: | buffers – the buffers info use to create the pyopencl.Buffer |
---|---|
Returns: | a dict containing the instanciated pyopencl.Buffer |
Return type: | dict(str, pyopencl.Buffer) |
This method instanciate the pyopencl.Buffer from the buffers description.
Parameters: | cl_buffer (dict(str, pyopencl.Buffer)) – the buffer you want to release |
---|
This method release the memory of the buffers store in the dict
Perform a 2x2 binning of the image
Calculate the optimal size for a kernel according to the workgroup size
Calculate the optimal kernel size for a convolution with sigma
Parameters: |
|
---|
Given the matching between two list of keypoints, return the linear transformation to correct kp2 with respect to kp1
Calculate the number of bytes needed to allocate for a given structure
Parameters: |
|
---|