Hello community, is it possible to analyze the frames of a video without performing the complete loop (update() and draw())?
I’m trying for a few days to make a program that is close to a motion video capture. I would like to keep only the frames that are active. For the moment there is a problem when I use Video_source.nextframe() in the while loop the Video_source.isFrameNew() becomes inactive. Here is the code in question, any suggestion will be appreciated.
Thank you so much!
void ofApp::update(){
Video_source.update();
if (Video_source.isFrameNew()){
int Frame_to_show = 0 ;
while(Frame_to_show == 0 ){
IMG_source_cv.allocate(Video_source.getWidth() ,Video_source.getHeight());
IMG_source_cv.setFromPixels(Video_source.getPixels());
IMG_source_cv.resize( VIDEO_width , VIDEO_height );
IMG_gray_cv = IMG_source_cv;
IMG_gray_diff_cv.absDiff(IMG_last_gray_cv, IMG_gray_cv);
IMG_last_gray_cv = IMG_gray_cv;
IMG_gray_diff_cv.threshold(Threshold);
unsigned int Total_changed_pixel = 0 ;
unsigned int size = IMG_gray_diff_cv.getWidth() * IMG_gray_diff_cv.getHeight();
for(int i = 0; i < size ; i++) if( IMG_gray_diff_cv.getPixels()[i] > 0)Total_changed_pixel ++;
if(Total_changed_pixel > 1000) Total_changed_pixel = 1000;
MOTION_value = ofMap(Total_changed_pixel , 0 , 1000, 0,100);
if(MOTION_value > Threshold2 ) {
Frame_to_show = 1;
IMG_action_cv = IMG_gray_cv;
}
else {
Video_source.nextFrame();
Video_source.update();
}
cout << Video_source.getCurrentFrame() << " " << Frame_to_show << endl;
}
}
}