Commit Graph

101 Commits

Author SHA1 Message Date
Zii
ad733f8317 v3.1.t2
added a buffer directory so the actual work of image frame capture
and live video recording can be moved off of main storage.

also removed installation of the apache2 http server from
install.sh to make this app more agnostic and leave it up to the
end user to install what ever web server they want.
2023-07-18 18:47:14 -04:00
Zii
c17f74bea9 v3.1.t1
-Fixed the compile error for older versions of QT.
2023-06-20 18:02:35 -04:00
Zii
5f9c4be6b2 v3.1.t1
-added event age to evt_t as a way to track the age of the event
 in EventLoop so now only events approching and exceeding
 evMaxSecs will have the video range added for writing.
2023-06-20 17:49:52 -04:00
Zii
ff5f95f445 v3.0.0
The app in it's current iteration is stable in testing. Releasing
to master.
2023-06-18 09:06:12 -04:00
Zii
4300651a52 v3.0.t19
-the ffmpeg auto refresh logic is working, just need to shorten
 the frequency by setting recloop's heartbeat to default.

-added hls flag "omit_endlist" so the auto refresh doesn't cut off
 the stream at the web browser end.
2023-06-14 20:57:18 -04:00
Zii
71fc5b0bc2 v3.0.t18
-ffmpeg still stalls even with tcp timeout parameters in place.
 added self end -t option to match the heart beat of RecLoop.
 doing this auto re-fresh ffmpeg every 30mins and should prevent
 stall. for some reason ffmpeg just can't run long term without
 stalling.
2023-06-13 20:58:45 -04:00
Zii
a493c7da5d v3.0.t17
-finally fixed the crashing issue. it turns out EventLoop::exec()
 was calling vidList.removeLast() on an empty list every now and
 then, causing qt to fatal assert. I removed the line since it is
 not even needed.
2023-06-11 09:09:49 -04:00
Zii
510bdda64c v3.0.t16
-the debug code from the previous commit help narrow down what
 function is causing the crash but that's it, I need more. decided
 add the debug build type to cmake and will use gdb to help with
 debugging.

-decided to remove the debug code since I'll use gdb as the long
 term solution going forward.
2023-06-11 07:41:57 -04:00
Zii
9e7d8ee1ee v3.0.t16
-the app is still crashing, adding a bunch of console output to
 help with debug.
2023-06-10 22:44:38 -04:00
Zii
09a0f030ac v3.0.t16
-added mutex thread protection. getting sigmentation faults on the
 test machine. added thread protection on various shared
 parameters in hope that it fix the random crashing issue.
2023-06-10 21:51:39 -04:00
Zii
51218198b5 v3.0.t15
-changed up the logic in EventLoop to better honer maxEventSecs
 and pick the highest scoring event as the event name and
 thumbnail.
2023-06-10 09:45:26 -04:00
Zii
baf0b86610 v3.0.t14
-didn't properly remove use of evhist from the last commit. it is
 truely removed now.

-added delay cycles to detectLoop is motion was detected to
 prevent some event overlap.
2023-06-09 19:59:16 -04:00
Zii
4b4c2649b8 v3.0.t13
-removed use of evtHist. will instead allow eventLoop to que up
 duplicate live video clips and then remove later using
 QStringList::removeDuplicates().

-changed up the ffmpeg commands to utilize tcp and re-added a tcp
 timeout argument, removing the need for command stall checking.

-added logic to pick the snapshot with the highest diff score as
 the event thumbnail.
2023-06-09 16:24:32 -04:00
Zii
16312a93f5 v3.0.t12
-added a termination slot to RecLoop that will kill the long term
 ffmpeg commands and connected it to 'aboutToQuit' signal. this is
 expected to kill the ffmpeg commands properly when quiting the
 main process.
2023-06-01 16:59:37 -04:00
Zii
4bf260c0ae v3.0.t11
-max_event_secs is not being honered correctly. EventLoop was not
 calculating the amount the hls clips to grab from live correctly.
 chanaged it to properly calculate file count based on hls segment
 size.

-updated the documentation as the current version nears stable
 release.
2023-06-01 16:11:58 -04:00
Zii
71df7d1eb5 v3.0.t10
-turns out the previous statment on the previous commit is
 incorrect. it is every possible to overlap events. to
 mitigate this, evtHist was added to shared_t to track
 recently copied source vids and remove them from the
 event queued to be written.
2023-05-30 20:03:22 -04:00
Zii
732a604c24 v3.0.t9
-removed the delay after motion was detected. it was not having
 the desired effect and after more thought event overlap would
 be impossible anyway.

-the test cameras are still picking up motion during the post
 command. adjusted the after command delay to see if that
 helps.

-reduced the DetectLoop heartbeat from 3 to 2 to better match
 the record loop's cadence.
2023-05-29 20:06:19 -04:00
Zii
de24a94bd4 v3.0.t8
-the test cameras are picking up motion as post command is running.
 added a delay increment to DetectLoop in hope to fix this.

-removed the upkeep log since it doesn't really provide any useful
 information.

-adjusted the default motion score again.

