本文整理汇总了C++中cv::Mat_::row方法的典型用法代码示例。如果您正苦于以下问题:C++ Mat_::row方法的具体用法?C++ Mat_::row怎么用?C++ Mat_::row使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cv::Mat_
的用法示例。
在下文中一共展示了Mat_::row方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: splitIntoPositiveAndNegativeClasses
// static
void CrossValidator::splitIntoPositiveAndNegativeClasses( const cv::Mat_<float>& xs, const cv::Mat_<int>& labels,
vector<cv::Mat_<float> >& pset,
vector<cv::Mat_<float> >& nset)
{
const int *labsVec = labels.ptr<int>(0);
for ( int i = 0; i < xs.rows; ++i)
{
assert( labsVec[i] == 0 || labsVec[i] == 1);
if (labsVec[i] == 1)
pset.push_back(xs.row(i));
else if (labsVec[i] == 0)
nset.push_back(xs.row(i));
} // end for
} // end splitIntoPositiveAndNegativeClasses
示例2: encode
void EncoderBoFSoft::encode(const cv::Mat_<float>& descriptors, cv::Mat_<float>& encoded)
{
int ndata = descriptors.rows;
int ndim = descriptors.cols;
if ( ndim != this->_m_nDim)
{
throw std::runtime_error("dimension not match when encode");
}
encoded.create(ndata,this->_m_nCode);
encoded.setTo(0.0f);
//encoded.zeros(ndata,this->_m_nCode);
#pragma omp parallel for
for(int i=0;i<ndata;i++)
{
Mat index,dist;
this->_m_pTree->findNearest(descriptors.row(i),_m_nz,INT_MAX,index,noArray(),dist);
Scalar mean,std;
cv::meanStdDev(dist,mean,std);
cv::divide(std(0),dist,dist);
for(int j=0;j<_m_nz;j++)
{
encoded(i,index.at<int>(j)) = dist.at<float>(j);
}
}
}
示例3: AddDescriptor
void AddDescriptor(cv::Mat_<double>& descriptors, cv::Mat_<double> new_descriptor, int curr_frame, int num_frames_to_keep)
{
if(descriptors.empty())
{
descriptors = Mat_<double>(num_frames_to_keep, new_descriptor.cols, 0.0);
}
int row_to_change = curr_frame % num_frames_to_keep;
new_descriptor.copyTo(descriptors.row(row_to_change));
}
示例4: throw
cv::Mat_<float> DescriptorJoiner::loadDescriptors( const string& dfile, int* label) throw (DescriptorLengthException)
{
const cv::Mat_<float> vecs = RFeatures::readDescriptors( dfile, false);
const int numVecs = vecs.rows;
const int lab = (int)_labCounts.size(); // Label for these desciptors
_labCounts.push_back(numVecs); // Store the number of descriptors for this class label (vector index)
// Add vecs to _xs
for ( int i = 0; i < numVecs; ++i)
{
_xs.push_back( vecs.row(i));
_labs.push_back(lab);
} // end for
return vecs.clone();
} // end loadDescriptors
示例5: randomGaussianBlobs
cv::Mat_<int> labels;
randomGaussianBlobs(3, 20, 2, 0.4f, centers, features, labels, -10.f, 10.f);
cv::Mat_<float> msCenters;
cv::Mat_<int> msLabels;
// We use weights here just for the purpose implicitly sort the cluster results
// the same way we provide the inputs.
cv::Mat_<float> msWeights(1, features.rows);
msWeights.colRange(0, 20).setTo(2);
msWeights.colRange(20, 40).setTo(1);
msWeights.colRange(40, 60).setTo(0.5);
// Note, 300 iterations are way too much, 5-10 suffice. Tests binning as well.
meanShift(features, cv::noArray(), msWeights, msCenters, msLabels, cv::noArray(), 1.2f, 300);
REQUIRE(msCenters.rows == 3);
REQUIRE(cv::norm(centers, msCenters) < 1);
REQUIRE(cv::countNonZero(msLabels == 0) == 20);
REQUIRE(cv::countNonZero(msLabels == 1) == 20);
REQUIRE(cv::countNonZero(msLabels == 2) == 20);
// Run again, but provide just one center;
cv::Mat_<float> oneCenter(1, 2);
oneCenter << 12, 12;
meanShift(features, oneCenter, msWeights, msCenters, msLabels, cv::noArray(), 3.0f, 300);
REQUIRE(msCenters.rows == 1);
REQUIRE(cv::norm(centers.row(0), msCenters) < 1);
}