Index: trunk/lib/FlairSensorActuator/src/Camera.cpp
===================================================================
--- trunk/lib/FlairSensorActuator/src/Camera.cpp	(revision 123)
+++ trunk/lib/FlairSensorActuator/src/Camera.cpp	(revision 124)
@@ -116,10 +116,23 @@
 void Camera::ProcessUpdate(core::io_data* data) {
 	if(getFrameworkManager()->IsLogging() && getFrameworkManager()->IsDeviceLogged(this)) {
-		switch(logFormat) {
-			case LogFormat::JPG:
-					IplImage *img=((cvimage*)data)->img;
-					string filename=getFrameworkManager()->GetLogPath()+"/"+ObjectName()+"_"+std::to_string(data->DataTime())+".jpg";
-					saveToJpeg(img,filename);
-				break;
+		if(logFormat==LogFormat::JPG) {
+			data->GetMutex();
+			IplImage *img=((cvimage*)data)->img;
+			string filename=getFrameworkManager()->GetLogPath()+"/"+ObjectName()+"_"+std::to_string(data->DataTime())+".jpg";
+			switch(((cvimage*)data)->GetDataType().GetFormat()) {
+				case cvimage::Type::Format::Gray:
+					saveToJpeg(img,filename,PictureFormat_t::Gray,PictureFormat_t::Gray);
+					break;
+				case cvimage::Type::Format::BGR:
+					saveToJpeg(img,filename,PictureFormat_t::RGB,PictureFormat_t::RGB);
+					break;
+				case cvimage::Type::Format::UYVY:
+					saveToJpeg(img,filename,PictureFormat_t::UYVY,PictureFormat_t::UYVY);
+					break;
+				default:
+					Warn("cannot log to this format\n");
+					break;
+			}
+			data->ReleaseMutex();
 		}
 	}
@@ -127,5 +140,27 @@
 }
 
-void Camera::SaveToFile(string filename) const {
+void Camera::SavePictureToFile(std::string filename) const {
+	string::size_type idx = filename.rfind('.');
+
+	if(idx != std::string::npos) {
+		Printf("saving %s\n", filename.c_str());
+		std::string extension = filename.substr(idx+1);
+		
+		output->GetMutex();
+		if(extension=="jpg") {
+			if(output->GetDataType().GetFormat()==cvimage::Type::Format::Gray) saveToJpeg(output->img,filename,PictureFormat_t::Gray,PictureFormat_t::Gray);
+			if(output->GetDataType().GetFormat()==cvimage::Type::Format::BGR) saveToJpeg(output->img,filename,PictureFormat_t::RGB,PictureFormat_t::RGB);
+			if(output->GetDataType().GetFormat()==cvimage::Type::Format::UYVY) saveToJpeg(output->img,filename,PictureFormat_t::UYVY,PictureFormat_t::UYVY);
+		} else {
+			cvSaveImage(filename.c_str(),output->img);
+		}
+		output->ReleaseMutex();
+			
+	} else {
+		Warn("saving %s no file extension!\n", filename.c_str());
+	}
+}
+
+void Camera::SaveRawPictureToFile(string filename) const {
   Printf("saving %s, size %i\n", filename.c_str(), output->img->imageSize);
   std::ofstream pFile;
Index: trunk/lib/FlairSensorActuator/src/Camera.h
===================================================================
--- trunk/lib/FlairSensorActuator/src/Camera.h	(revision 123)
+++ trunk/lib/FlairSensorActuator/src/Camera.h	(revision 124)
@@ -92,9 +92,16 @@
 
   /*!
+  * \brief Save raw picture to file
+  *
+  * \param filename filename
+  */
+  void SaveRawPictureToFile(std::string filename) const;
+	
+	/*!
   * \brief Save picture to file
   *
   * \param filename filename
   */
-  void SaveToFile(std::string filename) const;
+  void SavePictureToFile(std::string filename) const;
 
   /*!
Index: trunk/lib/FlairSensorActuator/src/V4LCamera.cpp
===================================================================
--- trunk/lib/FlairSensorActuator/src/V4LCamera.cpp	(revision 123)
+++ trunk/lib/FlairSensorActuator/src/V4LCamera.cpp	(revision 124)
@@ -43,12 +43,11 @@
     Thread::Err("cvCaptureFromCAM error\n");
 
-  if (cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, width) < 0)
+  if (cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, width)<0)
     Thread::Err("cvSetCaptureProperty error\n");
-  if (cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, height) < 0)
+  if (cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, height)<0)
     Thread::Err("cvSetCaptureProperty error\n");
 
   if (format == cvimage::Type::Format::UYVY) {
-    if (cvSetCaptureProperty(capture, CV_CAP_PROP_FORMAT, V4L2_PIX_FMT_UYVY) <
-        0)
+    if (cvSetCaptureProperty(capture, CV_CAP_PROP_FORMAT, V4L2_PIX_FMT_UYVY)<0)
       Thread::Err("cvSetCaptureProperty error\n");
   } else if (format == cvimage::Type::Format::YUYV) {
