add grabber for dual cam recordings
This commit is contained in:
parent
5a999fac54
commit
e259d668ad
29
dualcamgrabber.cpp
Normal file
29
dualcamgrabber.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
#include "dualcamgrabber.h"
|
||||
#include <iostream>
|
||||
#include <pylon/PylonIncludes.h>
|
||||
|
||||
void DualcamGrabber::run() {
|
||||
stop_request = false;
|
||||
size_t framecount = 0;
|
||||
if (wrapper->isOpen()) {
|
||||
Pylon::CInstantCameraArray &cameras = wrapper->getCameraArray();
|
||||
wrapper->frameRate(static_cast<uint>(framerate));
|
||||
wrapper->exposureTime(exposure);
|
||||
wrapper->gain(gain);
|
||||
cameras.StartGrabbing();
|
||||
Pylon::CGrabResultPtr frame0, frame1;
|
||||
|
||||
while (cameras.IsGrabbing() && !stop_request) {
|
||||
MyImage *img = new MyImage();
|
||||
cameras.RetrieveResult( 5000, framecount % 2 == 0 ? frame0 : frame1, Pylon::TimeoutHandling_ThrowException );
|
||||
img->setFrame(framecount % 2 == 0 ? frame0 : frame1);
|
||||
if (framecount % 2 == 0) {
|
||||
buffer0->push(img);
|
||||
} else {
|
||||
buffer1->push(img);
|
||||
}
|
||||
framecount += 1;
|
||||
}
|
||||
cameras.StopGrabbing();
|
||||
}
|
||||
}
|
58
dualcamgrabber.h
Normal file
58
dualcamgrabber.h
Normal file
@ -0,0 +1,58 @@
|
||||
#ifndef DUALCAMGRABBER_H
|
||||
#define DUALCAMGRABBER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QThread>
|
||||
#include "dualcamwrapper.h"
|
||||
#include "imagebuffer.h"
|
||||
|
||||
class DualcamGrabber : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DualcamGrabber(DualcamWrapper *wrapper, ImageBuffer *buffer0, ImageBuffer * buffer1, int framerate, QObject *parent = nullptr) :
|
||||
QThread(parent), wrapper(wrapper), buffer0(buffer0), buffer1(buffer1), framerate(framerate) {}
|
||||
|
||||
void run() override;
|
||||
void stop();
|
||||
int currentFramerate() {
|
||||
return framerate;
|
||||
}
|
||||
|
||||
double currentExposureTime() {
|
||||
return exposure;
|
||||
}
|
||||
|
||||
double currentGain() {
|
||||
return gain;
|
||||
}
|
||||
|
||||
private:
|
||||
bool stop_request = false;
|
||||
DualcamWrapper *wrapper;
|
||||
ImageBuffer *buffer0, *buffer1;
|
||||
int framerate;
|
||||
double exposure, gain;
|
||||
|
||||
public slots:
|
||||
void requestStop() {
|
||||
stop_request=true;
|
||||
}
|
||||
|
||||
void setFrameRate(int newFramerate) {
|
||||
framerate = newFramerate;
|
||||
}
|
||||
|
||||
void setExposureTime(double newExposureTime) {
|
||||
exposure = newExposureTime;
|
||||
}
|
||||
|
||||
void setGain(double gain_db) {
|
||||
gain = gain_db;
|
||||
}
|
||||
|
||||
signals:
|
||||
void terminated();
|
||||
};
|
||||
|
||||
#endif // DUALCAMGRABBER_H
|
Loading…
Reference in New Issue
Block a user