1 Star 0 Fork 0

qinxude/rk3568ui

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
faceidscreen.cpp 5.64 KB
一键复制 编辑 原始数据 按行查看 历史
qinxude 提交于 2024-09-03 09:38 . 3568ui base
#include "faceidscreen.h"
#include "ui_faceidscreen.h"
FaceIdScreen::FaceIdScreen(QWidget *parent) :
QWidget(parent),
ui(new Ui::FaceIdScreen)
{
ui->setupUi(this);
// hide();
//m_ScanTimer = new QTimer;
//m_ScanTimer->setInterval(100);
m_QuiteTimer = new QTimer;
m_QuiteTimer->setInterval(1000);
m_CaptureTimer = new QTimer;
m_CaptureTimer->setInterval(100);//1000
FaceIdCmp::GetInstance()->BuildCmpLib();
m_FaceIdSuccess = new FaceIdSuccess;
// setParent(parent);
// m_DataDictionary = DataDictionary::GetInstance();
//connect(m_ScanTimer,SIGNAL(timeout()),this,SLOT(ScanPic()));
// connect(m_QuiteTimer,SIGNAL(timeout()),this,SLOT(CountDown()));
// connect(m_CaptureTimer,SIGNAL(timeout()),this,SLOT(Capture()));
// connect(m_CaptureTimer,SIGNAL(timeout()),m_LocalCameraThread,SLOT(FrameRefreshStart()));
// connect(FaceIdCmp::GetInstance(),SIGNAL(ComparisonResult(bool,QImage &,QString &,QString &)),\
// this,SLOT(ComparisonResult(bool,QImage &,QString &,QString &)));
// connect(FaceIdCmp::GetInstance(),SIGNAL(ComparisonScore(int)),\
// this,SLOT(ComparisonScore(int)));
connect(m_FaceIdSuccess,SIGNAL(FaceIdEnd()),this,SIGNAL(Quite()));
// connect(m_DataDictionary,SIGNAL(SystemDataChange(SystemDataIndex_t)),\
// this,SLOT(SystemDataChange(SystemDataIndex_t)));
}
FaceIdScreen::~FaceIdScreen()
{
delete ui;
}
void FaceIdScreen::showEvent(QShowEvent *event)
{
ToolBar::GetInstance()->Show(this);
// m_ScanTimer->start();
m_QuiteCnt = 100;
CountDownShow(m_QuiteCnt);
ui->Score->setText(QString().number(0));
if(LocalCamera::GetInstance()->OpenCamera())
{
// if(m_DataDictionary->GetSystemData(SYS_FACEID_RUN).toUInt() == 1)
// m_CaptureTimer->start();
// m_CaptureTimer->start();
connect(LocalCamera::GetInstance(),SIGNAL(CameraFrameRefresh(cv::Mat)),\
this,SLOT(ShowCamera(cv::Mat)));
}
// if(m_DataDictionary->GetSystemData(SYS_FACEID_JUMP).toInt() == 0)
// {
// ui->Quite->hide();
// m_QuiteTimer->stop();
// ui->CountDown->hide();
// ui->ShowLabel1->hide();
// ui->ShowLabel2->hide();
// }
// else {
// ui->Quite->show();
// m_QuiteTimer->start();
// ui->CountDown->show();
// ui->ShowLabel1->show();
// ui->ShowLabel2->show();
// }
// int32_t Cnt = m_DataDictionary->GetPersonCnt();
// ui->PeopleCnt->setText(QString().number(Cnt));
}
void FaceIdScreen::hideEvent(QHideEvent *event)
{
disconnect(LocalCamera::GetInstance(),SIGNAL(CameraFrameRefresh(cv::Mat)),\
this,SLOT(ShowCamera(cv::Mat)));
LocalCamera::GetInstance()->CloseCamera();
// m_QuiteTimer->stop();
// m_CaptureTimer->stop();
}
void FaceIdScreen::ScanPic()
{
#if 0
static int cnt = 0;
int point_x = ui->FaceIdWaverod->x();
int point_y = ui->FaceIdFrame1->y();
cnt += 10; cnt %= ui->FaceIdFrame1->height();
point_y += cnt;
ui->FaceIdWaverod->move(point_x,point_y);
#endif
}
void FaceIdScreen::CountDown()
{
if(m_QuiteCnt == 0)
{
on_Quite_clicked();
return ;
}
m_QuiteCnt--;
CountDownShow(m_QuiteCnt);
}
void FaceIdScreen::Capture()
{
// CapImg = ui->ShowImg->pixmap()->toImage();
// CapImg = CapImg.scaled(620, 480,Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
//FaceIdCmp::GetInstance()->Comparison(QImage2Mat::Transform(CapImg));
// CmpMat = CvMat;
// FaceIdCmp::GetInstance()->Comparison(CmpMat);
// if(LocalCamera::GetInstance()->Capture(CmpMat))
// {
// FaceIdCmp::GetInstance()->Comparison(CmpMat);
// }
}
void FaceIdScreen::on_Quite_clicked()
{
disconnect(LocalCamera::GetInstance(),SIGNAL(CameraFrameRefresh(cv::Mat)),\
this,SLOT(ShowCamera(cv::Mat)));
LocalCamera::GetInstance()->CloseCamera();
// m_CaptureTimer->stop();
// m_QuiteTimer->stop();
Quite();
hide();
}
void FaceIdScreen::CountDownShow(uint32_t Cnt)
{
ui->CountDown->setText(QString().number(Cnt)+"S");
}
void FaceIdScreen::ShowCamera(cv::Mat Frm)
{
CvMat = Frm.clone();
// FaceIdCmp::GetInstance()->FaceIdAreaMark(CvMat);
QImage image = Mat2QImage::Transform(CvMat);
QImage newImage = image.scaled(ui->ShowImg->width(), ui->ShowImg->height(),\
Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
ui->ShowImg->setPixmap(QPixmap::fromImage(newImage));
}
void FaceIdScreen::ComparisonResult(bool Res,QImage &Img,QString &Str,QString &Uuid)
{
if(Res)
{
qDebug() << "ComparisonResult success";
m_CaptureTimer->stop();
m_FaceIdSuccess->SetInfo(Str,\
Img,Mat2QImage::Transform(CmpMat.clone()));
m_FaceIdSuccess->show();
PersonInfo_t Info;
Info = DataDictionary::GetInstance()->UuidSearchPersonInfo(Uuid);
QImage Img = Mat2QImage::Transform(CmpMat.clone());
Info.Pic = QImag2Jpg::Transform(Img);
DataDictionary::GetInstance()->SetMisData(MIS_FACEID_SUCCESS_UUID,Info);
this->hide();
}
else
{
qDebug() << "ComparisonResult failed";
}
}
void FaceIdScreen::ComparisonScore(int v)
{
ui->Score->setText(QString().number(v));
}
void FaceIdScreen::SystemDataChange(SystemDataIndex_t Index)
{
if(this->isHidden())
return ;
switch (Index) {
case SYS_FACEID_RUN:
if(m_DataDictionary->GetSystemData(SYS_FACEID_RUN).toUInt() == 1)
m_CaptureTimer->start();
else {
m_CaptureTimer->stop();
}
break;
default:
break;
}
}
void FaceIdScreen::on_SettingButton_clicked()
{
SettingButtonClicked();
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/qinxude/rk3568ui.git
[email protected]:qinxude/rk3568ui.git
qinxude
rk3568ui
rk3568ui
master

搜索帮助