-
Notifications
You must be signed in to change notification settings - Fork 0
/
BaslerCamera.h
80 lines (54 loc) · 1.85 KB
/
BaslerCamera.h
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef BASCAM_H
#define BASCAM_H
#include "opencv2/opencv.hpp"
#include "globals.h"
#include <QString>
#include <QImage>
#include <pylon/PylonIncludes.h>
using namespace Pylon;
class CVideoEventHandler;
class BaslerCamera : public QObject
{
Q_OBJECT
private:
int frameRate;
std::unique_ptr<Pylon::CInstantCamera> pOverviewCamera = nullptr;
std::unique_ptr<Pylon::CInstantCamera> pMicroscopeCamera = nullptr;
public:
BaslerCamera();
~BaslerCamera();
void detachCameras();
CVideoEventHandler* pEventHandler;
bool isOverviewCameraEmpty() { return pOverviewCamera == nullptr; };
bool isMicroscopeCameraEmpty() { return pOverviewCamera == nullptr; };
bool openCamera(cameraType::camera cameraType);
Pylon::CInstantCamera* getCamera(cameraType::camera cameraType);
void loadSettingsOverview();
cv::Mat grabImage(cameraType::camera cameraType = cameraType::overview, bool bCalledInLoop = false);
void setCameras(QString overviewSerialNumber, QString microscopeSerialNumber);
void grabVideo(cameraType::camera cameraType = cameraType::overview);
void stopGrabbing();
void sendImage(cv::Mat cv_im) {
emit processedImage(cv_im);
}
signals:
//Signal to output frame to be displayed
void processedImage(cv::Mat image);
void LOGCONSOLE(QString strText, CONSOLECOLOURS::colour col = CONSOLECOLOURS::colour::Information);
};
class CVideoEventHandler : public CImageEventHandler
{
private:
BaslerCamera* pParent;
public:
void setParent(BaslerCamera* pCam) { pParent = pCam; };
void CVideoEventHandler::OnImageGrabbed(CInstantCamera& camera, const CGrabResultPtr& ptrGrabResult)
{
CPylonImage image;
CImageFormatConverter fc;
fc.OutputPixelFormat = PixelType_RGB8packed;
fc.Convert(image, ptrGrabResult);
pParent->sendImage(cv::Mat(ptrGrabResult->GetHeight(), ptrGrabResult->GetWidth(), CV_8UC3, (uint8_t*)image.GetBuffer()).clone());
}
};
#endif