<commit_before>#include <boost/shared_ptr.hpp>
#include <lcm/lcm-cpp.hpp>
#include "lcmtypes/bot_core.hpp"
#include "lcmtypes/multisense.hpp"

#include <image-passthrough/image-passthrough-app.hpp>

#include <ConciseArgs>
using namespace std;


class Main{
  public:
    Main(int argc, char** argv, boost::shared_ptr<lcm::LCM> &publish_lcm, 
         std::string camera_channel_, int output_color_mode_, 
         bool use_convex_hulls, string camera_frame,
         bool verbose);
    
    ~Main(){
    }

  private:
    boost::shared_ptr<lcm::LCM> lcm_;
    void multisenseHandler(const lcm::ReceiveBuffer* rbuf, const std::string& channel, 
                           const  multisense::images_t* msg);  
    Pass::Ptr pass;
    
    image_io_utils*  imgutils_; 
    BotParam* botparam_; 
    CameraParams camera_params_;   
    uint8_t* img_buf_;
};
    
    
Main::Main(int argc, char** argv, boost::shared_ptr<lcm::LCM> &lcm_, 
           std::string camera_channel, int output_color_mode, 
           bool use_convex_hulls, std::string camera_frame,
           bool verbose): lcm_(lcm_){

  // Get Camera Parameters:
  botparam_ = bot_param_new_from_server(lcm_->getUnderlyingLCM(), 0);
  camera_params_.setParams(botparam_, string("cameras." + camera_channel) );
      
  pass = Pass::Ptr (new Pass (argc, argv, lcm_, 
                              camera_channel, output_color_mode, 
                              use_convex_hulls, camera_frame, 
                              camera_params_, verbose));
  lcm_->subscribe("CAMERA",&Main::multisenseHandler,this);  
  
  
  img_buf_= (uint8_t*) malloc(3* camera_params_.width  * camera_params_.height);
  imgutils_ = new image_io_utils( lcm_->getUnderlyingLCM(), 
                                  camera_params_.width, 
                                  3*camera_params_.height );
  
}

void Main::multisenseHandler(const lcm::ReceiveBuffer* rbuf, const std::string& channel, 
                             const  multisense::images_t* msg){
  int64_t msg_time = msg->utime;
  if (pass->createMask(msg_time) ){
    pass->sendOutput(msg_time);  
    
    imgutils_->decodeImageToRGB(&(msg->images[0]),  img_buf_ );
    
    pass->sendOutputOverlay(msg_time, img_buf_);  
    
  }
  
  
  
}

int main( int argc, char** argv ){
  ConciseArgs parser(argc, argv, "lidar-passthrough");
  string camera_channel="CAMERA_LEFT";
  int output_color_mode=1; // 0 =rgb, 1=grayscale mask, 2=binary black/white grayscale mask
  bool use_convex_hulls=false;
  string camera_frame = "left_camera_optical_frame";
  bool verbose = false;
  parser.add(camera_channel, "c", "camera_channel", "Camera channel");
  parser.add(camera_frame, "f", "camera_frame", "Camera frame");
  parser.add(output_color_mode, "o", "output_color_mode", "0rgb |1grayscale |2b/w");
  parser.add(use_convex_hulls, "u", "use_convex_hulls", "Use convex hull models");
  parser.add(verbose, "v", "verbose", "Verbose");
  parser.parse();
  cout << camera_channel << " is camera_channel\n"; 
  cout << camera_frame << " is camera_frame\n"; 
  cout << output_color_mode << " is output_color_mode\n"; 
  cout << use_convex_hulls << " is use_convex_hulls\n"; 
  cout << verbose << " is verbose\n"; 
  
  boost::shared_ptr<lcm::LCM> lcm(new lcm::LCM);
  if(!lcm->good()){
    std::cerr <<"ERROR: lcm is not good()" <<std::endl;
  }
  
  Main main(argc,argv, lcm, 
            camera_channel,output_color_mode, 
            use_convex_hulls, camera_frame, verbose);
  cout << "image-passthrough ready" << endl << endl;
  while(0 == lcm->handle());
  return 0;
}<commit_msg>image passthrough supports a single image now<commit_after>#include <boost/shared_ptr.hpp>
#include <lcm/lcm-cpp.hpp>
#include "lcmtypes/bot_core.hpp"
#include "lcmtypes/multisense.hpp"

#include <image-passthrough/image-passthrough-app.hpp>

#include <ConciseArgs>
using namespace std;


class Main{
  public:
    Main(int argc, char** argv, boost::shared_ptr<lcm::LCM> &publish_lcm, 
         std::string camera_channel_, int output_color_mode_, 
         bool use_convex_hulls, string camera_frame,
         bool verbose, bool use_mono);
    
    ~Main(){
    }

  private:
    boost::shared_ptr<lcm::LCM> lcm_;
    void multisenseHandler(const lcm::ReceiveBuffer* rbuf, const std::string& channel, 
                           const  multisense::images_t* msg);    
    void cameraHandler(const lcm::ReceiveBuffer* rbuf, const std::string& channel, 
                             const  bot_core::image_t* msg);
    Pass::Ptr pass;
    
    image_io_utils*  imgutils_; 
    BotParam* botparam_; 
    CameraParams camera_params_;   
    uint8_t* img_buf_;
};
    
    
Main::Main(int argc, char** argv, boost::shared_ptr<lcm::LCM> &lcm_, 
           std::string camera_channel, int output_color_mode, 
           bool use_convex_hulls, std::string camera_frame,
           bool verbose, bool use_mono): lcm_(lcm_){

  // Get Camera Parameters:
  botparam_ = bot_param_new_from_server(lcm_->getUnderlyingLCM(), 0);
  camera_params_.setParams(botparam_, string("cameras." + camera_channel) );
      
  pass = Pass::Ptr (new Pass (argc, argv, lcm_, 
                              camera_channel, output_color_mode, 
                              use_convex_hulls, camera_frame, 
                              camera_params_, verbose));
  if (use_mono){
    lcm_->subscribe("CAMERA_LEFT",&Main::cameraHandler,this);  
  }else{
    lcm_->subscribe("CAMERA",&Main::multisenseHandler,this);
  }
  
  img_buf_= (uint8_t*) malloc(3* camera_params_.width  * camera_params_.height);
  imgutils_ = new image_io_utils( lcm_->getUnderlyingLCM(), 
                                  camera_params_.width, 
                                  3*camera_params_.height );
  
}

void Main::multisenseHandler(const lcm::ReceiveBuffer* rbuf, const std::string& channel, 
                             const  multisense::images_t* msg){
  int64_t msg_time = msg->utime;
  if (pass->createMask(msg_time) ){
    pass->sendOutput(msg_time);  
    
    imgutils_->decodeImageToRGB(&(msg->images[0]),  img_buf_ );
    
    pass->sendOutputOverlay(msg_time, img_buf_);  
  }
}


void Main::cameraHandler(const lcm::ReceiveBuffer* rbuf, const std::string& channel, 
                             const  bot_core::image_t* msg){
  int64_t msg_time = msg->utime;
  if (pass->createMask(msg_time) ){
    pass->sendOutput(msg_time);  
    
    imgutils_->decodeImageToRGB( msg,  img_buf_ );
    
    pass->sendOutputOverlay(msg_time, img_buf_);  
  }
}

int main( int argc, char** argv ){
  ConciseArgs parser(argc, argv, "lidar-passthrough");
  string camera_channel="CAMERA_LEFT";
  int output_color_mode=1; // 0 =rgb, 1=grayscale mask, 2=binary black/white grayscale mask
  bool use_convex_hulls=false;
  string camera_frame = "left_camera_optical_frame";
  bool verbose = false;
  bool mono = false;
  parser.add(camera_channel, "c", "camera_channel", "Camera channel");
  parser.add(camera_frame, "f", "camera_frame", "Camera frame");
  parser.add(output_color_mode, "o", "output_color_mode", "0rgb |1grayscale |2b/w");
  parser.add(use_convex_hulls, "u", "use_convex_hulls", "Use convex hull models");
  parser.add(verbose, "v", "verbose", "Verbose");
  parser.add(mono, "m", "mono", "Key off of the left monocularimage");  
  parser.parse();
  cout << camera_channel << " is camera_channel\n"; 
  cout << camera_frame << " is camera_frame\n"; 
  cout << output_color_mode << " is output_color_mode\n"; 
  cout << use_convex_hulls << " is use_convex_hulls\n"; 
  cout << verbose << " is verbose\n";
  cout << mono << " is mono\n";
  
  boost::shared_ptr<lcm::LCM> lcm(new lcm::LCM);
  if(!lcm->good()){
    std::cerr <<"ERROR: lcm is not good()" <<std::endl;
  }
  
  Main main(argc,argv, lcm, 
            camera_channel,output_color_mode, 
            use_convex_hulls, camera_frame, verbose,
           mono);
  cout << "image-passthrough ready" << endl << endl;
  while(0 == lcm->handle());
  return 0;
}
{'fraction_non_alphanumeric': 0.13071895424836602, 'fraction_numerical': 0.004524886877828055, 'mean_word_length': 3.15075639019301, 'pattern_counts': {'":': 0, '<': 83, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1093559', 'n_tokens_mistral': 2825, 'n_tokens_neox': 2673, 'n_words': 530}