• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ cv::RNG类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中cv::RNG的典型用法代码示例。如果您正苦于以下问题:C++ RNG类的具体用法?C++ RNG怎么用?C++ RNG使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了RNG类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: RenderContourBounds

void RenderContourBounds(CVPipeline * pipe)
{
	rng = cv::RNG(5553);
	for (int i = 0; i < pipe->contours.Size(); ++i)
	{
		CVContour * contour = &pipe->contours[i];
		cv::Scalar color;
		switch(contour->contourClass)
		{
			case ContourClass::FINGERTIP: 
				color = cv::Scalar(255, 0, 0);	
				break;
			case ContourClass::FINGER: 
				color = cv::Scalar(0, 255, 0);	
				break;
			default: color = cv::Scalar(rng.uniform(0,225), rng.uniform(0,225), rng.uniform(0,255));
		}
		switch(contour->boundingType)
		{
			case BoundingType::ELLIPSE:
				// ellipse
				ellipse(pipe->output, contour->boundingEllipse, color, 2, 8 );
				break;
			case BoundingType::RECT: 
			{
				// rotated rectangle
				cv::Point2f rect_points[4]; 
				contour->boundingRect.points( rect_points );
				for( int j = 0; j < 4; j++ )
					line(pipe->output, rect_points[j], rect_points[(j+1)%4], color, 1, 8 );
				break;
			}
		}
	}
}
开发者ID:erenik,项目名称:engine,代码行数:35,代码来源:CVDataFilters.cpp


示例2: RenderPolygons

void RenderPolygons(CVPipeline * pipe)
{
	/// Use same random seed every time to avoid rainbow hell..
	rng = cv::RNG(12345);
	for (int i = 0; i < pipe->approximatedPolygons.size(); ++i)
	{			
		cv::Scalar color = cv::Scalar(rng.uniform(0,255), rng.uniform(0,255), rng.uniform(0,255));
		cv::drawContours(pipe->output, pipe->approximatedPolygons, i, color, 2, 8, pipe->contourHierarchy, 0, cv::Point());
	}
}
开发者ID:erenik,项目名称:engine,代码行数:10,代码来源:CVDataFilters.cpp


示例3: rng

void DataProviderDTang<Dtype>::shuffle() {
  static cv::RNG rng(time(0));
                                  
  std::vector<boost::filesystem::path> shuffled_depth_paths(depth_paths_.size());
  std::vector<std::vector<cv::Vec3f> > shuffled_annos(annos_.size());
  
  for(size_t idx = 0; idx < depth_paths_.size(); ++idx) {
    int rand_idx = rng.uniform(0, depth_paths_.size());
    shuffled_depth_paths[idx] = depth_paths_[rand_idx];
    shuffled_annos[idx] = annos_[rand_idx];
  }
  
  depth_paths_ = shuffled_depth_paths;
  annos_ = shuffled_annos;
}
开发者ID:devkicks,项目名称:handpose,代码行数:15,代码来源:data_provider_dtang.cpp


示例4: RenderContours

void RenderContours(CVPipeline * pipe)
{
	/// Use same random seed every time to avoid rainbow hell..
	rng = cv::RNG(12345);
	for (int i = 0; i < pipe->contours.Size(); ++i)
	{			
		CVContour * contour = &pipe->contours[i];
		if (contour->segments.Size())
			RenderContourSegments(contour, pipe);
		else 
		{
			cv::Scalar color = cv::Scalar(rng.uniform(0,255), rng.uniform(0,255), rng.uniform(0,255));
			cv::drawContours(pipe->output, pipe->cvContours, i, color, 2, 8, pipe->contourHierarchy, 0, cv::Point());
		}
	}
}
开发者ID:erenik,项目名称:engine,代码行数:16,代码来源:CVDataFilters.cpp


示例5: warpPerspectiveRand

