Go to Post Just proves those guys have loco-motives - Wayne C. [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 01-21-2012, 10:19 PM
Bryscus's Avatar
Bryscus Bryscus is offline
EE, CpE
AKA: Bryce B.
FRC #0180 (SPAM)
Team Role: Engineer
 
Join Date: Jan 2009
Rookie Year: 1999
Location: Jupiter, FL
Posts: 173
Bryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud of
Saving Image from Axis Camera to cRIO

Guys,

I've tried using some of the imaq commands from the nivision.h library, but whenever I run the code, I don't see any images stored anywhere.

I've tried:

int imaqWritePNGFile(const Image* image, const char* fileName, unsigned int compressionSpeed, const RGBValue* colorTable);

int imaqWriteVisionFile(const Image* image, const char* fileName, const RGBValue* colorTable);

int imaqWriteBMPFile(const Image* image, const char* fileName, int compress, const RGBValue* colorTable);

And some others even.

For example: imaqWriteVisionFile(imaqImage, "filename", NULL);

I need this to see the progression during image processing.

Does anyone have any suggestions for a file path or if the fileName is expecting an extension? The code compiles and runs in most instances but just doesn't leave an image anywhere.

- Bryce

EDIT: Apparently it returns a non zero value on success and zero otherwise. I'll have to try this on Monday.
__________________
The opulence of the front office decor varies inversely with the fundamental solvency of the firm.

Last edited by Bryscus : 01-21-2012 at 11:48 PM.
Reply With Quote
  #2   Spotlight this post!  
Unread 01-22-2012, 02:29 PM
aya94 aya94 is offline
Registered User
no team
 
Join Date: Jan 2010
Location: ISRAEL
Posts: 17
aya94 is an unknown quantity at this point
Re: Saving Image from Axis Camera to cRIO

Try using this command it worked for us:
AxisCamera& camera =AxisCamera :: GetInstance();
Reply With Quote
  #3   Spotlight this post!  
Unread 01-22-2012, 05:34 PM
Bryscus's Avatar
Bryscus Bryscus is offline
EE, CpE
AKA: Bryce B.
FRC #0180 (SPAM)
Team Role: Engineer
 
Join Date: Jan 2009
Rookie Year: 1999
Location: Jupiter, FL
Posts: 173
Bryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud of
Quote:
Originally Posted by aya94 View Post
Try using this command it worked for us:
AxisCamera& camera =AxisCamera :: GetInstance();
Thanks. I'm quite a bit past that point though. I'm grabbing images, but I need a way to inspect those images between processing steps.

- Bryce
__________________
The opulence of the front office decor varies inversely with the fundamental solvency of the firm.
Reply With Quote
  #4   Spotlight this post!  
Unread 01-23-2012, 12:35 PM
Bryscus's Avatar
Bryscus Bryscus is offline
EE, CpE
AKA: Bryce B.
FRC #0180 (SPAM)
Team Role: Engineer
 
Join Date: Jan 2009
Rookie Year: 1999
Location: Jupiter, FL
Posts: 173
Bryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud of
Re: Saving Image from Axis Camera to cRIO

Ok. I may have solved my own problem. If one were to take a look at the BinaryImage source code, it appears to be there.

void BinaryImage::Write(const char *fileName)
{
RGBValue colorTable[256];
Priv_SetWriteFileAllowed(1);
memset(colorTable, 0, sizeof(colorTable));
colorTable[0].R = 0;
colorTable[1].R = 255;
colorTable[0].G = colorTable[1].G = 0;
colorTable[0].B = colorTable[1].B = 0;
colorTable[0].alpha = colorTable[1].alpha = 0;
imaqWriteFile(m_imaqImage, fileName, colorTable);
}

I guess I needed to set up the colorTable properly. I haven't tried this yet, but I can't image that WPILib would have a non-working function.

- Bryce
__________________
The opulence of the front office decor varies inversely with the fundamental solvency of the firm.
Reply With Quote
  #5   Spotlight this post!  
Unread 01-23-2012, 02:00 PM
malachias malachias is offline
Registered User
FRC #1311
 
Join Date: Jan 2012
Location: Kell High School, Marietta, GA
Posts: 9
malachias is on a distinguished road
Re: Saving Image from Axis Camera to cRIO

Your current directory is "/" in the cRIO file system so your filename is relative to the root directory for relative paths. I have only successfully written to the root directory. Not all write operations generate files. Some generate errors that are visible on the Diagnostic screen of the the Driver Station. I am not certain that the first images retrieved from the camera are usable, but then I am still fumbling around.

I open a DOS window and use FTP to retrieve files from the cRIO. I just FTP to the ip address of the robot. "ls" returns a list of files. "get [filename]" retrieves a file to you current home directory. "delete [filename]" removes files. It appears to be a standard FTP implementation so you find documentation on the web.

I put a ".jpg" extension on the file when I write it out ("snapshot.jpg"). I can specify explicitly how to format the file using a specific imaqWrite*File method, so it may not matter except to indicate to Windows the format of the file. I do not know what format file the ImageBase::Write method generates (extension may be significant here).
Reply With Quote
  #6   Spotlight this post!  
Unread 01-23-2012, 02:51 PM
Bryscus's Avatar
Bryscus Bryscus is offline
EE, CpE
AKA: Bryce B.
FRC #0180 (SPAM)
Team Role: Engineer
 
Join Date: Jan 2009
Rookie Year: 1999
Location: Jupiter, FL
Posts: 173
Bryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud of
Re: Saving Image from Axis Camera to cRIO

Quote:
Originally Posted by malachias View Post
Your current directory is "/" in the cRIO file system so your filename is relative to the root directory for relative paths. I have only successfully written to the root directory. Not all write operations generate files. Some generate errors that are visible on the Diagnostic screen of the the Driver Station. I am not certain that the first images retrieved from the camera are usable, but then I am still fumbling around.

I open a DOS window and use FTP to retrieve files from the cRIO. I just FTP to the ip address of the robot. "ls" returns a list of files. "get [filename]" retrieves a file to you current home directory. "delete [filename]" removes files. It appears to be a standard FTP implementation so you find documentation on the web.

I put a ".jpg" extension on the file when I write it out ("snapshot.jpg"). I can specify explicitly how to format the file using a specific imaqWrite*File method, so it may not matter except to indicate to Windows the format of the file. I do not know what format file the ImageBase::Write method generates (extension may be significant here).
Malachias,

Thanks for the response. Yeah, I figured it would probably put everything in the root directory. It's good to hear some clarification.

An easier way to FTP to the robot is to type ftp://10.xx.yy.2 into an explorer window in windows (i.e., open up My Computer and enter the address in the address bar - it may have to be added).

With respect to file names, from what I can you if you use imaqWriteFile the extension is significant. It looks like the function parses the extension and then writes the type is parsed. I'll have to try the imaqWrite*File functions as well since they have a few more options.

Again, thanks for your help.

- Bryce
__________________
The opulence of the front office decor varies inversely with the fundamental solvency of the firm.
Reply With Quote
  #7   Spotlight this post!  
Unread 01-23-2012, 03:25 PM
Bongle's Avatar
Bongle Bongle is offline
Registered User
FRC #2702 (REBotics)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Waterloo
Posts: 1,069
Bongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond repute
Send a message via MSN to Bongle
Re: Saving Image from Axis Camera to cRIO

We have been using ColorImage::Write.

Something along these lines
Code:
ColorImage img;
camera.getImage(&img);

if(savingInAComplicatedWay)
{
  static int cImages = 0;
  char szSavePoint[200];
  sprintf(szSavePoint, "image%d.jpg",cImages++);
  img.Write(szSavePoint);
}
else
{
  img.write("img.jpg");
}
It ends up as a JPG in the root of the cRio. Then we just use windows explorer and go to ftp://10.te.am.2 to access the saved images and copy them to our PC for more analysis.

My standard disclaimer of "This code is from memory and probably won't compile" applies.
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 10:31 AM.

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