Go to Post IYou might get it all changed over and discover your robot has trouble moving from a dead stop, can no longer turn without playing morse code on the breakers... - KenWittlief [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

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 26-01-2012, 23:36
Glen Glen is offline
Registered User
FRC #1444
 
Join Date: Jan 2012
Location: St. Louis
Posts: 5
Glen is an unknown quantity at this point
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
Reply With Quote
  #2   Spotlight this post!  
Unread 26-01-2012, 23:40
basicxman basicxman is offline
Emily Horsman
FRC #2200 (MMRambotics)
Team Role: Programmer
 
Join Date: Oct 2007
Rookie Year: 2007
Location: Burlington, Ontario
Posts: 971
basicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant future
Send a message via AIM to basicxman Send a message via MSN to basicxman Send a message via Yahoo to basicxman
Re: How to capture image from Axis 206 and save to cRIO?

Quote:
Originally Posted by Glen View Post
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?
This line attempts to open an image at that location, not save it. See here, http://mmrambotics.ca/wpilib/class_h...8e2dd2 4383e6

You can use the ImageBase::Write function...

Code:
HSLImage *image = camera.GetImage();
image->Write("testImage.jpg");
Reply With Quote
  #3   Spotlight this post!  
Unread 26-01-2012, 23:54
Glen Glen is offline
Registered User
FRC #1444
 
Join Date: Jan 2012
Location: St. Louis
Posts: 5
Glen is an unknown quantity at this point
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?
Reply With Quote
  #4   Spotlight this post!  
Unread 27-01-2012, 17:26
Tommy.Brown's Avatar
Tommy.Brown Tommy.Brown is offline
Lead Programmer
FRC #1477 (Texas Torque)
Team Role: Programmer
 
Join Date: Jul 2011
Rookie Year: 2011
Location: The Woodlands
Posts: 27
Tommy.Brown is an unknown quantity at this point
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.
__________________
FRC Team 1477 - Texas Torque
The Woodlands, Texas
Reply With Quote
  #5   Spotlight this post!  
Unread 29-01-2012, 13:27
pentrium pentrium is offline
Registered User
FRC #1075
 
Join Date: Jan 2012
Location: Whitby
Posts: 5
pentrium is an unknown quantity at this point
Re: How to capture image from Axis 206 and save to cRIO?

@Basicxman, do you know where the image is saved?
Reply With Quote
  #6   Spotlight this post!  
Unread 29-01-2012, 13:34
basicxman basicxman is offline
Emily Horsman
FRC #2200 (MMRambotics)
Team Role: Programmer
 
Join Date: Oct 2007
Rookie Year: 2007
Location: Burlington, Ontario
Posts: 971
basicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant future
Send a message via AIM to basicxman Send a message via MSN to basicxman Send a message via Yahoo to basicxman
Re: How to capture image from Axis 206 and save to cRIO?

Quote:
Originally Posted by pentrium View Post
@Basicxman, do you know where the image is saved?
Should be saved in the root directory, you can open a browser or Windows Explorer and go to

Code:
ftp://10.te.am.2
Reply With Quote
  #7   Spotlight this post!  
Unread 29-01-2012, 15:59
pentrium pentrium is offline
Registered User
FRC #1075
 
Join Date: Jan 2012
Location: Whitby
Posts: 5
pentrium is an unknown quantity at this point
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?
Reply With Quote
  #8   Spotlight this post!  
Unread 29-01-2012, 17:35
Chiller Chiller is offline
Registered User
AKA: Connor Christie
FRC #4095 (RoXI Robotics)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Wisconsin
Posts: 118
Chiller is on a distinguished road
Re: How to capture image from Axis 206 and save to cRIO?

Quote:
Originally Posted by pentrium View Post
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?
Try Java, seems to work in there.
Reply With Quote
  #9   Spotlight this post!  
Unread 30-01-2012, 14:14
bob.wolff68's Avatar
bob.wolff68 bob.wolff68 is offline
Da' Mentor Man
FRC #1967
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2007
Location: United States
Posts: 157
bob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nice
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");
If this runs and says "Wrote file out...." then goto your browser when the robot is in DISABLED mode via ftp://10.te.am.2 and click (hopefully) on Image.jpg and see it.

Let me know where you encounter errors in this process and we'll go from there.

bob
__________________
~~~~~~~~~~~~~~~~~~~
Bob Wolff - Software from the old-school
Mentor / C / C++ guy
Team 1967 - The Janksters - San Jose, CA
Reply With Quote
  #10   Spotlight this post!  
Unread 31-01-2012, 16:17
mathgeek01 mathgeek01 is offline
C++ Ninja in Training
FRC #3397 (Robolions)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2010
Location: St. Louis, MO
Posts: 9
mathgeek01 is an unknown quantity at this point
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();
		}
	}
Daniel
Reply With Quote
  #11   Spotlight this post!  
Unread 01-02-2012, 14:48
pentrium pentrium is offline
Registered User
FRC #1075
 
Join Date: Jan 2012
Location: Whitby
Posts: 5
pentrium is an unknown quantity at this point
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?
Reply With Quote
Reply


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 03:04.

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