Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Not able to visualize the image

From the following code, i am not able to visualize the image instead a blank window appears and also it gives a blank xml file. How to obtain a correct xml file? Need some help

#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <math.h>
#include "opencv2/highgui/highgui.hpp"
#include <vector>
#include "opencv2/objdetect/objdetect.hpp"
#include <stdio.h>
#include <string.h>
#include <ctype.h>

 using namespace cv;
 using namespace std;


 int main(int argc, char** argv)
  {
Mat img = imread("C:/Users/nuzha/Desktop/Canny.jpg"); //load outline image
Mat imageData;
//Hog to build feature vector
HOGDescriptor hog;
vector<float> 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");

vector<float> features1;
//Mat HogFeat;
Mat HogFeat = Mat(features1, 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 << "Saving the normalised HOG matrix....." << endl;
FileStorage storage("normalisation.xml", FileStorage::WRITE);



return 0;
   }

Not able to visualize the image

From the following code, i am not able to visualize the image instead a blank window appears and also it gives a blank xml file. How to obtain a correct xml file? Need some help

#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <math.h>
#include "opencv2/highgui/highgui.hpp"
#include <vector>
#include "opencv2/objdetect/objdetect.hpp"
#include <stdio.h>
#include <string.h>
#include <ctype.h>

 using namespace cv;
 using namespace std;


 int main(int argc, char** argv)
  {
Mat img = imread("C:/Users/nuzha/Desktop/Canny.jpg"); imread("Canny.jpg"); //load outline image
Mat imageData;
//Hog to build feature vector
HOGDescriptor hog;
vector<float> 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");

vector<float> features1;
//Mat HogFeat;
Mat HogFeat = Mat(features1, 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 << "Saving the normalised HOG matrix....." << endl;
FileStorage storage("normalisation.xml", FileStorage::WRITE);



return 0;
   }