Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Priority: optional
Maintainer: Deepin Sysdev <sysdev@deepin.com>
Build-Depends: debhelper (>= 8.0.0),
pkg-config,
qt5-qmake,
qtbase5-dev,
libdtkcore-dev,
qmake6,
qt6-base-dev,
libdtk6core-dev,
seetaface-boxes,
seetaface-landmarker,
seetaface-anti-spoofing-x,
Expand All @@ -16,9 +16,9 @@ Build-Depends: debhelper (>= 8.0.0),
seetaface-pose-estimation,
seetaface-authorize,
seetaface-tennis,
libdtkwidget-dev,
libdtkcore5-bin,
qtmultimedia5-dev
libdtk6widget-dev,
libdtk6core-bin,
qt6-multimedia-dev
Standards-Version: 4.5.1
Homepage: https://github.com/linuxdeepin/deepin-face

Expand All @@ -36,7 +36,6 @@ Depends: ${shlibs:Depends},
seetaface-authorize,
seetaface-tennis,
seetaface-models,
libqt5multimedia5-plugins,
gstreamer1.0-plugins-bad
libqt6multimedia6,
Description: Face recognition service
deepin-face is a face recognition service implemented by the open source face recognition engine seetaface
5 changes: 1 addition & 4 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
export DH_VERBOSE = 1
export QT_SELECT=5


# see FEATURE AREAS in dpkg-buildflags(1)
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
Expand All @@ -16,8 +14,7 @@ export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed


%:
dh $@

dh $@ --buildsystem qmake6

