Ask Your Question
0

Bag of words insufficient memory

asked 2013-10-01 10:54:40 -0600

updated 2013-10-01 11:04:43 -0600

berak gravatar image

HI All,

I am using BOW on a high resolution human action recognition data set. I have tried several solutions online such as releasing the images as soon as they are processed, downsampling the images, converting images in 8 bit. As far as I understand the program works till calculating the descriptors on all video frames. However, it causes a problem at BOW clustering after reading few action classes.

I also tried to create one dictionary per class to simplify the problem. However, still the same problem. I would really appreciate some guidance.

Here is the code:

int do_something() { Mat frame(Size(1280,720),CV_8UC3); Mat frameDown(Size(640,360),CV_8UC3); Mat Grayframe(Size(640,360),CV_8UC1);

// vector of keypoints
vector<KeyPoint> keypoints;

VideoCapture capture(buffer);
// check if video successfully opened
if (!capture.isOpened())
return 1;

    // for all frames in video
    for (;;) 
    {
        // read next frame if any
        if (!capture.read(frame))
        break;

        // convert to half, i.e., 640 * 360, downsamplying
        pyrDown(frame,frameDown, Size( frame.cols/2, frame.rows/2 ));

            // Convert images to Gray Scale
        if (frameDown.channels()==3)
        cvtColor(frameDown,Grayframe,CV_BGR2GRAY);

        // feature point detection
        fast.detect(Grayframe,keypoints);

         extractor->compute(Grayframe, keypoints, descriptor);


                     // add features to BOW trainer
         bowtrainer.add(descriptor);

        // Delay to display the video frames
        //waitKey(10);  // Add this display to avoid blank screen


    } // End of For loop

    // Releasing memory

    capture.release();
    frame.release();
    frameDown.release();
    Grayframe.release();
    keypoints.clear();
    descriptor.release();

} // End of Do_Something

vocabulary = bowtrainer.cluster();

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-10-14 09:54:52 -0600

I have exactly the same problem. When I do bowtrainer.cluster() I get the runtime error on insufficient memory. It somehow deals with cv::Mat implementation because I get the error before cluster() if I collect all the descriptors in one Mat passing them via add() command.

I can collect and process no more than 500 000 descriptors (the process uses about 300 MB), If I collect more program fails:(

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-10-01 10:54:40 -0600

Seen: 404 times

Last updated: Oct 14 '13