本文整理汇总了C++中cv::Mat::reserve方法的典型用法代码示例。如果您正苦于以下问题:C++ Mat::reserve方法的具体用法?C++ Mat::reserve怎么用?C++ Mat::reserve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cv::Mat
的用法示例。
在下文中一共展示了Mat::reserve方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createColorMapImage
/**
* Filters the given image using the QuadcopterColor.
* The result is written to mapImage. White pixels mean in range,
* black pixels mean out of range.
*
* @param image The raw image.
* @param mapImage The resulting mapped image. (Output array)
* @param hsvImage The raw image in hsv format. (Output array)
*/
cv::Mat Tracker::createColorMapImage(cv::Mat &image, cv::Mat &mapImage, cv::Mat &hsvImage)
{
START_CLOCK(convertColorClock)
// This ensures that the mapImage has a buffer.
// Since the buffer is never freed during tracking, this only allocates memory once.
mapImage.reserve(480);
cv::cvtColor(image, hsvImage, CV_BGR2HSV);
STOP_CLOCK(convertColorClock, "Converting colors took: ")
START_CLOCK(maskImageClock)
uint8_t * current, *end, *source;
int minHue, maxHue, minSaturation, minValue;
QuadcopterColor *color = (QuadcopterColor*) qc;
minHue = color->getMinColor().val[0];
maxHue = color->getMaxColor().val[0];
minSaturation = color->getMinColor().val[1];
minValue = color->getMinColor().val[2];
end = mapImage.data + mapImage.size().width * mapImage.size().height;
source = hsvImage.data;
if (minHue < maxHue)
for (current = mapImage.data; current < end; ++current, source += 3) {
if (*source > maxHue || *source < minHue || *(source + 1) < minSaturation || *(source + 2) < minValue)
*current = 0;
else
*current = 255;
}
else
// Hue interval inverted here.
for (current = mapImage.data; current < end; ++current, source += 3) {
if ((*source > maxHue && *source < minHue) || *(source + 1) < minSaturation || *(source + 2) < minValue)
*current = 0;
else
*current = 255;
}
STOP_CLOCK(maskImageClock, "Image masking took: ")
return mapImage;
}