summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-09-17 16:09:40 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-09-17 16:20:19 +0200
commitc7215393794b7a901cfcca22c9afe200f5bb959e (patch)
tree1a96ae7e44f48ce84219fd778181b0a85f09bc77
parent1cb46ce512333342f292462121b6e23bee0a715d (diff)
cv: bring video property page from the attic
-rw-r--r--cv/video-property-page.cpp (renamed from cv/video-property-page.cpp_)121
-rw-r--r--cv/video-property-page.hpp21
2 files changed, 55 insertions, 87 deletions
diff --git a/cv/video-property-page.cpp_ b/cv/video-property-page.cpp
index 319a2a78..08ac00d0 100644
--- a/cv/video-property-page.cpp_
+++ b/cv/video-property-page.cpp
@@ -1,102 +1,26 @@
-#if 0
-#if 0
+/* Copyright (c) 2016 Stanislaw Halik
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ */
+
#include "video-property-page.hpp"
-#else
-#include <windows.h>
-#include <dshow.h>
-struct video_property_page final
-{
- video_property_page() = delete;
- static bool show(int id);
-
-private:
- static HRESULT ShowFilterPropertyPages(IBaseFilter* filter);
- static IBaseFilter* get_device(int id);
-};
-#endif
-// above is the header, for completeness
-// OleInitialize, CoCreateInstance et al. don't help with ps3 eye.
+#ifdef _WIN32
#include <cstring>
-
#include <QString>
#include <QDebug>
-#if 0
-DEFINE_GUID(CLSID_SampleGrabber,0xc1f400a0,0x3f08,0x11d3,0x9f,0x0b,0x00,0x60,0x08,0x03,0x9e,0x37);
-DEFINE_GUID(IID_ISampleGrabber,0x6b652fff,0x11fe,0x4fce,0x92,0xad,0x02,0x66,0xb5,0xd7,0xc7,0x8f);
-
-struct ISampleGrabberCB : public IUnknown
-{
- virtual HRESULT STDMETHODCALLTYPE SampleCB(
- double SampleTime,
- IMediaSample *pSample) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE BufferCB(
- double SampleTime,
- BYTE *pBuffer,
- LONG BufferLen) = 0;
-};
-
-struct ISampleGrabber : public IUnknown
-{
- virtual HRESULT STDMETHODCALLTYPE SetOneShot(
- BOOL OneShot) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetMediaType(
- const AM_MEDIA_TYPE *pType) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetConnectedMediaType(
- AM_MEDIA_TYPE *pType) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetBufferSamples(
- BOOL BufferThem) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetCurrentBuffer(
- LONG *pBufferSize,
- LONG *pBuffer) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetCurrentSample(
- IMediaSample **ppSample) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetCallback(
- ISampleGrabberCB *pCallback,
- LONG WhichMethodToCallback) = 0;
-};
-#endif
-
#define CHECK(expr) if (FAILED(hr = (expr))) { qDebug() << QStringLiteral(#expr) << hr; goto done; }
#define CHECK2(expr) if (!(expr)) { qDebug() << QStringLiteral(#expr); goto done; }
-#if 0
-static IPin* GetPin(IBaseFilter *pFilter, PIN_DIRECTION dir_)
+bool video_property_page::show_from_capture(cv::VideoCapture& cap, int)
{
- IPin* ret = NULL;
- IEnumPins* pin_enum = NULL;
- PIN_DIRECTION dir;
- HRESULT hr;
-
- CHECK(pFilter->EnumPins(&pin_enum));
-
- while (SUCCEEDED(pin_enum->Next(1, &ret, NULL)))
- {
- CHECK(ret->QueryDirection(&dir));
- if (dir == dir_)
- goto done;
- ret->Release();
- ret = NULL;
- }
-
- ret = NULL;
-
-done:
- if (pin_enum)
- pin_enum->Release();
-
- return ret;
+ cap.set(cv::CAP_PROP_SETTINGS, 0);
+ return true;
}
-#endif
bool video_property_page::show(int id)
{
@@ -128,6 +52,8 @@ HRESULT video_property_page::ShowFilterPropertyPages(IBaseFilter* filter)
filter->QueryInterface(IID_IUnknown, (void**)&unk);
+ // OleInitialize, CoCreateInstance et al. don't help with ps3 eye.
+
// cl-eye uses this
// perhaps more than IBaseFilter* -> IUnknown* needs be passed to lplpUnk
// and the OleCreatePropertyFrame equiv
@@ -205,4 +131,25 @@ done:
return filter;
}
+#elif defined(__linux)
+# include <QProcess>
+# include "compat/camera-names.hpp"
+
+bool video_property_page::show(int idx)
+{
+ const QList<QString> camera_names(get_camera_names());
+
+ if (idx >= 0 && idx < camera_names.size())
+ return QProcess::startDetached("qv4l2", QStringList() << "-d" << camera_names[idx]);
+ else
+ return false;
+}
+
+bool video_property_page::show_from_capture(cv::VideoCapture&, int idx)
+{
+ return show(idx);
+}
+#else
+bool video_property_page::show(int) { return false; }
+bool video_property_page::show_from_capture(cv::VideoCapture&, int) { return false; }
#endif
diff --git a/cv/video-property-page.hpp b/cv/video-property-page.hpp
new file mode 100644
index 00000000..7c51f111
--- /dev/null
+++ b/cv/video-property-page.hpp
@@ -0,0 +1,21 @@
+#pragma once
+
+#ifdef _WIN32
+# include <windows.h>
+# include <dshow.h>
+#endif
+
+#include "opencv2/videoio.hpp"
+
+struct video_property_page final
+{
+ video_property_page() = delete;
+ static bool show(int id);
+ static bool show_from_capture(cv::VideoCapture& cap, int idx);
+
+private:
+#ifdef _WIN32
+ static HRESULT ShowFilterPropertyPages(IBaseFilter* filter);
+ static IBaseFilter* get_device(int id);
+#endif
+};