diff --git a/server/motion_processor.cpp b/server/motion_processor.cpp index fa6fb7d3..d55b450b 100644 --- a/server/motion_processor.cpp +++ b/server/motion_processor.cpp @@ -37,6 +37,10 @@ motion_processor::motion_processor(bc_record *bcRecord) memset(&m_debugEventTime, 0, sizeof(struct tm)); m_debugEventTime.tm_sec = -1; + + // m_refFrames[2] is a static array so ctors, dtors are not called automatically on elements + new(&m_refFrames[0]) cv::Mat(); + new(&m_refFrames[1]) cv::Mat(); } motion_processor::~motion_processor() @@ -55,9 +59,9 @@ motion_processor::~motion_processor() } #endif - for (int i = 0; i < sizeof(m_refFrames); i++) { - m_refFrames[i].release(); - } + // m_refFrames[2] is a static array so ctors, dtors are not called automatically on elements + m_refFrames[0].~Mat(); + m_refFrames[1].~Mat(); delete output_source; } @@ -579,7 +583,6 @@ int motion_processor::detect_opencv(AVFrame *rawFrame) // first things first... get the original frame from the AVFrame and convert it to an OpenCV Grayscale Mat, and the "downscale" size. cv::Mat m = cv::Mat(dst_h, dst_w, CV_8UC1); if (convert_AVFrame_to_grayMat(rawFrame, m) == 0) { - m.release(); return 0; // error converting frame... } @@ -620,7 +623,6 @@ int motion_processor::detect_opencv(AVFrame *rawFrame) if (m_motionDebug) check_for_new_debug_event(ret); - m.release(); return ret; } @@ -633,7 +635,6 @@ int motion_processor::detect_opencv_advanced(AVFrame *rawFrame) // first things first... get the original frame from the AVFrame and convert it to an OpenCV Grayscale Mat, and the "downscale" size. cv::Mat m = cv::Mat(dst_h, dst_w, CV_8UC1); if (convert_AVFrame_to_grayMat(rawFrame, m) == 0) { - m.release(); return 0; // error converting frame... } @@ -669,7 +670,6 @@ int motion_processor::detect_opencv_advanced(AVFrame *rawFrame) } m_motionTriggered = (num_md_frames >= m_minMotionFrames); - m.release(); return m_motionTriggered; }