本文整理汇总了C++中cv::Rect::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Rect::size方法的具体用法?C++ Rect::size怎么用?C++ Rect::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cv::Rect
的用法示例。
在下文中一共展示了Rect::size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: prepare
void prepare(cv::Rect dst_roi)
{
using namespace cv;
dst_roi_final_ = dst_roi;
// Crop unnecessary bands
double max_len = static_cast<double>(max(dst_roi.width, dst_roi.height));
num_bands_ = min(actual_num_bands_, static_cast<int>(ceil(log(max_len) / log(2.0))));
// Add border to the final image, to ensure sizes are divided by (1 << num_bands_)
dst_roi.width += ((1 << num_bands_) - dst_roi.width % (1 << num_bands_)) % (1 << num_bands_);
dst_roi.height += ((1 << num_bands_) - dst_roi.height % (1 << num_bands_)) % (1 << num_bands_);
Blender::prepare(dst_roi);
dst_pyr_laplace_.resize(num_bands_ + 1);
dst_pyr_laplace_[0] = dst_;
dst_band_weights_.resize(num_bands_ + 1);
dst_band_weights_[0].create(dst_roi.size(), weight_type_);
dst_band_weights_[0].setTo(0);
for (int i = 1; i <= num_bands_; ++i)
{
dst_pyr_laplace_[i].create((dst_pyr_laplace_[i - 1].rows + 1) / 2,
(dst_pyr_laplace_[i - 1].cols + 1) / 2, CV_16SC3);
dst_band_weights_[i].create((dst_band_weights_[i - 1].rows + 1) / 2,
(dst_band_weights_[i - 1].cols + 1) / 2, weight_type_);
dst_pyr_laplace_[i].setTo(Scalar::all(0));
dst_band_weights_[i].setTo(0);
}
}
示例2: Cluster
MatCluster::MatCluster(const std::vector<cv::Point> &points,
const cv::Rect &boundsInWhole,
std::vector<cv::Point> deepest,
int smoothing)
: Cluster(points.size(), boundsInWhole, deepest, smoothing),
mat(boundsInWhole.size())
{
mat.setTo(0);
for (vector<Point>::const_iterator it = points.begin(), itEnd = points.end();
it != itEnd; ++it)
mat(*it - offset) = 1;
}
示例3: TransformData
const ImageLandmarkDataPtr ImageTransformer::TransformData(const ImageLandmarkDataPtr& landmarkData,
const cv::Rect& activeRect,
const cv::Size& destSize,
bool shouldSaveNewImage)
{
double scaleFactor = (double)destSize.width / (double)activeRect.size().width;
// double scaleY = destSize.height / activeRect.size().height;
const cv::Point2i center(activeRect.x + activeRect.width / 2, activeRect.y + activeRect.height / 2);
cv::Mat transformMat = cv::getRotationMatrix2D(center, 0.f, scaleFactor);
const ImageLandmarkDataPtr newLandmarkData = TransformDataWithMat(landmarkData, transformMat, shouldSaveNewImage);
return newLandmarkData;
}
示例4: TransformCollectionUsingFaceCrop
const LandmarkCollectionDataPtr ImageTransformer::TransformCollectionUsingFaceCrop(const LandmarkCollectionDataPtr& collectionData)
{
LandmarkCollectionDataPtr newCollection(new LandmarkCollectionData(collectionData->CollectionSize()));
CascadeClassifier classifier;
collectionData->EnumerateConstColectionWithCallback([&] (const ImageLandmarkDataPtr& landmarkData, const int index, bool* stop) {
const cv::Rect activeRect = classifier.DetectFace(landmarkData->ImageSource());
if (activeRect.size().width != 0)
{
const ImageLandmarkDataPtr newData = TransformData(landmarkData, activeRect, {kImageSize, kImageSize}, true);
newCollection->AddImageLandmarkData(newData);
}
else
{
std::cout<<"Face not found: "<<landmarkData->ImagePath()<<std::endl;
}
std::cout<<index<<std::endl;
});
return newCollection;
}