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