v3.0.t5
-fixed all loop structors used throughout the app. they were running too fast. -added more log lines to aid with debug.
This commit is contained in:
parent
496bac7d7e
commit
f850ec6a46
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
apt install apache2
|
||||||
if [ ! -d "/opt/mow" ]; then
|
if [ ! -d "/opt/mow" ]; then
|
||||||
mkdir /opt/mow
|
mkdir /opt/mow
|
||||||
fi
|
fi
|
||||||
|
|
2
setup.sh
2
setup.sh
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
apt update -y
|
apt update -y
|
||||||
apt install -y pkg-config cmake make g++ wget unzip git
|
apt install -y pkg-config cmake make g++ wget unzip git
|
||||||
apt install -y ffmpeg libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libgstreamer1.0-dev x264 libx264-dev libilmbase-dev libopencv-dev qt6-base-dev qtchooser qmake6 qt6-base-dev-tools qt6-multimedia-dev apache2
|
apt install -y ffmpeg libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libgstreamer1.0-dev x264 libx264-dev libilmbase-dev libopencv-dev qt6-base-dev qtchooser qmake6 qt6-base-dev-tools qt6-multimedia-dev libxkbcommon-dev
|
||||||
|
|
|
@ -36,18 +36,16 @@ Camera::Camera(QObject *parent) : QObject(parent)
|
||||||
|
|
||||||
int Camera::start(const QStringList &args)
|
int Camera::start(const QStringList &args)
|
||||||
{
|
{
|
||||||
auto ret = false;
|
|
||||||
|
|
||||||
shared.conf = getParam("-c", args);
|
shared.conf = getParam("-c", args);
|
||||||
|
|
||||||
if (rdConf(&shared))
|
if (rdConf(&shared))
|
||||||
{
|
{
|
||||||
QDir("live").removeRecursively();
|
QDir("live").removeRecursively();
|
||||||
|
|
||||||
auto thr1 = new QThread(QCoreApplication::instance());
|
auto thr1 = new QThread(nullptr);
|
||||||
auto thr2 = new QThread(QCoreApplication::instance());
|
auto thr2 = new QThread(nullptr);
|
||||||
auto thr3 = new QThread(QCoreApplication::instance());
|
auto thr3 = new QThread(nullptr);
|
||||||
auto thr4 = new QThread(QCoreApplication::instance());
|
auto thr4 = new QThread(nullptr);
|
||||||
|
|
||||||
new RecLoop(&shared, thr1, this);
|
new RecLoop(&shared, thr1, this);
|
||||||
new Upkeep(&shared, thr2, this);
|
new Upkeep(&shared, thr2, this);
|
||||||
|
@ -67,32 +65,29 @@ Loop::Loop(shared_t *sharedRes, QThread *thr, QObject *parent) : QObject(0)
|
||||||
{
|
{
|
||||||
shared = sharedRes;
|
shared = sharedRes;
|
||||||
heartBeat = 10;
|
heartBeat = 10;
|
||||||
|
loopTimer = new QTimer(nullptr);
|
||||||
|
|
||||||
|
loopTimer->setSingleShot(false);
|
||||||
|
|
||||||
connect(this, &Loop::loopSig, this, &Loop::loopSlot);
|
|
||||||
connect(thr, &QThread::started, this, &Loop::init);
|
connect(thr, &QThread::started, this, &Loop::init);
|
||||||
connect(parent, &QObject::destroyed, this, &Loop::deleteLater);
|
connect(parent, &QObject::destroyed, this, &Loop::deleteLater);
|
||||||
connect(parent, &QObject::destroyed, thr, &QThread::terminate);
|
connect(parent, &QObject::destroyed, thr, &QThread::terminate);
|
||||||
|
connect(parent, &QObject::destroyed, loopTimer, &QTimer::deleteLater);
|
||||||
|
connect(loopTimer, &QTimer::timeout, this, &Loop::loopSlot);
|
||||||
|
|
||||||
moveToThread(thr);
|
moveToThread(thr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Loop::init()
|
void Loop::init()
|
||||||
{
|
{
|
||||||
emit loopSig();
|
loopTimer->start(heartBeat * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Loop::loopSlot()
|
void Loop::loopSlot()
|
||||||
{
|
{
|
||||||
auto ret = exec();
|
if (!exec())
|
||||||
|
|
||||||
if (heartBeat != 0)
|
|
||||||
{
|
{
|
||||||
thread()->sleep(heartBeat);
|
loopTimer->stop(); QCoreApplication::exit(shared->retCode);
|
||||||
}
|
|
||||||
|
|
||||||
if (ret)
|
|
||||||
{
|
|
||||||
emit loopSig();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,6 +151,8 @@ bool RecLoop::exec()
|
||||||
|
|
||||||
auto hashLogLine = "stream_hash--prev:" + QString(streamMD5.toHex()) + "--new:" + QString(md5.toHex());
|
auto hashLogLine = "stream_hash--prev:" + QString(streamMD5.toHex()) + "--new:" + QString(md5.toHex());
|
||||||
|
|
||||||
|
streamMD5 = md5;
|
||||||
|
|
||||||
recLog(hashLogLine, shared);
|
recLog(hashLogLine, shared);
|
||||||
|
|
||||||
if (proc.state() == QProcess::NotRunning)
|
if (proc.state() == QProcess::NotRunning)
|
||||||
|
@ -316,7 +313,7 @@ bool EventLoop::wrOutVod(const evt_t &event)
|
||||||
|
|
||||||
DetectLoop::DetectLoop(shared_t *sharedRes, QThread *thr, QObject *parent) : Loop(sharedRes, thr, parent)
|
DetectLoop::DetectLoop(shared_t *sharedRes, QThread *thr, QObject *parent) : Loop(sharedRes, thr, parent)
|
||||||
{
|
{
|
||||||
heartBeat = 0;
|
heartBeat = 1;
|
||||||
evId = 0;
|
evId = 0;
|
||||||
pcId = 0;
|
pcId = 0;
|
||||||
player = new QMediaPlayer(this);
|
player = new QMediaPlayer(this);
|
||||||
|
@ -332,6 +329,8 @@ void DetectLoop::init()
|
||||||
thread()->sleep(1);
|
thread()->sleep(1);
|
||||||
|
|
||||||
resetTimers();
|
resetTimers();
|
||||||
|
|
||||||
|
Loop::init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DetectLoop::resetTimers()
|
void DetectLoop::resetTimers()
|
||||||
|
@ -339,8 +338,8 @@ void DetectLoop::resetTimers()
|
||||||
if (evId != 0) killTimer(evId);
|
if (evId != 0) killTimer(evId);
|
||||||
if (pcId != 0) killTimer(pcId);
|
if (pcId != 0) killTimer(pcId);
|
||||||
|
|
||||||
evId = startTimer(shared->evMaxSecs);
|
evId = startTimer(shared->evMaxSecs * 1000);
|
||||||
pcId = startTimer(shared->postSecs);
|
pcId = startTimer(shared->postSecs * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DetectLoop::timerEvent(QTimerEvent *event)
|
void DetectLoop::timerEvent(QTimerEvent *event)
|
||||||
|
@ -389,32 +388,28 @@ void DetectLoop::timerEvent(QTimerEvent *event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DetectLoop::resetDetect()
|
|
||||||
{
|
|
||||||
if (player->playbackState() != QMediaPlayer::PlayingState)
|
|
||||||
{
|
|
||||||
frameAnalyzer->stop();
|
|
||||||
|
|
||||||
exec();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DetectLoop::playError(QMediaPlayer::Error error, const QString &errorString)
|
void DetectLoop::playError(QMediaPlayer::Error error, const QString &errorString)
|
||||||
{
|
{
|
||||||
Q_UNUSED(error)
|
Q_UNUSED(error)
|
||||||
|
|
||||||
detLog("err: media player error - " + errorString, shared);
|
detLog("err: media player error - " + errorString, shared);
|
||||||
resetDetect();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DetectLoop::playStateChanged(QMediaPlayer::PlaybackState newState)
|
void DetectLoop::playStateChanged(QMediaPlayer::PlaybackState newState)
|
||||||
{
|
{
|
||||||
Q_UNUSED(newState)
|
if (newState == QMediaPlayer::PlayingState)
|
||||||
|
{
|
||||||
resetDetect();
|
detLog("detection playback started.", shared);
|
||||||
|
}
|
||||||
|
else if (newState == QMediaPlayer::StoppedState)
|
||||||
|
{
|
||||||
|
detLog("detection playback stopped.", shared);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DetectLoop::exec()
|
bool DetectLoop::exec()
|
||||||
|
{
|
||||||
|
if (player->playbackState() != QMediaPlayer::PlayingState)
|
||||||
{
|
{
|
||||||
QFile fileIn("stream.m3u8");
|
QFile fileIn("stream.m3u8");
|
||||||
QString tsPath;
|
QString tsPath;
|
||||||
|
@ -461,12 +456,15 @@ bool DetectLoop::exec()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
detLog("stream_clip: " + tsPath, shared);
|
||||||
|
|
||||||
prevTs = tsPath;
|
prevTs = tsPath;
|
||||||
|
|
||||||
player->setSource(QUrl::fromLocalFile(tsPath));
|
player->setSource(QUrl::fromLocalFile(tsPath));
|
||||||
frameAnalyzer->play(tsPath);
|
frameAnalyzer->play(tsPath);
|
||||||
player->play();
|
player->play();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Loop::exec();
|
return Loop::exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ class Loop : public QObject
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
shared_t *shared;
|
shared_t *shared;
|
||||||
|
QTimer *loopTimer;
|
||||||
int heartBeat;
|
int heartBeat;
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
|
@ -50,10 +51,6 @@ private slots:
|
||||||
|
|
||||||
void loopSlot();
|
void loopSlot();
|
||||||
|
|
||||||
signals:
|
|
||||||
|
|
||||||
void loopSig();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit Loop(shared_t *shared, QThread *thr, QObject *parent = nullptr);
|
explicit Loop(shared_t *shared, QThread *thr, QObject *parent = nullptr);
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <QVideoSink>
|
#include <QVideoSink>
|
||||||
#include <QVideoFrame>
|
#include <QVideoFrame>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include <opencv4/opencv2/opencv.hpp>
|
#include <opencv4/opencv2/opencv.hpp>
|
||||||
#include <opencv4/opencv2/videoio.hpp>
|
#include <opencv4/opencv2/videoio.hpp>
|
||||||
|
@ -35,7 +36,7 @@
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#define APP_VER "3.0.t4"
|
#define APP_VER "3.0.t5"
|
||||||
#define APP_NAME "Motion Watch"
|
#define APP_NAME "Motion Watch"
|
||||||
#define APP_BIN "mow"
|
#define APP_BIN "mow"
|
||||||
#define REC_LOG_NAME "rec_log_lines.html"
|
#define REC_LOG_NAME "rec_log_lines.html"
|
||||||
|
|
|
@ -20,8 +20,6 @@ int main(int argc, char** argv)
|
||||||
QCoreApplication::setApplicationName(APP_NAME);
|
QCoreApplication::setApplicationName(APP_NAME);
|
||||||
QCoreApplication::setApplicationVersion(APP_VER);
|
QCoreApplication::setApplicationVersion(APP_VER);
|
||||||
|
|
||||||
cv::utils::logging::setLogLevel(cv::utils::logging::LogLevel::LOG_LEVEL_DEBUG);
|
|
||||||
|
|
||||||
auto args = QCoreApplication::arguments();
|
auto args = QCoreApplication::arguments();
|
||||||
auto ret = 0;
|
auto ret = 0;
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,8 @@ void MoDetect::newFrame()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
gap = 0;
|
||||||
|
|
||||||
auto nextImg = videoFrame().toImage();
|
auto nextImg = videoFrame().toImage();
|
||||||
auto nextImgGray = nextImg.convertToFormat(QImage::Format_Grayscale8);
|
auto nextImgGray = nextImg.convertToFormat(QImage::Format_Grayscale8);
|
||||||
auto score = 0;
|
auto score = 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user