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


C++ BinaryImage::ConvexHull方法代码示例

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


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

示例1: DoImageProcessing

bool JankyTargeting::DoImageProcessing(void)
{
	bool isSuccessful = false;
	BinaryImage* firstBinaryImage = NULL;
	BinaryImage* readyForConvexHull = NULL;
	
	firstBinaryImage = hsl.ThresholdHSL(120,186,60,255,0,255);
	
	if (firstBinaryImage !=NULL)
	{
		// Prune down # particles by removing all small stuff before convexHull.
		readyForConvexHull = firstBinaryImage->RemoveSmallObjects(false, 2);

		if (readyForConvexHull != NULL)
		{
			samwise = readyForConvexHull->ConvexHull(false);
			
			if (samwise != NULL)
				isSuccessful = true;
		}
	}
	
	if (readyForConvexHull)
		delete readyForConvexHull;

	if (firstBinaryImage)
		delete firstBinaryImage;
	
	return isSuccessful;
}	
开发者ID:bobwolff68,项目名称:test,代码行数:30,代码来源:jankyTargeting.cpp

示例2: ProcessImage

int VisionControl::ProcessImage()
{
    if(m_camera->IsFreshImage())
    {
        ColorImage *image = NULL;
        m_camera->GetImage(image);
        
        Threshold threshold(60,100,90,255,20,255);
        ParticleFilterCriteria2 criteria[] = {IMAQ_MT_AREA,AREA_MINIMUM,65535,false,false};
        
        BinaryImage *thresholdImage = image->ThresholdHSV(threshold);
        BinaryImage *convexHullImage = thresholdImage->ConvexHull(false);
        BinaryImage *filteredImage = convexHullImage->ParticleFilter(criteria, 1);
        
        vector<ParticleAnalysisReport> *reports = filteredImage->GetOrderedParticleAnalysisReports();
        
        for (unsigned int i = 0; i < reports->size(); i++)
        {
            ParticleAnalysisReport *report = &(reports->at(i));
            
            // first, determine if this is a particle we are looking at.
            if(report->boundingRect.left > 320/2 || report->boundingRect.left + report->boundingRect.width < 320/2)
            {
                // particle is not lined up with center of vision
                // note: may not want to do this for autonomous!
                continue;
            }
            
            double aspectRatio = AspectRatio(filteredImage, report);

            double difference3ptGoal = fabs(1-(aspectRatio / ((54.f+4+4)/(12.f+4+4))));
            double difference2ptGoal = fabs(1-(aspectRatio / ((54.f+4+4)/(21.f+4+4))));
            
            if(difference2ptGoal < 0.25 && difference2ptGoal < difference3ptGoal)
            {
                m_elevation = 0;
                m_distance = ComputeDistance(thresholdImage, report, true);
                m_relativeAzimuth = 0;
            }
            else if(difference3ptGoal < 0.25 && difference3ptGoal < difference2ptGoal)
            {
                m_elevation = 0;
                m_distance = ComputeDistance(thresholdImage, report, false);
                m_relativeAzimuth = 0;
            }
            else
            {
                // didn't sufficiently match a target!
            }
        }
        /*
        Scores *scores = new Scores[reports->size()];
        
        //Iterate through each particle, scoring it and determining whether it is a target or not
        for (unsigned i = 0; i < reports->size(); i++)
        {
            ParticleAnalysisReport *report = &(reports->at(i));
            
            scores[i].rectangularity = ScoreRectangularity(report);
            scores[i].aspectRatioOuter = ScoreAspectRatio(filteredImage, report, true);
            scores[i].aspectRatioInner = ScoreAspectRatio(filteredImage, report, false);
            scores[i].xEdge = ScoreXEdge(thresholdImage, report);
            scores[i].yEdge = ScoreYEdge(thresholdImage, report);
            
            if(ScoreCompare(scores[i], false))
            {
                printf("particle: %d  is a High Goal  centerX: %f  centerY: %f \n", i, report->center_mass_x_normalized, report->center_mass_y_normalized);
                printf("Distance: %f \n", ComputeDistance(thresholdImage, report, false));
            }
            else if (ScoreCompare(scores[i], true))
            {
                printf("particle: %d  is a Middle Goal  centerX: %f  centerY: %f \n", i, report->center_mass_x_normalized, report->center_mass_y_normalized);
                printf("Distance: %f \n", ComputeDistance(thresholdImage, report, true));
            }
            else
            {
                printf("particle: %d  is not a goal  centerX: %f  centerY: %f \n", i, report->center_mass_x_normalized, report->center_mass_y_normalized);
            }
            printf("rect: %f  ARinner: %f \n", scores[i].rectangularity, scores[i].aspectRatioInner);
            printf("ARouter: %f  xEdge: %f  yEdge: %f  \n", scores[i].aspectRatioOuter, scores[i].xEdge, scores[i].yEdge);	
        }
        */
        
        delete image;
        delete thresholdImage;
        delete convexHullImage;
        delete filteredImage;
        delete reports;
        //delete scores;
        return 1;
    }
    
    return 0;
}
开发者ID:kjrokos,项目名称:RedArrow-2013,代码行数:94,代码来源:Vision.cpp