override_dh_auto_install:
dh_auto_install -- prefix=/usr
Expand Down
2 changes: 0 additions & 2 deletions drivermanger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ QDBusUnixFileDescriptor DriverManger::enrollStart(QString chara,
QMetaObject::invokeMethod(m_spErollthread.data(),
"Start",
Qt::QueuedConnection,
QGenericReturnArgument(),
Q_ARG(QString, actionId),
Q_ARG(int, fd[1]));

Expand Down Expand Up @@ -153,7 +152,6 @@ QDBusUnixFileDescriptor DriverManger::verifyStart(QStringList charas,
QMetaObject::invokeMethod(m_spVerifyThread.data(),
"Start",
Qt::QueuedConnection,
QGenericReturnArgument(),
Q_ARG(QString, actionId),
Q_ARG(QVector<float*>, faceCharas));
return QDBusUnixFileDescriptor(0);
Expand Down
85 changes: 36 additions & 49 deletions workmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#include "workmodule.h"
#include "modelmanger.h"

#include <QCameraInfo>
#include <QMediaDevices>

Check warning on line 8 in workmodule.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QMediaDevices> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QMutex>

Check warning on line 9 in workmodule.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QMutex> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QMutexLocker>

Check warning on line 10 in workmodule.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QMutexLocker> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtConcurrent>

Check warning on line 11 in workmodule.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtConcurrent> not found. Please note: Cppcheck does not need standard library headers to get proper results.


ErollThread::ErollThread(QObject *parent)
Expand All @@ -34,44 +34,40 @@
void ErollThread::run()
{
m_camera.reset();
auto cameras = QCameraInfo::availableCameras();
for (const auto &obj : qAsConst(cameras)) {
auto cameras = QMediaDevices::videoInputs();
for (const QCameraDevice &obj : cameras) {
m_camera.reset(new QCamera(obj));
if (m_camera->isAvailable())
break;
}


if (m_camera.isNull()) {
qDebug() << "open camera fail";
Q_EMIT processStatus(m_actionId, FaceEnrollException);
return;
}

m_camera->setCaptureMode(QCamera::CaptureStillImage);
m_imageCapture.reset(new QCameraImageCapture(m_camera.data()));
m_imageCapture->setCaptureDestination(QCameraImageCapture::CaptureToBuffer);
QList<QSize> supportedResolutions = m_imageCapture->supportedResolutions();
m_captureSession.reset(new QMediaCaptureSession);
m_captureSession->setCamera(m_camera.data());
m_imageCapture.reset(new QImageCapture);
m_captureSession->setImageCapture(m_imageCapture.data());
QList<QSize> supportedResolutions = m_camera->cameraDevice().photoResolutions();
if (supportedResolutions.contains(QSize(800, 600))) {
auto settings = m_imageCapture->encodingSettings();
settings.setResolution(QSize(800, 600));
m_imageCapture->setEncodingSettings(settings);
m_imageCapture->setResolution(QSize(800, 600));
}
connect(m_camera.data(), &QCamera::stateChanged, this, &ErollThread::updateCameraState);
connect(m_imageCapture.data(), &QCameraImageCapture::readyForCaptureChanged, this, &ErollThread::readyForCapture);
connect(m_imageCapture.data(), &QCameraImageCapture::imageCaptured, this, &ErollThread::processCapturedImage);
connect(m_imageCapture.data(), QOverload<int, QCameraImageCapture::Error, const QString &>::of(&QCameraImageCapture::error),
connect(m_imageCapture.data(), &QImageCapture::readyForCaptureChanged, this, &ErollThread::readyForCapture);
connect(m_imageCapture.data(), &QImageCapture::imageCaptured, this, &ErollThread::processCapturedImage);
connect(m_imageCapture.data(), QOverload<int, QImageCapture::Error, const QString &>::of(&QImageCapture::errorOccurred),
this, &ErollThread::captureError);
m_camera->start();
m_imageCapture->capture();
}

void ErollThread::Stop()
{
qDebug() << "ErollThread::Stop thread:" << QThread::currentThreadId();
m_imageCapture->cancelCapture();
m_stopCapture = true;
m_camera->stop();
m_camera->unload();
m_camera.reset();
close(m_fileSocket);
}
Expand Down Expand Up @@ -116,11 +112,6 @@
free(buf);
}

void ErollThread::updateCameraState(QCamera::State state)
{
qInfo() << "updateCameraState" << state;
}

void ErollThread::readyForCapture(bool ready)
{
if (m_imageCapture && ready) {
Expand All @@ -129,10 +120,12 @@
}
}

void ErollThread::captureError(int, QCameraImageCapture::Error, const QString &errorString)
void ErollThread::captureError(int err, QImageCapture::Error, const QString &errorString)
{
qDebug() << "read camera fail:" << errorString;
Q_EMIT processStatus(m_actionId, FaceEnrollException);
if (err > 0) {
qDebug() << "read camera fail:" << errorString;
Q_EMIT processStatus(m_actionId, FaceEnrollException);
}
return;
}

Expand Down Expand Up @@ -298,41 +291,35 @@
{
qDebug() << "Verify run";
m_camera.reset();
auto cameras = QCameraInfo::availableCameras();
for (const auto &obj : qAsConst(cameras)) {
auto cameras = QMediaDevices::videoInputs();
for (const QCameraDevice &obj : cameras) {
m_camera.reset(new QCamera(obj));
if (m_camera->isAvailable())
break;
}

if (m_camera.isNull()) {
qDebug() << "open camera fail";
Q_EMIT processStatus(m_actionId, FaceEnrollException);
return;
}

m_camera->setCaptureMode(QCamera::CaptureStillImage);
m_imageCapture.reset(new QCameraImageCapture(m_camera.data()));
m_imageCapture->setCaptureDestination(QCameraImageCapture::CaptureToBuffer);
QList<QSize> supportedResolutions = m_imageCapture->supportedResolutions();
m_captureSession.reset(new QMediaCaptureSession);
m_captureSession->setCamera(m_camera.data());
m_imageCapture.reset(new QImageCapture);
m_captureSession->setImageCapture(m_imageCapture.data());
QList<QSize> supportedResolutions = m_camera->cameraDevice().photoResolutions();
if (supportedResolutions.contains(QSize(800, 600))) {
auto settings = m_imageCapture->encodingSettings();
settings.setResolution(QSize(800, 600));
m_imageCapture->setEncodingSettings(settings);
m_imageCapture->setResolution(QSize(800, 600));
}

connect(m_camera.data(), &QCamera::stateChanged, this, &VerifyThread::updateCameraState);
connect(m_imageCapture.data(), &QCameraImageCapture::readyForCaptureChanged, this, &VerifyThread::readyForCapture);
connect(m_imageCapture.data(), &QCameraImageCapture::imageCaptured, this, &VerifyThread::processCapturedImage);
connect(m_imageCapture.data(), QOverload<int, QCameraImageCapture::Error, const QString &>::of(&QCameraImageCapture::error),
connect(m_imageCapture.data(), &QImageCapture::readyForCaptureChanged, this, &VerifyThread::readyForCapture);
connect(m_imageCapture.data(), &QImageCapture::imageCaptured, this, &VerifyThread::processCapturedImage);
connect(m_imageCapture.data(), QOverload<int, QImageCapture::Error, const QString &>::of(&QImageCapture::errorOccurred),
this, &VerifyThread::captureError);
m_camera->start();
}

void VerifyThread::updateCameraState(QCamera::State state)
{
qDebug() << "updateCameraState" << state;
}

void VerifyThread::readyForCapture(bool ready)
{
if (m_imageCapture && ready) {
Expand All @@ -341,10 +328,12 @@
}
}

void VerifyThread::captureError(int, QCameraImageCapture::Error, const QString &errorString)
void VerifyThread::captureError(int err, QImageCapture::Error, const QString &errorString)
{
qDebug() << "read camera fail:" << errorString;
Q_EMIT processStatus(m_actionId, FaceEnrollException);
if (err > 0) {
qDebug() << "read camera fail:" << errorString;
Q_EMIT processStatus(m_actionId, FaceEnrollException);
}
return;
}

Expand Down Expand Up @@ -467,11 +456,9 @@
{
qDebug() << "VerifyThread::Stop thread:" << QThread::currentThreadId();

m_imageCapture->cancelCapture();
// 当关闭相机后, 会取消图片的抓取, 此时不需要去处理抓取的图片
disconnect(m_imageCapture.data(), &QCameraImageCapture::imageCaptured, this, &VerifyThread::processCapturedImage);
disconnect(m_imageCapture.data(), &QImageCapture::imageCaptured, this, &VerifyThread::processCapturedImage);
m_camera->stop();
m_camera->unload();
for (int i = 0; i < m_charaDatas.size(); i++) {
if (m_charaDatas[i] != nullptr) {
free(m_charaDatas[i]);
Expand Down
20 changes: 12 additions & 8 deletions workmodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@
#ifndef WORKMODULE_H
#define WORKMODULE_H

#include "qcamera.h"
#include <QCamera>

Check warning on line 8 in workmodule.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QCamera> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <memory>

Check warning on line 9 in workmodule.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <memory> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <unistd.h>

Check warning on line 10 in workmodule.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDebug>

Check warning on line 11 in workmodule.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDebug> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QImage>

Check warning on line 12 in workmodule.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QImage> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QPixmap>

Check warning on line 13 in workmodule.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QPixmap> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QThread>
#include <QCameraImageCapture>
#include <QImageCapture>
#include <QMediaCaptureSession>

QT_BEGIN_NAMESPACE
class QMutex;
QT_END_NAMESPACE

class DriverManger;
class QMediaCaptureSession;
class ErollThread : public QObject
{
Q_OBJECT
Expand All @@ -39,14 +41,15 @@


private Q_SLOTS:
void updateCameraState(QCamera::State state);
// void updateCameraState(QCamera::State state);
void readyForCapture(bool ready);
void captureError(int, QCameraImageCapture::Error, const QString &errorString);
void captureError(int err, QImageCapture::Error, const QString &errorString);
void processCapturedImage(int id, const QImage &preview);

private:
QScopedPointer<QCamera> m_camera;
QScopedPointer<QCameraImageCapture> m_imageCapture;
QScopedPointer<QImageCapture> m_imageCapture;
QScopedPointer<QMediaCaptureSession> m_captureSession;
QString m_actionId;
int m_fileSocket;
bool m_bFirst;
Expand All @@ -72,14 +75,15 @@
void run();

private Q_SLOTS:
void updateCameraState(QCamera::State state);
// void updateCameraState(QCamera::State state);
void readyForCapture(bool ready);
void captureError(int, QCameraImageCapture::Error, const QString &errorString);
void captureError(int err, QImageCapture::Error, const QString &errorString);
void processCapturedImage(int id, const QImage &preview);

private:
QScopedPointer<QCamera> m_camera;
QScopedPointer<QCameraImageCapture> m_imageCapture;
QScopedPointer<QImageCapture> m_imageCapture;
QScopedPointer<QMediaCaptureSession> m_captureSession;
QString m_actionId;
QVector<float*> m_charaDatas;
};
Expand Down