handle single-point sets in kmeans properly

This commit is contained in:
Vadim Pisarevsky
2012-04-06 13:22:08 +00:00
parent 71d8769314
commit 61c7c441b9
2 changed files with 20 additions and 13 deletions

View File

@@ -2459,8 +2459,9 @@ double cv::kmeans( InputArray _data, int K,
{
const int SPP_TRIALS = 3;
Mat data = _data.getMat();
int N = data.rows > 1 ? data.rows : data.cols;
int dims = (data.rows > 1 ? data.cols : 1)*data.channels();
bool isrow = data.rows == 1 && data.channels() > 1;
int N = !isrow ? data.rows : data.cols;
int dims = (!isrow ? data.cols : 1)*data.channels();
int type = data.depth();
attempts = std::max(attempts, 1);