本文整理汇总了C++中Mat_d::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ Mat_d::empty方法的具体用法?C++ Mat_d::empty怎么用?C++ Mat_d::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mat_d
的用法示例。
在下文中一共展示了Mat_d::empty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getScaledNCCBlocks
void getScaledNCCBlocks(const ImgG& scaledImg, double scale,
const Mat_d& featpts, PtrVec<NCCBlock>& nccBlks) {
if (featpts.empty())
return;
int npts = (int) featpts.m;
nccBlks.clear();
nccBlks.reserve(npts * 2);
for (int i = 0; i < npts; i++) {
NCCBlock* blk = new NCCBlock();
getScaledNCCBlock(scaledImg, scale, featpts.data[2 * i],
featpts.data[2 * i + 1], *blk);
nccBlks.push_back(blk);
}
}
示例2: getNCCBlocks
void getNCCBlocks(const ImgG& scaledImg, Mat_d& pts, PtrVec<NCCBlock>& nccBlks,
double scale) {
if (pts.empty())
return;
nccBlks.clear();
nccBlks.reserve(pts.rows * 2);
int bw = 2 * SL_NCCBLK_HW + 1;
if (scale == 1.0) {
cv::Mat cvImg(scaledImg.rows, scaledImg.cols, CV_8UC1, scaledImg.data);
cv::Size patchSize(bw, bw);
cv::Mat patch;
for (int i = 0; i < pts.rows; i++) {
double x = pts.data[2 * i];
double y = pts.data[2 * i + 1];
cv::getRectSubPix(cvImg, patchSize, cv::Point2d(x, y), patch);
NCCBlock* blk = new NCCBlock(0);
/* copy image block */
for (int j = 0; j < SL_NCCBLK_LEN; ++j) {
blk->I[j] = patch.data[j];
}
/* compute NCC parameters */
double a = 0, b = 0;
blk->avgI = 0;
for (int j = 0; j < SL_NCCBLK_LEN; ++j) {
a += blk->I[j];
b += double(blk->I[j]) * blk->I[j];
blk->avgI += blk->I[j];
}
blk->A = a;
blk->B = b;
blk->C = 1 / sqrt(SL_NCCBLK_LEN * b - a * a);
blk->avgI /= SL_NCCBLK_LEN;
nccBlks.push_back(blk);
}
} else {
cv::Mat cvOrgImg(scaledImg.rows, scaledImg.cols, CV_8UC1,
scaledImg.data);
cv::Mat cvImg;
cv::resize(cvOrgImg, cvImg, cv::Size(), scale, scale);
cv::Size patchSize(bw, bw);
cv::Mat patch;
for (int i = 0; i < pts.rows; i++) {
double x = pts.data[2 * i] * scale;
double y = pts.data[2 * i + 1] * scale;
cv::getRectSubPix(cvImg, patchSize, cv::Point2d(x, y), patch);
NCCBlock* blk = new NCCBlock(0);
/* copy image block */
for (int j = 0; j < SL_NCCBLK_LEN; ++j) {
blk->I[j] = patch.data[j];
}
/* compute NCC parameters */
double a = 0, b = 0;
blk->avgI = 0;
for (int j = 0; j < SL_NCCBLK_LEN; ++j) {
a += blk->I[j];
b += double(blk->I[j]) * blk->I[j];
blk->avgI += blk->I[j];
}
blk->A = a;
blk->B = b;
blk->C = 1 / sqrt(SL_NCCBLK_LEN * b - a * a);
blk->avgI /= SL_NCCBLK_LEN;
nccBlks.push_back(blk);
}
}
}