Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AgiMaulana/f9114d4b108c47499974c4f35887f1af to your computer and use it in GitHub Desktop.
Save AgiMaulana/f9114d4b108c47499974c4f35887f1af to your computer and use it in GitHub Desktop.
#ifndef VIDEOPLAYER_H
#define VIDEOPLAYER_H
#include <QMutex>
#include <QThread>
#include <QImage>
#include <QWaitCondition>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
class VideoPlayer : public QThread
{
Q_OBJECT
private:
bool stop;
QMutex mutex;
QWaitCondition condition;
Mat frame;
int frameRate;
VideoCapture capture;
Mat RGBframe;
QImage img;
signals:
//Signal to output frame to be displayed
void processedImage(const QImage &image);
protected:
void run();
void msleep(int ms);
public:
VideoPlayer(QObject *parent = 0);
~VideoPlayer();
//Load a video from memory
bool loadVideo(int filename);
bool loadVideo(std::string filename);
//Play the video
void Play();
//Stop the video
void Stop();
//check if the player has been stopped
bool isStopped() const;
//Release Camera
void release();
};
#endif // VIDEOPLAYER_H
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment