当前位置: 首页>>代码示例>>C++>>正文


C++ Mat::reserve方法代码示例

本文整理汇总了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;
}
开发者ID:KITrokopter,项目名称:Camera-Application,代码行数:55,代码来源:Tracker.cpp


注:本文中的cv::Mat::reserve方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。