示例3: ProcessImage

void VisionSubsystem::ProcessImage() {
	printf("Vision: Starting Vision Subsystem\n");
	///////////////
	// Seting Up //
	///////////////
	
	
		
		targetVisable[TOP_TARGET] = false;
		targetVisable[MIDDLE_TARGET] = false;
		targetVisable[BOTTOM_TARGET] = false;
		
		targetDistances[TOP_TARGET] = 0.0;
		targetDistances[MIDDLE_TARGET] = 0.0;
		targetDistances[BOTTOM_TARGET] = 0.0;
		
		targetPositionX[TOP_TARGET] = 0.0;
		targetPositionY[TOP_TARGET] = 0.0;
		targetPositionX[MIDDLE_TARGET] = 0.0;
		targetPositionY[MIDDLE_TARGET] = 0.0;
		targetPositionX[BOTTOM_TARGET] = 0.0;
		targetPositionY[BOTTOM_TARGET] = 0.0;
	/*
	 * This creates a object with the needed values for the processing 
	 * the image later on, for a certain color. 
	 */
	printf("Vision: Setting the clor threshold values\n");
	Threshold threshold(THRESHOLD_HUE_MIN, 
						THRESHOLD_HUE_MAX, 
						THRESHOLD_SATURATION_MIN, 
						THRESHOLD_SATURATION_MAX, 
						THRESHOLD_VALUE_MIN, 
						THRESHOLD_VALUE_MAX);
	
	ParticleFilterCriteria2 criteria[] = {
			{IMAQ_MT_AREA, AREA_MINIMUM, 65535, false, false}
	};
	
	/*
	 * This is the function that sets up the axis camera to get images.
	 * To use the camera on the second port on the cRIO, uncommet the second line below 
	 * with "192.168.0.90" in it.
	 */
	printf("Vision: Setting camera IP to 10.30.81.12/n");
	AxisCamera &camera = AxisCamera::GetInstance("10.30.81.12");
	
	//AxisCamera &camera = AxisCamera::GetInstance("192.168.0.90"); //
	
	// This creates a Color image, then on the second line it fills it with the image from the camera.
	printf("Vision: Creating ColorImage object image\n");
	ColorImage *image;
	
	printf("Vision: Getting the Image from the camera \n");
	image = camera.GetImage();
	
	//////////////////////////////
	// Image processing section //
	//////////////////////////////
	
	//Process the image with the threshold values
	printf("Vision: Filtering the image with threshold values into object thresholdImage\n");
	BinaryImage *thesholdImage = image->ThresholdHSV(threshold);
	
	//This will fill shape that is complete and fill in the inside of siad shape.
	printf("Vision: Filling in the convex shapes into the object of convexHullImage\n");
	BinaryImage *convexHullImage = thesholdImage->ConvexHull(false);
	
	//This will get rid of random particles in the image that are notconcentrated enougth.
	printf("Vision: Filtering image for the unwanted random particles");
	BinaryImage *filteredImage = convexHullImage->ParticleFilter(criteria, 1);
	
	//This creates a report that will be used later to idenify targets
	printf("Vision: Creating the report of the filtered Image\n");
	vector<ParticleAnalysisReport> *reports = filteredImage->GetOrderedParticleAnalysisReports();
	
	//This creates a data stucture that is used to score objects.
	
	scores = new Scores[reports->size()];
	
	for (unsigned i = 0; i < reports->size(); i++) {
		ParticleAnalysisReport *report = &(reports->at(i));
		
		scores[i].rectangularity = scoreRectangularity(report);
		scores[i].aspectRatioOuter = scoreAspectRatio(filteredImage, report, true);
		scores[i].aspectRatioInner = scoreAspectRatio(filteredImage, report, false);
		scores[i].xEdge = scoreXEdge(thesholdImage, report);
		scores[i].yEdge = scoreYEdge(thesholdImage, report);
		
		if(scoreCompare(scores[i], false)) {
			printf("Vision: particle: %d is High Goal  centerX %f  centerY: %f \n", i , report->center_mass_x_normalized, report->center_mass_y_normalized);
			printf("Vision: Distance: %f \n", computeDistance(thesholdImage, report, false));
			
			targetPositionX[TOP_TARGET] = report->center_mass_x;
			targetPositionY[TOP_TARGET] = report->center_mass_y;
			targetDistances[TOP_TARGET] = computeDistance(thesholdImage, report, false);
			targetVisable[TOP_TARGET] = true;
			
			targetPositionX[TOP_TARGET] = targetPosition(TOP_TARGET, true);
			targetPositionY[TOP_TARGET] = targetPosition(TOP_TARGET, false);
			
//.........这里部分代码省略.........
开发者ID:stevep001,项目名称:RoboEagles,代码行数:101,代码来源:VisionSubsystem.cpp

示例4: mtdCameraCode

	void mtdCameraCode(void)
	{
		Threshold threshold(0, 255, 0, 255, 221, 255);

		ParticleFilterCriteria2 criteria[] = {{IMAQ_MT_AREA, AREA_MINIMUM, 65535, false, false}};		

		AxisCamera &camera = AxisCamera::GetInstance("10.26.3.11");
		camera.WriteResolution(AxisCamera::kResolution_320x240);
		camera.WriteCompression(20);
		camera.WriteBrightness(50);


		//SmartDashboard::PutNumber("Test", 3);
		if(timerCamera.Get() > 0.1)
		{	
			ColorImage *image;
			//image = new RGBImage("/HybridLine_DoubleGreenBK3.jpg");		// get the sample image from the cRIO flash
			image = camera.GetImage();
			//camera.GetImage(image);				//To get the images from the camera comment the line above and uncomment this one
			//Wait(.1);
	
			//SmartDashboard::PutNumber("Test", 4);
			BinaryImage *thresholdImage = image->ThresholdHSV(threshold);	// get just the green target pixels
			//		thresholdImage->Write("/threshold.bmp");
	
			//SmartDashboard::PutNumber("Test", 5);
			BinaryImage *convexHullImage = thresholdImage->ConvexHull(false);  // fill in partial and full rectangles
			//			convexHullImage->Write("ConvexHull.bmp");
	
			//SmartDashboard::PutNumber("Test", 6);
			BinaryImage *filteredImage = convexHullImage->ParticleFilter(criteria, 1);	//Remove small particles
			//		filteredImage->Write("/Filtered.bmp");
			//SmartDashboard::PutNumber("Test", 7);
			vector<ParticleAnalysisReport> *reports = filteredImage->GetOrderedParticleAnalysisReports();  //get a particle analysis report for each particle
	
			//SmartDashboard::PutNumber("Test", 8);
			int size = reports->size();
			scores = new Scores[size];
	
	
			//SmartDashboard::PutNumber("Test", 9);
			//Iterate through each particle, scoring it and determining whether it is a target or not
			for (unsigned i = 0; i < reports->size(); i++)
			{
				//SmartDashboard::PutNumber("Test", 10);
				ParticleAnalysisReport *report = &(reports->at(i));
	
				scores[i].rectangularity = scoreRectangularity(report);
				scores[i].aspectRatioOuter = scoreAspectRatio(filteredImage, report, true);
				scores[i].aspectRatioInner = scoreAspectRatio(filteredImage, report, false);			
				scores[i].xEdge = scoreXEdge(thresholdImage, report);
				scores[i].yEdge = scoreYEdge(thresholdImage, report);
	
	
				if(scoreCompare(scores[i], false))
				{
					//We hit this!! Note to self: changethe below printf statement
					//To use SmartDashboard::PutString so wecan seevalues.
					//printf("particle: %d  is a High Goal  centerX: %f  centerY: %f \n", i, report->center_mass_x_normalized, report->center_mass_y_normalized);
					//string particle = ("particle: %d  is a High Goal  centerX: %f  centerY: %f \n", i, report->center_mass_x_normalized, report->center_mass_y_normalized);
	
					SmartDashboard::PutNumber("CenterX", report->center_mass_x);
					SmartDashboard::PutNumber("CenterY", report->center_mass_y);
					SmartDashboard::PutNumber("Area", report->particleArea);
					SmartDashboard::PutNumber("Distance",computeDistance(thresholdImage,report, false));
					SmartDashboard::PutNumber("size", reports->size());
					SmartDashboard::PutNumber("height", report->boundingRect.height);
					SmartDashboard::PutNumber("Quality", report->particleQuality);
					//SmartDashboard::PutNumber("Test",computeDistance(thresholdImage, report, false));
					//SmartDashboard::PutNumber("Distance",computeDistance(thresholdImage,report, false));
					SmartDashboard::PutString("high goal detected", "asdf");
				} 
	
				else if (scoreCompare(scores[i], true))
				{
					printf("particle: %d  is a Middle Goal  centerX: %f  centerY: %f \n", i, report->center_mass_x_normalized, report->center_mass_y_normalized);
					SmartDashboard::PutNumber("Test", computeDistance(thresholdImage, report, true));
					SmartDashboard::PutNumber("CenterX", report->center_mass_x);
					SmartDashboard::PutNumber("CenterY", report->center_mass_y);
					SmartDashboard::PutNumber("height", report->boundingRect.height);
					SmartDashboard::PutNumber("Distance",computeDistance(thresholdImage,report, false));
					SmartDashboard::PutString("middle goal detected", "adsf");
	
				}
	
				else
				{
					printf("particle: %d  is not a goal  centerX: %f  centerY: %f \n", i, report->center_mass_x_normalized, report->center_mass_y_normalized);
					SmartDashboard::PutNumber("CenterX", report->center_mass_x);
					SmartDashboard::PutNumber("CenterY", report->center_mass_y);
					SmartDashboard::PutNumber("height", report->boundingRect.height);
					SmartDashboard::PutNumber("Distance",computeDistance(thresholdImage,report, false));
					SmartDashboard::PutString("we areinelse", "else");
	
				}
				if(report->center_mass_x < 85.00)
				{								
					SmartDashboard::PutString("Pausing", "paused");
					//image->Write("C:\\testimg.bmp");
					//Wait(10);
//.........这里部分代码省略.........
开发者ID:highlandprogramming,项目名称:WIP-2014-Code-FRC,代码行数:101,代码来源:MyRobot.cpp


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