Ask Your Question
0

averaging some frames

asked 2014-01-14 06:34:20 -0600

ati gravatar image

Hi. How do I get average of the 3 frames?

This is what I have done until now...

std::list<float*> Nframes;

 Mat Ex = Mat::zeros( width, height, CV_8UC1 );

 for(int i = 0; i < Nframes.size(); i++)
 {
     Ex += Nframes.front();
 } 
   Mat Result=Ex/Nframes.size();

I do not know what is the problem since I get error in line:

  `Ex += Nframes.front();`
edit retag flag offensive close merge delete

Comments

2

why are you trying to add a float pointer to a Mat ?

also, list.front() will be the same for all 3 times.

... man, that code is horribly broken. you want to start all new.

berak gravatar imageberak ( 2014-01-14 06:45:55 -0600 )edit

Actually, this is part of a code which my teacher has given to me. I should complete inside the for-loop. I should not change the code...

ati gravatar imageati ( 2014-01-14 07:05:37 -0600 )edit

Hi. let me to add something that there is a float pointer that points to the current frame all the time. to be able to add several frames I need to have something as a buffer(here list). So, this list contains some float pointer which pointing to the current frame! Now, I think it is meaningful that why I am adding it into a zero Mat. (because they are pointing to current frame which is a Mat)

ati gravatar imageati ( 2014-01-14 08:11:05 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-01-15 03:25:12 -0600

Nghia gravatar image

updated 2014-01-15 07:17:57 -0600

berak gravatar image

If you really have to, and I mean REALLY have to, use the existing weird code then this might be one way

std::list<float*>::iterator it = NFrames.begin();

Mat Ex = Mat::zeros( height, width, CV_32F );

for(int i = 0; i < Nframes.size(); i++)
{
    Mat tmp(height, width, CV_32F, *it);
    Ex += tmp;

    it++;
}

This is making the assumption your images are actually float data type and single channel. And the memory has been allocated in advance.

edit flag offensive delete link more

Comments

I get error in this line:// std::list<float*>::iterator it = Nframes;//

error: data member initializer is not allowed.

ati gravatar imageati ( 2014-01-15 06:08:45 -0600 )edit

Fixed the typo

Nghia gravatar imageNghia ( 2014-01-15 07:14:39 -0600 )edit

Question Tools

Stats

Asked: 2014-01-14 06:34:20 -0600

Seen: 173 times

Last updated: Jan 15 '14