2011-10-25 15:48:19 +00:00
|
|
|
/*
|
2011-12-02 18:34:08 +00:00
|
|
|
* Copyright (C) 2011, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
|
2011-10-25 15:48:19 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef CAMERA_H_
|
|
|
|
|
#define CAMERA_H_
|
|
|
|
|
|
|
|
|
|
#include <opencv2/highgui/highgui.hpp>
|
|
|
|
|
#include <QtCore/QObject>
|
2011-11-23 16:44:14 +00:00
|
|
|
#include <QtCore/QTimer>
|
2014-05-21 21:31:42 +00:00
|
|
|
#include <QtGui/QImage>
|
|
|
|
|
#include <QtNetwork/QTcpSocket>
|
|
|
|
|
|
|
|
|
|
class CameraTcpClient : public QTcpSocket
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT;
|
|
|
|
|
public:
|
|
|
|
|
CameraTcpClient(QObject * parent = 0);
|
|
|
|
|
cv::Mat getImage();
|
2014-07-25 19:31:34 +00:00
|
|
|
int imagesBuffered() const {return images_.size();}
|
2014-05-21 21:31:42 +00:00
|
|
|
|
2014-07-08 19:55:03 +00:00
|
|
|
private Q_SLOTS:
|
2014-05-22 15:46:43 +00:00
|
|
|
void readReceivedData();
|
2014-05-21 21:31:42 +00:00
|
|
|
void displayError(QAbstractSocket::SocketError socketError);
|
|
|
|
|
void connectionLost();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
quint64 blockSize_;
|
2014-07-25 19:31:34 +00:00
|
|
|
QVector<cv::Mat> images_;
|
2014-05-21 21:31:42 +00:00
|
|
|
};
|
2011-10-25 15:48:19 +00:00
|
|
|
|
|
|
|
|
class Camera : public QObject {
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2011-11-23 16:44:14 +00:00
|
|
|
Camera(QObject * parent = 0);
|
2011-10-25 15:48:19 +00:00
|
|
|
virtual ~Camera();
|
|
|
|
|
|
2011-11-23 16:44:14 +00:00
|
|
|
virtual bool start();
|
|
|
|
|
virtual void stop();
|
2011-11-24 00:00:37 +00:00
|
|
|
virtual bool isRunning() {return cameraTimer_.isActive();}
|
2011-10-25 15:48:19 +00:00
|
|
|
|
2012-01-30 03:16:30 +00:00
|
|
|
void pause();
|
2012-08-28 20:06:43 +00:00
|
|
|
int getTotalFrames();
|
|
|
|
|
int getCurrentFrameIndex();
|
|
|
|
|
void moveToFrame(int frame);
|
2012-01-30 03:16:30 +00:00
|
|
|
|
2014-07-08 19:55:03 +00:00
|
|
|
Q_SIGNALS:
|
2011-11-23 16:44:14 +00:00
|
|
|
void imageReceived(const cv::Mat & image);
|
2011-10-25 15:48:19 +00:00
|
|
|
|
2014-07-08 19:55:03 +00:00
|
|
|
public Q_SLOTS:
|
2011-11-24 00:00:37 +00:00
|
|
|
virtual void updateImageRate();
|
|
|
|
|
virtual void takeImage();
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
void startTimer();
|
|
|
|
|
void stopTimer();
|
2011-10-25 15:48:19 +00:00
|
|
|
|
|
|
|
|
private:
|
2012-05-16 01:42:10 +00:00
|
|
|
cv::VideoCapture capture_;
|
2011-11-23 16:44:14 +00:00
|
|
|
QTimer cameraTimer_;
|
2012-08-28 20:06:43 +00:00
|
|
|
QList<std::string> images_;
|
|
|
|
|
unsigned int currentImageIndex_;
|
2014-05-21 21:31:42 +00:00
|
|
|
CameraTcpClient cameraTcpClient_;
|
2011-10-25 15:48:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif /* CAMERA_H_ */
|