Ignore:
Timestamp:
07/23/18 17:03:47 (6 years ago)
Author:
Sanahuja Guillaume
Message:

add saturation to euler derivative

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairFilter/src/EulerDerivative_impl.cpp

    r223 r256  
    6060 
    6161  cvmatrix_descriptor *desc = new cvmatrix_descriptor(output->Rows(), output->Cols());
    62   prev_value = new Matrix(self, desc, output->GetDataType().GetElementDataType(), name);
     62  prev_input = new Matrix(self, desc, output->GetDataType().GetElementDataType(), name);
     63  prev_output = new Matrix(self, desc, output->GetDataType().GetElementDataType(), name);
     64  delete desc;
    6365
    6466
    6567  // init UI
    6668  GroupBox *reglages_groupbox = new GroupBox(position, name);
    67   T = new DoubleSpinBox(reglages_groupbox->NewRow(), "period, 0 for auto:",
    68                         " s", 0, 1, 0.01);
     69  T = new DoubleSpinBox(reglages_groupbox->NewRow(), "period, 0 for auto:"," s", 0, 1, 0.01);
     70  sat = new DoubleSpinBox(reglages_groupbox->NewRow(), "saturation, -1 to disable:",-1,100000,1,1,-1);
    6971}
    7072
     
    8789    for (int i = 0; i < input->Rows(); i++) {
    8890      for (int j = 0; j < input->Cols(); j++) {
    89         prev_value->SetValueNoMutex(i, j, input->ValueNoMutex(i, j));
     91        prev_input->SetValueNoMutex(i, j, input->ValueNoMutex(i, j));
    9092      }
    9193    }
     
    101103      for (int i = 0; i < input->Rows(); i++) {
    102104        for (int j = 0; j < input->Cols(); j++) {
    103           output->SetValueNoMutex(
    104               i, j, (input->ValueNoMutex(i, j) - prev_value->ValueNoMutex(i, j)) /
    105                         delta_t);
    106           prev_value->SetValueNoMutex(i, j, input->ValueNoMutex(i, j));
     105          float result=(input->ValueNoMutex(i, j) - prev_input->ValueNoMutex(i, j)) / delta_t;
     106          if(sat->Value()!=-1) {
     107            if(result>sat->Value() && result>0) result=sat->Value();
     108            if(result<-sat->Value() && result<0) result=-sat->Value();
     109          }/* filter by acc
     110          float acc=result-prev_output->ValueNoMutex(i, j)/delta_t;
     111          if(acc>20 || acc<-20)  {
     112            printf("%s %f\n",self->ObjectName().c_str(),acc);
     113          } else {*/
     114            output->SetValueNoMutex(i, j, result);
     115          //}
     116          prev_output->SetValueNoMutex(i, j, result);
     117          prev_input->SetValueNoMutex(i, j, input->ValueNoMutex(i, j));
     118         
    107119        }
    108120      }
Note: See TracChangeset for help on using the changeset viewer.