summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStéphane Lenclud <github@lenclud.com>2019-04-15 00:04:19 +0200
committerStéphane Lenclud <github@lenclud.com>2019-04-24 18:46:12 +0200
commit14a403d0928bb8ef600017294cafc8b15b1540e7 (patch)
tree4ad9da37b3af6f86d3ab97d227129f2ca8a2ed7d
parent5ebbcda77e2ad01932be9573a63242f4164fdbb8 (diff)
Easy Tracker: Minor changes to preview.
-rw-r--r--tracker-easy/preview.cpp18
-rw-r--r--tracker-easy/preview.h10
2 files changed, 17 insertions, 11 deletions
diff --git a/tracker-easy/preview.cpp b/tracker-easy/preview.cpp
index a44ab143..f5c239e9 100644
--- a/tracker-easy/preview.cpp
+++ b/tracker-easy/preview.cpp
@@ -63,7 +63,7 @@ namespace EasyTracker
Preview::Preview(int w, int h)
{
- ensure_size(frame_out, w, h, CV_8UC4);
+ ensure_size(iFrameWidget, w, h, CV_8UC4);
ensure_size(iFrameResized, w, h, CV_8UC3);
iFrameResized.setTo(cv::Scalar(0, 0, 0));
@@ -71,9 +71,9 @@ namespace EasyTracker
QImage Preview::get_bitmap()
{
- int stride = frame_out.step.p[0];
+ int stride = iFrameWidget.step.p[0];
- if (stride < 64 || stride < frame_out.cols * 4)
+ if (stride < 64 || stride < iFrameWidget.cols * 4)
{
eval_once(qDebug() << "bad stride" << stride
<< "for bitmap size" << iFrameResized.cols << iFrameResized.rows);
@@ -81,20 +81,20 @@ namespace EasyTracker
}
// Resize if needed
- const bool need_resize = iFrameRgb.cols != frame_out.cols || iFrameRgb.rows != frame_out.rows;
+ const bool need_resize = iFrameRgb.cols != iFrameWidget.cols || iFrameRgb.rows != iFrameWidget.rows;
if (need_resize)
{
- cv::resize(iFrameRgb, iFrameResized, cv::Size(frame_out.cols, frame_out.rows), 0, 0, cv::INTER_NEAREST);
+ cv::resize(iFrameRgb, iFrameResized, cv::Size(iFrameWidget.cols, iFrameWidget.rows), 0, 0, cv::INTER_NEAREST);
}
else
{
- iFrameRgb.copyTo(iFrameResized);
+ iFrameResized = iFrameRgb;
}
- cv::cvtColor(iFrameResized, frame_out, cv::COLOR_BGR2BGRA);
+ cv::cvtColor(iFrameResized, iFrameWidget, cv::COLOR_BGR2BGRA);
- return QImage((const unsigned char*)frame_out.data,
- frame_out.cols, frame_out.rows,
+ return QImage((const unsigned char*)iFrameWidget.data,
+ iFrameWidget.cols, iFrameWidget.rows,
stride,
QImage::Format_ARGB32);
}
diff --git a/tracker-easy/preview.h b/tracker-easy/preview.h
index 03de6684..785d76d4 100644
--- a/tracker-easy/preview.h
+++ b/tracker-easy/preview.h
@@ -32,9 +32,15 @@ namespace EasyTracker
static void ensure_size(cv::Mat& frame, int w, int h, int type);
public:
- cv::Mat iFrameResized, frame_out;
- cv::Mat iFrameRgb;
+ // Frame with an 8 bits channel size
cv::Mat iFrameChannelSizeOne;
+ // Frame with three channels for RGB
+ cv::Mat iFrameRgb;
+ // Frame rezised to widget dimension
+ cv::Mat iFrameResized;
+ // Frame ready to be packed in a QImage for use in our widget
+ cv::Mat iFrameWidget;
+
};
}