cv::Mat PerspectiveTransform::warpPerspectiveRand( cv::RNG& rng )
{
    cv::Mat H;
    
    H.create(3, 3, CV_64FC1);
    H.at<double>(0,0) = rng.uniform( 0.8f, 1.2f);
    H.at<double>(0,1) = rng.uniform(-0.1f, 0.1f);
    //H.at<double>(0,2) = rng.uniform(-0.1f, 0.1f)*src.cols;
    H.at<double>(0,2) = rng.uniform(-0.1f, 0.1f);
    H.at<double>(1,0) = rng.uniform(-0.1f, 0.1f);
    H.at<double>(1,1) = rng.uniform( 0.8f, 1.2f);
    //H.at<double>(1,2) = rng.uniform(-0.1f, 0.1f)*src.rows;
    H.at<double>(1,2) = rng.uniform(-0.1f, 0.1f);
    H.at<double>(2,0) = rng.uniform( -1e-4f, 1e-4f);
    H.at<double>(2,1) = rng.uniform( -1e-4f, 1e-4f);
    H.at<double>(2,2) = rng.uniform( 0.8f, 1.2f);

    return H;
}
开发者ID:dongbi,项目名称:OpenCV-Features-Comparison,代码行数:19,代码来源:ImageTransformation.cpp


示例6: getDistortionValues

    void getDistortionValues(cv::RNG &rng, const Size2i &inputSize, AugParams *agp) {
        // This function just gets the random distortion values without modifying the
        // image itself.  Useful if we need to reapply the same transformations over
        // again (e.g. for all frames of a video or for a corresponding target mask)

        // colornoise values
        // N.B. if _contrastMax == 100, then _colorNoiseStd will be 0.0
        for (int i=0; i<3; i++) {
            agp->colornoise[i] = rng.gaussian(_colorNoiseStd);
        }

        // contrast, brightness, saturation
        // N.B. all value ranges tied to _contrastMin and _contrastMax
        for (int i=0; i<3; i++) {
            agp->cbs[i] = rng.uniform(_contrastMin, _contrastMax) / 100.0f;
        }

        /**************************
        *  HORIZONTAL FLIP        *
        ***************************/
        agp->flip = _flip && rng(2) != 0  ? true : false;

        /**************************
        *  ROTATION ANGLE         *
        ***************************/
        agp->angle = rng.uniform(_rotateMin, _rotateMax);

        /**************************
        *  CROP BOX               *
        ***************************/
        float shortSide = std::min(inputSize.height, inputSize.width);

        // Special case where we just grab the whole image;
        if (_scaleMin == 0) {
            agp->cropBox = Rect(Point2i(), inputSize);
            return;
        }

        if (_center) {
            agp->cropBox.width = shortSide * _width / (float) _scaleMin;
            agp->cropBox.height = shortSide * _height / (float) _scaleMin;
            agp->cropBox.x = (inputSize.width - agp->cropBox.width) / 2;
            agp->cropBox.y = (inputSize.height - agp->cropBox.height) / 2;
        } else {
            cv::Size2f oSize = inputSize;

            // This is a hack for backward compatibility.
            // Valid aspect ratio range ( > 100) will override side scaling behavior
            if (_aspectRatio == 0) {
                float scaleFactor = rng.uniform(_scaleMin, _scaleMax);
                agp->cropBox.width = shortSide * _width / scaleFactor;
                agp->cropBox.height = shortSide * _height / scaleFactor;
            } else {
                float mAR = (float) _aspectRatio / 100.0f;
                float nAR = rng.uniform(1.0f / mAR, mAR);
                float oAR = oSize.width / oSize.height;
                // between minscale pct% to 100% subject to aspect ratio limitation
                float maxScale = nAR > oAR ? oAR / nAR : nAR / oAR;
                float minScale = std::min((float) _scaleMin / 100.0f, maxScale);
                float tgtArea = rng.uniform(minScale, maxScale) * oSize.area();

                agp->cropBox.height = sqrt(tgtArea / nAR);
                agp->cropBox.width = agp->cropBox.height * nAR;
            }

            agp->cropBox.x = rng.uniform(0, inputSize.width - agp->cropBox.width);
            agp->cropBox.y = rng.uniform(0, inputSize.height - agp->cropBox.height);

        }
        return;
    }
