Ask Your Question

slaw's profile - activity

2015-12-15 11:44:45 -0500 received badge  Notable Question (source)
2015-12-15 11:44:45 -0500 received badge  Popular Question (source)
2014-07-23 16:29:32 -0500 received badge  Nice Question (source)
2013-12-12 13:01:25 -0500 received badge  Student (source)
2013-12-12 12:54:16 -0500 asked a question Parallel Random Trees/Forest

Where can I find more detailed information on how to run the random trees/forest package in parallel? Is parallel random trees even implemented in OpenCV? Since each tree is independent of the others, the method obviously lends well to parallelization. Currently, I am training/predicting using a single CPU but would like to use as many CPUs as is available to me.

2013-11-16 22:59:07 -0500 asked a question Random Forest Predictor Variable Indices

After loading a predictor generated from the random forest method, how can I access the variable indices?

2013-11-13 15:39:56 -0500 asked a question APPEND to xml.gz

Hi OpenCV Community,

I have saved a predictor from the randomtrees class as a ".xml.gz" file. Then I try appending something to the end of the file:

//Save predictor as XML
forest->save(xmlfile);

//Append conversion map to XML
fs.open(xmlfile, cv::FileStorage::APPEND);
ss2Int=dat->get_class_labels_map();
fs << "strings" << "[";
for(iter=ss2Int.begin(); iter != ss2Int.end(); iter++){
  fs << static_cast<std::ostringstream*>( &(std::stringstream() << iter->second) )->str();
  fs << iter->first;
}
fs << "]";
fs.release();

Due to the extension of the file, I am getting the following runtime exception:

OpenCV/opencv-2.4.6/modules/core/src/persistence.cpp:2733: error: (-213) Appending data to compressed file is not implemented in function cvOpenFileStorage

Of course, this problem goes away when I only use files that end in ".xml" rather than ".xml.gz". However, the tradeoff is a big difference in file size (over 100 MB for the ".xml" file and only ~7.1 MB for the ".xml.gz" compressed file).

Can anybody offer a good way to resolve this within C++ (I know that I could compress it after the xml file is created but it would be sub-optimal)?

Sean

2013-10-24 17:19:47 -0500 received badge  Editor (source)
2013-10-24 17:03:29 -0500 asked a question Random Forest Class Labels

I have trained my data (using Random Forest) and saved an XML file for my predictor. Normally, the class labels from the training data can be obtained from the "get_class_labels_map()" method. I have class labels that are alphabets so I end up with std::map<std::string, int="">.

However, after I load the predictor, how do I access the class labels in the predictor? In other words, when I make a prediction, the method returns a float. I was hoping that I could somehow then convert this float to its corresponding alphabet based on the class labels from the training data.

Alternatively, is there some way to save the class labels in the XML predictor file?

In case it matters, I am programming this in C++.

Any suggestion would be greatly appreciated!