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.
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).
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.
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.