open cv functions in matlab

asked 2015-03-26 06:21:03 -0600

naveeN gravatar image

updated 2015-03-26 06:28:16 -0600

berak gravatar image

i have installed open cv libraries in matlab by this instructions https://github.com/kyamagu/mexopencv now i want to get BOW output in a single vector. in order to train the neural network i have found this in matlab in order to get the BOW **

 a = imread('C:\Users\commongh\Pictures\Images for Project\rocks.png');
        I = rgb2gray(a);
        trainer = cv.BOWKMeansTrainer();
        dictionary = trainer.cluster(train_descs);
        extractor = cv.BOWImgDescriptorExtractor('SURF','BruteForce');
        extractor.setVocabulary(dictionary);
        keypoints = cv.SURF(I);
        descs = extractor.compute(I,keypoints);**

can you please tell me what inputs we should input to cv.BOWKMeansTrainer?

edit retag flag offensive close merge delete

Comments

1

here, the inputs are number of clusters (aka k), TermCriteria, attempts, flags. it is also mentioned that the input parameters are the ones from kmeans(). I know that you are asking the parameters in MATLAB, but they should be the same, if it is OpenCV :)

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-03-26 07:56:04 -0600 )edit

thank you I find it. and I re written the code like this please verify this is this correct or not

%BOW clc; clear all;

    a = imread('image');

    I = rgb2gray(a);

    trainer = cv.BOWKMeansTrainer(10);

        % getting descriptors

    detector = cv.FeatureDetector('SURF');

    keypoints = detector.detect(I);

    extractor = cv.DescriptorExtractor('SURF');

    descriptors = extractor.compute(I, keypoints);

    %making dictionary

    dictionary = trainer.cluster(descriptors);

    extractor = cv.BOWImgDescriptorExtractor('SURF','BruteForce');

    extractor.setVocabulary(dictionary);

    descs = extractor.compute(I,keypoints);

Am I getting the correct Bag of Words which I can input the neural network?

naveeN gravatar imagenaveeN ( 2015-03-26 10:07:53 -0600 )edit