|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to capture image from Axis 206 and save to cRIO?
Hi, I am a beginner programmer for Team 1444, and we are trying to capture an image from the Axis camera and then save it to the cRIO. I have seen some other posts around, but looking through the FIRST documentation, we can't seem to figure out how that would work. We have the live video streaming correctly to the driver station, and we are using c++. We don't care where the image is saved to (the home directory is fine). Would anyone be able to provide some advice and/or a code example which would be much appreciated?
By the way, we directly took the code from FIRST's WPILib Guide for the 2012 Vision System, and it seems like this line is what saves the image, but we never find the image in the cRIO's file system(ftp://10.14.44.2): HSLImage *targetImage = new HSLImage("/testImage.png"); // create image I am unsure as to what this is supposed to be doing, but it looks like this should save the image , right? What could be wrong? Last edited by Glen : 26-01-2012 at 23:55. Reason: incorrect wording |
|
#2
|
|||
|
|||
|
Re: How to capture image from Axis 206 and save to cRIO?
Quote:
You can use the ImageBase::Write function... Code:
HSLImage *image = camera.GetImage();
image->Write("testImage.jpg");
|
|
#3
|
|||
|
|||
|
Re: How to capture image from Axis 206 and save to cRIO?
Awesome, I'll have to try that out tomorrow. I'll report back if it works! And I suppose that this will save it in the root directory?
|
|
#4
|
||||
|
||||
|
Re: How to capture image from Axis 206 and save to cRIO?
In nivision.h in WPILib there also exists several methods, such as imaqWriteBMP, that will save the picture in various different formats to the cRIO.
|
|
#5
|
|||
|
|||
|
Re: How to capture image from Axis 206 and save to cRIO?
@Basicxman, do you know where the image is saved?
|
|
#6
|
|||
|
|||
|
Re: How to capture image from Axis 206 and save to cRIO?
Should be saved in the root directory, you can open a browser or Windows Explorer and go to
Code:
ftp://10.te.am.2 |
|
#7
|
|||
|
|||
|
Re: How to capture image from Axis 206 and save to cRIO?
We keep on getting an Imaq image writeFile error in the driver station and the image doesn't show up in the root folder frt://10.10.75.2, do you have any suggestions on how we can solve this problem?
|
|
#8
|
|||
|
|||
|
Re: How to capture image from Axis 206 and save to cRIO?
Try Java, seems to work in there.
|
|
#9
|
||||
|
||||
|
Re: How to capture image from Axis 206 and save to cRIO?
I would suggest that you verify a few things. The write-error could be caused by something going wrong prior (upline)...
Are you able to do printf() or use the driver station LCD or SmartDashboard in order to get printouts? If so, then you need to verify a few things Code:
AxisCamera* pCamera = AxisCamera::GetInstance();
if (pCamera)
{
ColorImage* pImage = pCamera->GetImage();
if (pImage)
{
if (pImage->GetHeight() == 0 || pImage->GetWidth()==0)
printf("Error with image size - height/width is zero.\n");
else
{
pImage->Write("Image.jpg");
printf("Wrote file out to Image.jpg...should be a success.\n");
}
delete pImage;
}
else
printf("Image returned by GetImage was NULL. Big error.\n");
}
else
printf("Never got the camera instance. Big error.\n");
Let me know where you encounter errors in this process and we'll go from there. bob |
|
#10
|
|||
|
|||
|
Re: How to capture image from Axis 206 and save to cRIO?
I am having a similar problem to the OP. I'm using the below code, a modified version of what bob.wolff68 suggested. Running this function once at the beginning of teleop, I get the image size error on the DS LCD every time. Does anyone know what could be causing this behavior?
Code:
void CameraTest()
{
AxisCamera& pCamera = AxisCamera::GetInstance();
pCamera.WriteResolution(AxisCamera::kResolution_320x240);
pCamera.WriteCompression(20);
pCamera.WriteBrightness(0);
if (true/*pCamera*/) //since pCamera is not a pointer, this wouldn't work...
{
ColorImage* pImage = pCamera.GetImage();
if (pImage)
{
if (pImage->GetHeight() == 0 || pImage->GetWidth()==0)
{
dslcd->PrintfLine(dslcd->kUser_Line4,"Error with image size - height/width is zero.");
dslcd->UpdateLCD();
}
else
{
pImage->Write("Image.jpg");
dslcd->PrintfLine(dslcd->kUser_Line4,"Wrote file out to Image.jpg...should be a success.");
dslcd->UpdateLCD();
}
delete pImage;
}
else
{
dslcd->PrintfLine(dslcd->kUser_Line4,"Image returned by GetImage was NULL. Big error.");
dslcd->UpdateLCD();
}
}
else
{
dslcd->PrintfLine(dslcd->kUser_Line4,"Never got the camera instance. Big error.");
dslcd->UpdateLCD();
}
}
|
|
#11
|
|||
|
|||
|
Re: How to capture image from Axis 206 and save to cRIO?
I received an error for having no dimensions when I tested the code, is there a reason for this?
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|