Changeset 326 in flair-src for branches/sanscv


Ignore:
Timestamp:
Sep 3, 2019, 3:42:07 PM (5 years ago)
Author:
Sanahuja Guillaume
Message:

using pimpl

Location:
branches/sanscv
Files:
1 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • branches/sanscv/demos/OpticalFlow/uav/src/DemoOpticalFlow.h

    r325 r326  
    6565        flair::filter::OpticalFlowCompensated *opticalFlowCompensated;
    6666        flair::filter::OpticalFlowSpeed *opticalFlowSpeedRaw;
    67         //flair::filter::EulerDerivative *opticalFlowAccelerationRaw;
    68     flair::gui::PushButton *startOpticalflow,*stopOpticalflow;
    69     void StartOpticalFlow(void);
     67        flair::filter::EulerDerivative *opticalFlowAccelerationRaw;
     68        flair::gui::PushButton *startOpticalflow,*stopOpticalflow;
     69        void StartOpticalFlow(void);
    7070        flair::filter::LowPassFilter* opticalFlowSpeed;
    7171        flair::filter::LowPassFilter* opticalFlowAcceleration;
  • branches/sanscv/lib/FlairCore/src/Image.cpp

    r324 r326  
    2929    : io_data(parent, name, n), dataType(width, height, format) {
    3030  this->allocate_data = allocate_data;
    31 Printf("Image %s\n",ObjectName().c_str());
     31
    3232  if (allocate_data) {
    3333    switch (format) {
     
    7373
    7474char* Image::DefaultAllocFunction(ssize_t size){
    75   Printf("default alloc %i\n",size);
    7675  return (char*)malloc(size);
    7776}
    7877
    7978void Image::DefaultFreeFunction(char* buffer){
    80   Printf("default free\n");
    8179  free(buffer);
    8280}
  • branches/sanscv/lib/FlairVisionFilter/src/CvtColor.cpp

    r325 r326  
    1515#include "VisionFilter.h"
    1616#include <Image.h>
    17 //#include <dspcv_gpp.h>
    1817#include <typeinfo>
    1918
  • branches/sanscv/lib/FlairVisionFilter/src/HoughLines.cpp

    r325 r326  
    2020#include <GroupBox.h>
    2121#include <SpinBox.h>
    22 #include <DoubleSpinBox.h>
    23 //#include <dspcv_gpp.h>
     22#include <DoubleSpinBox.h>>
    2423#include <typeinfo>
    2524#include <math.h>
  • branches/sanscv/lib/FlairVisionFilter/src/ImgThreshold.cpp

    r325 r326  
    1818#include <GroupBox.h>
    1919#include <SpinBox.h>
    20 //#include <dspcv_gpp.h>
    2120#include <typeinfo>
    2221
  • branches/sanscv/lib/FlairVisionFilter/src/OpticalFlow.cpp

    r325 r326  
    1919#include <GroupBox.h>
    2020#include <SpinBox.h>
    21 //#include <dspcv_gpp.h>
    22 #include <algorithm>
    2321#include <OneAxisRotation.h>
    24 #include <Vector3D.h>
    2522#include <typeinfo>
    2623
  • branches/sanscv/lib/FlairVisionFilter/src/OpticalFlowData.cpp

    r324 r326  
    1212
    1313#include "OpticalFlowData.h"
    14 #include <cstring>
     14#include "VisionFilter.h"
     15#include <string.h>
    1516
    1617using std::string;
    1718
    18 namespace flair
    19 {
    20 namespace filter
    21 {
     19class OpticalFlowData_impl {
     20public:
     21    OpticalFlowData_impl(flair::filter::OpticalFlowData* self,uint32_t max_features) {
     22        this->self=self;
     23        this->max_features=max_features;
     24        nb_features=0;
     25        pointsA=(IntPoint*)malloc(max_features*sizeof(IntPoint));
     26        pointsB=(FloatPoint*)malloc(max_features*sizeof(FloatPoint));
    2227
    23 OpticalFlowData::OpticalFlowData(const Object* parent,uint32_t max_features,string name,uint32_t n): io_data(parent,name,n)
    24 {
    25     this->max_features=max_features;
    26     nb_features=0;
     28        found_features=(char*)malloc(max_features*sizeof(char));
     29        features_error=(uint32_t*)malloc(max_features*sizeof(uint32_t));
     30    }
    2731
    28     pointsA=(CvPoint *)malloc(max_features*sizeof(CvPoint));
    29     pointsB=(CvPoint2D32f *)malloc(max_features*sizeof(CvPoint2D32f));
     32    ~OpticalFlowData_impl() {
     33        free((char*)pointsA);
     34        free((char*)pointsB);
    3035
    31     found_features=(char *)malloc(max_features*sizeof(char));
    32     features_error=(uint32_t*)malloc(max_features*sizeof(uint32_t));
     36        free((char*)found_features);
     37        free((char*)features_error);
     38    }
     39   
     40    void Resize(uint32_t value) {
     41        IntPoint *new_pointsA;
     42        FloatPoint *new_pointsB;
     43        char *new_found_features;
     44        uint32_t *new_features_error;
     45
     46        new_pointsA=(IntPoint*)malloc(value*sizeof(IntPoint));
     47        new_pointsB=(FloatPoint*)malloc(value*sizeof(FloatPoint));
     48        new_found_features=(char*)malloc(value*sizeof(char));
     49        new_features_error=(uint32_t*)malloc(value*sizeof(uint32_t));
     50
     51        self->GetMutex();
     52        if(value>max_features) {
     53            memcpy(new_pointsA,pointsA,max_features*sizeof(IntPoint));
     54            memcpy(new_pointsB,pointsB,max_features*sizeof(FloatPoint));
     55            memcpy(new_found_features,found_features,max_features*sizeof(char));
     56            memcpy(new_features_error,features_error,max_features*sizeof(uint32_t));
     57        } else {
     58            memcpy(new_pointsA,pointsA,value*sizeof(IntPoint));
     59            memcpy(new_pointsB,pointsB,value*sizeof(FloatPoint));
     60            memcpy(new_found_features,found_features,value*sizeof(char));
     61            memcpy(new_features_error,features_error,value*sizeof(uint32_t));
     62            if(nb_features>value) nb_features=value; //si nb_features est le nombre de point qui ont effectivement une correspondande, ça me parait louche. Sauf si les points sont classés et que ceux qui ont une correpondance sont toujours au début
     63        }
     64        max_features=value;
     65        self->ReleaseMutex();
     66
     67        free((char*)pointsA);
     68        free((char*)pointsB);
     69        free((char*)found_features);
     70        free((char*)features_error);
     71
     72        pointsA=new_pointsA;
     73        pointsB=new_pointsB;
     74        found_features=new_found_features;
     75        features_error=new_features_error;
     76    }
     77       
     78    uint32_t max_features;
     79    uint32_t nb_features;
     80    IntPoint* pointsA;
     81    FloatPoint* pointsB;
     82    char *found_features;
     83    uint32_t *features_error;
     84
     85private:
     86    flair::filter::OpticalFlowData *self;
     87};
     88
     89namespace flair {
     90namespace filter {
     91
     92OpticalFlowData::OpticalFlowData(const Object* parent,uint32_t max_features,string name,uint32_t n): io_data(parent,name,n) {
     93    pimpl_=new OpticalFlowData_impl(this,max_features);
    3394}
    3495
    35 OpticalFlowData::~OpticalFlowData()
    36 {
    37     free(pointsA);
    38     free(pointsB);
    39 
    40     free(found_features);
    41     free(features_error);
     96OpticalFlowData::~OpticalFlowData() {
     97    delete pimpl_;
    4298}
    4399
    44 CvPoint* OpticalFlowData::PointsA(void) const
    45 {
    46     return pointsA;
     100IntPoint* OpticalFlowData::PointsA(void) const {
     101    return pimpl_->pointsA;
    47102}
    48103
    49 CvPoint2D32f* OpticalFlowData::PointsB(void) const
    50 {
    51     return pointsB;
     104FloatPoint* OpticalFlowData::PointsB(void) const {
     105    return pimpl_->pointsB;
    52106}
    53107
    54 char *OpticalFlowData::FoundFeature(void) const
    55 {
    56     return found_features;
     108char *OpticalFlowData::FoundFeature(void) const {
     109    return pimpl_->found_features;
    57110}
    58111
    59 uint32_t *OpticalFlowData::FeatureError(void) const
    60 {
    61     return features_error;
     112uint32_t *OpticalFlowData::FeatureError(void) const {
     113    return pimpl_->features_error;
    62114}
    63115
    64116// value is new max_features value
    65117void OpticalFlowData::Resize(uint32_t value) {
    66     CvPoint *new_pointsA;
    67     CvPoint2D32f *new_pointsB;
    68     char *new_found_features;
    69     uint32_t *new_features_error;
    70 
    71     new_pointsA=(CvPoint *)malloc(value*sizeof(CvPoint));
    72     new_pointsB=(CvPoint2D32f *)malloc(value*sizeof(CvPoint2D32f));
    73     new_found_features=(char *)malloc(value*sizeof(char));
    74     new_features_error=(uint32_t *)malloc(value*sizeof(uint32_t));
    75 
    76     GetMutex();
    77     if(value>max_features) {
    78         memcpy(new_pointsA,pointsA,max_features*sizeof(CvPoint));
    79         memcpy(new_pointsB,pointsB,max_features*sizeof(CvPoint2D32f));
    80         memcpy(new_found_features,found_features,max_features*sizeof(char));
    81         memcpy(new_features_error,features_error,max_features*sizeof(uint32_t));
    82     }
    83     else {
    84         memcpy(new_pointsA,pointsA,value*sizeof(CvPoint));
    85         memcpy(new_pointsB,pointsB,value*sizeof(CvPoint2D32f));
    86         memcpy(new_found_features,found_features,value*sizeof(char));
    87         memcpy(new_features_error,features_error,value*sizeof(uint32_t));
    88         if(nb_features>value) nb_features=value; //si nb_features est le nombre de point qui ont effectivement une correspondande, ça me parait louche. Sauf si les points sont classés et que ceux qui ont une correpondance sont toujours au début
    89     }
    90     max_features=value;
    91     ReleaseMutex();
    92 
    93     free(pointsA);
    94     free(pointsB);
    95     free(found_features);
    96     free(features_error);
    97 
    98     pointsA=new_pointsA;
    99     pointsB=new_pointsB;
    100     found_features=new_found_features;
    101     features_error=new_features_error;
     118    pimpl_->Resize(value);
    102119}
    103120
    104 void OpticalFlowData::RawRead(char* dst) const
    105 {
     121void OpticalFlowData::RawRead(char* dst) const {
    106122    Warn("non implementé\n");
    107123}
    108124
    109 void OpticalFlowData::SetPointsA(const CvPoint* points)
    110 {
     125void OpticalFlowData::SetPointsA(const IntPoint* points) {
    111126    GetMutex();
    112     memcpy(pointsA,points,max_features*sizeof(CvPoint));
     127    memcpy(pimpl_->pointsA,points,pimpl_->max_features*sizeof(IntPoint));
    113128    ReleaseMutex();
    114129}
    115130
    116 void OpticalFlowData::SetPointsB(const CvPoint2D32f* points)
    117 {
     131void OpticalFlowData::SetPointsB(const FloatPoint* points) {
    118132    GetMutex();
    119     memcpy(pointsB,points,max_features*sizeof(CvPoint2D32f));
     133    memcpy(pimpl_->pointsB,points,pimpl_->max_features*sizeof(FloatPoint));
    120134    ReleaseMutex();
    121135}
    122136
    123 void OpticalFlowData::SetFoundFeature(const char *found_features)
    124 {
     137void OpticalFlowData::SetFoundFeature(const char *found_features) {
    125138    GetMutex();
    126     memcpy(this->found_features,found_features,max_features*sizeof(char));
     139    memcpy(pimpl_->found_features,found_features,pimpl_->max_features*sizeof(char));
    127140    ReleaseMutex();
    128141}
    129142
    130 void OpticalFlowData::SetFeatureError(const uint32_t *features_error)
    131 {
     143void OpticalFlowData::SetFeatureError(const uint32_t *features_error) {
    132144    GetMutex();
    133     memcpy(this->features_error,features_error,max_features*sizeof(uint32_t));
     145    memcpy(pimpl_->features_error,features_error,pimpl_->max_features*sizeof(uint32_t));
    134146    ReleaseMutex();
    135147}
    136148
    137 uint32_t OpticalFlowData::MaxFeatures(void) const
    138 {
    139     return max_features;
     149uint32_t OpticalFlowData::MaxFeatures(void) const {
     150    return pimpl_->max_features;
    140151}
    141152
    142 uint32_t OpticalFlowData::NbFeatures(void) const
    143 {
    144     return nb_features;
     153uint32_t OpticalFlowData::NbFeatures(void) const {
     154    return pimpl_->nb_features;
    145155}
    146156
    147 void OpticalFlowData::SetNbFeatures(uint32_t value)
    148 {
     157void OpticalFlowData::SetNbFeatures(uint32_t value) {
    149158    GetMutex();
    150     nb_features=value;
     159    pimpl_->nb_features=value;
    151160    ReleaseMutex();
    152161}
  • branches/sanscv/lib/FlairVisionFilter/src/OpticalFlowData.h

    r324 r326  
    1111
    1212#include <io_data.h>
    13 #include <cvtypes.h>
     13
     14//TODO: use flai::core::Vector2D
     15typedef struct IntPoint {
     16    int x;
     17    int y;
     18}
     19IntPoint;
     20
     21typedef struct FloatPoint {
     22    float x;
     23    float y;
     24}
     25FloatPoint;
     26
     27class OpticalFlowData_impl;
    1428
    1529namespace flair { namespace filter {
     
    5367        *
    5468    */
    55         CvPoint* PointsA(void) const;
     69        IntPoint* PointsA(void) const;
    5670
    5771        /*!
     
    5973        *
    6074        */
    61         CvPoint2D32f* PointsB(void) const;
     75        FloatPoint* PointsB(void) const;
    6276
    6377        /*!
     
    7993        * \param points points
    8094        */
    81         void SetPointsA(const CvPoint *points);
     95        void SetPointsA(const IntPoint *points);
    8296
    8397        /*!
     
    86100        * \param points points
    87101        */
    88         void SetPointsB(const CvPoint2D32f *points);
     102        void SetPointsB(const FloatPoint *points);
    89103
    90104        /*!
     
    139153        */
    140154        void RawRead(char *dst) const;
    141 
     155       
    142156    private:
    143         uint32_t max_features;
    144         uint32_t nb_features;
    145         CvPoint* pointsA;
    146         CvPoint2D32f* pointsB;
    147         char *found_features;
    148         uint32_t *features_error;
    149157        Type dataType;
     158        OpticalFlowData_impl *pimpl_;
    150159    };
    151160} // end namespace filter
  • branches/sanscv/lib/FlairVisionFilter/src/Sobel.cpp

    r325 r326  
    1818#include <GroupBox.h>
    1919#include <SpinBox.h>
    20 //#include <dspcv_gpp.h>
    2120#include <typeinfo>
    2221
Note: See TracChangeset for help on using the changeset viewer.