SIFTMemLeakTest.cpp

CPP for mem leak test - Pavel Zykán, 2011-08-09 03:26 pm

Download (1.2 kB)

 
1
// SIFTMemLeakTest.cpp : main project file.
2
3
#include "stdafx.h"
4
5
using namespace System;
6
7
#include <opencv2\opencv.hpp>
8
#include <opencv2\features2d\features2d.hpp>
9
10
int main(array<System::String ^> ^args)
11
{
12
        cv::Mat image;
13
        image = cv::imread("image.jpg", 0);
14
    
15
        cv::SIFT::DetectorParams siftDetectorParams;
16
        cv::SIFT::CommonParams siftCommonParams;
17
        cv::SIFT::DescriptorParams siftDescriptorParams;
18
19
        // the problem seems to be more prominent when using these parameters
20
        //cv::SIFT::DetectorParams siftDetectorParams(0.006f, 100.0f);
21
        //cv::SIFT::CommonParams siftCommonParams(4, 3, -1, 1);
22
        //cv::SIFT::DescriptorParams siftDescriptorParams(3.0f, true, true);
23
24
        cv::SiftFeatureDetector* siftDetector = new cv::SiftFeatureDetector(siftDetectorParams, siftCommonParams);
25
        cv::SiftDescriptorExtractor* siftDescriptor = new cv::SiftDescriptorExtractor(siftDescriptorParams, siftCommonParams);
26
27
        while(true)
28
        {
29
                std::vector<cv::KeyPoint> keypoints;
30
                cv::Mat siftDescriptors;
31
32
                siftDetector->detect(image, keypoints);
33
                siftDescriptor->compute(image, keypoints, siftDescriptors);
34
35
                printf("descriptors computed\n");
36
37
                keypoints.clear();
38
                siftDescriptors.release();
39
        }
40
41
    return 0;
42
}