12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- #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);
- 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
|