View Single Post
  #1   Spotlight this post!  
Unread 12-03-2014, 22:25
dougwilliams's Avatar
dougwilliams dougwilliams is offline
Engineer - Controls, Electronics
FRC #2053 (TigerTronics)
Team Role: Mentor
 
Join Date: May 2013
Rookie Year: 2013
Location: Vestal, NY
Posts: 109
dougwilliams is on a distinguished road
Image Threshold Always Returns Black Image - C++ / Vision / AXIS

We have been struggling to get hot goal detection working using vision processing. We have an AXIS camera mounted with green LED rings and looking at the live camera feed we see the tape light up nicely. We have gone through camera settings and in the code can dump the raw image file and we see an expected dulled green target in a very dark background.

No matter what we have tried we keep getting an all black image back from the threshold operation.

We originally had the camera settings "normal", and that did the same thing (except produced a standard light image of the target).

We have messed around with all sorts of threshold values and code tweaks and nothing seems to work.

We are command-based / C++ (and a snapshot of the code section is below). It should basically be the reference code.

Some other items that we have tried - included changing to various sets of HSL and HSV settings (the reference code says one thing, the description online says another...), changed the ColorImage to HSLImage with no luck. The printf's all go through so it's running the threshold operation, but doesn't give us anything useful.

Any ideas????


Code:
void AutonomousCommandN::Execute() {
	printf("Begin Auto Exe\n");
	switch(state){
	case 0:
	{
		printf("Case 0:\n");
	//	Scheduler::GetInstance()->AddCommand(new DriveForwardcommand(3.0));
		printf("Starting Autonomous");
		Scores *scores;
		TargetReport target;
		int verticalTargets[MAX_PARTICLES];
		int horizontalTargets[MAX_PARTICLES];
		int verticalTargetCount, horizontalTargetCount;
		Threshold threshold(104, 117, 221, 255, 139, 255);	//HSV threshold criteria, ranges are in that order ie. Hue is 60-100
		ParticleFilterCriteria2 criteria[] = {
				{IMAQ_MT_AREA, AREA_MINIMUM, 65535, false, false}
		};												//Particle filter criteria, used to filter out small particles
		AxisCamera &camera = AxisCamera::GetInstance();	//To use the Axis camera uncomment this line

		ColorImage *image;
		printf("Now creating new image.");
		//image = new RGBImage("/testImage.jpg");		// get the sample image from the cRIO flash

		image = camera.GetImage();


		Scheduler::GetInstance()->AddCommand(new AutoDriveandLowerGroup());

		
		image->Write("rawI.bmp");
		//To get the images from the camera comment the line above and uncomment this one
		BinaryImage *thresholdImage = image->ThresholdHSL(threshold);	// get just the green target pixels
		thresholdImage->Write("/threshold.bmp");
		BinaryImage *filteredImage = thresholdImage->ParticleFilter(criteria, 1);	//Remove small particles
		filteredImage->Write("Filtered.bmp");

		vector<ParticleAnalysisReport> *reports = filteredImage->GetOrderedParticleAnalysisReports();  //get a particle analysis report for each particle