Go to Post Unfortunately, not everyone is Andy Baker. If everyone had this mindset, there would be far fewer problems. - Kevin Kolodziej [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 31-01-2012, 16:20
powerrbill powerrbill is offline
Registered User
FRC #0486
 
Join Date: Jan 2012
Location: Philadelphia area
Posts: 4
powerrbill is an unknown quantity at this point
IMage Width is 0

Our team has been having some trouble with vision... big surprise. Like most people we are having trouble 'getting' the image because the width of the image that the robot is using is 0. This has happened in two drafts of code written by two different programmers, and we have tried writing the compression to 30.

Here is the first draft:
Code:
 
#include "WPILib.h"

				



double Target::GetHorizontalAngle()
{
	double x = m_xPos;
	
	x = atan2(x, 1+cos(28)*-1);
	x = x * 180.0 / 3.14159;
	return x;
}

vector<Target>* Target::FindRectangleTarget()
{
	AxisCamera &camera = AxisCamera::GetInstance("10.4.86.11");
	//AxisCamera &camera = AxisCamera::GetInstance("10.4.86.11");
	camera.WriteCompression(0);
	camera.WriteResolution(AxisCamera::kResolution_320x240);

	camera.WriteBrightness(0);

	
		
		
		
	//threshold default 100,100,100,100,100,100
	
		//camera.GetImage()->Write("binaryImage.jpg")		
	 BinaryImage *binaryimage = camera.GetImage()->ThresholdHSL(105,202,1,22,241,250);
	
	 
	 
	 imaqConvexHull(binaryimage->GetImaqImage(),binaryimage->GetImaqImage(),1);
	 printf("AfterConvex\n");
	 vector<ParticleAnalysisReport> *results = binaryimage->GetOrderedParticleAnalysisReports();
	 delete binaryimage;
	 //results->at(0).center_mass_x_normalized;
	 vector<Target> *returnresults;
	 if(results->size()<0)
	 {
		 return returnresults;
	 }
	 
	 printf("BeforeFoorLoop\n");
	 int b;
	 b= results->size();
	 for(int x=0;x<b;x++)
	 {
		 if(results->at(x).particleArea>1000) //normally 800
		 {
			 Target t;
			 t.m_xPos = results->at(x).center_mass_x_normalized;
			 t.m_ypos = results->at(x).center_mass_y_normalized;
			 returnresults->push_back(t);
		 }
	 }
	 
	 
	 delete results;
	 
	 return returnresults;
	 
}
and here is the second:

Code:
#include "CameraSubsystem.h"
#include "../Robotmap.h"
#include "nivision.h"
#include "Vision/MonoImage.h"
#include "Vision/BinaryImage.h"

#include <algorithm>
#include <math.h>
#include "WPILib.h"
#include "../Commands/CameraCommand.h"

CameraSubsystem::CameraSubsystem() : Subsystem("CameraSubsystem") {
	
}
    
void CameraSubsystem::InitDefaultCommand() {
	SetDefaultCommand(new CameraCommand);
	// Set the default command for a subsystem here.
	//SetDefaultCommand(new MySpecialCommand());
}
void CameraSubsystem::Track()
{
	AxisCamera &camera = AxisCamera::GetInstance("10.4.86.11");

		camera.WriteCompression(0);
		camera.WriteResolution(AxisCamera::kResolution_320x240);	
		camera.WriteBrightness(30);
	ColorImage *colorimage;
		
	colorimage = camera.GetImage();
	double size; 
	size = colorimage->GetWidth();
	if (size==0)//the size is zero
	{
		printf("size is zero");
	}
	BinaryImage *binaryimage = colorimage->ThresholdHSL(100,100,100,100,100,100);
}
and both have the same error: 0xBFF60406 in ColorImage.cpp line 37.

Any help would be greatly appreciated
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:39.

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