-
Notifications
You must be signed in to change notification settings - Fork 0
/
worker.cpp
36 lines (28 loc) · 975 Bytes
/
worker.cpp
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
#include "worker.h"
Worker::Worker(QObject *parent)
: QObject{parent}
{
}
void Worker::doWork(QImage img,QString accessToken,QSslConfiguration sslConfig,QThread* overThread){
QByteArray ba;
qDebug() << "dowork over";
QBuffer buff(&ba);
qDebug() << "dowork over";
img.save(&buff, "jpg");
QByteArray postData("image=");
postData.append(ba.toBase64().toPercentEncoding());
qDebug() << "dowork over";
QUrl url("https://aip.baidubce.com/rest/2.0/image-classify/v1/gesture");
QUrlQuery query;
query.addQueryItem("access_token", accessToken);
url.setQuery(query);
qDebug() << "dowork over";
// 组装请求
QNetworkRequest req;
req.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/x-www-form-urlencoded"));
req.setUrl(url);
req.setSslConfiguration(sslConfig);
qDebug() << "dowork over";
emit resultReady(req, postData,overThread);
qDebug() << "dowork really over";
}