Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
57dc28fe
O
Opencv
项目概览
Greenplum
/
Opencv
大约 1 年 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
57dc28fe
编写于
1月 11, 2018
作者:
A
Alexander Alekhin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10504 from opentrack:fork
上级
18edd917
c8794c89
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
75 addition
and
25 deletion
+75
-25
modules/videoio/src/cap_dshow.cpp
modules/videoio/src/cap_dshow.cpp
+75
-25
未找到文件。
modules/videoio/src/cap_dshow.cpp
浏览文件 @
57dc28fe
...
...
@@ -434,6 +434,8 @@ class videoDevice{
int
myID
;
long
requestedFrameTime
;
//ie fps
LONG
volatile
property_window_count
;
char
nDeviceName
[
255
];
WCHAR
wDeviceName
[
255
];
...
...
@@ -499,7 +501,7 @@ class videoInput{
//Launches a pop up settings window
//For some reason in GLUT you have to call it twice each time.
void
showSettingsWindow
(
int
deviceID
);
bool
showSettingsWindow
(
int
deviceID
);
//Manual control over settings thanks.....
//These are experimental for now.
...
...
@@ -535,6 +537,8 @@ class videoInput{
bool
isDeviceDisconnected
(
int
deviceID
);
int
property_window_count
(
int
device_idx
);
private:
void
setPhyCon
(
int
deviceID
,
int
conn
);
void
setAttemptCaptureSize
(
int
deviceID
,
int
w
,
int
h
,
GUID
mediaType
=
MEDIASUBTYPE_RGB24
);
...
...
@@ -578,7 +582,6 @@ class videoInput{
static
void
__cdecl
basicThread
(
void
*
objPtr
);
static
char
deviceNames
[
VI_MAX_CAMERAS
][
255
];
};
/////////////////////////// HANDY FUNCTIONS /////////////////////////////
...
...
@@ -764,6 +767,8 @@ videoDevice::videoDevice(){
pixels
=
0
;
formatType
=
0
;
property_window_count
=
0
;
memset
(
wDeviceName
,
0
,
sizeof
(
WCHAR
)
*
255
);
memset
(
nDeviceName
,
0
,
sizeof
(
char
)
*
255
);
...
...
@@ -1240,6 +1245,7 @@ bool videoInput::setFormat(int deviceNumber, int format){
if
(
VDList
[
deviceNumber
]
->
pVideoInputFilter
)
VDList
[
deviceNumber
]
->
pVideoInputFilter
->
Release
();
if
(
VDList
[
deviceNumber
]
->
pVideoInputFilter
)
VDList
[
deviceNumber
]
->
pVideoInputFilter
=
NULL
;
if
(
FAILED
(
hr
)){
DebugPrintOut
(
"SETUP: couldn't set requested format
\n
"
);
}
else
{
...
...
@@ -1586,36 +1592,47 @@ bool videoInput::isDeviceSetup(int id) const
// ----------------------------------------------------------------------
void
__cdecl
videoInput
::
basicThread
(
void
*
objPtr
){
//get a reference to the video device
//not a copy as we need to free the filter
videoDevice
*
vd
=
*
(
(
videoDevice
**
)(
objPtr
)
);
ShowFilterPropertyPages
(
vd
->
pVideoInputFilter
);
//now we free the filter and make sure it set to NULL
if
(
vd
->
pVideoInputFilter
)
vd
->
pVideoInputFilter
->
Release
();
if
(
vd
->
pVideoInputFilter
)
vd
->
pVideoInputFilter
=
NULL
;
void
__cdecl
videoInput
::
basicThread
(
void
*
ptr
)
{
videoDevice
*
dev
=
(
videoDevice
*
)
ptr
;
IBaseFilter
*
filter
=
dev
->
pVideoInputFilter
;
return
;
(
void
)
ShowFilterPropertyPages
(
filter
);
(
void
)
InterlockedDecrement
(
&
dev
->
property_window_count
);
}
void
videoInput
::
showSettingsWindow
(
int
id
){
bool
videoInput
::
showSettingsWindow
(
int
id
){
if
(
isDeviceSetup
(
id
)){
//HANDLE myTempThread;
//we reconnect to the device as we have freed our reference to it
//why have we freed our reference? because there seemed to be an issue
//with some mpeg devices if we didn't
HRESULT
hr
=
getDevice
(
&
VDList
[
id
]
->
pVideoInputFilter
,
id
,
VDList
[
id
]
->
wDeviceName
,
VDList
[
id
]
->
nDeviceName
);
if
(
hr
==
S_OK
){
//myTempThread = (HANDLE)
_beginthread
(
basicThread
,
0
,
(
void
*
)
&
VDList
[
id
]);
// XXX TODO compare fourcc for mpeg devices? is this comment still valid? -sh 20180104
videoDevice
*
dev
=
VDList
[
id
];
HRESULT
hr
=
getDevice
(
&
dev
->
pVideoInputFilter
,
id
,
dev
->
wDeviceName
,
dev
->
nDeviceName
);
if
(
hr
==
S_OK
)
{
// it's pointless to keep the filter around. it crashes in
// pGraph or ISampleGrabber anyway
//dev->pVideoInputFilter->AddRef();
int
new_window_count
=
InterlockedIncrement
(
&
dev
->
property_window_count
);
// don't open multiple property windows at a time.
// will cause the camera to confuse itself anyway.
if
(
new_window_count
==
1
)
{
_beginthread
(
basicThread
,
0
,
dev
);
return
true
;
}
else
(
void
)
InterlockedDecrement
(
&
dev
->
property_window_count
);
}
}
return
false
;
}
...
...
@@ -1639,8 +1656,10 @@ bool videoInput::getVideoSettingFilter(int deviceID, long Property, long &min, l
hr
=
VD
->
pVideoInputFilter
->
QueryInterface
(
IID_IAMVideoProcAmp
,
(
void
**
)
&
pAMVideoProcAmp
);
if
(
FAILED
(
hr
)){
DebugPrintOut
(
"setVideoSetting - QueryInterface Error
\n
"
);
#if 0
if(VD->pVideoInputFilter)VD->pVideoInputFilter->Release();
if(VD->pVideoInputFilter)VD->pVideoInputFilter = NULL;
#endif
return
false
;
}
...
...
@@ -1654,8 +1673,10 @@ bool videoInput::getVideoSettingFilter(int deviceID, long Property, long &min, l
pAMVideoProcAmp
->
Get
(
Property
,
&
currentValue
,
&
flags
);
if
(
pAMVideoProcAmp
)
pAMVideoProcAmp
->
Release
();
#if 0
if(VD->pVideoInputFilter)VD->pVideoInputFilter->Release();
if(VD->pVideoInputFilter)VD->pVideoInputFilter = NULL;
#endif
return
true
;
...
...
@@ -1721,8 +1742,10 @@ bool videoInput::setVideoSettingFilter(int deviceID, long Property, long lValue,
hr
=
VD
->
pVideoInputFilter
->
QueryInterface
(
IID_IAMVideoProcAmp
,
(
void
**
)
&
pAMVideoProcAmp
);
if
(
FAILED
(
hr
)){
DebugPrintOut
(
"setVideoSetting - QueryInterface Error
\n
"
);
#if 0
if(VD->pVideoInputFilter)VD->pVideoInputFilter->Release();
if(VD->pVideoInputFilter)VD->pVideoInputFilter = NULL;
#endif
return
false
;
}
...
...
@@ -1745,8 +1768,10 @@ bool videoInput::setVideoSettingFilter(int deviceID, long Property, long lValue,
}
if
(
pAMVideoProcAmp
)
pAMVideoProcAmp
->
Release
();
#if 0
if(VD->pVideoInputFilter)VD->pVideoInputFilter->Release();
if(VD->pVideoInputFilter)VD->pVideoInputFilter = NULL;
#endif
return
true
;
...
...
@@ -1802,8 +1827,10 @@ bool videoInput::setVideoSettingCamera(int deviceID, long Property, long lValue,
hr
=
VDList
[
deviceID
]
->
pVideoInputFilter
->
QueryInterface
(
IID_IAMCameraControl
,
(
void
**
)
&
pIAMCameraControl
);
if
(
FAILED
(
hr
))
{
DebugPrintOut
(
"Error
\n
"
);
#if 0
if(VDList[deviceID]->pVideoInputFilter)VDList[deviceID]->pVideoInputFilter->Release();
if(VDList[deviceID]->pVideoInputFilter)VDList[deviceID]->pVideoInputFilter = NULL;
#endif
return
false
;
}
else
...
...
@@ -1822,8 +1849,10 @@ bool videoInput::setVideoSettingCamera(int deviceID, long Property, long lValue,
pIAMCameraControl
->
Set
(
Property
,
lValue
,
Flags
);
}
pIAMCameraControl
->
Release
();
#if 0
if(VDList[deviceID]->pVideoInputFilter)VDList[deviceID]->pVideoInputFilter->Release();
if(VDList[deviceID]->pVideoInputFilter)VDList[deviceID]->pVideoInputFilter = NULL;
#endif
return
true
;
}
}
...
...
@@ -1851,8 +1880,10 @@ bool videoInput::getVideoSettingCamera(int deviceID, long Property, long &min, l
hr
=
VD
->
pVideoInputFilter
->
QueryInterface
(
IID_IAMCameraControl
,
(
void
**
)
&
pIAMCameraControl
);
if
(
FAILED
(
hr
)){
DebugPrintOut
(
"setVideoSetting - QueryInterface Error
\n
"
);
#if 0
if(VD->pVideoInputFilter)VD->pVideoInputFilter->Release();
if(VD->pVideoInputFilter)VD->pVideoInputFilter = NULL;
#endif
return
false
;
}
...
...
@@ -1865,8 +1896,10 @@ bool videoInput::getVideoSettingCamera(int deviceID, long Property, long &min, l
pIAMCameraControl
->
Get
(
Property
,
&
currentValue
,
&
flags
);
if
(
pIAMCameraControl
)
pIAMCameraControl
->
Release
();
#if 0
if(VD->pVideoInputFilter)VD->pVideoInputFilter->Release();
if(VD->pVideoInputFilter)VD->pVideoInputFilter = NULL;
#endif
return
true
;
...
...
@@ -2203,7 +2236,6 @@ void videoInput::getVideoPropertyAsString(int prop, char * propertyAsString){
int
videoInput
::
getVideoPropertyFromCV
(
int
cv_property
){
// see VideoProcAmpProperty in strmif.h
switch
(
cv_property
)
{
case
CV_CAP_PROP_BRIGHTNESS
:
...
...
@@ -2780,8 +2812,10 @@ int videoInput::start(int deviceID, videoDevice *VD){
//if we release this then we don't have access to the settings
//we release our video input filter but then reconnect with it
//each time we need to use it
#if 0
VD->pVideoInputFilter->Release();
VD->pVideoInputFilter = NULL;
#endif
VD
->
pGrabberF
->
Release
();
VD
->
pGrabberF
=
NULL
;
...
...
@@ -2902,8 +2936,12 @@ HRESULT videoInput::getDevice(IBaseFilter** gottaFilter, int deviceId, WCHAR * w
count
++
;
}
// We found it, so send it back to the caller
hr
=
pMoniker
->
BindToObject
(
NULL
,
NULL
,
IID_IBaseFilter
,
(
void
**
)
gottaFilter
);
// reuse existing filter due to webcam problems
if
(
*
gottaFilter
)
hr
=
S_OK
;
else
// We found it, so send it back to the caller
hr
=
pMoniker
->
BindToObject
(
NULL
,
NULL
,
IID_IBaseFilter
,
(
void
**
)
gottaFilter
);
done
=
true
;
}
VariantClear
(
&
varName
);
...
...
@@ -3125,6 +3163,14 @@ HRESULT videoInput::routeCrossbar(ICaptureGraphBuilder2 **ppBuild, IBaseFilter *
return
hr
;
}
int
videoInput
::
property_window_count
(
int
idx
)
{
if
(
isDeviceSetup
(
idx
))
return
(
int
)
InterlockedCompareExchange
(
&
VDList
[
idx
]
->
property_window_count
,
0L
,
0L
);
return
0
;
}
namespace
cv
{
videoInput
VideoCapture_DShow
::
g_VI
;
...
...
@@ -3189,6 +3235,11 @@ double VideoCapture_DShow::getProperty(int propIdx) const
return
(
double
)
current_value
;
}
if
(
propIdx
==
CV_CAP_PROP_SETTINGS
)
{
return
g_VI
.
property_window_count
(
m_index
);
}
// unknown parameter or value not available
return
-
1
;
}
...
...
@@ -3260,8 +3311,7 @@ bool VideoCapture_DShow::setProperty(int propIdx, double propVal)
// show video/camera filter dialog
if
(
propIdx
==
CV_CAP_PROP_SETTINGS
)
{
g_VI
.
showSettingsWindow
(
m_index
);
return
true
;
return
g_VI
.
showSettingsWindow
(
m_index
);
}
//video Filter properties
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录