diff --git a/.gitignore b/.gitignore
index 8c2d2075634b0f037233d1af3dd1be93dd222728..fe0820942bce5ccd72d6447a0895db5244118ee3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -96,3 +96,5 @@ CMakeFiles
 /BioTracker/CoreApp/BioTracker/Release/TrackingOutput.txt
 /BioTracker/CoreApp/BioTracker/debug/BlobtrackerConfig.ini
 /BioTracker/CoreApp/BioTracker/debug/TrackingOutput.txt
+/BioTracker/CoreApp/BioTracker/BiotrackerCore.ini
+/BioTracker/Plugin/Sample/Sample.tracker.dir/Release/*.cache
diff --git a/BioTracker/CoreApp/BioTracker/Controller/ControllerGraphicScene.cpp b/BioTracker/CoreApp/BioTracker/Controller/ControllerGraphicScene.cpp
index 50150a4bb8b20836a39dd7ba19f515a9bbdfab27..e6c886b0442bc665ddd3b2175e55207cf62109d0 100644
--- a/BioTracker/CoreApp/BioTracker/Controller/ControllerGraphicScene.cpp
+++ b/BioTracker/CoreApp/BioTracker/Controller/ControllerGraphicScene.cpp
@@ -7,8 +7,8 @@
 ControllerGraphicScene::ControllerGraphicScene(QObject *parent, IBioTrackerContext *context, ENUMS::CONTROLLERTYPE ctr) :
     IController(parent, context, ctr)
 {
-	m_Element = NULL; //TODO Andi init properly!
-	m_GraphicsView = NULL; //TODO Andi init properly! 
+	m_Element = NULL;
+	m_GraphicsView = NULL;
 }
 
 void ControllerGraphicScene::addGraphicsItem(QGraphicsItem *item)
@@ -44,7 +44,7 @@ void ControllerGraphicScene::connectModelToController()
 
 void ControllerGraphicScene::connectControllerToController()
 {
-        IController * ctrM = m_BioTrackerContext->requestController(ENUMS::CONTROLLERTYPE::MAINWINDOW);
-        QPointer< MainWindow > mainWin = dynamic_cast<MainWindow *>(ctrM->getView());
-        mainWin->addVideoView(m_View);
+	IController * ctrM = m_BioTrackerContext->requestController(ENUMS::CONTROLLERTYPE::MAINWINDOW);
+	QPointer< MainWindow > mainWin = dynamic_cast<MainWindow *>(ctrM->getView());
+	mainWin->addVideoView(m_View);
 }
diff --git a/BioTracker/CoreApp/BioTracker/Controller/ControllerGraphicScene.h b/BioTracker/CoreApp/BioTracker/Controller/ControllerGraphicScene.h
index 48df25e9f9877eb4befc95be41de7cb06ac63469..4f8575d27b078b9230d13f5e0b43c8fa981100dc 100644
--- a/BioTracker/CoreApp/BioTracker/Controller/ControllerGraphicScene.h
+++ b/BioTracker/CoreApp/BioTracker/Controller/ControllerGraphicScene.h
@@ -31,7 +31,7 @@ class ControllerGraphicScene : public IController {
     /**
      * This methode adds a IViewGraphicsPixmapItem to the GraphicsView canvas for rendering.
      */
-    void addTextureObject(QGraphicsItem* item);
+	void addTextureObject(QGraphicsItem* item);
 
     // IController interface
   protected:
diff --git a/BioTracker/CoreApp/BioTracker/Controller/ControllerMainWindow.cpp b/BioTracker/CoreApp/BioTracker/Controller/ControllerMainWindow.cpp
index 2496ade7d12c2ce202d288a6432b5eef9c95d87a..3869e9ee7b1367ba33f22efee1d633b242ae0c9c 100644
--- a/BioTracker/CoreApp/BioTracker/Controller/ControllerMainWindow.cpp
+++ b/BioTracker/CoreApp/BioTracker/Controller/ControllerMainWindow.cpp
@@ -6,6 +6,7 @@
 #include "GuiContext.h"
 
 #include "QPluginLoader"
+#include "util/types.h"
 
 
 ControllerMainWindow::ControllerMainWindow(QObject* parent, IBioTrackerContext* context, ENUMS::CONTROLLERTYPE ctr) :
@@ -28,9 +29,9 @@ void ControllerMainWindow::loadPictures(std::vector<boost::filesystem::path> fil
     qobject_cast<ControllerPlayer*>(ctr)->loadPictures(files);
 }
 
