Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 4615

Problem in saving xml files

$
0
0
I am having difficulty in saving the xml files. I am using a loop to grab all the images in a folder and then to perform HoG. However, it is not saving any of the xml files. But, when done individually it works. Please help.. #include #include #include #include #include "opencv2/highgui/highgui.hpp" #include #include "opencv2/objdetect/objdetect.hpp" #include #include #include using namespace cv; using namespace std; vector files; int main(int argc, char** argv) { cv::glob("C:/Desktop/Extracted Frames/Front View/Feint and Dribble/2. Shooting Move/*.jpg", files); for (size_t i = 0; i < files.size(); i++) { Mat img = imread(files[i]); //Mat img = imread("C:/Proj//Front/7.Canny/Feint and Dribble/2. Shooting Move/Canny7.jpg"); Mat imageData; //Hog to build feature vector HOGDescriptor hog; vector descriptors; hog.winSize = Size(64, 128); resize(img, imageData, hog.winSize);//resize image hog.compute(img, descriptors); hog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector()); //HOG parameters hog.cellSize = Size(8, 8); hog.blockSize = Size(16, 16); hog.nbins = 9; //namedWindow("HOG"); imshow("Outline Image", img); vector features1; //Mat HogFeat; //Mat HogFeat = Mat(features1, true).reshape(1, 1); Mat HogFeat = Mat(descriptors, true).reshape(1, 1); //normalising data Mat mean, sigma; //matrices to save mean and standard deviation //store descriptor vector into matrix meanStdDev(HogFeat, mean, sigma); //get mean and std deviation HogFeat = (HogFeat - mean) / sigma; //normalization //store normalisation Mat meansigma; hconcat(mean, sigma, meansigma); cout << "mean " << mean << " sigma " << sigma << endl; cout << "Saving the normalised HOG matrix....." << endl; //FileStorage storage("normalisation.xml", FileStorage::WRITE); //storage << "hogfeature" << HogFeat; // basically - it's a key-value store. //storage.release(); // nothing will happen, unless you actually flush/close it. //Save image std::stringstream files(std::stringstream::in | std::stringstream::out); files << "Normalisation" << i << ".xml"; std::cout << "writing " << files.str().c_str() << " to disk" << std::endl; imwrite(files.str().c_str(), HogFeat); } waitKey(0); return 0; }

Viewing all articles
Browse latest Browse all 4615


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>