-reduced the amount of image files DetectLoop needs from 3 to 2.
2023-05-29 17:43:31 -04:00
Maurice ONeal
b445906403 v3.0.t7
-added a dely to DetectLoop after a positive motion detection to
 prevent motion event overlap.

-moved the 2 image diff pair compair to proper "end of array" in
 DetectLoop.

-increased the size of the image stream so queded up events will
 be able generate thumbnails properly.

-cleaned off a bunch of unused parameters in the code.

-adjusted the default motion sensitivity after real world
 testing.

-added libfuse-dev to setup.sh since imagemagic needs that to
 operate.
2023-05-27 09:33:14 -04:00
Maurice ONeal
4134d4befb v3.0.t6
The Qt approach to grabbing frames from the live stream was also
a failure.

- decided to switch to a combination ffmpeg and imagemagic was
  external commands to do motion detection. this approach
  elimates the need for opencv altogeather so it was removed
  from the project. system resource usage appears to be decent
  and perhaps better than opencv.
2023-05-26 16:12:53 -04:00
Maurice ONeal
f850ec6a46 v3.0.t5
-fixed all loop structors used throughout the app. they were
 running too fast.

-added more log lines to aid with debug.
2023-05-21 09:34:57 -04:00
Maurice ONeal
496bac7d7e v3.0.t4
I'm going to test a move away from opencv's videoio module.
Videoio simply refuses to open any video file even with
FFMPEG builtin. I tested old v2.2 code and even that failed
on a fresh install of ubuntu sever so this tells me an
update on opencv's side broke something.

This issue is not new and frankly I'm tired of chasing it.
I'm giving QT's QMediaPlayer a try to see how it works out.
Will still need opencv for the absdiff and threshold
functions, otherwise I would have dropped the API
altogeather.

Now that the app has QT::Multimedia, QT6 is now the minimum
version it will support. CMakeList.txt and the setup script
updated accordingly.
2023-05-20 19:18:55 -04:00
Zii
40ef014e0f v3.0.t3
Got the app up to "not failing immediately" state.

However, for some reason DetectLoop is failing hard via opencv
being unable to open the stream clips.

I'll continue deep diving this. For now everything else works.
2023-05-17 21:10:39 +00:00
Zii
80e6980d9e Fixed a compile error. 2023-05-17 19:40:09 +00:00
Maurice ONeal
bbad30a5b0 v3.0.t2
Added the much need code in Camera object to actual start all of
the threads.

Added multi instance support via the -d option.

Made the Loop object loop structure slot-signal compatible so
all objects using it can interupt the main loop to run other
slots.
2023-05-17 15:06:58 -04:00
Maurice ONeal
b5ebbace12 v3.0.t1
Fixed some compile errors and currently debugging some issue with
setup.sh.
2023-05-15 19:39:29 -04:00
Maurice ONeal
fa834aba6c v3.0.t1
Completely re-written the project to use the QT API. By using Qt,
I've open up use of useful tools like QCryptographicHash, QString,
QByteArray, QFile, etc.. In the future I could even make use of
slots/signals. The code is also in general much more readable and
thread management is by far much easier.

General operation of the app should be the same, this commit just
serves as a base for the migration over to QT.
2023-05-15 15:29:47 -04:00
Maurice ONeal
f4ea944f97 v2.2
Updated the documentation, current iteration of the code is deemed
stable. Releasing to main.
2023-05-06 09:08:47 -04:00
Maurice ONeal
3f3cbcc75b v2.1.t3
-adjusted config defaults

Attempting to slow down motion detection again. This time it should
properly match the camera's fps.
2023-04-21 16:01:14 -04:00
Maurice ONeal
b4ca30b0e1 v2.1.t2
the delay on the motion detection loop slowed it down too much to
the point that it falls too far behind live. I removed the delay
and re-introduced the frame gap so all frames in the video files
need to be decoded.

post command and event timers are now seperate but still tied to
a single thread so they can still be synced.

fixed an issued that cuased several thmubnails to not generate.

added more log lines the aid with debugging.
2023-04-20 14:52:59 -04:00
Maurice ONeal
bafd2bf727 v2.1.t1
- reduced the hls size to 2 seconds.
- motion clips are not being combined. fixed it by making event
  loop track the size of shared_t::recList instead of system time.
- maxScore is now global inside of shared_t instead of locally
  inside detectMoInStream().
2023-04-15 08:23:49 -04:00
Maurice ONeal
19872b3ff5 v2.0
updated documentation and cleaned up the code. preparing to release to
master.
2023-03-28 20:27:12 -04:00
Zii
83b206c06c v2.0.t13
Fixed the crashing issue by adding tcp timeout args to ffmpeg and
having the app handle empty frames from a disconnected camera
better.

Reformed the directory structure by having live, logs and events in
seperate directories.

