00001 #include "vpro_frame_diff_process.h" 00002 //: 00003 // \file 00004 #include <vcl_iostream.h> 00005 #include <brip/brip_vil1_float_ops.h> 00006 00007 vpro_frame_diff_process::vpro_frame_diff_process(vpro_frame_diff_params fdp): 00008 vpro_frame_diff_params(fdp) 00009 { 00010 first_frame_ = true; 00011 } 00012 00013 vpro_frame_diff_process::~vpro_frame_diff_process() 00014 { 00015 } 00016 00017 bool vpro_frame_diff_process::execute() 00018 { 00019 if (!this->get_N_input_images()==1) 00020 { 00021 vcl_cout << "In vpro_frame_diff_process::execute() -" 00022 << " not at exactly one input image\n"; 00023 return false; 00024 } 00025 vil1_image img = vpro_video_process::get_input_image(0); 00026 this->clear_input(); 00027 00028 vil1_memory_image_of<float> fimg = brip_vil1_float_ops::convert_to_float(img); 00029 00030 //if first frame, just cache 00031 if (first_frame_) 00032 { 00033 img0_=fimg; 00034 first_frame_ = false; 00035 return false; 00036 } 00037 00038 //compute difference 00039 vil1_memory_image_of<float> dif = brip_vil1_float_ops::difference(img0_,fimg); 00040 00041 00042 // push back buffer 00043 img0_=fimg; 00044 00045 //convert output back to unsigned char 00046 output_image_ = brip_vil1_float_ops::convert_to_byte(dif, -range_, range_); 00047 return true; 00048 } 00049 00050 bool vpro_frame_diff_process::finish() 00051 { 00052 first_frame_ = true; 00053 return true; 00054 }
1.7.5.1