Changeset 124 in flair-src for trunk/lib/FlairSensorActuator
- Timestamp:
- Jan 12, 2017, 10:39:23 AM (8 years ago)
- Location:
- trunk/lib/FlairSensorActuator/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairSensorActuator/src/Camera.cpp
r123 r124 116 116 void Camera::ProcessUpdate(core::io_data* data) { 117 117 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(); 124 137 } 125 138 } … … 127 140 } 128 141 129 void Camera::SaveToFile(string filename) const { 142 void 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 164 void Camera::SaveRawPictureToFile(string filename) const { 130 165 Printf("saving %s, size %i\n", filename.c_str(), output->img->imageSize); 131 166 std::ofstream pFile; -
trunk/lib/FlairSensorActuator/src/Camera.h
r122 r124 92 92 93 93 /*! 94 * \brief Save raw picture to file 95 * 96 * \param filename filename 97 */ 98 void SaveRawPictureToFile(std::string filename) const; 99 100 /*! 94 101 * \brief Save picture to file 95 102 * 96 103 * \param filename filename 97 104 */ 98 void Save ToFile(std::string filename) const;105 void SavePictureToFile(std::string filename) const; 99 106 100 107 /*! -
trunk/lib/FlairSensorActuator/src/V4LCamera.cpp
r15 r124 43 43 Thread::Err("cvCaptureFromCAM error\n"); 44 44 45 if (cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, width) <0)45 if (cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, width)<0) 46 46 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) 48 48 Thread::Err("cvSetCaptureProperty error\n"); 49 49 50 50 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) 53 52 Thread::Err("cvSetCaptureProperty error\n"); 54 53 } else if (format == cvimage::Type::Format::YUYV) {
Note:
See TracChangeset
for help on using the changeset viewer.