-void ControllerMainWindow::loadCameraDevice(int i) {
+void ControllerMainWindow::loadCameraDevice(CameraConfiguration conf) {
     IController* ctr = m_BioTrackerContext->requestController(ENUMS::CONTROLLERTYPE::PLAYER);
-    qobject_cast<ControllerPlayer*>(ctr)->loadCameraDevice(i);
+    qobject_cast<ControllerPlayer*>(ctr)->loadCameraDevice(conf);
 }
 
 void ControllerMainWindow::activeTracking() {
@@ -51,9 +52,8 @@ void ControllerMainWindow::setTrackerParamterWidget(IView* widget) {
     dynamic_cast<MainWindow*>(m_View)->addTrackerParameterView(widget);
 }
 
-void ControllerMainWindow::setTrackerElementsWidget(IView *widget) //MARKER
+void ControllerMainWindow::setTrackerElementsWidget(IView *widget)
 {
-	//TODO HAUKE attach this widget to the gvw to achieve auto-painting
 	dynamic_cast<MainWindow*>(m_View)->addTrackerElementsView(widget);
 }
 
diff --git a/BioTracker/CoreApp/BioTracker/Controller/ControllerMainWindow.h b/BioTracker/CoreApp/BioTracker/Controller/ControllerMainWindow.h
index 54ab89782eab47b308e3965c66e0756a3dbf52bb..34da57b43e4c6b279c5cb554e912e720a78ee932 100644
--- a/BioTracker/CoreApp/BioTracker/Controller/ControllerMainWindow.h
+++ b/BioTracker/CoreApp/BioTracker/Controller/ControllerMainWindow.h
@@ -13,6 +13,7 @@
 #include "QStringListModel"
 #include "boost/filesystem.hpp"
 #include <vector>
+#include "util/types.h"
 
 /**
  * The ControllerMainWindow class controlls the IView class MainWindow.
@@ -39,7 +40,7 @@ class ControllerMainWindow : public IController {
     /**
      * Receives the a string containing the camera device number from the MainWindow class. The string is then given to the ControllerPlayer class of the MediaPlayer-Component.
      */
-    void loadCameraDevice(int i);
+    void loadCameraDevice(CameraConfiguration conf);
     /**
      * Receives the command for activating the Tracking in a BioTracker Plugin from the MainWindow class. This command is given to the ControllerPlayer class of the MediaPlayer-component.
      */
diff --git a/BioTracker/CoreApp/BioTracker/Controller/ControllerPlayer.cpp b/BioTracker/CoreApp/BioTracker/Controller/ControllerPlayer.cpp
index a1a13184011160d6e0f7b4349b8447a2a07a3dd1..b6733bc53986aa12b0dacafcf61b05487bb80cfb 100644
--- a/BioTracker/CoreApp/BioTracker/Controller/ControllerPlayer.cpp
+++ b/BioTracker/CoreApp/BioTracker/Controller/ControllerPlayer.cpp
@@ -3,6 +3,8 @@
 #include "View/MainWindow.h"
 #include "Controller/ControllerTextureObject.h"
 #include "Controller/ControllerPlugin.h"
+#include "Controller/ControllerGraphicScene.h"
+#include <QGraphicsItem>
 
 ControllerPlayer::ControllerPlayer(QObject *parent, IBioTrackerContext *context, ENUMS::CONTROLLERTYPE ctr) :
     IController(parent, context, ctr)
@@ -22,8 +24,8 @@ void ControllerPlayer::loadPictures(std::vector<boost::filesystem::path> files)
     qobject_cast<MediaPlayer*>(m_Model)->loadPictures(files);
 }
 
-void ControllerPlayer::loadCameraDevice(int i) {
-    qobject_cast<MediaPlayer*>(m_Model)->loadCameraDevice(i);
+void ControllerPlayer::loadCameraDevice(CameraConfiguration conf) {
+    qobject_cast<MediaPlayer*>(m_Model)->loadCameraDevice(conf);
 }
 
 void ControllerPlayer::nextFrame() {
@@ -71,6 +73,17 @@ void ControllerPlayer::changeImageView(QString str) {
     ctrTextureObject->changeTextureModel(str);
 }
 
+int ControllerPlayer::recordOutput() {
+	//IController* ctr = m_BioTrackerContext->requestController(ENUMS::CONTROLLERTYPE::TEXTUREOBJECT);
+	//QPointer< ControllerTextureObject > ctrTextureObject = qobject_cast<ControllerTextureObject*>(ctr);
+	//TextureObject *to = dynamic_cast<TextureObject*>(ctrTextureObject->getModel());
+
+	IController* ctr = m_BioTrackerContext->requestController(ENUMS::CONTROLLERTYPE::GRAPHICSVIEW);
+	QPointer< ControllerGraphicScene > ctrTextureObject = qobject_cast<ControllerGraphicScene*>(ctr);
+
+	return qobject_cast<MediaPlayer*>(m_Model)->toggleRecordGraphicsScenes(dynamic_cast <GraphicsView *> (ctrTextureObject->getView()));
+}
+
 void ControllerPlayer::setTrackingActivated() {
     qobject_cast<MediaPlayer*>(m_Model)->setTrackingActive();
 }
@@ -100,7 +113,6 @@ void ControllerPlayer::connectModelToController() {
 
     QObject::connect(qobject_cast<MediaPlayer*>(m_Model), &MediaPlayer::renderCurrentImage, this, &ControllerPlayer::receiveRenderImage);
     QObject::connect(qobject_cast<MediaPlayer*>(m_Model), &MediaPlayer::trackCurrentImage, this, &ControllerPlayer::receiveImageToTracker);
-
 }
 
 void ControllerPlayer::receiveChangeDisplayImage(QString str) {
diff --git a/BioTracker/CoreApp/BioTracker/Controller/ControllerPlayer.h b/BioTracker/CoreApp/BioTracker/Controller/ControllerPlayer.h
index 7ffafe9d5b05a13f89f598955203bf8269fabc4d..e63f5c36f1391c7f06b749ca70cc4fa86c1e481c 100644
--- a/BioTracker/CoreApp/BioTracker/Controller/ControllerPlayer.h
+++ b/BioTracker/CoreApp/BioTracker/Controller/ControllerPlayer.h
@@ -10,6 +10,7 @@
 #include "Interfaces/IController/IController.h"
 #include "Model/MediaPlayer.h"
 #include "QPointer"
+#include "util/types.h"
 
 /**
  * The ControllerPlayer class it the controller of the MediaPlayer-Component. This controller creates and controlls the IModel class MediaPlayer and the IView class VideoControllWidget.
@@ -31,7 +32,7 @@ class ControllerPlayer : public IController {
     /**
      * Hands over the camera device number to the IModel class MediaPlayer.
      */
-    void loadCameraDevice(int i);
+    void loadCameraDevice(CameraConfiguration conf);
 
     /**
      * Tells the MediaPlayer-Component to hand over the current cv::Mat and the current frame number to the BioTracker Plugin.
@@ -71,6 +72,11 @@ class ControllerPlayer : public IController {
      */
     void changeImageView(QString str);
 
+	/**
+	* User clicked record -> record "what the user sees"
+	*/
+	int recordOutput();
+
     // IController interface
   public:
     void connectControllerToController() override;
diff --git a/BioTracker/CoreApp/BioTracker/Model/ImageStream.cpp b/BioTracker/CoreApp/BioTracker/Model/ImageStream.cpp
index 4a006470acd28c8332fad30077f509c8448dbdac..ff32634ccbf7b95fe099745c695cc7c290ad5f41 100644
--- a/BioTracker/CoreApp/BioTracker/Model/ImageStream.cpp
+++ b/BioTracker/CoreApp/BioTracker/Model/ImageStream.cpp
@@ -9,6 +9,9 @@
 #include "util/Exceptions.h"
 #include "QSharedPointer"
 #include "settings/Settings.h"
+#include "util/misc.h"
+
+#include "View/CameraDevice.h"
 
 namespace BioTracker {
 namespace Core {
@@ -238,7 +241,6 @@ class ImageStream3Video : public ImageStream {
 
 
 /*********************************************************/
-
 class ImageStream3Camera : public ImageStream {
   public:
     /**
@@ -247,8 +249,8 @@ class ImageStream3Camera : public ImageStream {
      * @brief ImageStreamCamera
      * @param device_id according to the VideoCapture class of OpenCV
      */
-    explicit ImageStream3Camera(int device_id)
-        : m_capture(device_id)
+    explicit ImageStream3Camera(CameraConfiguration conf)
+        : m_capture(conf._id)
         , m_fps(m_capture.get(CV_CAP_PROP_FPS)) {
 		// Give the camera some extra time to get ready:
 		// Somehow opening it on first try sometimes does not succeed.
@@ -260,11 +262,12 @@ class ImageStream3Camera : public ImageStream {
 
 		int w = set.getValueOrDefault<int>("BiotrackerCore/CameraWidth", -1);
 		int h = set.getValueOrDefault<int>("BiotrackerCore/CameraHeight", -1);
-		m_fps = set.getValueOrDefault<int>("BiotrackerCore/CameraFPS", -1);
+		m_fps = set.getValueOrDefault<int>("BiotrackerCore/CameraFPS", 30);
+		m_writeToFile = set.getValueOrDefault<bool>("BiotrackerCore/CameraWriteToFile", true);
 
 		int fails = 0;
-		while (!m_capture.isOpened() && fails < 10) {
-			m_capture.open(device_id);
+		while (!m_capture.isOpened() && fails < 5) {
+			m_capture.open(conf._id);
 			std::this_thread::sleep_for(std::chrono::milliseconds(1000));
 
 			if (w != -1)     m_capture.set(CV_CAP_PROP_FRAME_WIDTH, w);
@@ -276,6 +279,19 @@ class ImageStream3Camera : public ImageStream {
         if (! m_capture.isOpened()) {
             throw device_open_error(":(");
         }
+
+		w = m_capture.get(CV_CAP_PROP_FRAME_WIDTH);
+		h = m_capture.get(CV_CAP_PROP_FRAME_HEIGHT);
+		m_fps = m_capture.get(CV_CAP_PROP_FPS);
+
+		if (m_writeToFile) {
+			int codec = CV_FOURCC('X', '2', '6', '4');
+			//int codec = CV_FOURCC('M', 'J', 'P', 'G');
+			vWriter = std::make_shared<cv::VideoWriter>(getTimeAndDate("./CameraCapture",".avi"), codec, m_fps, CvSize(w,h), 1);
+			m_writeToFile = vWriter->isOpened();
+			std::cout << "Video is open:" << m_writeToFile << std::endl;
+		}
+
         // load first image
         if (this->numFrames() > 0) {
             this->nextFrame_impl();
@@ -295,12 +311,18 @@ class ImageStream3Camera : public ImageStream {
     }
 
   private:
+	  std::shared_ptr<cv::VideoWriter> vWriter;
+	  bool m_writeToFile;
+
     virtual bool nextFrame_impl() override {
         cv::Mat new_frame;
         m_capture.grab();
         m_capture.retrieve(new_frame);
         std::shared_ptr<cv::Mat> mat (new cv::Mat(new_frame));
         this->set_current_frame(mat);
+		if (m_writeToFile) {
+			vWriter->write(new_frame);
+		}
         return ! mat->empty();
     }
 
@@ -335,9 +357,9 @@ std::shared_ptr<ImageStream> make_ImageStream3Video(const boost::filesystem::pat
     }
 }
 
-std::shared_ptr<ImageStream> make_ImageStream3Camera(int device) {
+std::shared_ptr<ImageStream> make_ImageStream3Camera(CameraConfiguration conf) {
     try {
-        return std::make_shared<ImageStream3Camera>(device);
+        return std::make_shared<ImageStream3Camera>(conf);
     } catch (const device_open_error &) {
         return make_ImageStream3NoMedia();
     }
diff --git a/BioTracker/CoreApp/BioTracker/Model/ImageStream.h b/BioTracker/CoreApp/BioTracker/Model/ImageStream.h
index 1c9d4110c1ce7de494fca9c7ad43af507684f110..593f3d39c33e0f82839bb32d79a7dcc1e85931cb 100644
--- a/BioTracker/CoreApp/BioTracker/Model/ImageStream.h
+++ b/BioTracker/CoreApp/BioTracker/Model/ImageStream.h
@@ -17,6 +17,7 @@
 #include "QSharedPointer"
 
 #include "settings/ParamNames.h" // GUIPARAM::MediaType
+#include "util/types.h"
 
 namespace BioTracker {
 namespace Core {
@@ -140,7 +141,7 @@ std::shared_ptr<ImageStream> make_ImageStream3Pictures(
 std::shared_ptr<ImageStream> make_ImageStream3Video(const boost::filesystem::path
                                                     &filename);
 
-std::shared_ptr<ImageStream> make_ImageStream3Camera(int device);
+std::shared_ptr<ImageStream> make_ImageStream3Camera(CameraConfiguration conf);
 
 }
 }
diff --git a/BioTracker/CoreApp/BioTracker/Model/MediaPlayer.cpp b/BioTracker/CoreApp/BioTracker/Model/MediaPlayer.cpp
index 4b54904f42537e3aaf53fdeb5742e383f7b2ede9..498020423763f481fd2ad30ecef8371954312afa 100644
--- a/BioTracker/CoreApp/BioTracker/Model/MediaPlayer.cpp
+++ b/BioTracker/CoreApp/BioTracker/Model/MediaPlayer.cpp
@@ -1,153 +1,204 @@
-#include "MediaPlayer.h"
-
-MediaPlayer::MediaPlayer(QObject* parent) :
-    IModel(parent) {
-	m_currentFPS = 0;
-	m_fpsOfSourceFile = 0;
-
-    m_TrackingIsActive = false;
-    // Initialize PlayerStateMachine and a Thread for the Player
-    //    // Do not set a Parent for MediaPlayerStateMachine in order to run the Player in the QThread!
-
-    m_PlayerThread = new QThread(this);
-    m_Player = new MediaPlayerStateMachine();
-
-    // Connect MediaPlayer with PlayerStateMachine
-
-    // Load ImageStreams in StateMachine
-    QObject::connect(this, &MediaPlayer::loadVideoStream, m_Player, &MediaPlayerStateMachine::receiveLoadVideoCommand);
-    QObject::connect(this, &MediaPlayer::loadCameraDevice, m_Player, &MediaPlayerStateMachine::receiveLoadCameraDevice);
-    QObject::connect(this, &MediaPlayer::loadPictures, m_Player, &MediaPlayerStateMachine::receiveLoadPictures);
-
-    // Controll the Player
-    QObject::connect(this, &MediaPlayer::nextFrameCommand, m_Player, &MediaPlayerStateMachine::receiveNextFramCommand);
-    QObject::connect(this, &MediaPlayer::pauseCommand, m_Player, &MediaPlayerStateMachine::receivePauseCommand);
-    QObject::connect(this, &MediaPlayer::playCommand, m_Player, &MediaPlayerStateMachine::receivePlayCommand);
-    QObject::connect(this, &MediaPlayer::prevFrameCommand, m_Player, &MediaPlayerStateMachine::receivePrevFrameCommand);
-    QObject::connect(this, &MediaPlayer::stopCommand, m_Player, &MediaPlayerStateMachine::receiveStopCommand);
-    QObject::connect(this, &MediaPlayer::goToFrame, m_Player, &MediaPlayerStateMachine::receiveGoToFrame);
-
-    // Handel PlayerStateMachine results
-    QObject::connect(m_Player, &MediaPlayerStateMachine::emitPlayerParameters, this, &MediaPlayer::receivePlayerParameters, Qt::BlockingQueuedConnection);
-
-    // Handle next state operation
-    QObject::connect(m_Player, &MediaPlayerStateMachine::emitPlayerOperationDone, this, &MediaPlayer::receivePlayerOperationDone);
-    QObject::connect(this, &MediaPlayer::runPlayerOperation, m_Player, &MediaPlayerStateMachine::receiveRunPlayerOperation);
-
-    // Move the PlayerStateMachine to the Thread
-    m_Player->moveToThread(m_PlayerThread);
-
-    // Start the Thread
-    m_PlayerThread->start();
-}
-
-MediaPlayer::~MediaPlayer() {
-    m_PlayerThread->quit();
-    m_PlayerThread->wait();
-}
-
-void MediaPlayer::setTrackingActive() {
-    m_TrackingIsActive = true;
-}
-
-void MediaPlayer::setTrackingDeactive() {
-    m_TrackingIsActive = false;
-}
-
-bool MediaPlayer::getPlayState() {
-    return m_Play;
-}
-
-bool MediaPlayer::getForwardState() {
-    return m_Forw;
-}
-
-bool MediaPlayer::getBackwardState() {
-    return m_Back;
-}
-
-bool MediaPlayer::getStopState() {
-    return m_Stop;
-}
-
-bool MediaPlayer::getPauseState() {
-    return m_Paus;
-}
-
-bool MediaPlayer::getTrackingState() {
-    return m_TrackingIsActive;
-}
-
-size_t MediaPlayer::getTotalNumberOfFrames() {
-    return m_TotalNumbFrames;
-}
-
-size_t MediaPlayer::getCurrentFrameNumber() {
-    return m_CurrentFrameNumber;
-}
-
-double MediaPlayer::getFpsOfSourceFile() {
-    return m_fpsOfSourceFile;
-}
-
-double MediaPlayer::getCurrentFPS() {
-    return m_currentFPS;
-}
-
-QString MediaPlayer::getCurrentFileName() {
-    return m_CurrentFilename;
-}
-
-std::shared_ptr<cv::Mat> MediaPlayer::getCurrentFrame() {
-    return m_CurrentFrame;
-}
-
-void MediaPlayer::receivePlayerParameters(playerParameters* param) {
-
-    m_Back = param->m_Back;
-    m_Paus = param->m_Paus;
-    m_Play = param->m_Play;
-    m_Stop = param->m_Stop;
-    m_Forw = param->m_Forw;
-
-    m_CurrentFilename = param->m_CurrentFilename;
-    m_CurrentFrame = param->m_CurrentFrame;
-    m_CurrentFrameNumber = param->m_CurrentFrameNumber;
-    m_fpsOfSourceFile = param->m_fpsSourceVideo;
-    m_TotalNumbFrames = param->m_TotalNumbFrames;
-
-    m_CurrentFrame = param->m_CurrentFrame;
-
-    Q_EMIT renderCurrentImage(m_CurrentFrame, m_NameOfCvMat);
-
-    if(m_TrackingIsActive)
-        Q_EMIT trackCurrentImage(m_CurrentFrame, m_CurrentFrameNumber);
-    Q_EMIT notifyView();
-}
-
-
-void MediaPlayer::receivePlayerOperationDone() {
-    // Only emit this SIGNL when tracking is not active
-	end = std::chrono::steady_clock::now();
-    std::cout << "Printing took "
-              << std::chrono::duration_cast<std::chrono::microseconds>(end - start).count()
-              << "us.\n";
-	long s = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
-	m_currentFPS = floor(1.0/(double(s)/1000000.0));
-
-    Q_EMIT runPlayerOperation();
-
-	start = std::chrono::steady_clock::now();
-}
-
-void MediaPlayer::receiveTrackingOperationDone() {
-    // Only emit this SIGNAL when tracking is active
-    if(m_TrackingIsActive)
-        Q_EMIT runPlayerOperation();
-
-}
-
-void MediaPlayer::receiveChangeDisplayImage(QString str) {
-	int x = 0;
-}
-
+#include "MediaPlayer.h"
+#include "util/misc.h"
+
+MediaPlayer::MediaPlayer(QObject* parent) :
+    IModel(parent) {
+	m_currentFPS = 0;
+	m_fpsOfSourceFile = 0;
+	_imagew = 0;
+	_imageh = 0;
+
+    m_TrackingIsActive = false;
+	m_recd = false;
+    // Initialize PlayerStateMachine and a Thread for the Player
+    //    // Do not set a Parent for MediaPlayerStateMachine in order to run the Player in the QThread!
+
+    m_PlayerThread = new QThread(this);
+    m_Player = new MediaPlayerStateMachine();
+
+    // Connect MediaPlayer with PlayerStateMachine
+
+    // Load ImageStreams in StateMachine
+    QObject::connect(this, &MediaPlayer::loadVideoStream, m_Player, &MediaPlayerStateMachine::receiveLoadVideoCommand);
+    QObject::connect(this, &MediaPlayer::loadCameraDevice, m_Player, &MediaPlayerStateMachine::receiveLoadCameraDevice);
+    QObject::connect(this, &MediaPlayer::loadPictures, m_Player, &MediaPlayerStateMachine::receiveLoadPictures);
+
+    // Controll the Player
+    QObject::connect(this, &MediaPlayer::nextFrameCommand, m_Player, &MediaPlayerStateMachine::receiveNextFramCommand);
+    QObject::connect(this, &MediaPlayer::pauseCommand, m_Player, &MediaPlayerStateMachine::receivePauseCommand);
+    QObject::connect(this, &MediaPlayer::playCommand, m_Player, &MediaPlayerStateMachine::receivePlayCommand);
+    QObject::connect(this, &MediaPlayer::prevFrameCommand, m_Player, &MediaPlayerStateMachine::receivePrevFrameCommand);
+    QObject::connect(this, &MediaPlayer::stopCommand, m_Player, &MediaPlayerStateMachine::receiveStopCommand);
+    QObject::connect(this, &MediaPlayer::goToFrame, m_Player, &MediaPlayerStateMachine::receiveGoToFrame);
+
+    // Handel PlayerStateMachine results
+    QObject::connect(m_Player, &MediaPlayerStateMachine::emitPlayerParameters, this, &MediaPlayer::receivePlayerParameters, Qt::BlockingQueuedConnection);
+
+    // Handle next state operation
+    QObject::connect(m_Player, &MediaPlayerStateMachine::emitPlayerOperationDone, this, &MediaPlayer::receivePlayerOperationDone);
+    QObject::connect(this, &MediaPlayer::runPlayerOperation, m_Player, &MediaPlayerStateMachine::receiveRunPlayerOperation);
+
+    // Move the PlayerStateMachine to the Thread
+    m_Player->moveToThread(m_PlayerThread);
+
+    // Start the Thread
+    m_PlayerThread->start();
+}
+
+MediaPlayer::~MediaPlayer() {
+    m_PlayerThread->quit();
+    m_PlayerThread->wait();
+}
+
+void MediaPlayer::setTrackingActive() {
+    m_TrackingIsActive = true;
+}
+
+void MediaPlayer::setTrackingDeactive() {
+    m_TrackingIsActive = false;
+}
+
+bool MediaPlayer::getPlayState() {
+    return m_Play;
+}
+
+bool MediaPlayer::getForwardState() {
+    return m_Forw;
+}
+
+bool MediaPlayer::getBackwardState() {
+    return m_Back;
+}
+
+bool MediaPlayer::getStopState() {
+    return m_Stop;
+}
+
+bool MediaPlayer::getPauseState() {
+    return m_Paus;
+}
+
+bool MediaPlayer::getTrackingState() {
+    return m_TrackingIsActive;
+}
+
+size_t MediaPlayer::getTotalNumberOfFrames() {
+    return m_TotalNumbFrames;
+}
+
+size_t MediaPlayer::getCurrentFrameNumber() {
+    return m_CurrentFrameNumber;
+}
+
+double MediaPlayer::getFpsOfSourceFile() {
+    return m_fpsOfSourceFile;
+}
+
+double MediaPlayer::getCurrentFPS() {
+    return m_currentFPS;
+}
+
+QString MediaPlayer::getCurrentFileName() {
+    return m_CurrentFilename;
+}
+
+std::shared_ptr<cv::Mat> MediaPlayer::getCurrentFrame() {
+    return m_CurrentFrame;
+}
+
+int MediaPlayer::reopenVideoWriter() {
+	QRectF r = m_gv->sceneRect();
+	if (_imagew != r.width() || _imageh != r.height() || !m_recd) {
+		if (m_videoWriter && m_videoWriter->isOpened())
+			m_videoWriter->release();
+		_imagew = r.width();
+		_imageh = r.height();
+
+		int codec = CV_FOURCC('X', '2', '6', '4');
+		std::string path = getTimeAndDate(".\\ViewCapture", ".avi");
+		m_videoWriter = std::make_shared<cv::VideoWriter>(getTimeAndDate("./ViewCapture", ".avi"), codec, 30, CvSize(r.width(), r.height()), 1);
+		m_recd = m_videoWriter->isOpened();
+	}
+	return m_recd;
+}
+
+
+void MediaPlayer::receivePlayerParameters(playerParameters* param) {
+
+    m_Back = param->m_Back;
+    m_Paus = param->m_Paus;
+    m_Play = param->m_Play;
+    m_Stop = param->m_Stop;
+    m_Forw = param->m_Forw;
+
+    m_CurrentFilename = param->m_CurrentFilename;
+    m_CurrentFrame = param->m_CurrentFrame;
+    m_CurrentFrameNumber = param->m_CurrentFrameNumber;
+    m_fpsOfSourceFile = param->m_fpsSourceVideo;
+    m_TotalNumbFrames = param->m_TotalNumbFrames;
+
+    m_CurrentFrame = param->m_CurrentFrame;
+
+    Q_EMIT renderCurrentImage(m_CurrentFrame, m_NameOfCvMat);
+
+    if(m_TrackingIsActive)
+        Q_EMIT trackCurrentImage(m_CurrentFrame, m_CurrentFrameNumber);
+
+	if (m_recd) {
+		reopenVideoWriter();
+		QRectF r = m_gv->sceneRect();
+		QPixmap *pix = new QPixmap(r.size().toSize());
+		QPainter *paint = new QPainter(pix);
+		//gview->render(paint, ir);
+		m_gv->scene()->render(paint);
+		QImage image = pix->toImage();
+		int x = image.format();
+		cv::Mat mat(image.height(), image.width(), CV_8UC(image.depth()/8), (uchar*)image.bits(), image.bytesPerLine());
+		cv::cvtColor(mat, mat, CV_BGR2RGB);
+		cv::cvtColor(mat, mat, CV_BGR2RGB);
+		m_videoWriter->write(mat);
+	}
+
+    Q_EMIT notifyView();
+}
+
+
+void MediaPlayer::receivePlayerOperationDone() {
+    // Only emit this SIGNL when tracking is not active
+	end = std::chrono::steady_clock::now();
+    std::cout << "Printing took "
+              << std::chrono::duration_cast<std::chrono::microseconds>(end - start).count()
+              << "us.\n";
+	long s = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
+	m_currentFPS = floor(1.0/(double(s)/1000000.0));
+
+    Q_EMIT runPlayerOperation();
+
+	start = std::chrono::steady_clock::now();
+}
+
+void MediaPlayer::receiveTrackingOperationDone() {
+    // Only emit this SIGNAL when tracking is active
+    if(m_TrackingIsActive)
+        Q_EMIT runPlayerOperation();
+
+}
+
+void MediaPlayer::receiveChangeDisplayImage(QString str) {
+	int x = 0;
+}
+
+int MediaPlayer::toggleRecordGraphicsScenes(GraphicsView *gv) {
+
+	if (m_recd) {
+		if (m_videoWriter->isOpened()) {
+			m_videoWriter->release();
+		}
+		m_recd = false;
+	}
+	else {
+		m_gv = gv;
+		reopenVideoWriter();
+	}
+	return m_recd;
+}
diff --git a/BioTracker/CoreApp/BioTracker/Model/MediaPlayer.h b/BioTracker/CoreApp/BioTracker/Model/MediaPlayer.h
index 5f97270ce0a8d21bb85bc0882ba60702ed6c5ab2..cf1bc9a888f487b2363deb61d5432c3544d82eed 100644
--- a/BioTracker/CoreApp/BioTracker/Model/MediaPlayer.h
+++ b/BioTracker/CoreApp/BioTracker/Model/MediaPlayer.h
@@ -12,9 +12,11 @@
 #include "Interfaces/IModel/IModel.h"
 #include "QThread"
 #include "Model/MediaPlayerStateMachine/MediaPlayerStateMachine.h"
+#include "View/GraphicsView.h"
 
 #include <ctime>
 #include <chrono>
+#include "util/types.h"
 
 /**
  * The MediaPlayer class is an IModel class an part of the MediaPlayer component. This class creats a MediaPlayerStateMachine object and moves it to a QThread.
@@ -41,7 +43,7 @@ class MediaPlayer : public IModel {
     /**
     * Emit the camera device number. This signal will be received by the MediaPlayerStateMachine which runns in a separate Thread.
     */
-    void loadCameraDevice(int i);
+    void loadCameraDevice(CameraConfiguration conf);
 
     /**
     * Emit a frame number. This signal will be received by the MediaPlayerStateMachine which runns in a separate Thread.
@@ -95,6 +97,9 @@ class MediaPlayer : public IModel {
 
     bool getTrackingState();
 
+
+	int toggleRecordGraphicsScenes(GraphicsView * gv);
+
     size_t getTotalNumberOfFrames();
     size_t getCurrentFrameNumber();
     double getFpsOfSourceFile();
@@ -124,6 +129,13 @@ class MediaPlayer : public IModel {
 
 
   private:
+	  /**
+	  * helper function which opens a video. If video size has changed, a new video is opened. 
+	  */
+	int reopenVideoWriter();
+	int _imagew;
+	int _imageh;
+
     QPointer< QThread > m_PlayerThread;
     QPointer< MediaPlayerStateMachine > m_Player;
 
@@ -144,7 +156,10 @@ class MediaPlayer : public IModel {
     bool m_Back;
     bool m_Stop;
     bool m_Paus;
+	bool m_recd;
 
+	std::shared_ptr<cv::VideoWriter> m_videoWriter;
+	GraphicsView *m_gv;
 
     bool m_TrackingIsActive;
 
diff --git a/BioTracker/CoreApp/BioTracker/Model/MediaPlayerStateMachine/MediaPlayerStateMachine.cpp b/BioTracker/CoreApp/BioTracker/Model/MediaPlayerStateMachine/MediaPlayerStateMachine.cpp
index 3099ddc11a5ffc4c5b95f6c6e922ea297eff370e..ebc1863d35c59f228d1b79d31a4b3c450ffe5812 100644
--- a/BioTracker/CoreApp/BioTracker/Model/MediaPlayerStateMachine/MediaPlayerStateMachine.cpp
+++ b/BioTracker/CoreApp/BioTracker/Model/MediaPlayerStateMachine/MediaPlayerStateMachine.cpp
@@ -9,6 +9,8 @@
 #include "PlayerStates/PStateWait.h"
 #include "PlayerStates/PStateGoToFrame.h"
 
+#include "util/types.h"
+
 MediaPlayerStateMachine::MediaPlayerStateMachine(QObject* parent) :
     IModel(parent),
     m_ImageStream(BioTracker::Core::make_ImageStream3NoMedia()) {
@@ -73,8 +75,8 @@ void MediaPlayerStateMachine::receiveLoadPictures(std::vector<boost::filesystem:
 
 }
 
-void MediaPlayerStateMachine::receiveLoadCameraDevice(int x) {
-    std::shared_ptr<BioTracker::Core::ImageStream> stream(BioTracker::Core::make_ImageStream3Camera(x));
+void MediaPlayerStateMachine::receiveLoadCameraDevice(CameraConfiguration conf) {
+    std::shared_ptr<BioTracker::Core::ImageStream> stream(BioTracker::Core::make_ImageStream3Camera(conf));
 
     //   m_PlayerParameters->m_TotalNumbFrames = stream->numFrames();
 
diff --git a/BioTracker/CoreApp/BioTracker/Model/MediaPlayerStateMachine/MediaPlayerStateMachine.h b/BioTracker/CoreApp/BioTracker/Model/MediaPlayerStateMachine/MediaPlayerStateMachine.h
index bfe51cb26fee02a301ab5d7baeda6728a464907d..eb905bcb708e9b95d1900e5c21fa0c3db472334e 100644
--- a/BioTracker/CoreApp/BioTracker/Model/MediaPlayerStateMachine/MediaPlayerStateMachine.h
+++ b/BioTracker/CoreApp/BioTracker/Model/MediaPlayerStateMachine/MediaPlayerStateMachine.h
@@ -26,6 +26,8 @@
 
 #include "PlayerParameters.h"
 
+#include "View/CameraDevice.h"
+
 /**
  * The MediaPlayerStateMachine class is an IModel class and is responsible for the executing and setting Player Stats. The instance of this class runns in a separate Thread.
  */
@@ -47,7 +49,7 @@ class MediaPlayerStateMachine : public IModel {
 
     void receiveLoadVideoCommand(QString fileDir);
     void receiveLoadPictures(std::vector<boost::filesystem::path> files);
-    void receiveLoadCameraDevice(int i);
+    void receiveLoadCameraDevice(CameraConfiguration conf);
 
     void receivePrevFrameCommand();
     void receiveNextFramCommand();
diff --git a/BioTracker/CoreApp/BioTracker/View/CameraDevice.cpp b/BioTracker/CoreApp/BioTracker/View/CameraDevice.cpp
index 1fe82a2f9b7f816eadbeb25cfc37408ab98737b3..fa5e9b1d0f2ec5b4375e4e2dcf63f13a559096dd 100644
--- a/BioTracker/CoreApp/BioTracker/View/CameraDevice.cpp
+++ b/BioTracker/CoreApp/BioTracker/View/CameraDevice.cpp
@@ -2,6 +2,9 @@
 #include "ui_CameraDevice.h"
 
 #include "QCameraInfo"
+#include "util/types.h"
+#include <thread>
+#include <opencv2/opencv.hpp>
 
 CameraDevice::CameraDevice(QWidget *parent) :
     QWidget(parent),
@@ -17,21 +20,74 @@ CameraDevice::CameraDevice(QWidget *parent) :
 CameraDevice::~CameraDevice()
 {
     delete ui;
-    camera->stop();
+    //camera->stop();
+}
+
+CameraConfiguration CameraDevice::grabUICameraConfiguration() {
+	int i = ui->comboBox->currentIndex();
+	std::string sx = ui->lineEdit->text().toStdString();
+	std::string sy = ui->lineEdit_2->text().toStdString();
+	std::string sf = ui->lineEdit_3->text().toStdString();
+	int x, y, f;
+	x = (sx == "Default" ? -1 : std::stoi(sx));
+	y = (sx == "Default" ? -1 : std::stoi(sy));
+	f = (sf == "Default" ? -1 : std::stoi(sf));
+	bool record = ui->checkBox->isChecked();
+
+	CameraConfiguration conf(i, x, y, f, record, "FMP4");
+	return conf;
 }
 
 void CameraDevice::on_buttonBox_accepted()
 {
     int i = ui->comboBox->currentIndex();
-
-    Q_EMIT emitSelectedCameraDevice(i);
+	CameraConfiguration conf = grabUICameraConfiguration();
+    Q_EMIT emitSelectedCameraDevice(conf);
 
     this->close();
 }
 
+void CameraDevice::on_pushButton_clicked()
+{
+	int id = ui->comboBox->currentIndex();
+	m_capture.open(id);
+	CameraConfiguration conf = grabUICameraConfiguration();
+	std::this_thread::sleep_for(std::chrono::milliseconds(1000));
+	int fails = 0;
+
+	while (!m_capture.isOpened() && fails < 5) {
+		m_capture.open(id);
+		std::this_thread::sleep_for(std::chrono::milliseconds(1000));
+		fails++;
+	}
+
+	if (conf._width != -1) m_capture.set(CV_CAP_PROP_FRAME_WIDTH, conf._width);
+	if (conf._height != -1) m_capture.set(CV_CAP_PROP_FRAME_HEIGHT, conf._height);
+	if (conf._fps != -1) m_capture.set(CV_CAP_PROP_FPS, conf._fps);
+	
+	if (!m_capture.isOpened()) {
+		//throw device_open_error(":(");
+		ui->label_NoImage->setText("Error loading camera");
+	}
+	else
+	{
+		cv::Mat mat;
+		m_capture.grab();
+		m_capture.retrieve(mat);
+		m_capture.grab();
+		m_capture.retrieve(mat);
+		cv::Mat destination;
+		cv::resize(mat, destination, cv::Size(240, 180));
+		QPixmap image = QPixmap::fromImage(QImage((unsigned char*)destination.data, destination.cols, destination.rows, QImage::Format_RGB888));
+		ui->label_NoImage->setPixmap(image);
+		m_capture.release();
+	}
+	
+}
+
 void CameraDevice::on_comboBox_currentIndexChanged(int index)
 {
-    startCamera(index);
+    //startCamera(index);
 }
 
 void CameraDevice::listAllCameras()
@@ -43,7 +99,7 @@ void CameraDevice::listAllCameras()
         ui->comboBox->addItem(cameraInfo.deviceName());
     }
 
-    startCamera(0);
+    //startCamera(0);
 }
 
 void CameraDevice::startCamera(int i)
diff --git a/BioTracker/CoreApp/BioTracker/View/CameraDevice.h b/BioTracker/CoreApp/BioTracker/View/CameraDevice.h
index f70a7da396c6ab2207b20642fef3f3c4c4dd3567..d111b00680aaf9dfe30254da7799644354ae0108 100644
--- a/BioTracker/CoreApp/BioTracker/View/CameraDevice.h
+++ b/BioTracker/CoreApp/BioTracker/View/CameraDevice.h
@@ -6,6 +6,8 @@
 #include <QCamera>
 #include "QCameraViewfinder"
 #include "QPointer"
+#include "util/types.h"
+#include <opencv2/opencv.hpp>
 
 namespace Ui {
 class CameraDevice;
@@ -22,19 +24,23 @@ public:
 private Q_SLOTS:
     void on_buttonBox_accepted();
 
+	void on_pushButton_clicked();
+
     void on_comboBox_currentIndexChanged(int index);
 
     void on_buttonBox_rejected();
 
 Q_SIGNALS:
-    void emitSelectedCameraDevice(int i);
+    void emitSelectedCameraDevice(CameraConfiguration conf);
 
 private:
+	CameraConfiguration grabUICameraConfiguration();
     void listAllCameras();
     void startCamera(int i);
 
 private:
-    Ui::CameraDevice *ui;
+    Ui::CameraDevice *ui;
+	cv::VideoCapture m_capture;
 
     QPointer< QCamera > camera;
     QPointer< QCameraViewfinder > viewfinder;
diff --git a/BioTracker/CoreApp/BioTracker/View/CameraDevice.ui b/BioTracker/CoreApp/BioTracker/View/CameraDevice.ui
index 5fb28ade64a04e8094ce81ed82490d41278aaec2..32aeb984a5849168264a7e257b49522ac69f886c 100644
--- a/BioTracker/CoreApp/BioTracker/View/CameraDevice.ui
+++ b/BioTracker/CoreApp/BioTracker/View/CameraDevice.ui
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>493</width>
-    <height>300</height>
+    <width>489</width>
+    <height>370</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -16,9 +16,9 @@
   <widget class="QWidget" name="layoutWidget">
    <property name="geometry">
     <rect>
-     <x>19</x>
+     <x>10</x>
      <y>250</y>
-     <width>461</width>
+     <width>471</width>
      <height>31</height>
     </rect>
    </property>
@@ -33,6 +33,13 @@
     <item>
      <widget class="QComboBox" name="comboBox"/>
     </item>
+    <item>
+     <widget class="QPushButton" name="pushButton">
+      <property name="text">
+       <string>Preview</string>
+      </property>
+     </widget>
+    </item>
     <item>
      <widget class="QDialogButtonBox" name="buttonBox">
       <property name="standardButtons">
@@ -51,6 +58,150 @@
      <height>231</height>
     </rect>
    </property>
+   <widget class="QWidget" name="verticalLayoutWidget">
+    <property name="geometry">
+     <rect>
+      <x>0</x>
+      <y>0</y>
+      <width>471</width>
+      <height>231</height>
+     </rect>
+    </property>
+    <layout class="QVBoxLayout" name="verticalLayout">
+     <item>
+      <widget class="QLabel" name="label_NoImage">
+       <property name="text">
+        <string>&lt;No Image&gt;</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </widget>
+  </widget>
+  <widget class="QWidget" name="horizontalLayoutWidget">
+   <property name="geometry">
+    <rect>
+     <x>10</x>
+     <y>290</y>
+     <width>471</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <layout class="QHBoxLayout" name="horizontalLayout_2">
+    <item>
+     <widget class="QLabel" name="label_2">
+      <property name="sizePolicy">
+       <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
+        <horstretch>0</horstretch>
+        <verstretch>0</verstretch>
+       </sizepolicy>
+      </property>
+      <property name="text">
+       <string>Resolution:</string>
+      </property>
+     </widget>
+    </item>
+    <item>
+     <widget class="QLineEdit" name="lineEdit">
+      <property name="sizePolicy">
+       <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+        <horstretch>0</horstretch>
+        <verstretch>0</verstretch>
+       </sizepolicy>
+      </property>
+      <property name="maximumSize">
+       <size>
+        <width>100</width>
+        <height>16777215</height>
+       </size>
+      </property>
+      <property name="text">
+       <string>Default</string>
+      </property>
+     </widget>
+    </item>
+    <item>
+     <widget class="QLabel" name="label_3">
+      <property name="sizePolicy">
+       <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
+        <horstretch>0</horstretch>
+        <verstretch>0</verstretch>
+       </sizepolicy>
+      </property>
+      <property name="text">
+       <string>x</string>
+      </property>
+     </widget>
+    </item>
+    <item>
+     <widget class="QLineEdit" name="lineEdit_2">
+      <property name="maximumSize">
+       <size>
+        <width>100</width>
+        <height>16777215</height>
+       </size>
+      </property>
+      <property name="text">
+       <string>Default</string>
+      </property>
+     </widget>
+    </item>
+    <item>
+     <spacer name="horizontalSpacer">
+      <property name="orientation">
+       <enum>Qt::Horizontal</enum>
+      </property>
+      <property name="sizeHint" stdset="0">
+       <size>
+        <width>40</width>
+        <height>20</height>
+       </size>
+      </property>
+     </spacer>
+    </item>
+    <item>
+     <widget class="QLabel" name="label_4">
+      <property name="sizePolicy">
+       <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
+        <horstretch>0</horstretch>
+        <verstretch>0</verstretch>
+       </sizepolicy>
+      </property>
+      <property name="text">
+       <string>FPS:</string>
+      </property>
+     </widget>
+    </item>
+    <item>
+     <widget class="QLineEdit" name="lineEdit_3">
+      <property name="text">
+       <string>Default</string>
+      </property>
+     </widget>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QWidget" name="horizontalLayoutWidget_2">
+   <property name="geometry">
+    <rect>
+     <x>10</x>
+     <y>330</y>
+     <width>471</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <layout class="QHBoxLayout" name="horizontalLayout_3">
+    <item>
+     <widget class="QCheckBox" name="checkBox">
+      <property name="text">
+       <string>Record Input stream</string>
+      </property>
+     </widget>
+    </item>
+    <item>
+     <widget class="QComboBox" name="comboBox_2"/>
+    </item>
+   </layout>
   </widget>
  </widget>
  <resources/>
diff --git a/BioTracker/CoreApp/BioTracker/View/GraphicsView.cpp b/BioTracker/CoreApp/BioTracker/View/GraphicsView.cpp
index c6ed5ed3cf03a63205f30d267e7c151759032d27..c01140ae8906c941fe92f17a902b52590483ac65 100644
--- a/BioTracker/CoreApp/BioTracker/View/GraphicsView.cpp
+++ b/BioTracker/CoreApp/BioTracker/View/GraphicsView.cpp
@@ -2,6 +2,9 @@
 #include "QTimeLine"
 #include "QWheelEvent"
 
+#include <qpixmap.h>
+#include <QGraphicsItem>
+
 GraphicsView::GraphicsView(QWidget *parent, IController *controller, IModel *model) :
 	IViewGraphicsView(parent, controller, model)
 {
diff --git a/BioTracker/CoreApp/BioTracker/View/MainWindow.cpp b/BioTracker/CoreApp/BioTracker/View/MainWindow.cpp
index fdc8ac08b9585dd7dbcc280151e6522416a2e684..8d9cec5177f148b8937e868d2ef11311d3cbbed9 100644
--- a/BioTracker/CoreApp/BioTracker/View/MainWindow.cpp
+++ b/BioTracker/CoreApp/BioTracker/View/MainWindow.cpp
@@ -102,7 +102,23 @@ void MainWindow::on_actionOpen_Picture_triggered() {
 }
 
 void MainWindow::on_actionLoad_tracking_data_triggered() {
-
+	QRect r = ui->trackingArea->frameRect();
+	QObjectList l = ui->trackingArea->children();
+	uint cnt = l.count();
+
+	QPixmap *pix = new QPixmap(2048,2048);
+	QPainter *paint = new QPainter(pix);
+	for (int i = 0; i < cnt; i++) {
+		GraphicsView *go = dynamic_cast<GraphicsView*>(l.at(i));
+		if (go) {
+			//go->m_GraphicsScene->
+		}
+		QGraphicsItem *go2 = dynamic_cast<QGraphicsObject*>(l.at(i));
+		if (go2) {
+			go2->paint(paint, 0);
+		}
+	}
+	pix->save("test.png");
 }
 
 void MainWindow::on_actionSave_tracking_data_triggered() {
@@ -121,8 +137,8 @@ void MainWindow::on_actionOpen_Camera_triggered() {
     QObject::connect(m_CameraDevice, &CameraDevice::emitSelectedCameraDevice, this, &MainWindow::receiveSelectedCameraDevice);
 }
 
-void MainWindow::receiveSelectedCameraDevice(int i) {
-    qobject_cast<ControllerMainWindow*> (getController())->loadCameraDevice(i);
+void MainWindow::receiveSelectedCameraDevice(CameraConfiguration conf) {
+    qobject_cast<ControllerMainWindow*> (getController())->loadCameraDevice(conf);
 
 }
 
diff --git a/BioTracker/CoreApp/BioTracker/View/MainWindow.h b/BioTracker/CoreApp/BioTracker/View/MainWindow.h
index 98376402662230c806279dc4eef7cc68ac180ebe..3ada09829c2598cc27e3dce39800ec95d3ee8875 100644
--- a/BioTracker/CoreApp/BioTracker/View/MainWindow.h
+++ b/BioTracker/CoreApp/BioTracker/View/MainWindow.h
@@ -9,7 +9,8 @@
 #include "CameraDevice.h"
 #include "QPointer"
 #include "QStringListModel"
-#include "View/GraphicsView.h"//MARKER
+#include "View/GraphicsView.h"
+#include "util/types.h"
 
 namespace Ui {
 class MainWindow;
@@ -47,7 +48,7 @@ class MainWindow : public IViewMainWindow {
 
     void on_actionOpen_Camera_triggered();
 
-    void receiveSelectedCameraDevice(int i);
+    void receiveSelectedCameraDevice(CameraConfiguration conf);
 
     void on_checkBox_TrackingActivated_stateChanged(int arg1);
 
diff --git a/BioTracker/CoreApp/BioTracker/View/VideoControllWidget.cpp b/BioTracker/CoreApp/BioTracker/View/VideoControllWidget.cpp
index 12c130bf307f698f1711c27ccbc8b715bce589b9..7150e174ff67df6354a75cea453445bf44b221bb 100644
--- a/BioTracker/CoreApp/BioTracker/View/VideoControllWidget.cpp
+++ b/BioTracker/CoreApp/BioTracker/View/VideoControllWidget.cpp
@@ -104,11 +104,30 @@ void VideoControllWidget::on_PositionChanged(int position) {
 }
 
 
+void VideoControllWidget::on_pushButton_clicked() { //TODO This is named "pushButton" although I renamed it to button_record!?
+	//QString name = arg1;
+	ControllerPlayer* controller = dynamic_cast<ControllerPlayer*>(getController());
+
+	int success = controller->recordOutput();
+	if (success == 1) {
+		QPixmap pix(":/Images/resources/recording.png");
+		QIcon icon(pix);
+		ui->pushButton->setIcon(icon);
+		ui->pushButton->setIconSize(QSize(32,32));
+	}
+	else {
+		QPixmap pix(":/Images/resources/record.png");
+		QIcon icon(pix);
+		ui->pushButton->setIcon(icon);
+		ui->pushButton->setIconSize(QSize(32, 32));
+	}
+}
+
 void VideoControllWidget::on_comboBoxSelectedView_currentTextChanged(const QString& arg1) {
-    QString name = arg1;
-    ControllerPlayer* controller = dynamic_cast<ControllerPlayer*>(getController());
+	QString name = arg1;
+	ControllerPlayer* controller = dynamic_cast<ControllerPlayer*>(getController());
 
-    controller->changeImageView(name);
+	controller->changeImageView(name);
 }
 
 void VideoControllWidget::on_sld_video_sliderReleased() {
diff --git a/BioTracker/CoreApp/BioTracker/View/VideoControllWidget.h b/BioTracker/CoreApp/BioTracker/View/VideoControllWidget.h
index 3050b30f1f6f6217c01ba5033ebc5e634ccaff60..1a0b166b4fef2a93df0b07e6b3bc5b8a026b88eb 100644
--- a/BioTracker/CoreApp/BioTracker/View/VideoControllWidget.h
+++ b/BioTracker/CoreApp/BioTracker/View/VideoControllWidget.h
@@ -38,6 +38,7 @@ class VideoControllWidget : public IViewWidget {
     void on_PositionChanged(int position);
     void on_button_nextFrame_clicked();
     void on_button_playPause_clicked();
+	void on_pushButton_clicked();
 
     void on_button_stop_clicked();
 
@@ -46,7 +47,6 @@ class VideoControllWidget : public IViewWidget {
 
     void on_comboBoxSelectedView_currentTextChanged(const QString& arg1);
 
-
     void on_sld_video_sliderReleased();
 
     void on_sld_video_sliderMoved(int position);
diff --git a/BioTracker/CoreApp/BioTracker/View/VideoControllWidget.ui b/BioTracker/CoreApp/BioTracker/View/VideoControllWidget.ui
index 1678def84f717eea754c487bbd15c58bf6585038..aa8afe818df0ae2cd7ae959d7bc123b215d53774 100644
--- a/BioTracker/CoreApp/BioTracker/View/VideoControllWidget.ui
+++ b/BioTracker/CoreApp/BioTracker/View/VideoControllWidget.ui
@@ -9,7 +9,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>798</width>
+    <width>817</width>
     <height>109</height>
    </rect>
   </property>
@@ -237,6 +237,23 @@
         </property>
        </widget>
       </item>
+      <item>
+       <widget class="QPushButton" name="button_record">
+        <property name="text">
+         <string/>
+        </property>
+        <property name="icon">
+         <iconset resource="../guiresources.qrc">
+          <normaloff>:/Images/resources/record.png</normaloff>:/Images/resources/record.png</iconset>
+        </property>
+        <property name="iconSize">
+         <size>
+          <width>32</width>
+          <height>32</height>
+         </size>
+        </property>
+       </widget>
+      </item>
       <item>
        <widget class="QLabel" name="lbl_frame">
         <property name="text">
diff --git a/BioTracker/CoreApp/BioTracker/guiresources.qrc b/BioTracker/CoreApp/BioTracker/guiresources.qrc
index b80fc16911b5333e7b494dfd96a817d50e4a81a2..0a77b223c190acb1031a1b485a59482f5a4abce8 100644
--- a/BioTracker/CoreApp/BioTracker/guiresources.qrc
+++ b/BioTracker/CoreApp/BioTracker/guiresources.qrc
@@ -9,5 +9,7 @@
         <file>resources/pause-sign.png</file>
         <file>resources/screenshot.png</file>
         <file>resources/stop.png</file>
+        <file>resources/record.png</file>
+        <file>resources/recording.png</file>
     </qresource>
 </RCC>
diff --git a/BioTracker/CoreApp/BioTracker/main.cpp b/BioTracker/CoreApp/BioTracker/main.cpp
index 571c323e520da10d9de472c9b4ec4165373ad772..b4e48cde2d2b615c77add597054d79e43e7ed2fe 100644
--- a/BioTracker/CoreApp/BioTracker/main.cpp
+++ b/BioTracker/CoreApp/BioTracker/main.cpp
@@ -5,6 +5,7 @@
 #include <boost/filesystem.hpp>
 #include "QVector"
 #include "Model/MediaPlayerStateMachine/PlayerParameters.h"
+#include "util/types.h"
 
 int main(int argc, char* argv[]) {
     QApplication app(argc, argv);
@@ -18,6 +19,7 @@ int main(int argc, char* argv[]) {
     qRegisterMetaType<std::vector<boost::filesystem::path>>("std::vector<boost::filesystem::path>");
     qRegisterMetaType<QVector<bool>>("QVector<bool>");
     qRegisterMetaType<playerParameters*>("playerParameters*");
+	qRegisterMetaType<CameraConfiguration>("CameraConfiguration");
 
 
 
diff --git a/BioTracker/CoreApp/BioTracker/resources/record.png b/BioTracker/CoreApp/BioTracker/resources/record.png
new file mode 100644
index 0000000000000000000000000000000000000000..c58ad8791b4a024b873755c77428c774bcefe5c2
Binary files /dev/null and b/BioTracker/CoreApp/BioTracker/resources/record.png differ
diff --git a/BioTracker/CoreApp/BioTracker/resources/recording.png b/BioTracker/CoreApp/BioTracker/resources/recording.png
new file mode 100644
index 0000000000000000000000000000000000000000..07164f9743f0f68af984f6005ca7d636cb6b3d29
Binary files /dev/null and b/BioTracker/CoreApp/BioTracker/resources/recording.png differ
diff --git a/BioTracker/CoreApp/BioTracker/util/types.h b/BioTracker/CoreApp/BioTracker/util/types.h
new file mode 100644
index 0000000000000000000000000000000000000000..90e2e34257bd27f9ed710d6fdcf857db8f8dd9e4
--- /dev/null
+++ b/BioTracker/CoreApp/BioTracker/util/types.h
@@ -0,0 +1,22 @@
+#pragma once
+
+
+#include <string>
+
+class CameraConfiguration
+{
+public:
+	CameraConfiguration() :
+		_id(0), _width(-1), _height(-1), _fps(-1), _recordInput(false), _fourcc("FMP4") {
+	}
+	CameraConfiguration(int p_id, int p_width, int p_height, double p_fps, bool p_recordInput, std::string p_fourcc) :
+		_id(p_id), _width(p_width), _height(p_height), _fps(p_fps), _recordInput(p_recordInput), _fourcc(p_fourcc) {
+	}
+
+	int _id;
+	int _width;
+	int _height;
+	bool _recordInput;
+	double _fps;
+	std::string _fourcc;
+};
\ No newline at end of file
diff --git a/BioTracker/Plugin/BackgroundSubtraction/Model/BioTrackerTrackingAlgorithm.cpp b/BioTracker/Plugin/BackgroundSubtraction/Model/BioTrackerTrackingAlgorithm.cpp
index 819c12dfecdf061f455e6c7848ee2cf4be910713..9a094d08f082e1380fc9069962ceca3533d04448 100644
--- a/BioTracker/Plugin/BackgroundSubtraction/Model/BioTrackerTrackingAlgorithm.cpp
+++ b/BioTracker/Plugin/BackgroundSubtraction/Model/BioTrackerTrackingAlgorithm.cpp
@@ -193,7 +193,7 @@ void BioTrackerTrackingAlgorithm::doTracking(std::shared_ptr<cv::Mat> p_image, u
 	}
 
 	//First the user still wants to see the original image, right?
-	if (framenumber) {
+	if (framenumber==1) {
 		Q_EMIT emitChangeDisplayImage("Original");
 	}
 
diff --git a/BioTracker/Plugin/Sample/Sample.tracker.dir/Debug/Sample.tracker.vcxprojResolveAssemblyReference.cache b/BioTracker/Plugin/Sample/Sample.tracker.dir/Debug/Sample.tracker.vcxprojResolveAssemblyReference.cache
index 96b42710d643c6a3b74e58fc9744a3281c6d0583..cffab191f17b7befef9f8482dcb87bcb8cfc22e4 100644
Binary files a/BioTracker/Plugin/Sample/Sample.tracker.dir/Debug/Sample.tracker.vcxprojResolveAssemblyReference.cache and b/BioTracker/Plugin/Sample/Sample.tracker.dir/Debug/Sample.tracker.vcxprojResolveAssemblyReference.cache differ
diff --git a/BioTracker/Utils/BioTrackerUtils/src/util/misc.cpp b/BioTracker/Utils/BioTrackerUtils/src/util/misc.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..302ecb7ea4c665fb25fe7165cddeb94dada2ebef
--- /dev/null
+++ b/BioTracker/Utils/BioTrackerUtils/src/util/misc.cpp
@@ -0,0 +1,15 @@
+#include "util/misc.h"
+
+std::string getTimeAndDate(std::string prefix, std::string suffix)
+{
+	time_t  timetitle;
+	std::string timeInfo = prefix;
+	time(&timetitle);
+	std::string t = ctime(&timetitle);
+	for (int i = 0; i < t.size(); i++)
+		if (t[i] == ' ' || t[i] == ':')
+			t[i] = '_';
+	timeInfo += t.substr(0, t.size() - 1);
+	timeInfo += suffix;
+	return timeInfo;
+}
\ No newline at end of file
diff --git a/BioTracker/Utils/BioTrackerUtils/util/misc.h b/BioTracker/Utils/BioTrackerUtils/util/misc.h
new file mode 100644
index 0000000000000000000000000000000000000000..18daeadba2fab9d45263ec3fa496fedad74c7870
--- /dev/null
+++ b/BioTracker/Utils/BioTrackerUtils/util/misc.h
@@ -0,0 +1,9 @@
+#ifndef MISC_H
+#define MISC_H
+#include <string>
+#include <time.h>
+
+
+std::string getTimeAndDate(std::string prefix, std::string suffix);
+
+#endif
\ No newline at end of file