summaryrefslogtreecommitdiffhomepage
path: root/cv
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-12-20 19:05:44 +0100
committerStanislaw Halik <sthalik@misaki.pl>2018-12-24 19:31:24 +0100
commite202dab212ef8fd284d2745dd66496dcc3a2043e (patch)
tree345437664c02e65f4b6f3b0dd960d20fd5c2bf58 /cv
parent48de00ec978261c25e9c4a59479f0607cae751ff (diff)
fix undefined behavior undescore prefixes
Diffstat (limited to 'cv')
-rw-r--r--cv/video-property-page.cpp29
-rw-r--r--cv/video-widget.cpp30
-rw-r--r--cv/video-widget.hpp2
3 files changed, 30 insertions, 31 deletions
diff --git a/cv/video-property-page.cpp b/cv/video-property-page.cpp
index e6177c5c..1b8b94cf 100644
--- a/cv/video-property-page.cpp
+++ b/cv/video-property-page.cpp
@@ -27,9 +27,6 @@
#include <dshow.h>
-#define CHECK(expr) if (FAILED(hr = (expr))) { qDebug() << QLatin1String(#expr) << hr; goto done; }
-#define CHECK2(expr) if (!(expr)) { qDebug() << QLatin1String(#expr); goto done; }
-
bool video_property_page::show_from_capture(cv::VideoCapture& cap, int /*index */)
{
return cap.set(cv::CAP_PROP_SETTINGS, 0);
@@ -39,14 +36,16 @@ struct prop_settings_worker final : QThread
{
explicit prop_settings_worker(int idx);
~prop_settings_worker() override;
- void _open_prop_page();
+
+private:
+ void open_prop_page();
void run() override;
cv::VideoCapture cap;
- int _idx = -1;
+ int idx = -1;
};
-prop_settings_worker::prop_settings_worker(int idx)
+prop_settings_worker::prop_settings_worker(int idx_)
{
int ret = (int)cap.get(cv::CAP_PROP_SETTINGS);
@@ -60,16 +59,16 @@ prop_settings_worker::prop_settings_worker(int idx)
});
else
{
- _idx = idx;
+ idx = idx_;
// DON'T MOVE IT
// ps3 eye will reset to default settings if done from another thread
- _open_prop_page();
+ open_prop_page();
}
}
-void prop_settings_worker::_open_prop_page()
+void prop_settings_worker::open_prop_page()
{
- cap.open(_idx);
+ cap.open(idx);
if (cap.isOpened())
{
@@ -87,14 +86,14 @@ void prop_settings_worker::_open_prop_page()
}
qDebug() << "property-page: can't open camera";
- _idx = -1;
+ idx = -1;
return;
ok:
portable::sleep(100);
- qDebug() << "property-page: opening for" << _idx;
+ qDebug() << "property-page: opening for" << idx;
if (!cap.set(cv::CAP_PROP_SETTINGS, 0))
{
@@ -110,7 +109,7 @@ ok:
prop_settings_worker::~prop_settings_worker()
{
- if (_idx != -1)
+ if (idx != -1)
{
// ax filter is race condition-prone
portable::sleep(250);
@@ -118,13 +117,13 @@ prop_settings_worker::~prop_settings_worker()
// idem
portable::sleep(250);
- qDebug() << "property-page: closed" << _idx;
+ qDebug() << "property-page: closed" << idx;
}
}
void prop_settings_worker::run()
{
- if (_idx != -1)
+ if (idx != -1)
{
while (cap.get(cv::CAP_PROP_SETTINGS) > 0)
portable::sleep(1000);
diff --git a/cv/video-widget.cpp b/cv/video-widget.cpp
index c80bd96b..e7df087e 100644
--- a/cv/video-widget.cpp
+++ b/cv/video-widget.cpp
@@ -29,29 +29,29 @@ void cv_video_widget::update_image(const cv::Mat& frame)
if (width < 1 || height < 1)
return;
- if (_frame.cols != frame.cols || _frame.rows != frame.rows)
- _frame = cv::Mat(frame.rows, frame.cols, CV_8UC3);
- frame.copyTo(_frame);
+ if (frame1.cols != frame.cols || frame1.rows != frame.rows)
+ frame1 = cv::Mat(frame.rows, frame.cols, CV_8UC3);
+ frame.copyTo(frame1);
freshp = true;
- if (_frame2.cols != _frame.cols || _frame2.rows != _frame.rows)
- _frame2 = cv::Mat(_frame.rows, _frame.cols, CV_8UC4);
+ if (frame2.cols != frame1.cols || frame2.rows != frame1.rows)
+ frame2 = cv::Mat(frame1.rows, frame1.cols, CV_8UC4);
- if (_frame3.cols != width || _frame3.rows != height)
- _frame3 = cv::Mat(height, width, CV_8UC4);
+ if (frame3.cols != width || frame3.rows != height)
+ frame3 = cv::Mat(height, width, CV_8UC4);
- cv::cvtColor(_frame, _frame2, cv::COLOR_BGR2BGRA);
+ cv::cvtColor(frame1, frame2, cv::COLOR_BGR2BGRA);
const cv::Mat* img;
- if (_frame.cols != width || _frame.rows != height)
+ if (frame1.cols != width || frame1.rows != height)
{
- cv::resize(_frame2, _frame3, cv::Size(width, height), 0, 0, cv::INTER_NEAREST);
+ cv::resize(frame2, frame3, cv::Size(width, height), 0, 0, cv::INTER_NEAREST);
- img = &_frame3;
+ img = &frame3;
}
else
- img = &_frame2;
+ img = &frame2;
const unsigned nbytes = unsigned(4 * img->rows * img->cols);
@@ -101,9 +101,9 @@ void cv_video_widget::paintEvent(QPaintEvent*)
width = W, height = H;
- _frame = cv::Mat();
- _frame2 = cv::Mat();
- _frame3 = cv::Mat();
+ frame1 = cv::Mat();
+ frame2 = cv::Mat();
+ frame3 = cv::Mat();
}
}
diff --git a/cv/video-widget.hpp b/cv/video-widget.hpp
index 8ad62a3c..104fa21e 100644
--- a/cv/video-widget.hpp
+++ b/cv/video-widget.hpp
@@ -40,7 +40,7 @@ private:
QImage texture;
std::vector<unsigned char> vec;
QTimer timer;
- cv::Mat _frame, _frame2, _frame3;
+ cv::Mat frame1, frame2, frame3;
int width = 320, height = 240;
bool freshp = false;
};