50 lines
1.2 KiB
C++
50 lines
1.2 KiB
C++
#ifndef DATACOLLECTION_H
|
|
#define DATACOLLECTION_H
|
|
|
|
#include "DataStructure.h"
|
|
#include <QObject>
|
|
#include <QQmlEngine>
|
|
|
|
class QNetworkAccessManager;
|
|
|
|
class DataCollection : public QObject {
|
|
Q_OBJECT
|
|
QML_ELEMENT
|
|
QML_UNCREATABLE("Only created in C++...")
|
|
|
|
Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
|
|
Q_PROPERTY(bool enabled READ enabled NOTIFY enabledChanged)
|
|
public:
|
|
explicit DataCollection(QObject *parent = nullptr);
|
|
Q_INVOKABLE void start(const QString &address);
|
|
Q_INVOKABLE void stop();
|
|
void setImageFormat(ImageFormat format, int quality);
|
|
|
|
QString path() const;
|
|
void setPath(const QString &path);
|
|
|
|
bool enabled() const;
|
|
|
|
signals:
|
|
void pathChanged();
|
|
void enabledChanged();
|
|
|
|
protected:
|
|
void start();
|
|
void onCaptureFinished();
|
|
void onDataGetFinished();
|
|
static std::vector<uint8_t> encodeNv21ToJpeg(uint8_t *nv21, int width, int height, int quality);
|
|
|
|
private:
|
|
QNetworkAccessManager *m_manager = nullptr;
|
|
bool m_enabled = false;
|
|
QString m_address;
|
|
QString m_path;
|
|
QString m_filename;
|
|
|
|
ImageFormat m_format = ImageFormat::Jpeg;
|
|
int m_quality = 100;
|
|
};
|
|
|
|
#endif // DATACOLLECTION_H
|