schLoop() no longer exists, postCmd is now handled by
detectMoInStream() to ensure motion detection is not done while the
command is running.
2023-03-26 10:45:23 -04:00
Maurice ONeal
93723bb7b1 v2.0.t11
also removed moDetect() loop for debugging.
2023-03-18 21:08:40 -04:00
Maurice ONeal
58d957d0a4 v2.0.t11
removed detectloop() for debug. the app is crashing without explanation.
2023-03-18 20:52:13 -04:00
Maurice ONeal
533c27d9cb v.20.t10
Event files are still not concatenating. I suspect the issue was in
eventLoop() caching old event objects. Changed up the loop to so it will
grab latest event object on each iteration.
2023-03-12 17:19:11 -04:00
Maurice ONeal
061c2571b4 v2.0.t9
Event VODs are still not playing back correctly. Trying mp4 format
instead of hls.
2023-03-12 15:27:53 -04:00
Maurice ONeal
baa69da2cd v2.0.t8
Adjusted the event loop and motion detection to make better stand alone
m3u8 files. Hopefully doing this will make browsers treat the recorded
events as VODs instead of streams.
2023-03-12 13:22:10 -04:00
Maurice ONeal
3c5dbec24c v2.0.t7
Apparently native html5 or modern browsers do not support running .m3u8
playlist directly or I was missing something in the original code. Even
adding the correct mime types in apache2 didn't work so I decided to
embed hls.js into the video html files to support hls playlist.
2023-03-11 16:32:00 -05:00
Maurice ONeal
78919effcf v2.0.t6
Added live camera streaming support to the web interface for testing.
2023-03-11 07:56:16 -05:00
Maurice ONeal
0f6e7603df v.2.0.t5
Found the write out bug. genEventPath() was getting unexpected input
causing it to output empty strings.
2023-03-10 20:51:18 -05:00
Maurice ONeal
bddde644c1 v.2.0.t4
Fixed the compile error.
2023-03-10 19:47:36 -05:00
Maurice ONeal
ae46834777 v2.0.t3
Event recordings are not writing out correctly. added more log lines to
help debug.
2023-03-10 19:35:44 -05:00
Maurice ONeal
b0dbfa0852 v2.0.t2
Logs are not rotating correctly. Changed up the code to append the logs
in memory and then dump them to permanent storage on every loop of
upkeep(). Hopefully this fixes the issue.
2023-03-10 19:05:54 -05:00
Maurice ONeal
a065b7a1d3 v2.0.t1
Completely reformed the internal workings of the application code. I
brought back multi-threaded functions so there is now 5 separate threads
for different tasks.

recLoop() - this function calls ffmpeg to begin recording footage from
the defined camera and stores the footage in hls format. It is designed
to keep running for as long as the application is running and if it does
stop for whatever reason, it will attempt to auto re-start.

upkeep() - this function does regular cleanup and enforcement of maxDays
maxLogSize and maxEvents without the need to stop recording or detecting
motion.

detectMo() - this function reads directly from recLoop's hls output and
list all footage that has motion in it. motion detection no longer has
to wait for the clip to finish recording thanks to the use of .ts
containers for the video clips. this makes the motion detection for less
cpu intensive now that it will now operate at the camera's fps (slower).

eventLoop() - this function reads the motion list from detectMo and
copies the footage pointed out by the list to an events folder, also in
hls format.

schLoop() - this function runs an optional user defined external command
every amount of seconds defined in sch_sec. this command temporary stops
motion detection without actually terminating the thread. It will also
not run the command at the scheduled time if motion was detected.

Benefits to this reform:

- far less cpu intensive operation
- multi-threaded architecture for better asynchronous operation
- it has support for live streaming now that hls is being used
- a buff_dir is no longer necessary
2023-03-05 16:07:07 -05:00
Maurice ONeal
81da33ba81 v1.6.t9
The fork() architecture from the previous commit is also deemed a
failure. Reverted back to v1.5.t19 code. I'll start from scratch, using
this commit as the new base.
2023-02-18 21:21:34 -05:00
Maurice ONeal
13eaf75c8a v1.6.t8
going back to basics. removed all threading code and opted for a multi
process architecture using fork(). previous code had a bad memory leak
and doesn't handle unexpected camera disconnects and for some reason it
also didn't recover gracefully in systemctl when it crashes. Hopefully
this new re-write fixes all of those numerous issues.

moDetect() will now try multiple times to grab buffer footage before
giving up and moving on.
2023-02-18 17:43:10 -05:00
Maurice ONeal
4dcd6c05a3 v1.6.t7
the crashing issue might be the detection threads going out-of-scope
before properly finishing. re-implemented share->detThreads from
previous stable code to see if this fixes the issue.
2023-02-14 19:29:02 -05:00
Maurice ONeal
4758b62275 v1.6.t6
The crashing problems may have started after switching my test machine
to to multiple config file setup. I'll test this theory by completely
removing the multiple config file feasure and see if it crashes again.

I'll figure out a better solution for multi config files in the next
round of deveoplment.
2023-02-12 15:04:32 -05:00
Maurice ONeal
6ffe80b672 v1.6.t5
Added a signal handler that will print out signal details upon receiving
them. This should give up some hint to the cause of crashes for
debugging reasons.

The root index web page will now only be updated once. Hopefully this
reduces chance of multiple instances clashing with each other.
2023-02-11 20:59:19 -05:00