本文整理汇总了C++中Mat::assignTo方法的典型用法代码示例。如果您正苦于以下问题:C++ Mat::assignTo方法的具体用法?C++ Mat::assignTo怎么用?C++ Mat::assignTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mat
的用法示例。
在下文中一共展示了Mat::assignTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readDatabase
bool ObjectRecognition::readDatabase(const string& dir, vector<Mat>& databaseDescriptors, vector<string>& files)
{
TickMeter tm;
tm.start();
getdir(dir,files);
string outString = "Start Reading Directory.png";
cout << outString << endl;
string extention = ".png";
vector<string>::iterator it = files.begin();
for (unsigned int i = 0;i < files.size();i++)
{
if ( files[i].size() > 4 && files[i].compare( files[i].size() - 4, 4 , extention) == 0)
{
Mat img = imread( dir + files[i] , CV_LOAD_IMAGE_GRAYSCALE );
//if( img.empty() ) cout << "Database descriptor " << files[i] << " can not be read or has no information." << endl;
//cout << files[i] << "\tRows" << img.rows << "\t Cols" << img.cols << "\t Type/Depth: " << img.depth() << endl;
img.assignTo(img, 5);
databaseDescriptors.push_back( img );
}
it++;
}
tm.stop();
cout << "End reading directory in " << tm.getTimeMilli() << " ms, of size " << DB.size() << endl;
return true;
}
示例2: applyMask
Mat applyMask(const Mat &image, int *mask, int maskSize) {
// Applies generic 3x3 mask on image
Mat blur;
image.assignTo(blur, CV_32S);
for (int row = maskSize / 2; row < image.rows - maskSize / 2; row++) {
for (int col = maskSize / 2; col < image.cols - maskSize / 2; col++) {
// Gets the value of an applied mask of size 3x3
short val = 0;
for (int m = 0; m < maskSize; m++) {
for (int n = 0; n < maskSize; n++) {
int r = row+m - 1,
c = col+n - 1;
val += mask[maskSize*m + n] * image.at<uchar>(r, c);
}
}
blur.at<int>(row, col) = val;
}
}
double mn, mx;
minMaxLoc(blur, &mn, &mx);
cout << "Max: " << mx << endl;
cout << "Min: " << mn << endl;
cout << "Scale factor: " << 255 / (mx-mn) << endl;
blur -= mn;
blur.convertTo(blur, CV_8U, 255 / (mx-mn));
return blur;
}
示例3: read_frame
bool ImageFileListSequence::read_frame(Mat& img)
{
if (current_frame < size())
{
DEBUGMSG("Reading image file '%s'\n", files[current_frame + file_start - 1].c_str());
Mat tmp = imread(files[current_frame + file_start - 1].c_str());
if (tmp.empty())
{
img.release();
return false;
}
if (sequence_width == img.cols && sequence_height == img.rows)
{
tmp.assignTo(img);
}
else resize(tmp, img, cv::Size(sequence_width, sequence_height));
}
else img.release();
if (!img.empty())
current_frame++;
return !img.empty();
}