|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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. Last edited by Bryscus : 01-21-2012 at 11:48 PM. |
|
#2
|
|||
|
|||
|
Re: Saving Image from Axis Camera to cRIO
Try using this command it worked for us:
AxisCamera& camera =AxisCamera :: GetInstance(); |
|
#3
|
||||
|
||||
|
Quote:
- Bryce |
|
#4
|
||||
|
||||
|
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 |
|
#5
|
|||
|
|||
|
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). |
|
#6
|
||||
|
||||
|
Re: Saving Image from Axis Camera to cRIO
Quote:
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 |
|
#7
|
||||
|
||||
|
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");
}
My standard disclaimer of "This code is from memory and probably won't compile" applies. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|