// +-------------------------------- DISCLAIMER ---------------------------------+
// |                                                                             |
// | This program is provided to you free of charge "as such".                   |
// | You should not assume that this program is error-free or suitable for any   |
// | purpose whatsoever.                                                         |
// |                                                                             |
// | EURESYS does not give any representation, warranty or undertaking that this |
// | program is free of any defect or error or suitable for any purpose. EURESYS |
// | shall not be liable, in contract, in torts or otherwise, for any damages,   |
// | loss, costs, expenses or other claims for compensation, including those     |
// | asserted by third parties, arising out of or in connection with the use of  |
// | this program.                                                               |
// +-----------------------------------------------------------------------------+

#ifndef CAMERAHANDLER_H
#define CAMERAHANDLER_H

#include <vector>
#include <memory>
#include <thread>
#include <condition_variable>
#include <string>

namespace Euresys
{
  namespace Open_eVision
  {
    class EImageC24;
  }
}


class CameraHandler
{
public:
  CameraHandler(const std::string& params = "");
  ~CameraHandler();

  void launchCamera();
public:
  std::mutex processImageMutex_;
  std::condition_variable canProcessImage_;

  uint8_t* data_;
  uint32_t width_;
  uint32_t height_;
  uint32_t pitch_;
  bool abort_;

  std::string videoFile_;

private:
  void run();

  std::thread thread_;
  std::unique_ptr<Euresys::Open_eVision::EImageC24> img_;

  // make non-copyable
  CameraHandler( const CameraHandler& );
  CameraHandler& operator=( const CameraHandler& );
};

#endif // CAMERAHANDLER_H


