1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #ifndef HANDWRITINGENGINE_H
- #define HANDWRITINGENGINE_H
- #include <QObject>
- #include <QUrl>
- #include <QByteArray>
- #include <QtProtobufTypes>
- #include "matrix.h"
- #include <memory>
- namespace handwriting {
- class HandwritingClient;
- }
- class HandwritingEngine final : public QObject
- {
- Q_OBJECT
- Q_PROPERTY(int result READ result WRITE setResult NOTIFY resultChanged)
- Q_PROPERTY(handwriting::Matrix *matrix READ matrix CONSTANT)
- public:
- explicit HandwritingEngine(QObject *parent = nullptr);
- virtual ~HandwritingEngine() = default;
- Q_INVOKABLE void recognize();
- Q_INVOKABLE void setNeuralNetworkData(const QString &networkDataPath);
- Q_INVOKABLE void updateValue(int index, double value);
- int result() const
- {
- return m_result;
- }
- handwriting::Matrix *matrix()
- {
- return &m_matrix;
- }
- public slots:
- void setResult(int result)
- {
- if (m_result == result)
- return;
- m_result = result;
- emit resultChanged(m_result);
- }
- signals:
- void resultChanged(int result);
- private:
- std::shared_ptr<handwriting::HandwritingClient> m_client;
- int m_result;
- QtProtobuf::DoubleList m_data;
- handwriting::Matrix m_matrix;
- };
- #endif // HANDWRITINGENGINE_H
|