Changeset 124 in flair-src for trunk/demos


Ignore:
Timestamp:
Jan 12, 2017, 10:39:23 AM (8 years ago)
Author:
Sanahuja Guillaume
Message:

modifs jpeg

Location:
trunk/demos/OpticalFlow/uav/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/demos/OpticalFlow/uav/src/DemoOpticalFlow.cpp

    r122 r124  
    2626#include <GroupBox.h>
    2727#include <DoubleSpinBox.h>
     28#include <PushButton.h>
    2829#include <FrameworkManager.h>
    2930#include <MetaDualShock3.h>
     
    4950uav->GetVerticalCamera()->SetLogFormat(Camera::LogFormat::JPG);
    5051getFrameworkManager()->AddDeviceToLog(uav->GetVerticalCamera());
    51     greyCameraImage=new CvtColor(uav->GetVerticalCamera(),"gray",CvtColor::Conversion_t::GRAY);
     52       
     53        startOpticalflow=new PushButton(GetButtonsLayout()->NewRow(),"start optical flow");
    5254
    53     uav->GetVerticalCamera()->UseDefaultPlot(greyCameraImage->Output()); // Le defaultPlot de la caméra peut afficher n'importe quoi?
     55        greyCameraImage=new CvtColor(uav->GetVerticalCamera(),"gray",CvtColor::Conversion_t::ToGray);
    5456
    55     //optical flow stack
    56     opticalFlow=new OpticalFlow(greyCameraImage,uav->GetVerticalCamera()->GetLayout()->NewRow(),"flux optique");
    57     opticalFlowSpeed=new OpticalFlowSpeed(opticalFlow,"vitesse du flux optique");
     57        uav->GetVerticalCamera()->UseDefaultPlot(greyCameraImage->Output()); // Le defaultPlot de la caméra peut afficher n'importe quoi?
    5858
    59     cvmatrix_descriptor* desc=new cvmatrix_descriptor(2,1);
    60     for(int i=0;i<2;i++) {
    61         desc->SetElementName(i,0,opticalFlowSpeed->Output()->Name(i,0));
    62     }
    63     cvmatrix* prev_value=new cvmatrix((const Thread*)this,desc,floatType,uav->ObjectName()); // diamond inheritance
    64     for(int i=0;i<2;i++) {
    65         prev_value->SetValue(i,0,0);
    66     }
     59        //optical flow stack
     60        opticalFlow=new OpticalFlow(greyCameraImage,uav->GetVerticalCamera()->GetLayout()->NewRow(),"flux optique");
     61        opticalFlowSpeed=new OpticalFlowSpeed(opticalFlow,"vitesse du flux optique");
    6762
    68     opticalFlowSpeedFiltered=new LowPassFilter(opticalFlowSpeed,uav->GetVerticalCamera()->GetLayout()->NewRow(),"passe bas",prev_value);
     63        cvmatrix_descriptor* desc=new cvmatrix_descriptor(2,1);
     64        for(int i=0;i<2;i++) {
     65                        desc->SetElementName(i,0,opticalFlowSpeed->Output()->Name(i,0));
     66        }
     67        cvmatrix* prev_value=new cvmatrix((const Thread*)this,desc,floatType,uav->ObjectName()); // diamond inheritance
     68        for(int i=0;i<2;i++) {
     69                        prev_value->SetValue(i,0,0);
     70        }
     71
     72        opticalFlowSpeedFiltered=new LowPassFilter(opticalFlowSpeed,uav->GetVerticalCamera()->GetLayout()->NewRow(),"passe bas",prev_value);
    6973// delete prev_value?
    7074
    71     getFrameworkManager()->AddDeviceToLog(opticalFlowSpeed);
     75        getFrameworkManager()->AddDeviceToLog(opticalFlowSpeed);
    7276
    73     Tab* opticalFlowTab=new Tab(getFrameworkManager()->GetTabWidget(),"flux optique");
    74     DataPlot1D* xVelocityPlot=new DataPlot1D(opticalFlowTab->NewRow(),"x_velocity",-5,5);
    75     DataPlot1D* yVelocityPlot=new DataPlot1D(opticalFlowTab->LastRowLastCol(),"y_velocity",-5,5);
     77        Tab* opticalFlowTab=new Tab(getFrameworkManager()->GetTabWidget(),"flux optique");
     78        DataPlot1D* xVelocityPlot=new DataPlot1D(opticalFlowTab->NewRow(),"x_velocity",-5,5);
     79        DataPlot1D* yVelocityPlot=new DataPlot1D(opticalFlowTab->LastRowLastCol(),"y_velocity",-5,5);
    7680
    77     xVelocityPlot->AddCurve(opticalFlowSpeed->Output()->Element(0,0));
    78     xVelocityPlot->AddCurve(opticalFlowSpeedFiltered->Matrix()->Element(0,0),DataPlot::Blue);
    79     yVelocityPlot->AddCurve(opticalFlowSpeed->Output()->Element(1,0));
    80     yVelocityPlot->AddCurve(opticalFlowSpeedFiltered->Matrix()->Element(1,0),DataPlot::Blue);
     81        xVelocityPlot->AddCurve(opticalFlowSpeed->Output()->Element(0,0));
     82        xVelocityPlot->AddCurve(opticalFlowSpeedFiltered->Matrix()->Element(0,0),DataPlot::Blue);
     83        yVelocityPlot->AddCurve(opticalFlowSpeed->Output()->Element(1,0));
     84        yVelocityPlot->AddCurve(opticalFlowSpeedFiltered->Matrix()->Element(1,0),DataPlot::Blue);
    8185
    82     u_x=new Pid(setupLawTab->At(1,0),"u_x");
    83     u_x->UseDefaultPlot(graphLawTab->NewRow());
    84     u_y=new Pid(setupLawTab->At(1,1),"u_y");
    85     u_y->UseDefaultPlot(graphLawTab->LastRowLastCol());
     86        u_x=new Pid(setupLawTab->At(1,0),"u_x");
     87        u_x->UseDefaultPlot(graphLawTab->NewRow());
     88        u_y=new Pid(setupLawTab->At(1,1),"u_y");
     89        u_y->UseDefaultPlot(graphLawTab->LastRowLastCol());
    8690
    87     opticalFlowGroupBox=new GroupBox(GetJoystick()->GetTab()->NewRow(),"consignes fo");
    88     maxXSpeed=new DoubleSpinBox(opticalFlowGroupBox->NewRow(),"debattement x"," m/s",-5,5,0.1,1);
    89     maxYSpeed=new DoubleSpinBox(opticalFlowGroupBox->LastRowLastCol(),"debattement y"," m/s",-5,5,0.1,1);
     91        opticalFlowGroupBox=new GroupBox(GetJoystick()->GetTab()->NewRow(),"consignes fo");
     92        maxXSpeed=new DoubleSpinBox(opticalFlowGroupBox->NewRow(),"debattement x"," m/s",-5,5,0.1,1);
     93        maxYSpeed=new DoubleSpinBox(opticalFlowGroupBox->LastRowLastCol(),"debattement y"," m/s",-5,5,0.1,1);
    9094
    91     opticalFlowReference=new cvmatrix((const Thread*)this,2,1,floatType);
    92     xVelocityPlot->AddCurve(opticalFlowReference->Element(0,0),DataPlot::Green,"consigne");
    93     yVelocityPlot->AddCurve(opticalFlowReference->Element(1,0),DataPlot::Green,"consigne");
     95        opticalFlowReference=new cvmatrix((const Thread*)this,2,1,floatType);
     96        xVelocityPlot->AddCurve(opticalFlowReference->Element(0,0),DataPlot::Green,"consigne");
     97        yVelocityPlot->AddCurve(opticalFlowReference->Element(1,0),DataPlot::Green,"consigne");
    9498
    95     customReferenceOrientation= new AhrsData(this,"reference");
    96     uav->GetAhrs()->AddPlot(customReferenceOrientation,DataPlot::Yellow);
    97     AddDataToControlLawLog(customReferenceOrientation);
     99        customReferenceOrientation= new AhrsData(this,"reference");
     100        uav->GetAhrs()->AddPlot(customReferenceOrientation,DataPlot::Yellow);
     101        AddDataToControlLawLog(customReferenceOrientation);
    98102}
    99103
     
    107111}
    108112
     113void DemoOpticalFlow::StartOpticalFlow(void) {
     114        if (SetOrientationMode(OrientationMode_t::Custom)) {
     115                        Thread::Info("(Re)entering optical flow mode\n");
     116                        u_x->Reset();
     117                        u_y->Reset();
     118        } else {
     119                        Thread::Warn("Could not enter optical flow mode\n");
     120        }
     121}
     122
     123void DemoOpticalFlow::ExtraCheckPushButton(void) {
     124        if(startOpticalflow->Clicked()) {
     125        //StartOpticalFlow();
     126                                GetUav()->GetVerticalCamera()->SavePictureToFile("./toto.jpg");
     127                               
     128        }
     129}
     130
    109131void DemoOpticalFlow::ExtraCheckJoystick(void) {
    110132    static bool wasOpticalFlowModeButtonPressed=false;
     
    113135        if (!wasOpticalFlowModeButtonPressed) {
    114136            wasOpticalFlowModeButtonPressed=true;
    115             if (SetOrientationMode(OrientationMode_t::Custom)) {
    116                 Thread::Info("(Re)entering optical flow mode\n");
    117                 u_x->Reset();
    118                 u_y->Reset();
    119             } else {
    120                 Thread::Warn("Could not enter optical flow mode\n");
    121             }
     137            StartOpticalFlow();
    122138        }
    123139    } else {
  • trunk/demos/OpticalFlow/uav/src/DemoOpticalFlow.h

    r122 r124  
    2525        class GroupBox;
    2626        class DoubleSpinBox;
     27        class PushButton;
    2728    }
    2829    namespace filter {
     
    4647        void SignalEvent(Event_t event);
    4748        void ExtraCheckJoystick(void);
     49                                void ExtraCheckPushButton(void);
    4850        const flair::core::AhrsData *GetReferenceOrientation(void);
    4951
     
    5961        flair::filter::OpticalFlow *opticalFlow;
    6062        flair::filter::OpticalFlowSpeed *opticalFlowSpeed;
     63                                flair::gui::PushButton *startOpticalflow,*stopOpticalflow;
     64                                void StartOpticalFlow(void);
    6165};
    6266
Note: See TracChangeset for help on using the changeset viewer.