25 #ifndef INCLUDED_DirectShowHDKCameraFactory_h_GUID_383B0AE1_8BD2_4B9D_5176_ABEFEF534DBE 26 #define INCLUDED_DirectShowHDKCameraFactory_h_GUID_383B0AE1_8BD2_4B9D_5176_ABEFEF534DBE 44 inline void setGainMode(IBaseFilter &filter,
bool highGain) {
46 filter.QueryInterface(__uuidof(IKsPropertySet), AttachPtr(ksPropSet));
51 auto prop = KSPROPERTY{};
52 prop.Set = GUID{STATICGUIDOF(
53 PROPSETID_VIDCAP_VIDEOPROCAMP)};
55 prop.Id = KSPROPERTY_VIDEOPROCAMP_POWERLINE_FREQUENCY;
57 auto supportType = DWORD{0};
58 auto hr = ksPropSet->QuerySupported(prop.Set, prop.Id, &supportType);
59 if (SUCCEEDED(hr) && (supportType & KSPROPERTY_SUPPORT_SET)) {
64 static const long POWERLINE_DISABLED = 0;
65 static const long POWERLINE_50HZ = 1;
66 static const long POWERLINE_60HZ = 2;
68 auto propData = KSPROPERTY_VIDEOPROCAMP_S{};
69 propData.Property = prop;
70 propData.Property.Flags = KSPROPERTY_TYPE_SET;
72 propData.Value = highGain ? POWERLINE_50HZ : POWERLINE_60HZ;
73 propData.Flags = KSPROPERTY_VIDEOPROCAMP_FLAGS_MANUAL;
75 hr = ksPropSet->Set(prop.Set, prop.Id, &propData,
sizeof(propData),
76 &propData,
sizeof(propData));
80 <<
"Tried but failed to put the camera in desired gain mode..." 86 inline std::unique_ptr<directx_camera_server> getDirectShowHDKCamera(
bool highGain =
true) {
89 static const auto HDK_CAMERA_PATH_PREFIX =
90 "\\\\?\\usb#vid_0bda&pid_57e8&mi_00";
91 auto ret = std::unique_ptr<directx_camera_server>{
new directx_camera_server(
92 HDK_CAMERA_PATH_PREFIX,
93 [highGain](IBaseFilter &filter) { setGainMode(filter, highGain); })};
95 if (!ret->working()) {
102 #endif // INCLUDED_DirectShowHDKCameraFactory_h_GUID_383B0AE1_8BD2_4B9D_5176_ABEFEF534DBE
boost::intrusive_ptr< T > Ptr
Template alias for our desired COM smart pointer.
Definition: ComPtr.h:40