83 lines
1.9 KiB
C++
83 lines
1.9 KiB
C++
#ifndef IDSCAM_H
|
|
#define IDSCAM_H
|
|
|
|
#include <QString>
|
|
#include <QDebug>
|
|
#include <QList>
|
|
#undef signals
|
|
#include <arv.h>
|
|
#undef signals
|
|
#define signals Q_SIGNALS
|
|
#include <QObject>
|
|
#include <QMutex>
|
|
#include <QTimer>
|
|
#include <QImage>
|
|
#include <QElapsedTimer>
|
|
#include <opencv4/opencv2/opencv.hpp>
|
|
|
|
#include "processing.h"
|
|
#include "framebatch.h"
|
|
|
|
typedef struct {
|
|
ArvStream *stream;
|
|
QList<FrameBatch*> *pendingData;
|
|
QMutex *pendingMutex;
|
|
uint counter;
|
|
quint64 counter_total;
|
|
FrameBatch *cur = nullptr;
|
|
} ArvStreamCallbackData;
|
|
|
|
static void stream_callback(void *user_data, ArvStreamCallbackType type, ArvBuffer *buffer);
|
|
|
|
class IdsCam : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
IdsCam();
|
|
void update_av_cams();
|
|
void select_cam(uint id);
|
|
void set_pixel_format(int idx);
|
|
void set_exposure_time(double val);
|
|
void set_frame_rate(double val);
|
|
void set_gain(double val);
|
|
void set_trig(uint idx);
|
|
bool setup_buffering();
|
|
bool stop_buffering();
|
|
void buffer_polling();
|
|
|
|
QList<QString> av_cams_info{};
|
|
QList<QString> av_pixel_formats{};
|
|
QList<QString> av_trig_sources{};
|
|
double exposure_time = 0;
|
|
double frame_rate = 0;
|
|
double gain = 0;
|
|
|
|
ArvStream *stream = NULL;
|
|
private:
|
|
ArvCamera *camera = nullptr;
|
|
GError *error = NULL;
|
|
ArvStreamCallbackData callback_data;
|
|
QMutex pendingMutex;
|
|
QList<FrameBatch*> pendingData;
|
|
QElapsedTimer fps_timer;
|
|
quint64 last_n = 0;
|
|
float fps = 0;
|
|
|
|
QTimer timer;
|
|
|
|
QThreadPool workers{};
|
|
ProcessingConfig pro_cfg{};
|
|
|
|
ResList results{};
|
|
|
|
cv::Mat average_all = cv::Mat::zeros(100, 100, CV_8UC1); // TODO config size!
|
|
signals:
|
|
void new_status_text(QString text);
|
|
void vis_new_frame(QImage img);
|
|
void new_hist_av(quint64 hit_hist[10]);
|
|
void new_batch_view(cv::Mat *img);
|
|
void new_avg_view(cv::Mat *img);
|
|
};
|
|
|
|
#endif // IDSCAM_H
|