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
|
||||
apt install apache2
|
||||
if [ ! -d "/opt/mow" ]; then
|
||||
mkdir /opt/mow
|
||||
fi
|
||||
|
|
2
setup.sh
2
setup.sh
|
@ -1,4 +1,4 @@
|
|||
#!/bin/sh
|
||||
apt update -y
|
||||
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)
|
||||
{
|
||||
auto ret = false;
|
||||
|
||||
shared.conf = getParam("-c", args);
|
||||
|
||||
if (rdConf(&shared))
|
||||
{
|
||||
QDir("live").removeRecursively();
|
||||
|
||||
auto thr1 = new QThread(QCoreApplication::instance());
|
||||
auto thr2 = new QThread(QCoreApplication::instance());
|
||||
auto thr3 = new QThread(QCoreApplication::instance());
|
||||
auto thr4 = new QThread(QCoreApplication::instance());
|
||||
auto thr1 = new QThread(nullptr);
|
||||
auto thr2 = new QThread(nullptr);
|
||||
auto thr3 = new QThread(nullptr);
|
||||
auto thr4 = new QThread(nullptr);
|
||||
|
||||
new RecLoop(&shared, thr1, this);
|
||||
new Upkeep(&shared, thr2, this);
|
||||
|
@ -67,32 +65,29 @@ Loop::Loop(shared_t *sharedRes, QThread *thr, QObject *parent) : QObject(0)
|
|||
{
|
||||
shared = sharedRes;
|
||||
heartBeat = 10;
|
||||
loopTimer = new QTimer(nullptr);
|
||||
|
||||
loopTimer->setSingleShot(false);
|
||||
|
||||
connect(this, &Loop::loopSig, this, &Loop::loopSlot);
|
||||
connect(thr, &QThread::started, this, &Loop::init);
|
||||
connect(parent, &QObject::destroyed, this, &Loop::deleteLater);
|
||||
connect(parent, &QObject::destroyed, thr, &QThread::terminate);
|
||||
connect(parent, &QObject::destroyed, loopTimer, &QTimer::deleteLater);
|
||||
connect(loopTimer, &QTimer::timeout, this, &Loop::loopSlot);
|
||||
|
||||
moveToThread(thr);
|
||||
}
|
||||
|
||||
void Loop::init()
|
||||
{
|
||||
emit loopSig();
|
||||
loopTimer->start(heartBeat * 1000);
|
||||
}
|
||||
|
||||
void Loop::loopSlot()
|
||||
{
|
||||
auto ret = exec();
|
||||
|
||||
if (heartBeat != 0)
|
||||
if (!exec())
|
||||
{
|
||||
thread()->sleep(heartBeat);
|
||||
}
|
||||
|
||||
if (ret)
|
||||
{
|
||||
emit loopSig();
|
||||
loopTimer->stop(); QCoreApplication::exit(shared->retCode);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,6 +151,8 @@ bool RecLoop::exec()
|
|||
|
||||
auto hashLogLine = "stream_hash--prev:" + QString(streamMD5.toHex()) + "--new:" + QString(md5.toHex());
|
||||
|
||||
streamMD5 = md5;
|
||||
|
||||
recLog(hashLogLine, shared);
|
||||
|
||||
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)
|
||||
{
|
||||
heartBeat = 0;
|
||||
heartBeat = 1;
|
||||
evId = 0;
|
||||
pcId = 0;
|
||||
player = new QMediaPlayer(this);
|
||||
|
@ -332,6 +329,8 @@ void DetectLoop::init()
|
|||
thread()->sleep(1);
|
||||
|
||||
resetTimers();
|
||||
|
||||
Loop::init();
|
||||
}
|
||||
|
||||
void DetectLoop::resetTimers()
|
||||
|
@ -339,8 +338,8 @@ void DetectLoop::resetTimers()
|
|||
if (evId != 0) killTimer(evId);
|
||||
if (pcId != 0) killTimer(pcId);
|
||||
|
||||
evId = startTimer(shared->evMaxSecs);
|
||||
pcId = startTimer(shared->postSecs);
|
||||
evId = startTimer(shared->evMaxSecs * 1000);
|
||||
pcId = startTimer(shared->postSecs * 1000);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
Q_UNUSED(error)
|
||||
|
||||
detLog("err: media player error - " + errorString, shared);
|
||||
resetDetect();
|
||||
}
|
||||
|
||||
void DetectLoop::playStateChanged(QMediaPlayer::PlaybackState newState)
|
||||
{
|
||||
Q_UNUSED(newState)
|
||||
|
||||
resetDetect();
|
||||
if (newState == QMediaPlayer::PlayingState)
|
||||
{
|
||||
detLog("detection playback started.", shared);
|
||||
}
|
||||
else if (newState == QMediaPlayer::StoppedState)
|
||||
{
|
||||
detLog("detection playback stopped.", shared);
|
||||
}
|
||||
}
|
||||
|
||||
bool DetectLoop::exec()
|
||||
{
|
||||
if (player->playbackState() != QMediaPlayer::PlayingState)
|
||||
{
|
||||
QFile fileIn("stream.m3u8");
|
||||
QString tsPath;
|
||||
|
@ -461,12 +456,15 @@ bool DetectLoop::exec()
|
|||
}
|
||||
else
|
||||
{
|
||||
detLog("stream_clip: " + tsPath, shared);
|
||||
|
||||
prevTs = tsPath;
|
||||
|
||||
player->setSource(QUrl::fromLocalFile(tsPath));
|
||||
frameAnalyzer->play(tsPath);
|
||||
player->play();
|
||||
}
|
||||
}
|
||||
|
||||
return Loop::exec();
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ class Loop : public QObject
|
|||
protected:
|
||||
|
||||
shared_t *shared;
|
||||
QTimer *loopTimer;
|
||||
int heartBeat;
|
||||
|
||||
protected slots:
|
||||
|
@ -50,10 +51,6 @@ private slots:
|
|||
|
||||
void loopSlot();
|
||||
|
||||
signals:
|
||||
|
||||
void loopSig();
|
||||
|
||||
public:
|
||||
|
||||
explicit Loop(shared_t *shared, QThread *thr, QObject *parent = nullptr);
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <QVideoSink>
|
||||
#include <QVideoFrame>
|
||||
#include <QImage>
|
||||
#include <QTimer>
|
||||
|
||||
#include <opencv4/opencv2/opencv.hpp>
|
||||
#include <opencv4/opencv2/videoio.hpp>
|
||||
|
@ -35,7 +36,7 @@
|
|||
using namespace cv;
|
||||
using namespace std;
|
||||
|
||||
#define APP_VER "3.0.t4"
|
||||
#define APP_VER "3.0.t5"
|
||||
#define APP_NAME "Motion Watch"
|
||||
#define APP_BIN "mow"
|
||||
#define REC_LOG_NAME "rec_log_lines.html"
|
||||
|
|
|
@ -20,8 +20,6 @@ int main(int argc, char** argv)
|
|||
QCoreApplication::setApplicationName(APP_NAME);
|
||||
QCoreApplication::setApplicationVersion(APP_VER);
|
||||
|
||||
cv::utils::logging::setLogLevel(cv::utils::logging::LogLevel::LOG_LEVEL_DEBUG);
|
||||
|
||||
auto args = QCoreApplication::arguments();
|
||||
auto ret = 0;
|
||||
|
||||
|
|
|
@ -41,6 +41,8 @@ void MoDetect::newFrame()
|
|||
}
|
||||
else
|
||||
{
|
||||
gap = 0;
|
||||
|
||||
auto nextImg = videoFrame().toImage();
|
||||
auto nextImgGray = nextImg.convertToFormat(QImage::Format_Grayscale8);
|
||||
auto score = 0;
|
||||
|
|
Loading…
Reference in New Issue
Block a user