开发者ID:SmartPlanetInternational,项目名称:neon,代码行数:71,代码来源:image.hpp


示例7: RGB

void CVDataFilter::Paint(CVPipeline * pipe)
{
	if (returnType == CVReturnType::QUADS)
	{
		// Draw quads.
		if (!pipe->quads.Size())
			return;
		// Copy original input
		pipe->initialInput.copyTo(pipe->output);
		// Convert to color if needed.
		int channelsBefore = pipe->output.channels();
		if (channelsBefore == 1)
		{
		//	pipe->output.convertTo(pipe->output, CV_8UC3);
			cv::cvtColor(pipe->output, pipe->output, CV_GRAY2RGB);
		}
		int channelsAfter = pipe->output.channels();
		// o.o Paste!
		for (int i = 0; i < pipe->quads.Size(); ++i)
		{
			Quad quad = pipe->quads[i];
	#define RGB(r,g,b) cv::Scalar(b,g,r)
			rng = cv::RNG(1344);
			cv::Scalar color = RGB(rng.uniform(0, 255),rng.uniform(0, 255),rng.uniform(0, 255));
		//	cv::Mat rectImage = cv::Mat::zeros(pipe->output.size(), CV_8UC3);
			cv::rectangle(pipe->output, cv::Point(quad.point1.x, quad.point1.y), cv::Point(quad.point3.x, quad.point3.y), color, CV_FILLED);
			float alpha = 0.2f;
			float beta = 1 - alpha;
		//	cv::addWeighted(rectImage, alpha, pipe->output, beta, 0.0, pipe->output); 
		//	rectImage.copyTo(pipe->output);		
		}
	}
	else if (returnType == CVReturnType::APPROXIMATED_POLYGONS)
	{
		// Copy original input..
		pipe->initialInput.copyTo(pipe->output);
		RenderPolygons(pipe);
	}
	else if (returnType == CVReturnType::CV_IMAGE)
	{
		// Do nothing as the image should already be in the ouput matrix of the pipeline.
	}
	else if (returnType == CVReturnType::LINES ||
		returnType == CVReturnType::CV_LINES)
	{
		// Convert the color to colors again for visualization...
		pipe->initialInput.copyTo(pipe->output);
		for( size_t i = 0; i < pipe->lines.Size(); i++ )
		{
			Line & line = pipe->lines[i];
			// Multiply the line coordinates with the last used inverted scale.
			line.start *= pipe->currentScaleInv;
			line.stop *= pipe->currentScaleInv;

			cv::line( pipe->output, cv::Point(line.start.x, line.start.y),
				cv::Point(line.stop.x, line.stop.y), cv::Scalar(0,0,255), 3, 8 );
		}
	}
	else if (returnType == CVReturnType::CV_CONTOURS)
	{
		pipe->initialInput.copyTo(pipe->output);
		RenderContours(pipe);
	}

	switch(returnType)
	{
		case CVReturnType::CV_CONTOUR_SEGMENTS:
		{
			// Render shit!
			pipe->initialInput.copyTo(pipe->output);
			RenderContourSegments(pipe);
			break;
		}
	}

	if (returnType == CVReturnType::CV_CONTOUR_ELLIPSES)
	{
		pipe->initialInput.copyTo(pipe->output);
		RenderContours(pipe);
		RenderContourBounds(pipe);
	}
	else if (returnType == CVReturnType::CV_CONVEX_HULLS)
	{
		pipe->initialInput.copyTo(pipe->output);
		RenderContours(pipe);
		RenderConvexHulls(pipe);
	}
	else if (returnType == CVReturnType::CV_CONVEXITY_DEFECTS)
	{
		pipe->initialInput.copyTo(pipe->output);
		RenderContours(pipe);
		RenderConvexHulls(pipe);
		RenderConvexityDefects(pipe);
	}
	else if (returnType == CVReturnType::HANDS)
	{
		// Convert image to RGB for easier display
		int channelsBefore = pipe->initialInput.channels();
	//	cv::cvtColor(*pipe->initialInput, pipe->output, CV_GRAY2RGB);
		pipe->initialInput.copyTo(pipe->output);
//.........这里部分代码省略.........
开发者ID:erenik,项目名称:engine,代码行数:101,代码来源:CVDataFilters.cpp


示例8: PERF_TEST_P

PERF_TEST_P(Size_Dp_MinDist, OCL_HoughCircles,
            testing::Combine(
                testing::Values(perf::sz720p, perf::szSXGA, perf::sz1080p),
                testing::Values(1.0f, 2.0f, 4.0f),
                testing::Values(1.0f, 10.0f)))
{
    const cv::Size size = std::tr1::get<0>(GetParam());
    const float dp      = std::tr1::get<1>(GetParam());
    const float minDist = std::tr1::get<2>(GetParam());

    const int minRadius = 10;
    const int maxRadius = 30;
    const int cannyThreshold = 100;
    const int votesThreshold = 15;

    cv::RNG rng(123456789);

    cv::Mat src(size, CV_8UC1, cv::Scalar::all(0));

    const int numCircles = rng.uniform(50, 100);
    for (int i = 0; i < numCircles; ++i)
    {
        cv::Point center(rng.uniform(0, src.cols), rng.uniform(0, src.rows));
        const int radius = rng.uniform(minRadius, maxRadius + 1);

        cv::circle(src, center, radius, cv::Scalar::all(255), -1);
    }

    cv::ocl::oclMat ocl_src(src);
    cv::ocl::oclMat ocl_circles;
开发者ID:406089450,项目名称:opencv,代码行数:30,代码来源:perf_hough.cpp


示例9: randomMat

 Mat randomMat(Size size, int type, double minVal, double maxVal, bool useRoi = false)
 {
     RNG dataRng(rng.next());
     return cvtest::randomMat(dataRng, size, type, minVal, maxVal, useRoi);
 }
开发者ID:Aspie96,项目名称:opencv,代码行数:5,代码来源:ocl_test.hpp


示例10: randomScalar

static cv::Scalar randomScalar() {
   static cv::RNG rng(12345);
   return cv::Scalar(rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255));
}
开发者ID:KubaO,项目名称:stackoverflown,代码行数:4,代码来源:main.cpp


示例11: extractPatch

void extractPatch(cv::Mat &img, 
				  int *hull,
				  int bbW,
				  int bbH,
				  unsigned char filledColor,
				  cv::RNG &rng,
				  double noise,
				  double angle,
				  double shift,
				  double scale,
				  cv::Mat & noiseM,
				  cv::Mat &result) {

	int cpX         = (hull[0] + hull[2]) / 2;
	int cpY         = (hull[1] + hull[3]) / 2;
	cv::Mat h       = cv::Mat::eye(3, 3, CV_64FC1);
	cv::Mat temp    = cv::Mat::eye(3, 3, CV_64FC1);
	double *tempPtr = temp.ptr<double>();
	double sc;
	double ang, ca, sa;
	double shR, shC;
	double xMin, yMin, xMax, yMax;
	unsigned char *resPtr;
	double *noisePtr;
	int size;

	
	//****Translating...
	shR  = shift * bbH * (rng.uniform(1e-4, 1.)-0.5);
	shC  = shift * bbW * (rng.uniform(1e-4, 1.)-0.5);
	*(tempPtr + 2)             = shC;
	*(tempPtr + temp.cols + 2) = shR;
	h                          *= temp;
	//Reset...
	*(tempPtr + 2)              = 0.0;
	*(tempPtr +  temp.cols + 2) = 0.0;

	//****Rotating...
	ang  = 2 * CV_PI / 360.0 * angle * (rng.uniform(1e-4, 1.)-0.5);
	ca   = cos(ang);
    sa   = sin(ang);
	*tempPtr                   = ca;
	*(tempPtr + 1)             = -sa;
	*(tempPtr + temp.cols)     = sa;
	*(tempPtr + temp.cols + 1) = ca;
	h                          *= temp;
	//Reset...
	*tempPtr                   = 1.0;
	*(tempPtr + 1)             = 0.0;
	*(tempPtr + temp.cols)     = 0.0;
	*(tempPtr + temp.cols + 1) = 1.0;
	
	//****Scaling...
	sc   = 1.0 - scale*(rng.uniform(1e-4, 1.)-0.5);
	*tempPtr                   = (double)sc;
	*(tempPtr + temp.cols + 1) = (double)sc;
	h                          *= temp;
	//Reset...
	*tempPtr                   = 1.0;
	*(tempPtr + temp.cols + 1) = 1.0;
	
	//****Shifting Center of BB to (0, 0)...
	*(tempPtr + 2)             = -cpX;
	*(tempPtr + temp.cols + 2) = -cpY;
	h                          *= temp;
	
	//Now Warp the Patch...
	bbW--; 
	bbH--;
	xMin = -bbW / 2.0;
	yMin = -bbH / 2.0;
	xMax = bbW / 2.0;
	yMax = bbH / 2.0;
	warpImageROI(img,
				 xMin,
				 yMin,
				 xMax,
				 yMax,
				 bbW,
				 bbH,
				 h,
				 filledColor,
				 result.data);

	//Add Random Noise...
	rng.fill(noiseM, 
		     cv::RNG::NORMAL, 
			 cv::Mat::zeros(1,1,CV_64FC1), 
			 cv::Mat::ones(1,1,CV_64FC1));
	noiseM *= noise;
	//Here OpenCV Applies Saturation Arithmetic by Itself...
	cv::add(result, noise, result, cv::noArray(), CV_8UC1);
}
开发者ID:CGAnderson,项目名称:htld,代码行数:93,代码来源:PPatchGenerator.cpp


示例12: Plane

 Plane()
 {
     n[0] = rng.uniform(-0.5, 0.5);
     n[1] = rng.uniform(-0.5, 0.5);
     n[2] = -0.3; //rng.uniform(-1.f, 0.5f);
     n = n / cv::norm(n);
     set_d(rng.uniform(-2.0, 0.6));
 }
开发者ID:nlyubova,项目名称:opencv_candidate,代码行数:8,代码来源:test_normal.cpp


示例13: clamp

const cv::Vec3b Brush::get_color(const cv::Point center, const cv::Mat& reference_image, const Style& style) const {
    cv::Vec3b color = reference_image.at<cv::Vec3b>(center);
    color[0] = clamp(color[0] + color[0] * (rng.uniform(-0.5, 0.5) * style.blue_jitter()));
    color[1] = clamp(color[1] + color[1] * (rng.uniform(-0.5, 0.5) * style.green_jitter()));
    color[2] = clamp(color[2] + color[2] * (rng.uniform(-0.5, 0.5) * style.red_jitter()));
    cv::cvtColor(color, color, CV_RGB2HSV);
    color[0] = clamp(color[0] + color[0] * (rng.uniform(-0.5, 0.5) * style.hue_jitter()));
    color[1] = clamp(color[1] + color[1] * (rng.uniform(-0.5, 0.5) * style.saturation_jitter()));
    color[2] = clamp(color[2] + color[2] * (rng.uniform(-0.5, 0.5) * style.value_jitter()));
    cv::cvtColor(color, color, CV_HSV2RGB);
    return color;
}
开发者ID:twentylemon,项目名称:painterly,代码行数:12,代码来源:Brush.cpp


示例14: cannyDetector

void cannyDetector(cv::Mat src, cv::Mat &imgMap)
{

	/*Obsolete version for detection of colored contours... date : 	*/

	int ratio = 3;
	int kernel_size = 3;
	cv::Mat srcGray, srcHsv, cannyOutput;
	std::vector<std::vector<cv::Point> > contours;

	// from color to gray
	cv::cvtColor(src, srcGray, cv::COLOR_BGR2GRAY);
	// from color to hsv
	cv::cvtColor(src, srcHsv, cv::COLOR_BGR2HSV); 

	/// Reduce noise with a kernel 3x3
	cv::blur( srcGray, srcGray, cv::Size(3,3) );

	/// Canny detector
	cv::Canny( srcGray, cannyOutput, lowThreshold, lowThreshold*ratio, kernel_size );

	/// Find contours
	cv::findContours(cannyOutput, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);

	// Select orange contours
	imgMap = cv::Mat::zeros( srcGray.size(), srcGray.type() );
	cv::Rect bRect = cv::Rect(0,0,0,0);
	for( int i = 0; i< contours.size(); i++ )
	{
		if (cv::contourArea(contours[i]) > 0.00001*src.rows*src.cols)
		{
			bRect = cv::boundingRect(contours[i]);
			cv::inRange(srcHsv(bRect), cv::Scalar(h_min,50,50), cv::Scalar(h_max,255,255), imgMap(bRect));
		}
	}
	cv::erode(imgMap, imgMap, getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(1, 1)));
	cv::dilate(imgMap, imgMap, getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(3, 3)));

	//Draw contours
	cv::Mat drawing = cv::Mat::zeros( cannyOutput.size(), CV_8UC3 );
	for( int i = 0; i< contours.size(); i++ )
	{
		cv::Scalar color = cv::Scalar( rng.uniform(0, 255), rng.uniform(0,255), rng.uniform(0,255) );
		drawContours( drawing, contours, i, cv::Scalar(0,0,255), 1, 8);
	}
	/*// Show in a window
	cv::namedWindow( "Contours", CV_WINDOW_AUTOSIZE );
	cv::imshow( "Contours", drawing );
	cv::namedWindow( "imgMap", CV_WINDOW_AUTOSIZE );
	cv::imshow( "imgMap", imgMap );*/
	
}
开发者ID:LaboratoireCosmerTOULON,项目名称:turtlebot_visual_servoing,代码行数:52,代码来源:workingTurtle.cpp


