本文整理汇总了C++中cv::Mat::locateROI方法的典型用法代码示例。如果您正苦于以下问题:C++ Mat::locateROI方法的具体用法?C++ Mat::locateROI怎么用?C++ Mat::locateROI使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cv::Mat
的用法示例。
在下文中一共展示了Mat::locateROI方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveCvMat
bool Utils::saveCvMat(const char* filename, const cv::Mat& image)
{
if (!filename || strlen(filename) == 0)
return false;
FILE* file = NULL;
#ifdef _WIN32
errno_t err = fopen_s(&file, filename, "wb");
if(!file || err) {
std::cerr << "could not create file: " << filename << std::endl;
return false;
}
#elif __APPLE__ & __MACH__
file = fopen(filename, "wb");
if(!file || ferror(file)) {
cerr << "could not create file: " << filename << endl;
return false;
}
#endif
// process roi information if available
cv::Size origSize = cv::Size(0, 0);
cv::Point startPoint = cv::Point(0, 0);
image.locateROI(origSize, startPoint);
int size = image.elemSize() * origSize.width * origSize.height;
// header size
const int headerSize = 3 * sizeof(char) +
10 * sizeof(int);
// write identification string
fwrite("CVM", sizeof(char), 3, file);
// write header
fwrite(&headerSize, sizeof(int), 1, file);
fwrite(&image.flags, sizeof(int), 1, file);
fwrite(&image.cols, sizeof(int), 1, file);
fwrite(&image.rows, sizeof(int), 1, file);
fwrite(&image.dims, sizeof(int), 1, file);
fwrite(&origSize.width, sizeof(int), 1, file);
fwrite(&origSize.height, sizeof(int), 1, file);
fwrite(&startPoint.x, sizeof(int), 1, file);
fwrite(&startPoint.y, sizeof(int), 1, file);
fwrite(&size, sizeof(int), 1, file);
// write data
fwrite(image.data, sizeof(uchar), size, file);
fclose(file);
return true;
}
示例2: DetectColorFaces
unsigned long PeopleDetector::DetectColorFaces(cv::Mat& img, std::vector<cv::Rect>& faceCoordinates)
{
IplImage imgPtr = (IplImage)img;
CvSeq* faces = cvHaarDetectObjects(&imgPtr, m_face_cascade, m_storage, m_faces_increase_search_scale, m_faces_drop_groups, CV_HAAR_DO_CANNY_PRUNING,
cvSize(m_faces_min_search_scale_x, m_faces_min_search_scale_y));
cv::Size parentSize;
cv::Point roiOffset;
for (int i = 0; i < faces->total; i++)
{
cv::Rect* face = (cv::Rect*)cvGetSeqElem(faces, i);
img.locateROI(parentSize, roiOffset);
face->x += roiOffset.x; // todo: check what happens if the original matrix is used without roi
face->y += roiOffset.y;
faceCoordinates.push_back(*face);
}
return ipa_Utils::RET_OK;
}
示例3: sideMatch
double BackgroundInitializationModule::sideMatch(cv::Mat ROI, cv::Mat block, bool isBlockImg)
{
double SM_metric = 0.0;
cv::Mat backup, vector;
uchar *ptr_vector;
cv::Size bgDimension;
cv::Point ROIloc;
bool growUp, growLeft, growRight, growBottom;
if(isBlockImg)
{
ROI.copyTo(backup);
block.copyTo(ROI);
}
ROI.locateROI(bgDimension, ROIloc);
growUp = (ROIloc.y - 1 < 0)? false: true ;
growLeft = (ROIloc.x - 1 < 0)? false: true ;
growRight = (ROIloc.x + sizeBlock + 1 >= bgDimension.width)? false: true ;
growBottom = (ROIloc.y + sizeBlock + 1 >= bgDimension.width)? false: true ;
ROI.adjustROI(1,1,1,1); //grow 1 pixel in every direction
if(growUp)
{
vector = block.row(0) - block.row(1);
vector = vector.mul(vector);
ptr_vector = vector.data;
for(int i = 0; i < vector.rows*vector.cols; i++)
SM_metric += ptr_vector[i];
}
if(growLeft)
{
vector = block.row(0) - block.row(1);
vector = vector.mul(vector);
ptr_vector = vector.data;
for(int i = 0; i < vector.rows*vector.cols; i++)
SM_metric += ptr_vector[i];
}
if(growRight)
{
vector = block.row(0) - block.row(1);
vector = vector.mul(vector);
ptr_vector = vector.data;
for(int i = 0; i < vector.rows*vector.cols; i++)
SM_metric += ptr_vector[i];
}
if(growBottom)
{
vector = block.row(0) - block.row(1);
vector = vector.mul(vector);
ptr_vector = vector.data;
for(int i = 0; i < vector.rows*vector.cols; i++)
SM_metric += ptr_vector[i];
}
if(isBlockImg)
backup.copyTo(ROI);
return SM_metric;
}
示例4: ippiGetImage
static inline void ippiGetImage(const cv::Mat &src, ::ipp::IwiImage &dst)
{
::ipp::IwiBorderSize inMemBorder;
if(src.isSubmatrix()) // already have physical border
{
cv::Size origSize;
cv::Point offset;
src.locateROI(origSize, offset);
inMemBorder.left = (IwSize)offset.x;
inMemBorder.top = (IwSize)offset.y;
inMemBorder.right = (IwSize)(origSize.width - src.cols - offset.x);
inMemBorder.bottom = (IwSize)(origSize.height - src.rows - offset.y);
}
dst.Init(ippiSize(src.size()), ippiGetDataType(src.depth()), src.channels(), inMemBorder, (void*)src.ptr(), src.step);
}