Ask Your Question

alfageme's profile - activity

2016-07-11 10:38:49 -0500 received badge  Supporter (source)
2016-07-11 10:37:53 -0500 commented answer Why does it takes so long to capture the frames and store them in memory?

I tried it using the std::clock() functions again and taking into account the declaration of the VideoCapture object and the releases/memory frees, but It keeps giving me the same number D: But the thing is, if I switch to openCV time measure functions, it gives a much more realistic approximation to the run time. Any clue on why the standard library fails at this point?

2016-07-11 06:01:26 -0500 received badge  Enthusiast
2016-07-08 13:32:07 -0500 commented question Why does it takes so long to capture the frames and store them in memory?

The thing is that the total time the program takes to run and return to the shell is 36,409s, leading me to think, the in-code timer measure is not right. And we're talking about ~200 frames, I agree 0.7s will be fast enough, but instead it runs in about 40s!

2016-07-07 18:06:16 -0500 asked a question Why does it takes so long to capture the frames and store them in memory?

So, I'm writting a program that loads a video in memory to determine if it's unstabilized. I realized the program was taking way too long to execute, so I put a timer on my code:

const clock_t begin = std::clock();

int frame_count = 0;
bool should_stop = false;

std::vector <cv::Mat> frames;

while(!should_stop)
{
    cv::Mat frame;
    cap >> frame;

    frames.push_back(frame.clone());

    if (frame.empty())
    {
        should_stop = true;
        continue;
    }
    frame_count++;
}

std::cout << "Time: " << float( std::clock () - begin ) / CLOCKS_PER_SEC << std::endl;

But this prints times around ~0.70s as opposed as what I observe and measure with the time command:

$ time ./program ~/Desktop/video.mp4
Time: 0.700728s
./program ~/Desktop/video.mp4  0,56s user 0,19s system 2% cpu 36,409 total

Any ideas on why this is happening?