Ask Your Question

Revision history [back]

Is it possible to embed a Neural Network database in c++ code for reading directly to memory?

I am developing an image recognition module in C++ for later deployment to Android. I have a satisfactory XML file which I currently read in using:
CvANN_MLP nnetworkRank;
CvFileStorage* storageRank = cvOpenFileStorage("C:\Development\NN\param_4.xml", 0, CV_STORAGE_READ);
CvFileNode *nRank = cvGetFileNodeByName(storageRank, 0, "RankOCR");
nnetworkRank.read(storageRank, nRank);
cvReleaseFileStorage(&storageRank);

I am about to try to deploy to Android, and I want to avoid deploying the param_4 xml file with the app, and instead load it in C++ as, say, a header file to be included at compile time. I have tried including "char param_4[258982] = { 0x3c, 0x3f, 0x78, 0x6d, ......etc" (i.e. creating a char variable consisting of the contents of my XML file) and then the following code:

**FileStorage fs(".xml", FileStorage::WRITE + FileStorage::MEMORY);
fs << "RankOCR" << param_4; //this line crashes.
string buf = fs.releaseAndGetString();
FileStorage fu(buf, FileStorage::READ + FileStorage::MEMORY);

but, although it compiles, it crashes when trying to read the char variable with "Unhandled exception at 0x000007FEE554FFCD (opencv_core2410d.dll) in OpencvDev_1.exe: 0xC0000005: Access violation writing location 0x0000000064307827" [environment: Visual Studio Express 2013 on Windows 7]

Any thoughts on how to include an XML file for CvANN_MLP?

click to hide/show revision 2
No.2 Revision

updated 2015-03-25 02:43:15 -0600

berak gravatar image

Is it possible to embed a Neural Network database in c++ code for reading directly to memory?

I am developing an image recognition module in C++ for later deployment to Android. I have a satisfactory XML file which I currently read in using:

CvANN_MLP nnetworkRank; 
CvFileStorage* storageRank = cvOpenFileStorage("C:\Development\NN\param_4.xml", cvOpenFileStorage("C:\\Development\\NN\\param_4.xml", 0, CV_STORAGE_READ);
CvFileNode *nRank = cvGetFileNodeByName(storageRank, 0, "RankOCR");
nnetworkRank.read(storageRank, nRank);
cvReleaseFileStorage(&storageRank);

cvReleaseFileStorage(&storageRank);

I am about to try to deploy to Android, and I want to avoid deploying the param_4 xml file with the app, and instead load it in C++ as, say, a header file to be included at compile time. I have tried including

"char param_4[258982] = {   0x3c, 0x3f, 0x78, 0x6d, ......etc" (i.e. creating a char variable consisting of the contents of my XML file) and then the following code:

code: **FileStorage fs(".xml", FileStorage::WRITE + FileStorage::MEMORY);
fs << "RankOCR" << param_4; //this line crashes.
string buf = fs.releaseAndGetString();
FileStorage fu(buf, FileStorage::READ + FileStorage::MEMORY);

FileStorage::MEMORY);

but, although it compiles, it crashes when trying to read the char variable with

 "Unhandled exception at 0x000007FEE554FFCD (opencv_core2410d.dll) in OpencvDev_1.exe: 0xC0000005: Access violation writing location 0x0000000064307827"

[environment: Visual Studio Express 2013 on Windows 7]

Any thoughts on how to include an XML file for CvANN_MLP?