2024-08-21 09:26:06 +08:00
|
|
|
#ifndef DATACOLLECTION_H
|
|
|
|
#define DATACOLLECTION_H
|
|
|
|
|
2024-09-11 14:18:56 +08:00
|
|
|
#include "DataStructure.h"
|
2024-08-21 09:26:06 +08:00
|
|
|
#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();
|
2024-09-11 14:18:56 +08:00
|
|
|
void setImageFormat(ImageFormat format, int quality);
|
2024-08-21 09:26:06 +08:00
|
|
|
|
|
|
|
QString path() const;
|
|
|
|
void setPath(const QString &path);
|
|
|
|
|
|
|
|
bool enabled() const;
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void pathChanged();
|
|
|
|
void enabledChanged();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void start();
|
|
|
|
void onCaptureFinished();
|
|
|
|
void onDataGetFinished();
|
2024-09-11 14:18:56 +08:00
|
|
|
static std::vector<uint8_t> encodeNv21ToJpeg(uint8_t *nv21, int width, int height, int quality);
|
2024-08-21 09:26:06 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
QNetworkAccessManager *m_manager = nullptr;
|
|
|
|
bool m_enabled = false;
|
|
|
|
QString m_address;
|
|
|
|
QString m_path;
|
|
|
|
QString m_filename;
|
2024-09-11 14:18:56 +08:00
|
|
|
|
|
|
|
ImageFormat m_format = ImageFormat::Jpeg;
|
|
|
|
int m_quality = 100;
|
2024-08-21 09:26:06 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // DATACOLLECTION_H
|