use more accurate reshape
This commit is contained in:
parent
55a714c83b
commit
f16503743f
@ -2691,17 +2691,17 @@ double cv::kmeans( InputArray _data, int K,
|
||||
int flags, OutputArray _centers )
|
||||
{
|
||||
const int SPP_TRIALS = 3;
|
||||
Mat data = _data.getMat();
|
||||
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();
|
||||
Mat data0 = _data.getMat();
|
||||
bool isrow = data0.rows == 1 && data0.channels() > 1;
|
||||
int N = !isrow ? data0.rows : data0.cols;
|
||||
int dims = (!isrow ? data0.cols : 1)*data0.channels();
|
||||
int type = data0.depth();
|
||||
|
||||
attempts = std::max(attempts, 1);
|
||||
CV_Assert( data.dims <= 2 && type == CV_32F && K > 0 );
|
||||
CV_Assert( data0.dims <= 2 && type == CV_32F && K > 0 );
|
||||
CV_Assert( N >= K );
|
||||
|
||||
data = data.reshape(1, N);
|
||||
Mat data(N, dims, CV_32F, data0.data, isrow ? dims * sizeof(float) : static_cast<size_t>(data0.step));
|
||||
|
||||
_bestLabels.create(N, 1, CV_32S, -1, true);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user