Ask Your Question
0

Not able to visualize the image

asked 2017-01-19 11:10:28 -0600

Nuz gravatar image

updated 2017-01-19 11:25:01 -0600

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("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;
   }
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-01-19 11:18:09 -0600

berak gravatar image

updated 2017-01-19 11:28:07 -0600

both mean and sigma are actually simple Scalars, not images. in the case of your Hog features, only a single channel is used, so, -- there won't be much to see, if you concat those to another Mat.

you could try to print them out on console, like:

cout << "mean " << mean << " sigma " << sigma << endl;

then, your filestorage idea lacks the actual writing of the Hog features, which would be:

storage << "hogfeature" << HogFeat; // basically - it's a key-value store.
storage.release(); // nothing will happen, unless you actually flush/close it.
edit flag offensive delete link more

Comments

Thank you, but still no image appears but a grey window..

Nuz gravatar imageNuz ( 2017-01-19 11:49:09 -0600 )edit

again, neither mean, sigma, or the Hog feature are "images" in the 1st place.

if you're looking for a "gradient visualization" (of the hog features), have another look here

berak gravatar imageberak ( 2017-01-19 11:54:11 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-01-19 11:10:28 -0600

Seen: 174 times

Last updated: Jan 19 '17