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


C++ RNG::uniform方法代码示例

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


在下文中一共展示了RNG::uniform方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: CropIm

void CropIm(std::string destFoldPath, cv::Mat Im, double s)
{
	int w = Im.rows;
	int h = Im.cols;

	int wStart;
	int hStart;
	
	wStart = rng.uniform(0.0, w*(1-s));
	hStart = rng.uniform(0.0, h*(1-s));

	cv::Rect myROI(hStart, wStart, h*s, w*s);

	cv::Mat croppedImage = Im(myROI);
	cv::imwrite(destFoldPath + "_crop" + int2string(int(s * 100)) + ".jpg", croppedImage);
}
开发者ID:stolgayldrn,项目名称:TestImageCreatot,代码行数:16,代码来源:Source.cpp

示例15: outp

void
gen_points_3d(std::vector<Plane>& planes_out, cv::Mat_<unsigned char> &plane_mask, cv::Mat& points3d, cv::Mat& normals,
              int n_planes)
{
    std::vector<Plane> planes;
    for (int i = 0; i < n_planes; i++)
    {
        Plane px;
        for (int j = 0; j < 1; j++)
        {
            px.set_d(rng.uniform(-3.f, -0.5f));
            planes.push_back(px);
        }
    }
    cv::Mat_ < cv::Vec3f > outp(H, W);
    cv::Mat_ < cv::Vec3f > outn(H, W);
    plane_mask.create(H, W);

    // n  ( r - r_0) = 0
    // n * r_0 = d
    //
    // r_0 = (0,0,0)
    // r[0]
    for (int v = 0; v < H; v++)
    {
        for (int u = 0; u < W; u++)
        {
            unsigned int plane_index = (u / float(W)) * planes.size();
            Plane plane = planes[plane_index];
            outp(v, u) = plane.intersection(u, v, Kinv);
            outn(v, u) = plane.n;
            plane_mask(v, u) = plane_index;
        }
    }
    planes_out = planes;
    points3d = outp;
    normals = outn;
}
开发者ID:nlyubova,项目名称:opencv_candidate,代码行数:38,代码来源:test_normal.cpp


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