Ask Your Question
0

sum a sequence of frames using opencv/c++

asked 2013-12-13 02:32:03 -0600

mahsa gravatar image

I want to sum all values in 4 frames in real-time. current frame and 3 frames before that. To do that, every time that current farme is produced, I store it in a vector called Nframe. This is what I have done until now but seems incorrect..

float *amp;   //points to the current frame
vector<float *>Nframe;

   for(int i=0; i<4; i++){
           Nframe.push_back(amp);
        }

         int sum_of_elems=0;
         for(std::vector<int>::iterator j=Nframe.begin();j!=Nframe.end();++j){
         sum_of_elems += *j;
         }
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-12-13 04:59:32 -0600

OpenCV provides a function to calculate the sum of pixels in one frame.

cv::Mat A = //blabla

float sum_of_elems = cv::sum(A);

Repeat this ad nauseum for all the frames you want

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-12-13 02:32:03 -0600

Seen: 345 times

Last updated: Dec 13 '13