Code: Select all
// Learn the background statistics for one more frame
void accumulateBackground( IplImage *I ){
static int first = 1;
cvCvtScale( I, Iscratch, 1, 0 );
if( !first ){
cvAcc( Iscratch, IavgF );
cvAbsDiff( Iscratch, IprevF, Iscratch2 );
cvAcc( Iscratch2, IdiffF );
Icount += 1.0;
}
first = 0;
cvCopy( Iscratch, IprevF );
}
http://dasl.mem.drexel.edu/~noahKuntz/o ... l#Step%201
It seems the way the code is designed that becuse the:
if( !first )
the program will never reach this part of the code:
Code: Select all
cvAcc( Iscratch, IavgF );
cvAbsDiff( Iscratch, IprevF, Iscratch2 );
cvAcc( Iscratch2, IdiffF );
Icount += 1.0;
Code: Select all
(defun accumulate-background (i)
(setf 1st 1)
(cvt-scale i i-scratch-1 1 0) ;; To float
(if (not 1st)
(progn (acc i-scratch-1 i-avg-f)
(abs-diff i-scratch-1 i-prev-f i-scratch-2)
(acc i-scratch-2 i-diff-f)
(setf i-count (+ i-count 1.0))))
(setf 1st 0)
(copy i-scratch-1 i-prev-f))
in c i do
Code: Select all
static int first = 1;
if( first ){
cout << "reached this part of code " << endl << " " << first << endl << endl;
}