-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhistogramwidget.h
39 lines (37 loc) · 1.02 KB
/
histogramwidget.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
#ifndef HISTOGRAMWIDGET_H
#define HISTOGRAMWIDGET_H
#include <QThread>
#include <QVideoFrame>
#include <QAudioBuffer>
#include <QWidget>
class QAudioLevel;
class FrameProcessor: public QObject
{
Q_OBJECT
public slots:
void processFrame(QVideoFrame frame, int levels);
signals:
void histogramReady(const QVector<qreal> &histogram);
};
class HistogramWidget : public QWidget
{
Q_OBJECT
public:
explicit HistogramWidget(QWidget *parent = nullptr);
~HistogramWidget();
void setLevels(int levels) { m_levels = levels; }
public slots:
void processFrame(const QVideoFrame &frame);
void processBuffer(const QAudioBuffer &buffer);
void setHistogram(const QVector<qreal> &histogram);
protected:
void paintEvent(QPaintEvent *event) override;
private:
QVector<qreal> m_histogram;
int m_levels = 128;
FrameProcessor m_processor;
QThread m_processorThread;
bool m_isBusy = false;
QVector<QAudioLevel *> m_audioLevels;
};
#endif // HISTOGRAMWIDGET_H