Changeset 160 in flair-src for trunk/lib/FlairMeta/src/SimuX4.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/SimuX4.cpp

    r158 r160  
    5353  GetBatteryMonitor()->SetBatteryValue(12);
    5454 
    55   string camvOpts=FindArgument(options,"camv=",false);
    5655  uint16_t camvWidth=320,camvHeight=240;
    57         if(camvOpts=="") {
    58     Info("using default vertical camera resolution: %ix%i\n",camvWidth, camvHeight);
    59         }
     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));
    6059 
    61   SetVerticalCamera(new SimuCamera("simu_cam_v", camvWidth, camvHeight, 3, simu_id,0, 10));
    62   //SetHorizontalCamera(new SimuCamera("simu_cam_h", 320, 240, 3, simu_id,1, 10));
     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));
    6364}
    6465
     
    6970  ((SimuUs *)GetUsRangeFinder())->Start();
    7071  ((SimuCamera *)GetVerticalCamera())->Start();
     72  ((SimuCamera *)GetHorizontalCamera())->Start();
    7173}
    7274
     75void SimuX4::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  }
     86}
    7387
    7488} // end namespace meta
Note: See TracChangeset for help on using the changeset viewer.