mirror of
https://github.com/vale981/Taevitas
synced 2025-03-05 09:31:42 -05:00
quit the thread right
This commit is contained in:
parent
7a3eaee5f8
commit
28ec5db59c
5 changed files with 36 additions and 34 deletions
|
@ -58,8 +58,8 @@ void CameraManager::stopCapture() {
|
|||
|
||||
|
||||
grabber->stopCapturing();
|
||||
grabber->quit();
|
||||
grabber->wait();
|
||||
|
||||
Error error = camera.StopCapture();
|
||||
if ( error != PGRERROR_OK ) {
|
||||
throw error;
|
||||
|
|
|
@ -4,30 +4,30 @@
|
|||
void ImageGrabber::run() {
|
||||
qDebug() << "Starting Capture.";
|
||||
capture = true;
|
||||
while( true ) {
|
||||
FlyCapture2::Image* tmp = new FlyCapture2::Image();
|
||||
FlyCapture2::Image* stored_img = new FlyCapture2::Image();
|
||||
while ( true ) {
|
||||
tmp = new FlyCapture2::Image();
|
||||
stored_img = new FlyCapture2::Image();
|
||||
|
||||
// TODO: Errors
|
||||
cam->RetrieveBuffer(tmp);
|
||||
|
||||
if( !capture )
|
||||
return;
|
||||
cam->RetrieveBuffer( tmp );
|
||||
|
||||
qDebug() << "Image Grabbed!";
|
||||
|
||||
stored_img->DeepCopy(tmp);
|
||||
emit imageCaptured(stored_img);
|
||||
stored_img->DeepCopy( tmp );
|
||||
emit imageCaptured( stored_img );
|
||||
delete tmp;
|
||||
}
|
||||
}
|
||||
|
||||
void ImageGrabber::setCamera(FlyCapture2::Camera *cam) {
|
||||
void ImageGrabber::setCamera( FlyCapture2::Camera * cam ) {
|
||||
this->cam = cam;
|
||||
}
|
||||
|
||||
void ImageGrabber::stopCapturing() {
|
||||
qDebug() << "Stopping Capture.";
|
||||
capture = false;
|
||||
}
|
||||
qDebug() << "Stopping Capture.";
|
||||
capture = false;
|
||||
|
||||
delete tmp;
|
||||
delete stored_img;
|
||||
terminate();
|
||||
}
|
||||
|
|
|
@ -4,24 +4,26 @@
|
|||
#include <QThread>
|
||||
#include "FlyCapture2.h"
|
||||
|
||||
class ImageGrabber : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
class ImageGrabber : public QThread {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ImageGrabber(QObject *parent = 0) : QThread(parent) {}
|
||||
void run() Q_DECL_OVERRIDE;
|
||||
void setCamera(FlyCapture2::Camera *cam);
|
||||
public:
|
||||
ImageGrabber( QObject * parent = 0 ) : QThread( parent ) {}
|
||||
void run() Q_DECL_OVERRIDE;
|
||||
void setCamera( FlyCapture2::Camera * cam );
|
||||
|
||||
private:
|
||||
bool capture;
|
||||
FlyCapture2::Camera *cam;
|
||||
private:
|
||||
bool capture;
|
||||
FlyCapture2::Camera * cam;
|
||||
|
||||
signals:
|
||||
void imageCaptured(FlyCapture2::Image *image);
|
||||
FlyCapture2::Image * tmp;
|
||||
FlyCapture2::Image * stored_img;
|
||||
|
||||
public slots:
|
||||
void stopCapturing();
|
||||
signals:
|
||||
void imageCaptured( FlyCapture2::Image * image );
|
||||
|
||||
public slots:
|
||||
void stopCapturing();
|
||||
};
|
||||
|
||||
#endif // IMAGEGRABBER_H
|
||||
|
|
|
@ -39,9 +39,9 @@ MainWindow::MainWindow( QWidget * parent ) :
|
|||
|
||||
// TODO: Finish -> quit
|
||||
// Move Recorder into another thread
|
||||
capThread = new QThread();
|
||||
recorder.moveToThread( capThread );
|
||||
connect( capThread, &QThread::finished, capThread, &QThread::deleteLater );
|
||||
recThread = new QThread();
|
||||
recorder.moveToThread( recThread );
|
||||
connect( recThread, &QThread::finished, recThread, &QThread::deleteLater );
|
||||
|
||||
// Initialize Image buffer.
|
||||
image_buffer = new QVector<FlyCapture2::Image *>;
|
||||
|
@ -84,8 +84,8 @@ MainWindow::~MainWindow() {
|
|||
if ( RECORDING )
|
||||
startStopRecording();
|
||||
|
||||
capThread->quit();
|
||||
capThread->wait();
|
||||
recThread->quit();
|
||||
recThread->wait();
|
||||
}
|
||||
|
||||
void MainWindow::setStatus( STATUS status ) {
|
||||
|
|
|
@ -50,7 +50,7 @@ class MainWindow : public QMainWindow {
|
|||
|
||||
QVector<FlyCapture2::Image *> * image_buffer;
|
||||
|
||||
QThread * capThread;
|
||||
QThread * recThread;
|
||||
|
||||
private slots:
|
||||
// Fills Camera Combobox with Cameras
|
||||
|
|
Loading…
Add table
Reference in a new issue