-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathSLCameraWorker.cpp
50 lines (34 loc) · 1.15 KB
/
SLCameraWorker.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "SLCameraWorker.h"
#include "Camera.h"
#include <QApplication>
void SLCameraWorker::setup(unsigned iNum, unsigned cNum){
// Initialize camera
camera = Camera::NewCamera(iNum, cNum);
unsigned int frameWidth, frameHeight;
camera->getFrameWidthHeight(&frameWidth, &frameHeight);
std::cout << "SLCameraWorker: opened camera " << frameWidth << " x " << frameHeight << std::endl << std::flush;
}
void SLCameraWorker::doWork(){
_isWorking = true;
camera->startCapture();
while(_isWorking){
std::vector<cv::Mat> frameSeq;
for(unsigned int i=0; i<3; i++){
// Run camera in continous mode
CameraFrame frame = camera->lockFrame();
cv::Mat frameCV(frame.height, frame.width, CV_8U, frame.memory);
frameCV = frameCV.clone();
camera->unlockFrame();
frameSeq.push_back(frameCV);
}
// Emit new frame sequence signal
emit newFrameSeq(frameSeq);
QApplication::processEvents();
}
camera->stopCapture();
// Emit finished signal
emit finished();
}
SLCameraWorker::~SLCameraWorker(){
delete camera;
}