示例15: RenderConvexityDefects

void RenderConvexityDefects(CVPipeline * pipe)
{
	cv::Scalar color = cv::Scalar(rng.uniform(155,255), rng.uniform(125,255), rng.uniform(0,200));
	List<cv::Vec4i> defects = pipe->convexityDefects;
	for (int i = 0; i < defects.Size(); ++i)
	{
		cv::Vec4i defect = defects[i];
		int farthestPointIndex = defect[2];
		cv::Point farthestPoint = pipe->cvContours[0][farthestPointIndex];
		// Render point furthest away?
		cv::circle(pipe->output, farthestPoint, 3, color, 5);
	}
}
开发者ID:erenik,项目名称:engine,代码行数:13,代码来源:CVDataFilters.cpp


示例16: myShiTomasi_function

void CornerDetection::myShiTomasi_function(cv::Mat img, cv::Mat img_gray, cv::Mat myShiTomasi_dst)
{
	myShiTomasi_copy = img.clone();

	if( myShiTomasi_qualityLevel < 1 )
		myShiTomasi_qualityLevel = 1;

	for( int j = 0; j < img_gray.rows; j++ )
		for( int i = 0; i < img_gray.cols; i++ )
			if( myShiTomasi_dst.at<float>(j,i) > myShiTomasi_minVal + ( myShiTomasi_maxVal - myShiTomasi_minVal )*myShiTomasi_qualityLevel/max_qualityLevel )
				cv::circle( myShiTomasi_copy, cv::Point(i,j), 4, cv::Scalar( rng.uniform(0,255), rng.uniform(0,255), rng.uniform(0,255) ), -1, 8, 0 );
		
	cv::imshow( shiTomasi_win, myShiTomasi_copy );
}
开发者ID:rizasif,项目名称:Robotics_intro,代码行数:14,代码来源:corner_detection.cpp


