1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

extended cv.KMeans2 API in Python (ticket #414; thanks to hogelog). fixed failures in the opencv python tests.

This commit is contained in:
Vadim Pisarevsky
2010-11-30 10:11:38 +00:00
parent 53e362e403
commit 8754cafffb
4 changed files with 83 additions and 32 deletions
+8 -5
View File
@@ -766,11 +766,14 @@ CheckArr int
int flags 0
double min_val 0
double max_val 0
KMeans2
KMeans2 double
CvArr samples
int nclusters
CvArr labels
CvTermCriteria termcrit
CvTermCriteria termcrit
int attempts 1
int flags 0
CvArr centers NULL
# Gradients, Edges, Corners and Features
Sobel
@@ -1648,7 +1651,7 @@ HOGDetectMultiScale CvSeq*
int nbins 9
int gammaCorrection 1
grabCut
GrabCut
CvArr image
CvArr mask
CvRect rect
@@ -1700,11 +1703,11 @@ CreateHist CvHistogram /doconly
ranges ranges None
int uniform 1
CreateImageHeader IplImage* /doconly
int size
CvSize size
int depth
int channels
CreateImage IplImage* /doconly
int size
CvSize size
int depth
int channels
CreateMatHeader CvMat /doconly
+17 -1
View File
@@ -3800,7 +3800,7 @@ static CvSeq* cvHOGDetectMultiScale( const CvArr* image, CvMemStorage* storage,
return seq;
}
static void cvgrabCut(CvArr *image,
static void cvGrabCut(CvArr *image,
CvArr *mask,
CvRect rect,
CvArr *bgdModel,
@@ -3845,6 +3845,22 @@ static int zero = 0;
cvSnakeImage(image, points, length, a, b, g, coeff_usage, win, criteria, calc_gradient); \
} while (0)
static double cppKMeans(const CvArr* _samples, int cluster_count, CvArr* _labels,
CvTermCriteria termcrit, int attempts, int flags, CvArr* _centers)
{
cv::Mat data = cv::cvarrToMat(_samples), labels = cv::cvarrToMat(_labels), centers;
if( _centers )
centers = cv::cvarrToMat(_centers);
CV_Assert( labels.isContinuous() && labels.type() == CV_32S &&
(labels.cols == 1 || labels.rows == 1) &&
labels.cols + labels.rows - 1 == data.rows );
return cv::kmeans(data, cluster_count, labels, termcrit, attempts,
flags, _centers ? &centers : 0 );
}
#define cvKMeans2(samples, nclusters, labels, termcrit, attempts, flags, centers) \
cppKMeans(samples, nclusters, labels, termcrit, attempts, flags, centers)
#include "generated0.i"
#if PYTHON_USE_NUMPY
+25 -23
View File
@@ -305,25 +305,25 @@
#define CV_EVENT_FLAG_SHIFTKEY 16
#define CV_EVENT_FLAG_ALTKEY 32
#define CV_MAX_DIM 32
include/highgui.h:#define CV_CAP_PROP_POS_MSEC 0
include/highgui.h:#define CV_CAP_PROP_POS_FRAMES 1
include/highgui.h:#define CV_CAP_PROP_POS_AVI_RATIO 2
include/highgui.h:#define CV_CAP_PROP_FRAME_WIDTH 3
include/highgui.h:#define CV_CAP_PROP_FRAME_HEIGHT 4
include/highgui.h:#define CV_CAP_PROP_FPS 5
include/highgui.h:#define CV_CAP_PROP_FOURCC 6
include/highgui.h:#define CV_CAP_PROP_FRAME_COUNT 7
include/highgui.h:#define CV_CAP_PROP_FORMAT 8
include/highgui.h:#define CV_CAP_PROP_MODE 9
include/highgui.h:#define CV_CAP_PROP_BRIGHTNESS 10
include/highgui.h:#define CV_CAP_PROP_CONTRAST 11
include/highgui.h:#define CV_CAP_PROP_SATURATION 12
include/highgui.h:#define CV_CAP_PROP_HUE 13
include/highgui.h:#define CV_CAP_PROP_GAIN 14
include/highgui.h:#define CV_CAP_PROP_EXPOSURE 15
include/highgui.h:#define CV_CAP_PROP_CONVERT_RGB 16
include/highgui.h:#define CV_CAP_PROP_WHITE_BALANCE 17
include/highgui.h:#define CV_CAP_PROP_RECTIFICATION 18
#define CV_CAP_PROP_POS_MSEC 0
#define CV_CAP_PROP_POS_FRAMES 1
#define CV_CAP_PROP_POS_AVI_RATIO 2
#define CV_CAP_PROP_FRAME_WIDTH 3
#define CV_CAP_PROP_FRAME_HEIGHT 4
#define CV_CAP_PROP_FPS 5
#define CV_CAP_PROP_FOURCC 6
#define CV_CAP_PROP_FRAME_COUNT 7
#define CV_CAP_PROP_FORMAT 8
#define CV_CAP_PROP_MODE 9
#define CV_CAP_PROP_BRIGHTNESS 10
#define CV_CAP_PROP_CONTRAST 11
#define CV_CAP_PROP_SATURATION 12
#define CV_CAP_PROP_HUE 13
#define CV_CAP_PROP_GAIN 14
#define CV_CAP_PROP_EXPOSURE 15
#define CV_CAP_PROP_CONVERT_RGB 16
#define CV_CAP_PROP_WHITE_BALANCE 17
#define CV_CAP_PROP_RECTIFICATION 18
#define CV_CN_SHIFT 3
#define CV_IMWRITE_JPEG_QUALITY 1
#define CV_IMWRITE_PNG_COMPRESSION 16
@@ -333,7 +333,9 @@ include/highgui.h:#define CV_CAP_PROP_RECTIFICATION 18
#define CV_PI
#define CV_GAUSSIAN_5x5
#define CV_CN_MAX
../include/opencv/highgui.h:#define CV_WINDOW_AUTOSIZE 1
../include/opencv/highgui.h:#define CV_WINDOW_NORMAL 0
../include/opencv/highgui.h:#define CV_WINDOW_FULLSCREEN 1
../include/opencv/highgui.h:#define HG_AUTOSIZE CV_WINDOW_AUTOSIZE
#define CV_WINDOW_AUTOSIZE 1
#define CV_WINDOW_NORMAL 0
#define CV_WINDOW_FULLSCREEN 1
#define HG_AUTOSIZE CV_WINDOW_AUTOSIZE
#define CV_CVTIMG_FLIP 1
#define CV_CVTIMG_SWAP_RB 2