Changeset 124 in flair-src for trunk/lib/FlairSensorActuator/src/Camera.cpp
- Timestamp:
- Jan 12, 2017, 10:39:23 AM (8 years ago)
- File:
-
- 1 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;
Note:
See TracChangeset
for help on using the changeset viewer.