示例17: randomDoubleLog

 double randomDoubleLog(double minVal, double maxVal)
 {
     double logMin = log((double)minVal + 1);
     double logMax = log((double)maxVal + 1);
     double pow = rng.uniform(logMin, logMax);
     double v = exp(pow) - 1;
     CV_Assert(v >= minVal && (v < maxVal || (v == minVal && v == maxVal)));
     return v;
 }
开发者ID:Aspie96,项目名称:opencv,代码行数:9,代码来源:ocl_test.hpp


示例18: RenderConvexHulls

void RenderConvexHulls(CVPipeline * pipe)
{
	if (pipe->cvContours.size() == 0)
		return;
	cv::Scalar color = cv::Scalar(rng.uniform(125,255), rng.uniform(125,255), rng.uniform(125,255));
//	cv::drawContours(pipe->output, pipe->convexHull, 0, color, 1, 8, std::vector<cv::Vec4i>(), 0, cv::Point() );
	std::vector<int> & convexHull = pipe->convexHull;
	std::vector<cv::Point> & contour = pipe->cvContours[0];
	for (int i = 0; i < convexHull.size(); ++i)
	{
		int index = convexHull[i];
		cv::Point point = contour[index];
		cv::circle(pipe->output, point, 15, color);
		int nextIndex = convexHull[(i+1) % convexHull.size()];
		cv::Point point2 = contour[nextIndex];
		// Line!
		cv::line(pipe->output, point, point2, color, 3);
	}
}
开发者ID:erenik,项目名称:engine,代码行数:19,代码来源:CVDataFilters.cpp


