summaryrefslogtreecommitdiffhomepage
path: root/tracker-pt
diff options
context:
space:
mode:
Diffstat (limited to 'tracker-pt')
-rw-r--r--tracker-pt/module/frame.cpp15
-rw-r--r--tracker-pt/module/frame.hpp2
-rw-r--r--tracker-pt/module/point_extractor.cpp14
3 files changed, 9 insertions, 22 deletions
diff --git a/tracker-pt/module/frame.cpp b/tracker-pt/module/frame.cpp
index b1690aa1..09d469f2 100644
--- a/tracker-pt/module/frame.cpp
+++ b/tracker-pt/module/frame.cpp
@@ -36,15 +36,14 @@ void Preview::set_last_frame(const pt_frame& frame_)
Preview::Preview(int w, int h)
{
- ensure_size(frame_out, w, h, CV_8UC4);
- ensure_size(frame_copy, w, h, CV_8UC3);
-
- frame_copy.setTo(cv::Scalar(0, 0, 0));
+ frame_out.create(w, h, CV_8UC4);
+ frame_copy.create(w, h, CV_8UC3);
+ frame_copy.setTo({0});
}
QImage Preview::get_bitmap()
{
- int stride = frame_out.step.p[0];
+ int stride = (int)frame_out.step.p[0];
if (stride < 64 || stride < frame_out.cols * 4)
{
@@ -80,10 +79,4 @@ void Preview::draw_head_center(f x, f y)
color, 1);
}
-void Preview::ensure_size(cv::Mat& frame, int w, int h, int type)
-{
- if (frame.cols != w || frame.rows != h || frame.type() != type)
- frame = cv::Mat(h, w, type);
-}
-
} // ns pt_module
diff --git a/tracker-pt/module/frame.hpp b/tracker-pt/module/frame.hpp
index 1e7c82b6..239a3474 100644
--- a/tracker-pt/module/frame.hpp
+++ b/tracker-pt/module/frame.hpp
@@ -32,8 +32,6 @@ struct Preview final : pt_preview
operator cv::Mat const&() const { return frame_copy; }
private:
- static void ensure_size(cv::Mat& frame, int w, int h, int type);
-
cv::Mat frame_copy, frame_out, frame_tmp;
};
diff --git a/tracker-pt/module/point_extractor.cpp b/tracker-pt/module/point_extractor.cpp
index d8a23fcf..9814d974 100644
--- a/tracker-pt/module/point_extractor.cpp
+++ b/tracker-pt/module/point_extractor.cpp
@@ -87,21 +87,17 @@ PointExtractor::PointExtractor(const QString& module_name) : s(module_name)
void PointExtractor::ensure_channel_buffers(const cv::Mat& orig_frame)
{
- if (ch[0].rows != orig_frame.rows || ch[0].cols != orig_frame.cols)
- for (cv::Mat1b& x : ch)
- x = cv::Mat1b(orig_frame.rows, orig_frame.cols);
+ for (cv::Mat1b& x : ch)
+ x.create(orig_frame.rows, orig_frame.cols);
}
void PointExtractor::ensure_buffers(const cv::Mat& frame)
{
const int W = frame.cols, H = frame.rows;
- if (frame_gray.rows != W || frame_gray.cols != H)
- {
- frame_gray = cv::Mat1b(H, W);
- frame_bin = cv::Mat1b(H, W);
- frame_gray_unmasked = cv::Mat1b(H, W);
- }
+ frame_gray.create(H, W);
+ frame_bin.create(H, W);
+ frame_gray_unmasked.create(H, W);
}
void PointExtractor::extract_single_channel(const cv::Mat& orig_frame, int idx, cv::Mat1b& dest)