summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-02-21 21:23:38 +0100
committerStanislaw Halik <sthalik@misaki.pl>2017-02-21 21:23:38 +0100
commita652bf3333365c9b306361d4819262a95390bbcc (patch)
tree30a2b94c8fa98c2cc6dad928c16f41fb6dc2285c
parenta50cfd62d89eebda30b7dfffbe761e2b930118eb (diff)
cv/video-widget: short-circuit early in widget creation
Otherwise opencv has an assertion failure when creating a matrix with a zero dimension.
-rw-r--r--cv/video-widget.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/cv/video-widget.cpp b/cv/video-widget.cpp
index b9c1e38e..3158fa8a 100644
--- a/cv/video-widget.cpp
+++ b/cv/video-widget.cpp
@@ -22,6 +22,11 @@ void cv_video_widget::update_image(const cv::Mat& frame)
if (!freshp)
{
+ const int w = preview_size.width(), h = preview_size.height();
+
+ if (!w || !h)
+ return;
+
if (_frame.cols != frame.cols || _frame.rows != frame.rows)
_frame = cv::Mat(frame.rows, frame.cols, CV_8UC3);
frame.copyTo(_frame);
@@ -30,8 +35,6 @@ void cv_video_widget::update_image(const cv::Mat& frame)
if (_frame2.cols != _frame.cols || _frame2.rows != _frame.rows)
_frame2 = cv::Mat(_frame.rows, _frame.cols, CV_8UC3);
- const int w = preview_size.width(), h = preview_size.height();
-
if (_frame3.cols != w || _frame3.rows != h)
_frame3 = cv::Mat(h, w, CV_8UC3);
@@ -50,7 +53,7 @@ void cv_video_widget::update_image(const cv::Mat& frame)
const cv::Mat& img = *img_;
- texture = QImage((const unsigned char*) img.data, img.cols, img.rows, QImage::Format_RGB888);
+ texture = QImage((const unsigned char*) img.data, w, h, QImage::Format_RGB888);
}
}