本文主要是介绍基于Qt的人脸识别项目(功能:颜值检测,口罩检测,表情检测,性别检测,年龄预测等),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
完整代码链接在文章末尾
效果展示
代码讲解(待更新)
qt图片文件上传
#include <QtWidgets>
#include <QFileDialog>
#include <QPixmap>class ImageUploader : public QWidget {Q_OBJECTpublic:ImageUploader(QWidget *parent = nullptr) : QWidget(parent) {QVBoxLayout *layout = new QVBoxLayout(this);// 文件按钮QPushButton *fileButton = new QPushButton("上传图片", this);connect(fileButton, &QPushButton::clicked, this, &ImageUploader::uploadImage);layout->addWidget(fileButton);// 图片显示imageLabel = new QLabel(this);imageLabel->setAlignment(Qt::AlignCenter);layout->addWidget(imageLabel);}private slots:void uploadImage() {QString filePath = QFileDialog::getOpenFileName(this, "选择图片", "", "Images (*.png *.jpg *.jpeg *.bmp)");if (!filePath.isEmpty()) {// 显示选择的图片QPixmap pixmap(filePath);imageLabel->setPixmap(pixmap.scaled(imageLabel->size(), Qt::KeepAspectRatio));// 可以在这里添加上传图片到服务器等其他操作}}private:QLabel *imageLabel;
};int main(int argc, char *argv[]) {QApplication app(argc, argv);ImageUploader uploader;uploader.show();return app.exec();
}#include "main.moc"
需求
界面可以拖动
按钮上的字变成拍照
拍照之后保存图片,可以选择保存或丢弃
可以录像
做个人脸识别库,进行人脸识别
上传图片进行颜值识别
一.创建项目
二.导入Qt中的摄像头包
查看QCamera类的帮助文档
双击QCamera类,按F1
三.导入QCameraViewfinder
该类是取景器
调用百度AI接口
百度智能云
百度AI API接口
https://console.bce.baidu.com/#/index/overview
创建成功
把如下Url输入到浏览器:
https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=DVAhdFiLPvQyARPgePhkoaF9&client_secret=unIthBNsNUU73GpILlLYQ01WFIvNgyWm
得到如下内容:
{
"refresh_token":"25.d5006b48c5cfc5174b1a6ddd71e9d6fb.315360000.2022720937.282335-50197470",
"expires_in":2592000,
"session_key":"9mzdXvDRdai+wFKXFidzD7gHgzoFr3djEcSfChXAsc2EOY3POlFgHiEuVDv\/\/VZ\/JKVxaHY+vCqhcFwieNyhmyY2SgyAuw==",
"access_token":"24.e5cb172fbd5a305e7d2128c8fa89c083.2592000.1709952937.282335-50197470",
"scope":"public brain_all_scope vis-faceverify_faceverify_h5-face-liveness vis-faceverify_FACE_V3 vis-faceverify_idl_face_merge vis-faceverify_FACE_EFFECT vis-faceverify_face_feature_sdk brain_face_scene_scope wise_adapt lebo_resource_base lightservice_public hetu_basic lightcms_map_poi kaidian_kaidian ApsMisTest_Test\u6743\u9650 vis-classify_flower lpq_\u5f00\u653e cop_helloScope ApsMis_fangdi_permission smartapp_snsapi_base smartapp_mapp_dev_manage iop_autocar oauth_tp_app smartapp_smart_game_openapi oauth_sessionkey smartapp_swanid_verify smartapp_opensource_openapi smartapp_opensource_recapi fake_face_detect_\u5f00\u653eScope vis-ocr_\u865a\u62df\u4eba\u7269\u52a9\u7406 idl-video_\u865a\u62df\u4eba\u7269\u52a9\u7406 smartapp_component smartapp_search_plugin avatar_video_test b2b_tp_openapi b2b_tp_openapi_online smartapp_gov_aladin_to_xcx",
"session_secret":"3ff481359f44a9436f1f76aa2769a56a"
}
expires_in 是Access Token的有效期,30天,单位是秒
API Key = DVAhdFiLPvQyARPgePhkoaF9
Secret Key = unIthBNsNUU73GpILlLYQ01WFIvNgyWm
各Qt版访问https的库
完整代码链接
链接:https://pan.baidu.com/s/13Vj8bpIsfbhB38Er27F6GA?pwd=1234
提取码:1234
这篇关于基于Qt的人脸识别项目(功能:颜值检测,口罩检测,表情检测,性别检测,年龄预测等)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!