MCPcopy Create free account
hub / github.com/creatale/node-dv / getPoints

Method getPoints

deps/opencv/modules/core/src/datastructs.cpp:3956–3998  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3954
3955
3956void KDTree::getPoints(InputArray _idx, OutputArray _pts, OutputArray _labels) const
3957{
3958 Mat idxmat = _idx.getMat(), pts, labelsmat;
3959 CV_Assert( idxmat.isContinuous() && idxmat.type() == CV_32S &&
3960 (idxmat.cols == 1 || idxmat.rows == 1) );
3961 const int* idx = idxmat.ptr<int>();
3962 int* dstlabels = 0;
3963
3964 int ptdims = points.cols;
3965 int i, nidx = (int)idxmat.total();
3966 if( nidx == 0 )
3967 {
3968 _pts.release();
3969 _labels.release();
3970 return;
3971 }
3972
3973 if( _pts.needed() )
3974 {
3975 _pts.create( nidx, ptdims, points.type());
3976 pts = _pts.getMat();
3977 }
3978
3979 if(_labels.needed())
3980 {
3981 _labels.create(nidx, 1, CV_32S, -1, true);
3982 labelsmat = _labels.getMat();
3983 CV_Assert( labelsmat.isContinuous() );
3984 dstlabels = labelsmat.ptr<int>();
3985 }
3986 const int* srclabels = !labels.empty() ? &labels[0] : 0;
3987
3988 for( i = 0; i < nidx; i++ )
3989 {
3990 int k = idx[i];
3991 CV_Assert( (unsigned)k < (unsigned)points.rows );
3992 const float* src = points.ptr<float>(k);
3993 if( pts.data )
3994 std::copy(src, src + ptdims, pts.ptr<float>(i));
3995 if( dstlabels )
3996 dstlabels[i] = srclabels ? srclabels[k] : k;
3997 }
3998}
3999
4000
4001const float* KDTree::getPoint(int ptidx, int* label) const

Callers

nothing calls this directly

Calls 8

neededMethod · 0.80
getMatMethod · 0.45
isContinuousMethod · 0.45
typeMethod · 0.45
totalMethod · 0.45
releaseMethod · 0.45
createMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected