summaryrefslogtreecommitdiffhomepage
path: root/cv
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-01-10 18:34:47 +0100
committerStanislaw Halik <sthalik@misaki.pl>2018-01-10 18:34:47 +0100
commit676c2ebb6ebaac778969b4610975ed327437eded (patch)
treeafc7f8378f6826f87166a22b4e7078c836d4e6ca /cv
parent26fa71fc2fdef236d4f31ab2501ea041178071e6 (diff)
cv: cleanup
Diffstat (limited to 'cv')
-rw-r--r--cv/video-property-page.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/cv/video-property-page.cpp b/cv/video-property-page.cpp
index 8589f11a..58670e83 100644
--- a/cv/video-property-page.cpp
+++ b/cv/video-property-page.cpp
@@ -32,8 +32,7 @@
bool video_property_page::show_from_capture(cv::VideoCapture& cap, int /*index */)
{
- cap.set(cv::CAP_PROP_SETTINGS, 0);
- return true;
+ return cap.set(cv::CAP_PROP_SETTINGS, 0);
}
struct prop_settings_worker final : QThread
@@ -69,7 +68,7 @@ prop_settings_worker::prop_settings_worker(int idx)
run_in_thread_async(qApp, []() {
QMessageBox::warning(nullptr,
"Camera properties",
- "Dialog already opened",
+ "Camera dialog already opened",
QMessageBox::Cancel,
QMessageBox::NoButton);
});
@@ -93,7 +92,10 @@ void prop_settings_worker::_open_prop_page()
for (unsigned k = 0; k < 2000/50; k++)
{
if (cap.read(tmp))
+ {
+ qDebug() << "got frame" << tmp.rows << tmp.cols;
goto ok;
+ }
portable::sleep(50);
}
}
@@ -107,7 +109,17 @@ ok:
portable::sleep(100);
qDebug() << "property-page: opening for" << _idx;
- cap.set(cv::CAP_PROP_SETTINGS, 0);
+
+ if (!cap.set(cv::CAP_PROP_SETTINGS, 0))
+ {
+ run_in_thread_async(qApp, []() {
+ QMessageBox::warning(nullptr,
+ "Camera properties",
+ "Can't open camera dialog",
+ QMessageBox::Cancel,
+ QMessageBox::NoButton);
+ });
+ }
}
prop_settings_worker::~prop_settings_worker()
@@ -131,13 +143,16 @@ void prop_settings_worker::run()
while (cap.get(cv::CAP_PROP_SETTINGS) > 0)
portable::sleep(1000);
}
-
- connect(this, &QThread::finished, this, &QObject::deleteLater);
}
bool video_property_page::show(int idx)
{
auto thread = new prop_settings_worker(idx);
+
+ // XXX is this a race condition?
+ thread->moveToThread(qApp->thread());
+ QObject::connect(thread, &QThread::finished, qApp, [thread]() { thread->deleteLater(); }, Qt::DirectConnection);
+
thread->start();
return true;