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
30 changes: 25 additions & 5 deletions workmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ ErollThread::ErollThread(QObject *parent)
, m_bFirst(false)
, m_stopCapture(false)
, m_checkDone(true)
, m_nullCount(0)
{
}

void ErollThread::Start(QString actionId, int socket)
{
qDebug() << "ErollThread::Start thread:" << QThread::currentThreadId();
m_stopCapture = false;
m_nullCount = 0;
m_actionId = actionId;
m_fileSocket = socket;
m_bFirst = true;
Expand Down Expand Up @@ -134,9 +136,9 @@ void ErollThread::sendCapture(QImage &img)

void ErollThread::readyForCapture(bool ready)
{
if (m_imageCapture && ready) {
if (m_imageCapture && ready && !m_stopCapture) {
m_imageCapture->capture();
qInfo() << "ErollThread::readyForCapture";
qDebug() << "ErollThread::readyForCapture";
}
}

Expand All @@ -151,8 +153,27 @@ void ErollThread::captureError(int err, QImageCapture::Error, const QString &err

void ErollThread::processCapturedImage(int id, const QImage &preview)
{
if (m_stopCapture)
if (m_stopCapture) {
m_nullCount = 0;
return;
}

if (preview.isNull()) {
if (++m_nullCount > 10) {
qWarning() << "captured image is null too many times, aborting";
m_nullCount = 0;
Q_EMIT processStatus(m_actionId, FaceEnrollException);
return;
}
qWarning() << "captured image is null, retrying capture";
QThread::msleep(100);
if (m_stopCapture)
return;
m_imageCapture->capture();
return;
}

m_nullCount = 0;

QImage img;
if (preview.size() == QSize(800, 600)) {
Expand All @@ -169,7 +190,7 @@ void ErollThread::processCapturedImage(int id, const QImage &preview)
.scaled(800, 600, Qt::IgnoreAspectRatio, Qt::FastTransformation);
}

if (1 == id) {
if (m_bFirst) {
sendCapture(img);
m_bFirst = false;
} else {
Expand All @@ -180,7 +201,6 @@ void ErollThread::processCapturedImage(int id, const QImage &preview)
sendCapture(img);
}


m_imageCapture->capture();

if (!m_checkDone) {
Expand Down
1 change: 1 addition & 0 deletions workmodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ private Q_SLOTS:
int m_fileSocket;
bool m_bFirst;
bool m_checkDone;
std::atomic<int> m_nullCount;
};


Expand Down
Loading