示例19: rect

Rectangle::Rectangle(const cv::Rect &_rect, const int &_id) :
    rect(_rect)
{
    tl = _rect.tl();
    br = _rect.br();
    left = new VerticalLine();
    left->set(tl, cv::Point(tl.x, br.y));
    top = new HorizontalLine();
    top->set(tl, cv::Point(br.x, tl.y));
    bottom = new HorizontalLine();
    bottom->set(cv::Point(tl.x, br.y), br);
    right = new VerticalLine();
    right->set(cv::Point(br.x, tl.y), br);
    info.set(_id, _rect);
    selected = false;
    selected_color = RED_COLOR;
    offset = 4;
    lineOffset = LINE_WEIGHT;
    color = cv::Scalar( rng.uniform(0, 255), rng.uniform(0,255), rng.uniform(0,255) );

}
开发者ID:apennisi,项目名称:annotationtool,代码行数:21,代码来源:rectangle.cpp


示例20: drawEpipolar

void drawEpipolar( cv::Mat _imga, cv::Mat _imgb,
                   std::vector<Eigen::VectorXi> _p2Da,
                   std::vector<Eigen::VectorXi> _p2Db,
                   std::vector<Eigen::VectorXd> _pda,
                   std::vector<Eigen::VectorXd> _pdb )
{

    char num[] = "12";

    for( unsigned int i = 0; i < _p2Da.size(); i++ )
    {
        Scalar color = Scalar( rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255) );
        sprintf( num, "%d ", i);

        circle( _imga, Point( _p2Da[i](0), _p2Da[i](1)), 5, color, -1, 8, 0 );
        putText( _imga, num, Point( _p2Da[i](0), _p2Da[i](1) ), FONT_HERSHEY_SIMPLEX, 1, color, 2, 8, false);

        sprintf( num, "%d ", i);
        circle( _imgb, Point( _p2Db[i](0), _p2Db[i](1)), 5, color, -1, 8, 0 );
        putText( _imgb, num, Point( _p2Db[i](0), _p2Db[i](1) ), FONT_HERSHEY_SIMPLEX, 1, color, 2, 8, false);

        Point2f pt1a;
        Point2f pt2a;
        pt1a.x = _pda[i](0);
        pt1a.y = _pda[i](1);
        pt2a.x = _pda[i](2);
        pt2a.y = _pda[i](3);

        line( _imga, pt1a, pt2a, color, 2, CV_AA );

        Point2f pt1b;
        Point2f pt2b;
        pt1b.x = _pdb[i](0);
        pt1b.y = _pdb[i](1);
        pt2b.x = _pdb[i](2);
        pt2b.y = _pdb[i](3);

        line( _imgb, pt1b, pt2b, color, 2, CV_AA );
    }
}
开发者ID:ana-GT,项目名称:CVHacking,代码行数:40,代码来源:proj3-2-4.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ cv::Rect类代码示例发布时间:2022-05-31
下一篇:
C++ cv::Ptr类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap