Changeset 124 in flair-src for trunk/lib


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

modifs jpeg

Location:
trunk/lib
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairCore/src/cvimage.cpp

    r15 r124  
    3636      img = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3);
    3737      break;
    38     case Type::Format::GRAY:
     38    case Type::Format::Gray:
    3939      img = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 1);
    4040      break;
     
    5555      img = cvCreateImageHeader(cvSize(width, height), IPL_DEPTH_8U, 3);
    5656      break;
    57     case Type::Format::GRAY:
     57    case Type::Format::Gray:
    5858      img = cvCreateImageHeader(cvSize(width, height), IPL_DEPTH_8U, 1);
    5959      break;
  • trunk/lib/FlairCore/src/cvimage.h

    r15 r124  
    3939      UYVY, /*!< UYVY 16 bits */
    4040      BGR,  /*!< BGR 24 bits */
    41       GRAY, /*!< gray 8 bits */
     41      Gray, /*!< gray 8 bits */
    4242    };
    4343    Type(uint16_t _width, uint16_t _height, Format _format)
     
    4747      size_t pixelSize;
    4848      switch (format) {
    49       case Format::GRAY:
     49      case Format::Gray:
    5050        pixelSize = 1;
    5151        break;
  • trunk/lib/FlairSensorActuator/src/Camera.cpp

    r123 r124  
    116116void Camera::ProcessUpdate(core::io_data* data) {
    117117        if(getFrameworkManager()->IsLogging() && getFrameworkManager()->IsDeviceLogged(this)) {
    118                 switch(logFormat) {
    119                         case LogFormat::JPG:
    120                                         IplImage *img=((cvimage*)data)->img;
    121                                         string filename=getFrameworkManager()->GetLogPath()+"/"+ObjectName()+"_"+std::to_string(data->DataTime())+".jpg";
    122                                         saveToJpeg(img,filename);
    123                                 break;
     118                if(logFormat==LogFormat::JPG) {
     119                        data->GetMutex();
     120                        IplImage *img=((cvimage*)data)->img;
     121                        string filename=getFrameworkManager()->GetLogPath()+"/"+ObjectName()+"_"+std::to_string(data->DataTime())+".jpg";
     122                        switch(((cvimage*)data)->GetDataType().GetFormat()) {
     123                                case cvimage::Type::Format::Gray:
     124                                        saveToJpeg(img,filename,PictureFormat_t::Gray,PictureFormat_t::Gray);
     125                                        break;
     126                                case cvimage::Type::Format::BGR:
     127                                        saveToJpeg(img,filename,PictureFormat_t::RGB,PictureFormat_t::RGB);
     128                                        break;
     129                                case cvimage::Type::Format::UYVY:
     130                                        saveToJpeg(img,filename,PictureFormat_t::UYVY,PictureFormat_t::UYVY);
     131                                        break;
     132                                default:
     133                                        Warn("cannot log to this format\n");
     134                                        break;
     135                        }
     136                        data->ReleaseMutex();
    124137                }
    125138        }
     
    127140}
    128141
    129 void Camera::SaveToFile(string filename) const {
     142void Camera::SavePictureToFile(std::string filename) const {
     143        string::size_type idx = filename.rfind('.');
     144
     145        if(idx != std::string::npos) {
     146                Printf("saving %s\n", filename.c_str());
     147                std::string extension = filename.substr(idx+1);
     148               
     149                output->GetMutex();
     150                if(extension=="jpg") {
     151                        if(output->GetDataType().GetFormat()==cvimage::Type::Format::Gray) saveToJpeg(output->img,filename,PictureFormat_t::Gray,PictureFormat_t::Gray);
     152                        if(output->GetDataType().GetFormat()==cvimage::Type::Format::BGR) saveToJpeg(output->img,filename,PictureFormat_t::RGB,PictureFormat_t::RGB);
     153                        if(output->GetDataType().GetFormat()==cvimage::Type::Format::UYVY) saveToJpeg(output->img,filename,PictureFormat_t::UYVY,PictureFormat_t::UYVY);
     154                } else {
     155                        cvSaveImage(filename.c_str(),output->img);
     156                }
     157                output->ReleaseMutex();
     158                       
     159        } else {
     160                Warn("saving %s no file extension!\n", filename.c_str());
     161        }
     162}
     163
     164void Camera::SaveRawPictureToFile(string filename) const {
    130165  Printf("saving %s, size %i\n", filename.c_str(), output->img->imageSize);
    131166  std::ofstream pFile;
  • trunk/lib/FlairSensorActuator/src/Camera.h

    r122 r124  
    9292
    9393  /*!
     94  * \brief Save raw picture to file
     95  *
     96  * \param filename filename
     97  */
     98  void SaveRawPictureToFile(std::string filename) const;
     99       
     100        /*!
    94101  * \brief Save picture to file
    95102  *
    96103  * \param filename filename
    97104  */
    98   void SaveToFile(std::string filename) const;
     105  void SavePictureToFile(std::string filename) const;
    99106
    100107  /*!
  • trunk/lib/FlairSensorActuator/src/V4LCamera.cpp

    r15 r124  
    4343    Thread::Err("cvCaptureFromCAM error\n");
    4444
    45   if (cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, width) < 0)
     45  if (cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, width)<0)
    4646    Thread::Err("cvSetCaptureProperty error\n");
    47   if (cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, height) < 0)
     47  if (cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, height)<0)
    4848    Thread::Err("cvSetCaptureProperty error\n");
    4949
    5050  if (format == cvimage::Type::Format::UYVY) {
    51     if (cvSetCaptureProperty(capture, CV_CAP_PROP_FORMAT, V4L2_PIX_FMT_UYVY) <
    52         0)
     51    if (cvSetCaptureProperty(capture, CV_CAP_PROP_FORMAT, V4L2_PIX_FMT_UYVY)<0)
    5352      Thread::Err("cvSetCaptureProperty error\n");
    5453  } else if (format == cvimage::Type::Format::YUYV) {
  • trunk/lib/FlairVisionFilter/src/CvtColor.cpp

    r122 r124  
    2525
    2626    switch(conversion) {
    27     case Conversion_t::GRAY:
     27    case Conversion_t::ToGray:
    2828        try{
    2929            cvimage::Type const &imageType=dynamic_cast<cvimage::Type const &>(parent->GetOutputDataType());
    30             output=new cvimage(this,imageType.GetWidth(),imageType.GetHeight(),cvimage::Type::Format::GRAY,"conversion",true,2);
     30            output=new cvimage(this,imageType.GetWidth(),imageType.GetHeight(),cvimage::Type::Format::Gray,"conversion",true,2);
    3131
    3232        } catch(std::bad_cast& bc) {
     
    6161
    6262    switch(conversion) {
    63     case Conversion_t::GRAY:
     63    case Conversion_t::ToGray:
    6464        switch(((cvimage*)data)->GetDataType().GetFormat()) {
    6565        case cvimage::Type::Format::YUYV:
  • trunk/lib/FlairVisionFilter/src/CvtColor.h

    r122 r124  
    3939            */
    4040            enum class Conversion_t {
    41                 BGR,/*!< BGR 24 bits */
    42                 GRAY,/*!< gray 8 bits */
     41                ToBGR,/*!< BGR 24 bits */
     42                ToGray,/*!< gray 8 bits */
    4343                } ;
    4444
  • trunk/lib/FlairVisionFilter/src/HoughLines.cpp

    r122 r124  
    5353    try{
    5454        cvimage::Type const &imageType=dynamic_cast<cvimage::Type const &>(parent->GetOutputDataType());
    55         if(imageType.GetFormat()!=cvimage::Type::Format::GRAY) {
    56             Err("input image is not grey\n");
     55        if(imageType.GetFormat()!=cvimage::Type::Format::Gray) {
     56            Err("input image is not gray\n");
    5757        }
    5858    } catch(std::bad_cast& bc) {
  • trunk/lib/FlairVisionFilter/src/ImgThreshold.cpp

    r122 r124  
    3232    try{
    3333        cvimage::Type const &imageType=dynamic_cast<cvimage::Type const &>(parent->GetOutputDataType());
    34         if(imageType.GetFormat()==cvimage::Type::Format::GRAY) {
     34        if(imageType.GetFormat()==cvimage::Type::Format::Gray) {
    3535            output=new cvimage(this,imageType.GetWidth(),imageType.GetHeight(),imageType.GetFormat(),"threshold");
    3636        } else {
    37             Err("input image is not grey\n");
     37            Err("input image is not gray\n");
    3838        }
    3939    } catch(std::bad_cast& bc) {
  • trunk/lib/FlairVisionFilter/src/Sobel.cpp

    r122 r124  
    3434    try{
    3535        cvimage::Type const &imageType=dynamic_cast<cvimage::Type const &>(parent->GetOutputDataType());
    36         if(imageType.GetFormat()==cvimage::Type::Format::GRAY) {
     36        if(imageType.GetFormat()==cvimage::Type::Format::Gray) {
    3737            output=new cvimage(this,imageType.GetWidth(),imageType.GetHeight(),imageType.GetFormat(),"sobel");
    3838        } else {
    39             Err("input image is not grey\n");
     39            Err("input image is not gray\n");
    4040        }
    4141
  • trunk/lib/FlairVisionFilter/src/VisionFilter.cpp

    r123 r124  
    99}
    1010
    11 void saveToJpeg(IplImage* src_img,std::string filename,unsigned char compression_level) {
     11void saveToJpeg(IplImage* src_img,std::string filename,PictureFormat_t input_format,PictureFormat_t output_format,unsigned char compression_level) {
    1212        if(!cvSaveImage(filename.c_str(),src_img)) printf("Could not save.\n");
    1313}
  • trunk/lib/FlairVisionFilter/src/VisionFilter.h

    r123 r124  
    1212void CloseVisionFilter(void);
    1313
    14 void saveToJpeg(IplImage* src_img,std::string filename,unsigned char compression_level=95);
     14enum class PictureFormat_t {
     15                Gray,/*!< gray 8 bits */
     16                                                                RGB,/*!< rgb 24 bits */
     17                                                                UYVY,/*!< YUV 4:2:2 planer */
     18                } ;
     19                                                               
     20void saveToJpeg(IplImage* src_img,std::string filename,PictureFormat_t input_format,PictureFormat_t output_format,unsigned char compression_level=95);
  • trunk/lib/FlairVisionFilter/src/unexported/compile_info.h

    r123 r124  
    55
    66#define USER "gsanahuj@gsanahuj-Latitude-E6420"
    7 #define DATE "mardi 10 janvier 2017, 15:56:33 (UTC+0100)"
     7#define DATE "jeudi 12 janvier 2017, 09:32:25 (UTC+0100)"
    88#define GCC_REV "4.9.1"
    99#define GCC_PATH "/opt/robomap3/1.7.3/armv7a-neon/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc"
    1010#define SVN_PATH "/home/gsanahuj/HDS/igep/flair-src_svn/trunk/lib/FlairVisionFilter"
    11 #define SVN_REV "122M"
     11#define SVN_REV "122:123M"
    1212
    1313inline void compile_info(std::string name) {
Note: See TracChangeset for help on using the changeset viewer.