From 7e9c707f92d5c8c7221e36449441f5171fcccfd3 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 3 Feb 2022 08:19:08 -0500 Subject: [PATCH 1/7] V plane is actually the 3rd array entry, not the 4th --- src/zm_monitor.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index c3333e051..2b6436379 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -2003,7 +2003,7 @@ bool Monitor::Analyse() { ) ) { Debug(1, "assigning refimage from v-channel"); Image v_image(snap->in_frame->width, - snap->in_frame->height, 1, ZM_SUBPIX_ORDER_NONE, snap->in_frame->data[3], 0); + snap->in_frame->height, 1, ZM_SUBPIX_ORDER_NONE, snap->in_frame->data[2], 0); ref_image.Assign(v_image); } else if (snap->image) { Debug(1, "assigning refimage from snap->image"); @@ -2093,7 +2093,7 @@ bool Monitor::Analyse() { ((AVPixelFormat)snap->in_frame->format == AV_PIX_FMT_YUVJ420P) ) ) { Debug(1, "assigning refimage from v-channel"); - Image v_image(snap->in_frame->width, snap->in_frame->height, 1, ZM_SUBPIX_ORDER_NONE, snap->in_frame->data[3], 0); + Image v_image(snap->in_frame->width, snap->in_frame->height, 1, ZM_SUBPIX_ORDER_NONE, snap->in_frame->data[2], 0); ref_image.Assign(v_image); } else { Debug(1, "assigning refimage from snap->image"); @@ -2108,7 +2108,7 @@ bool Monitor::Analyse() { || ((AVPixelFormat)snap->in_frame->format == AV_PIX_FMT_YUVJ420P) ) ) { - Image v_image(snap->in_frame->width, snap->in_frame->height, 1, ZM_SUBPIX_ORDER_NONE, snap->in_frame->data[3], 0); + Image v_image(snap->in_frame->width, snap->in_frame->height, 1, ZM_SUBPIX_ORDER_NONE, snap->in_frame->data[2], 0); snap->score = DetectMotion(v_image, zoneSet); } else { snap->score = DetectMotion(*(snap->image), zoneSet); @@ -2337,7 +2337,7 @@ bool Monitor::Analyse() { ((AVPixelFormat)snap->in_frame->format == AV_PIX_FMT_YUVJ420P) ) ) { Debug(1, "Assigning from vchannel"); - Image v_image(snap->in_frame->width, snap->in_frame->height, 1, ZM_SUBPIX_ORDER_NONE, snap->in_frame->data[3], 0); + Image v_image(snap->in_frame->width, snap->in_frame->height, 1, ZM_SUBPIX_ORDER_NONE, snap->in_frame->data[2], 0); ref_image.Assign(v_image); } else if (snap->image) { Debug(1, "Assigning"); @@ -2352,7 +2352,7 @@ bool Monitor::Analyse() { ) ) { Debug(1, "Blending from vchannel"); - Image v_image(snap->in_frame->width, snap->in_frame->height, 1, ZM_SUBPIX_ORDER_NONE, snap->in_frame->data[3], 0); + Image v_image(snap->in_frame->width, snap->in_frame->height, 1, ZM_SUBPIX_ORDER_NONE, snap->in_frame->data[2], 0); ref_image.Blend(v_image, ( state==ALARM ? alarm_ref_blend_perc : ref_blend_perc )); } else if (snap->image) { Debug(1, "Blending because %p and format %d != %d, %d", snap->in_frame, From b05bc211f744870e82193a5737985866b19dbb18 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 3 Feb 2022 10:50:40 -0500 Subject: [PATCH 2/7] Apparently it is actually the Y channel that we want. --- src/zm_monitor.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 2b6436379..a33b00c40 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -2003,7 +2003,7 @@ bool Monitor::Analyse() { ) ) { Debug(1, "assigning refimage from v-channel"); Image v_image(snap->in_frame->width, - snap->in_frame->height, 1, ZM_SUBPIX_ORDER_NONE, snap->in_frame->data[2], 0); + snap->in_frame->height, 1, ZM_SUBPIX_ORDER_NONE, snap->in_frame->data[0], 0); ref_image.Assign(v_image); } else if (snap->image) { Debug(1, "assigning refimage from snap->image"); @@ -2093,7 +2093,7 @@ bool Monitor::Analyse() { ((AVPixelFormat)snap->in_frame->format == AV_PIX_FMT_YUVJ420P) ) ) { Debug(1, "assigning refimage from v-channel"); - Image v_image(snap->in_frame->width, snap->in_frame->height, 1, ZM_SUBPIX_ORDER_NONE, snap->in_frame->data[2], 0); + Image v_image(snap->in_frame->width, snap->in_frame->height, 1, ZM_SUBPIX_ORDER_NONE, snap->in_frame->data[0], 0); ref_image.Assign(v_image); } else { Debug(1, "assigning refimage from snap->image"); @@ -2108,7 +2108,7 @@ bool Monitor::Analyse() { || ((AVPixelFormat)snap->in_frame->format == AV_PIX_FMT_YUVJ420P) ) ) { - Image v_image(snap->in_frame->width, snap->in_frame->height, 1, ZM_SUBPIX_ORDER_NONE, snap->in_frame->data[2], 0); + Image v_image(snap->in_frame->width, snap->in_frame->height, 1, ZM_SUBPIX_ORDER_NONE, snap->in_frame->data[0], 0); snap->score = DetectMotion(v_image, zoneSet); } else { snap->score = DetectMotion(*(snap->image), zoneSet); @@ -2337,7 +2337,7 @@ bool Monitor::Analyse() { ((AVPixelFormat)snap->in_frame->format == AV_PIX_FMT_YUVJ420P) ) ) { Debug(1, "Assigning from vchannel"); - Image v_image(snap->in_frame->width, snap->in_frame->height, 1, ZM_SUBPIX_ORDER_NONE, snap->in_frame->data[2], 0); + Image v_image(snap->in_frame->width, snap->in_frame->height, 1, ZM_SUBPIX_ORDER_NONE, snap->in_frame->data[0], 0); ref_image.Assign(v_image); } else if (snap->image) { Debug(1, "Assigning"); @@ -2352,7 +2352,7 @@ bool Monitor::Analyse() { ) ) { Debug(1, "Blending from vchannel"); - Image v_image(snap->in_frame->width, snap->in_frame->height, 1, ZM_SUBPIX_ORDER_NONE, snap->in_frame->data[2], 0); + Image v_image(snap->in_frame->width, snap->in_frame->height, 1, ZM_SUBPIX_ORDER_NONE, snap->in_frame->data[0], 0); ref_image.Blend(v_image, ( state==ALARM ? alarm_ref_blend_perc : ref_blend_perc )); } else if (snap->image) { Debug(1, "Blending because %p and format %d != %d, %d", snap->in_frame, From 838704e58e2ac24ef2af10282ddfa27be3ce4a39 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 3 Feb 2022 10:07:21 -0500 Subject: [PATCH 3/7] Add more stop_ tests so that when we are told to terminate, we actually do so. --- src/zm_rtsp_server_fifo_source.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/zm_rtsp_server_fifo_source.cpp b/src/zm_rtsp_server_fifo_source.cpp index 40dbc14fc..1845c96ef 100644 --- a/src/zm_rtsp_server_fifo_source.cpp +++ b/src/zm_rtsp_server_fifo_source.cpp @@ -109,7 +109,7 @@ void ZoneMinderFifoSource::WriteRun() { fuNal.buffer()[2] = fuNal.buffer()[2]&~0x80; // FU header (no S bit) headerSize = 3; } - while (nalRemaining) { + while (nalRemaining && !stop_) { if ( nalRemaining < maxNalSize ) { // This is the last fragment: fuNal.buffer()[headerSize-1] |= 0x40; // set the E bit in the FU header @@ -166,7 +166,7 @@ int ZoneMinderFifoSource::getNextFrame() { } Debug(3, "%s bytes read %d bytes, buffer size %u", m_fifo.c_str(), bytes_read, m_buffer.size()); - while (m_buffer.size()) { + while (m_buffer.size() and !stop_) { unsigned int data_size = 0; int64_t pts; unsigned char *header_end = nullptr; @@ -224,7 +224,7 @@ int ZoneMinderFifoSource::getNextFrame() { int bytes_needed = data_size - (m_buffer.size() - header_size); if (bytes_needed > 0) { Debug(4, "Need another %d bytes. Trying to read them", bytes_needed); - while (bytes_needed) { + while (bytes_needed and !stop_) { bytes_read = m_buffer.read_into(m_fd, bytes_needed); if (bytes_read <= 0) { Debug(1, "Failed to read another %d bytes, got %d.", bytes_needed, bytes_read); @@ -252,13 +252,14 @@ int ZoneMinderFifoSource::getNextFrame() { { std::unique_lock lck(mutex_); Debug(3, "have lock"); - while (framesList.size()) { + while (!stop_ && framesList.size()) { std::pair nal = framesList.front(); framesList.pop_front(); NAL_Frame *Nal = new NAL_Frame(nal.first, nal.second, pts); m_nalQueue.push(Nal); } } + Debug(3, "notifying"); condition_.notify_all(); } // end while m_buffer.size() return 1; From 67ac0fdffd2003e7605a8b9ff1138205223c6115 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 3 Feb 2022 11:57:00 -0500 Subject: [PATCH 4/7] Disable alleged y-channel image motion detection. Doesn't work. --- src/zm_monitor.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index a33b00c40..6b2b44e63 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -1996,7 +1996,7 @@ bool Monitor::Analyse() { } else { event->addNote(SIGNAL_CAUSE, "Reacquired"); } - if (snap->in_frame && ( + if (0 and snap->in_frame && ( ((AVPixelFormat)snap->in_frame->format == AV_PIX_FMT_YUV420P) || ((AVPixelFormat)snap->in_frame->format == AV_PIX_FMT_YUVJ420P) @@ -2087,7 +2087,7 @@ bool Monitor::Analyse() { // decoder may not have been able to provide an image if (!ref_image.Buffer()) { Debug(1, "Assigning instead of Detecting"); - if (snap->in_frame && ( + if (0 and snap->in_frame && ( ((AVPixelFormat)snap->in_frame->format == AV_PIX_FMT_YUV420P) || ((AVPixelFormat)snap->in_frame->format == AV_PIX_FMT_YUVJ420P) @@ -2103,7 +2103,7 @@ bool Monitor::Analyse() { } else if (!(analysis_image_count % (motion_frame_skip+1))) { Debug(1, "Detecting motion on image %d, image %p", snap->image_index, snap->image); // Get new score. - if (snap->in_frame && ( + if (0 and snap->in_frame && ( ((AVPixelFormat)snap->in_frame->format == AV_PIX_FMT_YUV420P) || ((AVPixelFormat)snap->in_frame->format == AV_PIX_FMT_YUVJ420P) @@ -2331,7 +2331,7 @@ bool Monitor::Analyse() { if (function == MODECT or function == MOCORD) { if (!ref_image.Buffer()) { - if (snap->in_frame && ( + if (0 snap->in_frame && ( ((AVPixelFormat)snap->in_frame->format == AV_PIX_FMT_YUV420P) || ((AVPixelFormat)snap->in_frame->format == AV_PIX_FMT_YUVJ420P) From 02a2c783e495edeb2c22a8f24a3d3a4d0e84a34b Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 3 Feb 2022 11:57:27 -0500 Subject: [PATCH 5/7] Disable alleged y-channel image motion detection. Doesn't work. --- src/zm_monitor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 6b2b44e63..3a4879e5c 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -2331,7 +2331,7 @@ bool Monitor::Analyse() { if (function == MODECT or function == MOCORD) { if (!ref_image.Buffer()) { - if (0 snap->in_frame && ( + if (0 and snap->in_frame && ( ((AVPixelFormat)snap->in_frame->format == AV_PIX_FMT_YUV420P) || ((AVPixelFormat)snap->in_frame->format == AV_PIX_FMT_YUVJ420P) From d24b419f0e6a6af95f0c38a125b3e46ed17deab9 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 3 Feb 2022 12:06:00 -0500 Subject: [PATCH 6/7] Only create packages for master --- .github/workflows/create-packages.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/create-packages.yml b/.github/workflows/create-packages.yml index 93279cc57..e62c5aec1 100644 --- a/.github/workflows/create-packages.yml +++ b/.github/workflows/create-packages.yml @@ -2,8 +2,7 @@ name: Create packages on: push: - branches: - - '*' + branches: [ master ] pull_request: branches: [ master ] From da4c8802333c4e5acbb11c8cfa2752b222b84f27 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 3 Feb 2022 12:16:01 -0500 Subject: [PATCH 7/7] 0 out another used of y-image --- src/zm_monitor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 3a4879e5c..fcd8e4b9e 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -2344,7 +2344,7 @@ bool Monitor::Analyse() { ref_image.Assign(*(snap->image)); } } else { - if (snap->in_frame && + if (0 and snap->in_frame && ( ((AVPixelFormat)snap->in_frame->format == AV_PIX_FMT_YUV420P) ||