Python bindings for KeyPoint methods

Usage:

import numpy as np
import cv2
img = cv2.imread('messi5.jpg',0)
sift = cv2.SIFT()
kp = sift.detect(img)

pts = cv2.KeyPoint_convert(kp)

kps = cv2.KeyPoint_convert(pts.reshape(-1,1,2))

overlap = cv2.KeyPoint_overlap(kp[0],kp[1])
This commit is contained in:
abidrahmank 2013-08-30 11:11:06 +05:30
parent fc37df05ec
commit 14af369640
3 changed files with 46 additions and 4 deletions

View File

@ -638,6 +638,48 @@ The keypoint constructors
:param _class_id: object id
KeyPoint::convert
--------------------
This method converts vector of keypoints to vector of points or the reverse, where each keypoint is assigned the same size and the same orientation.
.. ocv:function:: KeyPoint::convert(const std::vector<KeyPoint>& keypoints, CV_OUT std::vector<Point2f>& points2f, const std::vector<int>& keypointIndexes=std::vector<int>())
.. ocv:function:: KeyPoint::convert(const std::vector<Point2f>& points2f, CV_OUT std::vector<KeyPoint>& keypoints, float size=1, float response=1, int octave=0, int class_id=-1)
.. ocv:pyfunction:: cv2.KeyPoint_convert(keypoints[, keypointIndexes]) -> points2f
.. ocv:pyfunction:: cv2.KeyPoint_convert(points2f[, size[, response[, octave[, class_id]]]]) -> keypoints
:param keypoints: Keypoints obtained from any feature detection algorithm like SIFT/SURF/ORB
:param points2f: Array of (x,y) coordinates of each keypoint
:param keypointIndexes: Array of indexes of keypoints to be converted to points. (Acts like a mask to convert only specified keypoints)
:param _size: keypoint diameter
:param _response: keypoint detector response on the keypoint (that is, strength of the keypoint)
:param _octave: pyramid octave in which the keypoint has been detected
:param _class_id: object id
KeyPoint::overlap
--------------------
This method computes overlap for pair of keypoints. Overlap is the ratio between area of keypoint regions' intersection and area of keypoint regions' union (considering keypoint region as circle). If they don't overlap, we get zero. If they coincide at same location with same size, we get 1.
.. ocv:function:: KeyPoint::overlap(const KeyPoint& kp1, const KeyPoint& kp2)
.. ocv:pyfunction:: cv2.KeyPoint_overlap(kp1, kp2) -> retval
:param kp1: First keypoint
:param kp2: Second keypoint
DMatch
------
.. ocv:class:: DMatch

View File

@ -551,18 +551,18 @@ public:
size_t hash() const;
//! converts vector of keypoints to vector of points
static void convert(const std::vector<KeyPoint>& keypoints,
CV_WRAP static void convert(const std::vector<KeyPoint>& keypoints,
CV_OUT std::vector<Point2f>& points2f,
const std::vector<int>& keypointIndexes=std::vector<int>());
//! converts vector of points to the vector of keypoints, where each keypoint is assigned the same size and the same orientation
static void convert(const std::vector<Point2f>& points2f,
CV_WRAP static void convert(const std::vector<Point2f>& points2f,
CV_OUT std::vector<KeyPoint>& keypoints,
float size=1, float response=1, int octave=0, int class_id=-1);
//! computes overlap for pair of keypoints;
//! overlap is a ratio between area of keypoint regions intersection and
//! area of keypoint regions union (now keypoint region is circle)
static float overlap(const KeyPoint& kp1, const KeyPoint& kp2);
CV_WRAP static float overlap(const KeyPoint& kp1, const KeyPoint& kp2);
CV_PROP_RW Point2f pt; //!< coordinates of the keypoints
CV_PROP_RW float size; //!< diameter of the meaningful keypoint neighborhood

View File

@ -81,7 +81,7 @@ The function ``imshow`` displays an image in the specified window. If the window
If window was created with OpenGL support, ``imshow`` also support :ocv:class:`ogl::Buffer` , :ocv:class:`ogl::Texture2D` and :ocv:class:`gpu::GpuMat` as input.
.. note:: This function should be followed by ``waitKey`` function which displays the image for specified milliseconds. Otherwise, it won't display the image.
.. note:: This function should be followed by ``waitKey`` function which displays the image for specified milliseconds. Otherwise, it won't display the image. For example, ``waitKey(0)`` will display the window infinitely until any keypress (it is suitable for image display). ``waitKey(25)`` will display a frame for 25 ms, after which display will be automatically closed. (If you put it in a loop to read videos, it will display the video frame-by-frame)
namedWindow