first Commit
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
//CameraManager.h
|
||||
#pragma once
|
||||
#include <QObject>
|
||||
#include <QThread>
|
||||
#include <QImage>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <atomic>
|
||||
#include "GalaxyIncludes.h"
|
||||
|
||||
class CaptureWorker;
|
||||
|
||||
class CameraManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum CamIndex { LEFT = 0, RIGHT = 1 };
|
||||
static const QString LEFT_SN;
|
||||
static const QString RIGHT_SN;
|
||||
|
||||
explicit CameraManager(QObject* parent = nullptr);
|
||||
~CameraManager();
|
||||
|
||||
static bool initSDK();
|
||||
static void uninitSDK();
|
||||
static QStringList enumerateDevices();
|
||||
|
||||
// Override the default serial numbers before connectCamera(). Keeping the
|
||||
// serial numbers on the manager instance lets the SDK wrapper support a
|
||||
// customer's cameras without changing the original application defaults.
|
||||
void setSerialNumber(CamIndex idx, const QString& serialNumber);
|
||||
QString serialNumber(CamIndex idx) const;
|
||||
|
||||
bool connectCamera(CamIndex idx);
|
||||
void disconnectCamera(CamIndex idx);
|
||||
bool isConnected(CamIndex idx) const;
|
||||
|
||||
bool startPreview(CamIndex idx);
|
||||
void stopPreview(CamIndex idx);
|
||||
bool isPreviewing(CamIndex idx) const { return m_thread[idx] != nullptr; }
|
||||
QImage captureSingleFrame(CamIndex idx);
|
||||
CGXDevicePointer getDevice(CamIndex idx) const { return m_device[idx]; }
|
||||
|
||||
bool setExposureTime(CamIndex idx, double us);
|
||||
bool getExposureTime(CamIndex idx, double& us);
|
||||
bool setGain(CamIndex idx, double dB);
|
||||
// Run the camera's one-shot automatic white-balance procedure.
|
||||
// The camera performs the adjustment and returns to its normal state.
|
||||
bool applyWhiteBalanceOnce(CamIndex idx);
|
||||
|
||||
signals:
|
||||
void leftFrameReady(const QImage& img);
|
||||
void rightFrameReady(const QImage& img);
|
||||
void cameraConnected(CamIndex idx);
|
||||
void cameraDisconnected(CamIndex idx);
|
||||
void errorOccurred(int idx, const QString& msg);
|
||||
|
||||
private:
|
||||
QString snForIndex(CamIndex idx) const;
|
||||
CGXDevicePointer m_device[2];
|
||||
bool m_connected[2];
|
||||
QString m_serial[2];
|
||||
QThread* m_thread[2];
|
||||
CaptureWorker* m_worker[2];
|
||||
};
|
||||
|
||||
class CaptureWorker : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CaptureWorker(CGXDevicePointer dev);
|
||||
public slots:
|
||||
void startCapture();
|
||||
void stopCapture();
|
||||
signals:
|
||||
void frameReady(const QImage& img);
|
||||
void errorOccurred(const QString& msg);
|
||||
private:
|
||||
CGXDevicePointer m_device;
|
||||
std::atomic_bool m_running;
|
||||
};
|
||||
Reference in New Issue
Block a user