Go to Post The heat gun is not an arm rest. Especially when it is on. - Fuego247 [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 16-02-2012, 04:21
Method's Avatar
Method Method is offline
Registered User
no team
 
Join Date: Jan 2012
Rookie Year: 2011
Location: Ca
Posts: 38
Method is an unknown quantity at this point
general image tracking commands

Hello- simple playing around with wrappers
I have two errors highlighted in red and would appreciate a nudge in the right direction(they're different instances of the same error).

Also, I'd love some more simple commands examples like this: particularly the one which uses a particle filter to add or remove particles based on %Area/(Particle & Holes' Area) which is in the NI Vision Assistant.

One last:There are many references to reading and writing image files. Is this only necessary in Java or when making an example which uses pictures from the a folder, e.g., 'vision images' in the project?

Thankyou for any help!

Code:
#include "WPILib.h"
#include "Vision/RGBImage.h"
#include "Vision/BinaryImage.h"

#define RL 200
#define RH 260
#define GL 140
#define GH 210
#define BL 90
#define BH 135

#define BS 1.0f
#define CT 1.0f
#define GA 1.0f

static AxisCamera &eyeOfSauron = AxisCamera::GetInstance("255.255.255.255");
DriverStationLCD* driverOut = DriverStationLCD::GetInstance();

class VisionSample2012 : public SimpleRobot
{
DriverStationLCD* driverOut;
Joystick pilot;
public:
	VisionSample2012(void):
		pilot(1)
	{
		GetWatchdog().Kill();
		driverOut  = DriverStationLCD::GetInstance();
		
		eyeOfSauron.WriteBrightness(30);
		eyeOfSauron.WriteWhiteBalance(AxisCamera::kWhiteBalance_Hold);
		eyeOfSauron.WriteResolution(AxisCamera::kResolution_320x240);
		eyeOfSauron.WriteColorLevel(100);
		eyeOfSauron.WriteCompression(30);
		eyeOfSauron.WriteMaxFPS(5);
		//lower easier on CRIO and harder on cam
	}
	
	void Autonomous(void)
	{
		GetWatchdog().Kill();		
		while (IsAutonomous() && IsEnabled()) 
		{
			GetWatchdog().Kill();
			CamAnOut();
		}
	}
	void OperatorControl(void)
	{
		GetWatchdog().Kill();
		while (IsOperatorControl() && IsEnabled())
		{
			GetWatchdog().Kill();
			CamAnOut();
		}
	}
	void CamAnOut (void)
	{
//used to remove red, green or blue particles out of range
		Threshold threshold(RL, RH, GL, GH, BL, BH);

//used to remove particles out of criteria
		ParticleFilterCriteria2 criteria[] = {
											{IMAQ_MT_BOUNDING_RECT_WIDTH, 10, 200, false, false},
											{IMAQ_MT_BOUNDING_RECT_HEIGHT, 10, 200, false, false}};
				
		ColorImage image(IMAQ_IMAGE_RGB);
		//make image
		
		if (eyeOfSauron.IsFreshImage())//if latest from cam not recieved
		{
			eyeOfSauron.GetImage(&image);
			//store camera feed to image
			//out new im # ()  ---  add a big number to it
		}
		else
		{
			//out old im  ---  sub a small number from it
			//play till refreshes at 0 for awesomeness XD
			


			/*	AxisCamera::GetImage returns ColorImage* ... (or HSLImage* due to inheritance)
				ColorImage::ThresholdHSL returns BinaryImage*
				BinaryImage:: has the particle analysis routines
			*/	
			
			
//changes brightness, contrast and gamma
			Image* BCG = image.GetImaqImage();
			delete ℑ
			BCGOptions bcg;
			bcg.brightness = BS;
			bcg.contrast = CT;
			bcg.gamma = GA;
			imaqBCGTransform(BCG, BCG, &bcg, NULL);
			
			HSLImage *thresholdLUM = BCG->ThresholdHSL(1,2,1,2,1,2);
//would remove out of range HSL particles
			delete &BCG;

//separates luminance
			MonoImage* luminance = thresholdLUM->GetLuminancePlane();
			 delete thresholdLUM;
			imaqDispose(BCG);
			image.ReplaceRedPlane(luminance);
			image.ReplaceGreenPlane(luminance);
			image.ReplaceBluePlane(luminance);
			
//not with HSL image and threshold-removes out of range RGB	BinaryImage *thresholdImage = BCG->ThresholdRGB(threshold);
			//pixel range		

//change img type
			BinaryImage *binImg = luminance;
				delete luminance;
//complete particles
			 imaqConvexHull(binImg->GetImaqImage(),binImg->GetImaqImage(),1);
	
			BinaryImage *bigObjectsImage = binImg->RemoveSmallObjects(false, 2);
			// remove small objects (noise)
			delete binImg;
			
			BinaryImage *convexHullImage = bigObjectsImage->ConvexHull(false);
			// fill in partial and full rectangles
			delete bigObjectsImage;
			
			BinaryImage *filteredImage = convexHullImage->ParticleFilter(criteria, 2);
			// find the rectangles by above cruteria
			delete convexHullImage;
			
			vector<ParticleAnalysisReport> *particles = filteredImage->GetOrderedParticleAnalysisReports();
			// get the results
			delete filteredImage;
			
			
			ParticleAnalysisReport *high = &(particles)->at(1);
			ParticleAnalysisReport *particle = &(particles)->at(2);
			for (unsigned int i = 1; i <= particles->size(); i++)
			{
				particle = &(particles)->at(i);
							
				//target select
				if(particle->center_mass_y_normalized > high->center_mass_y_normalized) 
				{
					high = &(particles)->at(i);
				}
				delete particle;
			}
			
			//LCD output
			driverOut->UpdateLCD();
			
	//			delete reports;
			
			delete particles;
			delete high;
			
		}
		
	}
};

START_ROBOT_CLASS(VisionSample2012);
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 17:41.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi