First time here? Check out the FAQ!

Ask Your Question
0

sum a sequence of frames using opencv/c++

asked Dec 13 '13

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;
         }
Preview: (hide)

1 answer

Sort by » oldest newest most voted
1

answered Dec 13 '13

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

Preview: (hide)

Question Tools

Stats

Asked: Dec 13 '13

Seen: 422 times

Last updated: Dec 13 '13