Changeset 160 in flair-src for trunk/lib/FlairMeta/src/SimuX8.cpp


Ignore:
Timestamp:
03/05/17 12:21:41 (5 years ago)
Author:
Sanahuja Guillaume
Message:

cam

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairMeta/src/SimuX8.cpp

    r158 r160  
    2626#include <BatteryMonitor.h>
    2727#include <Tab.h>
     28#include <FindArgument.h>
    2829
    2930using std::string;
     
    5152  SetBatteryMonitor(new BatteryMonitor(bat_tab->NewRow(), "battery"));
    5253  GetBatteryMonitor()->SetBatteryValue(12);
    53   SetVerticalCamera(new SimuCamera("simu_cam_v", 320, 240, 3, simu_id,0, 10));
    54   //SetHorizontalCamera(new SimuCamera("simu_cam_h", 320, 240, 3, simu_id,1, 10));
     54 
     55  uint16_t camvWidth=320,camvHeight=240;
     56        ReadCameraResolutionOption(options,"camv",camvWidth,camvHeight);
     57  Info("using vertical camera resolution: %ix%i\n",camvWidth, camvHeight);
     58  SetVerticalCamera(new SimuCamera("simu_cam_v", camvWidth, camvHeight, 3, simu_id,0, 10));
     59 
     60  uint16_t camhWidth=320,camhHeight=240;
     61  ReadCameraResolutionOption(options,"camh",camhWidth,camhHeight);
     62  Info("using horizontal camera resolution: %ix%i\n",camhWidth, camhHeight);
     63  SetHorizontalCamera(new SimuCamera("simu_cam_h", camhWidth, camhHeight, 3, simu_id,1, 10));
    5564}
    5665
     
    6170  ((SimuUs *)GetUsRangeFinder())->Start();
    6271  ((SimuCamera *)GetVerticalCamera())->Start();
     72  ((SimuCamera *)GetHorizontalCamera())->Start();
     73}
     74
     75void SimuX8::ReadCameraResolutionOption(string options,string cameraName,uint16_t &camWidth,uint16_t &camHeight) const {
     76  string camOpts=FindArgument(options,cameraName +"=",false);
     77        if(camOpts!="") {
     78    size_t position=camOpts.find("x");
     79    if(position!=std::string::npos) {
     80        camWidth=std::stoi(camOpts.substr(0,position));
     81        camHeight=std::stoi(camOpts.substr(position+1,std::string::npos));
     82    } else {
     83      Warn("bad camera resolution parameter (%s) should be WIDTHxHEIGHT format\n",camOpts.c_str());
     84    }
     85  }
    6386}
    6487
Note: See TracChangeset for help on using the changeset viewer.