Ask Your Question

v3xd's profile - activity

2014-10-26 17:23:21 -0600 commented answer Visualizing HOG's detection

Thanks but I would like to show the features from that image without any training. How would you do that?

2014-10-26 16:51:23 -0600 asked a question Visualizing HOG's detection

How can I visualize the features on the image?

String imName = "images/out/cropped";
Mat im;
Size padding = Size(0, 0);
Size winStride = Size(8, 8);
vector<Point> locations;
vector<float> features;
HOGDescriptor descriptor = HOGDescriptor(Size(168, 192), Size(16, 16), Size(8, 8), Size(8, 8), 9);
Mat descriptors;

im = imread(imName +"0.pgm", CV_LOAD_IMAGE_UNCHANGED);
descriptor.compute(im, features, winStride, padding, locations);
2014-10-23 13:30:10 -0600 received badge  Editor (source)
2014-10-23 13:22:20 -0600 asked a question How can I get the histogram of words in a bag of words creation?
    String imName = "images/out/cropped";
//to store the current input image
Mat input;

//To store the keypoints that will be extracted by SIFT
vector<KeyPoint> keypoints;
//To store the SIFT descriptor of current image
Mat descriptor;
//To store all the descriptors that are extracted from all the images.
Mat featuresUnclustered;
//The SIFT feature extractor and descriptor
SiftDescriptorExtractor detector;
Mat bow_descs;
//feature descriptors and build the vocabulary
for(int i=0;i<10;i++)
{
    std::stringstream cntS;
    cntS << i;
    //open the file
    input = imread(imName + cntS.str()+".pgm", CV_LOAD_IMAGE_UNCHANGED);
    //detect feature points
    detector.detect(input, keypoints);
    //compute the descriptors for each keypoint
    detector.compute(input, keypoints, descriptor);
    //put the all feature descriptors in a single Mat object
    featuresUnclustered.push_back(descriptor);
}

//Construct BOWKMeansTrainer
//the number of bags
int dictionarySize=100;

//Create the BoW (or BoF) trainer
BOWKMeansTrainer bowTrainer(dictionarySize);
//cluster the feature vectors
Mat dictionary = bowTrainer.cluster(featuresUnclustered);