diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2016-08-12 17:03:51 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2016-08-12 17:03:51 +0200 |
commit | eda47922d9bd6d10e4e2fb3d3191edfaa126aef5 (patch) | |
tree | 86cef123f082a743275842d0c110dfa3d6115020 /cv/camera-dialog.cpp | |
parent | 0ed45348c428a950db589caa227efa86af499170 (diff) |
few: use existing com threading init function
Diffstat (limited to 'cv/camera-dialog.cpp')
-rw-r--r-- | cv/camera-dialog.cpp | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/cv/camera-dialog.cpp b/cv/camera-dialog.cpp index 1be54ece..c3e8f6fe 100644 --- a/cv/camera-dialog.cpp +++ b/cv/camera-dialog.cpp @@ -20,27 +20,19 @@ void camera_dialog::maybe_grab_frame(cv::VideoCapture& cap) } } -#ifdef _WIN32 -void camera_dialog::init_com_threading() -{ - HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); - if (FAILED(hr)) - qDebug() << "failed CoInitializeEx" << hr << "code" << GetLastError(); -} -#endif - camera_dialog::~camera_dialog() {} void camera_dialog::open_camera_settings(cv::VideoCapture* cap, const QString& camera_name, QMutex* camera_mtx) { #ifdef _WIN32 + init_com_threading(com_apartment); + if (cap) { QMutexLocker l(camera_mtx); if (cap->isOpened()) { - init_com_threading(); maybe_grab_frame(*cap); cap->set(cv::CAP_PROP_SETTINGS, 1); return; @@ -54,7 +46,6 @@ void camera_dialog::open_camera_settings(cv::VideoCapture* cap, const QString& c if (!t.isSingleShot()) QObject::connect(&t, &QTimer::timeout, [&]() -> void { delete_capture(); }); - init_com_threading(); fake_capture = cv::VideoCapture(camera_name_to_index(camera_name)); maybe_grab_frame(fake_capture); fake_capture.set(cv::CAP_PROP_SETTINGS, 1); |