Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
e031bada
Commit
e031bada
authored
Jul 27, 2018
by
Maksim Shabunin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed several issues found by static analysis, Windows-specific
parent
2f0fc920
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
40 deletions
+33
-40
window_w32.cpp
modules/highgui/src/window_w32.cpp
+8
-6
cap_dshow.cpp
modules/videoio/src/cap_dshow.cpp
+11
-30
cap_msmf.cpp
modules/videoio/src/cap_msmf.cpp
+13
-3
cap_vfw.cpp
modules/videoio/src/cap_vfw.cpp
+1
-1
No files found.
modules/highgui/src/window_w32.cpp
View file @
e031bada
...
@@ -307,8 +307,8 @@ icvLoadWindowPos( const char* name, CvRect& rect )
...
@@ -307,8 +307,8 @@ icvLoadWindowPos( const char* name, CvRect& rect )
{
{
HKEY
hkey
;
HKEY
hkey
;
char
szKey
[
1024
];
char
szKey
[
1024
];
strcpy
(
szKey
,
icvWindowPosRootKey
);
strcpy
_s
(
szKey
,
1024
,
icvWindowPosRootKey
);
strcat
(
szKey
,
name
);
strcat
_s
(
szKey
,
1024
,
name
);
rect
.
x
=
rect
.
y
=
CW_USEDEFAULT
;
rect
.
x
=
rect
.
y
=
CW_USEDEFAULT
;
rect
.
width
=
rect
.
height
=
320
;
rect
.
width
=
rect
.
height
=
320
;
...
@@ -368,8 +368,8 @@ icvSaveWindowPos( const char* name, CvRect rect )
...
@@ -368,8 +368,8 @@ icvSaveWindowPos( const char* name, CvRect rect )
HKEY
hkey
;
HKEY
hkey
;
char
szKey
[
1024
];
char
szKey
[
1024
];
char
rootKey
[
1024
];
char
rootKey
[
1024
];
strcpy
(
szKey
,
icvWindowPosRootKey
);
strcpy
_s
(
szKey
,
1024
,
icvWindowPosRootKey
);
strcat
(
szKey
,
name
);
strcat
_s
(
szKey
,
1024
,
name
);
if
(
RegOpenKeyEx
(
HKEY_CURRENT_USER
,
szKey
,
0
,
KEY_READ
,
&
hkey
)
!=
ERROR_SUCCESS
)
if
(
RegOpenKeyEx
(
HKEY_CURRENT_USER
,
szKey
,
0
,
KEY_READ
,
&
hkey
)
!=
ERROR_SUCCESS
)
{
{
...
@@ -379,7 +379,7 @@ icvSaveWindowPos( const char* name, CvRect rect )
...
@@ -379,7 +379,7 @@ icvSaveWindowPos( const char* name, CvRect rect )
char
oldestKey
[
1024
];
char
oldestKey
[
1024
];
char
currentKey
[
1024
];
char
currentKey
[
1024
];
strcpy
(
rootKey
,
icvWindowPosRootKey
);
strcpy
_s
(
rootKey
,
1024
,
icvWindowPosRootKey
);
rootKey
[
strlen
(
rootKey
)
-
1
]
=
'\0'
;
rootKey
[
strlen
(
rootKey
)
-
1
]
=
'\0'
;
if
(
RegCreateKeyEx
(
HKEY_CURRENT_USER
,
rootKey
,
0
,
NULL
,
REG_OPTION_NON_VOLATILE
,
KEY_READ
+
KEY_WRITE
,
0
,
&
hroot
,
NULL
)
!=
ERROR_SUCCESS
)
if
(
RegCreateKeyEx
(
HKEY_CURRENT_USER
,
rootKey
,
0
,
NULL
,
REG_OPTION_NON_VOLATILE
,
KEY_READ
+
KEY_WRITE
,
0
,
&
hroot
,
NULL
)
!=
ERROR_SUCCESS
)
//RegOpenKeyEx( HKEY_CURRENT_USER,rootKey,0,KEY_READ,&hroot) != ERROR_SUCCESS )
//RegOpenKeyEx( HKEY_CURRENT_USER,rootKey,0,KEY_READ,&hroot) != ERROR_SUCCESS )
...
@@ -398,7 +398,7 @@ icvSaveWindowPos( const char* name, CvRect rect )
...
@@ -398,7 +398,7 @@ icvSaveWindowPos( const char* name, CvRect rect )
oldestTime
.
dwLowDateTime
>
accesstime
.
dwLowDateTime
)
)
oldestTime
.
dwLowDateTime
>
accesstime
.
dwLowDateTime
)
)
{
{
oldestTime
=
accesstime
;
oldestTime
=
accesstime
;
strcpy
(
oldestKey
,
currentKey
);
strcpy
_s
(
oldestKey
,
1024
,
currentKey
);
}
}
}
}
...
@@ -1500,6 +1500,8 @@ MainWindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
...
@@ -1500,6 +1500,8 @@ MainWindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
rgn
=
CreateRectRgn
(
0
,
0
,
wrc
.
right
,
wrc
.
bottom
);
rgn
=
CreateRectRgn
(
0
,
0
,
wrc
.
right
,
wrc
.
bottom
);
rgn1
=
CreateRectRgn
(
cr
.
left
,
cr
.
top
,
cr
.
right
,
cr
.
bottom
);
rgn1
=
CreateRectRgn
(
cr
.
left
,
cr
.
top
,
cr
.
right
,
cr
.
bottom
);
rgn2
=
CreateRectRgn
(
tr
.
left
,
tr
.
top
,
tr
.
right
,
tr
.
bottom
);
rgn2
=
CreateRectRgn
(
tr
.
left
,
tr
.
top
,
tr
.
right
,
tr
.
bottom
);
CV_Assert
(
rgn
!=
0
,
rgn1
!=
0
,
rgn2
!=
0
);
ret
=
CombineRgn
(
rgn
,
rgn
,
rgn1
,
RGN_DIFF
);
ret
=
CombineRgn
(
rgn
,
rgn
,
rgn1
,
RGN_DIFF
);
ret
=
CombineRgn
(
rgn
,
rgn
,
rgn2
,
RGN_DIFF
);
ret
=
CombineRgn
(
rgn
,
rgn
,
rgn2
,
RGN_DIFF
);
...
...
modules/videoio/src/cap_dshow.cpp
View file @
e031bada
...
@@ -811,6 +811,8 @@ void videoDevice::NukeDownstream(IBaseFilter *pBF){
...
@@ -811,6 +811,8 @@ void videoDevice::NukeDownstream(IBaseFilter *pBF){
IEnumPins
*
pins
=
NULL
;
IEnumPins
*
pins
=
NULL
;
PIN_INFO
pininfo
;
PIN_INFO
pininfo
;
HRESULT
hr
=
pBF
->
EnumPins
(
&
pins
);
HRESULT
hr
=
pBF
->
EnumPins
(
&
pins
);
if
(
hr
!=
S_OK
||
!
pins
)
return
;
pins
->
Reset
();
pins
->
Reset
();
while
(
hr
==
NOERROR
)
while
(
hr
==
NOERROR
)
{
{
...
@@ -838,7 +840,7 @@ void videoDevice::NukeDownstream(IBaseFilter *pBF){
...
@@ -838,7 +840,7 @@ void videoDevice::NukeDownstream(IBaseFilter *pBF){
pP
->
Release
();
pP
->
Release
();
}
}
}
}
if
(
pins
)
pins
->
Release
();
pins
->
Release
();
}
}
...
@@ -999,17 +1001,6 @@ videoDevice::~videoDevice(){
...
@@ -999,17 +1001,6 @@ videoDevice::~videoDevice(){
(
pGraph
)
=
0
;
(
pGraph
)
=
0
;
}
}
//delete our pointers
delete
pDestFilter
;
delete
pVideoInputFilter
;
delete
pGrabberF
;
delete
pGrabber
;
delete
pControl
;
delete
streamConf
;
delete
pMediaEvent
;
delete
pCaptureGraph
;
delete
pGraph
;
DebugPrintOut
(
"SETUP: Device %i disconnected and freed
\n\n
"
,
myID
);
DebugPrintOut
(
"SETUP: Device %i disconnected and freed
\n\n
"
,
myID
);
}
}
...
@@ -1654,7 +1645,7 @@ bool videoInput::getVideoSettingFilter(int deviceID, long Property, long &min, l
...
@@ -1654,7 +1645,7 @@ bool videoInput::getVideoSettingFilter(int deviceID, long Property, long &min, l
IAMVideoProcAmp
*
pAMVideoProcAmp
=
NULL
;
IAMVideoProcAmp
*
pAMVideoProcAmp
=
NULL
;
hr
=
VD
->
pVideoInputFilter
->
QueryInterface
(
IID_IAMVideoProcAmp
,
(
void
**
)
&
pAMVideoProcAmp
);
hr
=
VD
->
pVideoInputFilter
->
QueryInterface
(
IID_IAMVideoProcAmp
,
(
void
**
)
&
pAMVideoProcAmp
);
if
(
FAILED
(
hr
)){
if
(
FAILED
(
hr
)
||
!
pAMVideoProcAmp
){
DebugPrintOut
(
"setVideoSetting - QueryInterface Error
\n
"
);
DebugPrintOut
(
"setVideoSetting - QueryInterface Error
\n
"
);
#if 0
#if 0
if(VD->pVideoInputFilter)VD->pVideoInputFilter->Release();
if(VD->pVideoInputFilter)VD->pVideoInputFilter->Release();
...
@@ -1676,7 +1667,7 @@ bool videoInput::getVideoSettingFilter(int deviceID, long Property, long &min, l
...
@@ -1676,7 +1667,7 @@ bool videoInput::getVideoSettingFilter(int deviceID, long Property, long &min, l
hr
=
pAMVideoProcAmp
->
Get
(
Property
,
&
currentValue
,
&
flags
);
hr
=
pAMVideoProcAmp
->
Get
(
Property
,
&
currentValue
,
&
flags
);
}
}
if
(
pAMVideoProcAmp
)
pAMVideoProcAmp
->
Release
();
pAMVideoProcAmp
->
Release
();
#if 0
#if 0
if(VD->pVideoInputFilter)VD->pVideoInputFilter->Release();
if(VD->pVideoInputFilter)VD->pVideoInputFilter->Release();
if(VD->pVideoInputFilter)VD->pVideoInputFilter = NULL;
if(VD->pVideoInputFilter)VD->pVideoInputFilter = NULL;
...
@@ -1881,7 +1872,7 @@ bool videoInput::getVideoSettingCamera(int deviceID, long Property, long &min, l
...
@@ -1881,7 +1872,7 @@ bool videoInput::getVideoSettingCamera(int deviceID, long Property, long &min, l
IAMCameraControl
*
pIAMCameraControl
=
NULL
;
IAMCameraControl
*
pIAMCameraControl
=
NULL
;
hr
=
VD
->
pVideoInputFilter
->
QueryInterface
(
IID_IAMCameraControl
,
(
void
**
)
&
pIAMCameraControl
);
hr
=
VD
->
pVideoInputFilter
->
QueryInterface
(
IID_IAMCameraControl
,
(
void
**
)
&
pIAMCameraControl
);
if
(
FAILED
(
hr
)){
if
(
FAILED
(
hr
)
||
!
pIAMCameraControl
){
DebugPrintOut
(
"setVideoSetting - QueryInterface Error
\n
"
);
DebugPrintOut
(
"setVideoSetting - QueryInterface Error
\n
"
);
#if 0
#if 0
if(VD->pVideoInputFilter)VD->pVideoInputFilter->Release();
if(VD->pVideoInputFilter)VD->pVideoInputFilter->Release();
...
@@ -1902,7 +1893,7 @@ bool videoInput::getVideoSettingCamera(int deviceID, long Property, long &min, l
...
@@ -1902,7 +1893,7 @@ bool videoInput::getVideoSettingCamera(int deviceID, long Property, long &min, l
hr
=
pIAMCameraControl
->
Get
(
Property
,
&
currentValue
,
&
flags
);
hr
=
pIAMCameraControl
->
Get
(
Property
,
&
currentValue
,
&
flags
);
}
}
if
(
pIAMCameraControl
)
pIAMCameraControl
->
Release
();
pIAMCameraControl
->
Release
();
#if 0
#if 0
if(VD->pVideoInputFilter)VD->pVideoInputFilter->Release();
if(VD->pVideoInputFilter)VD->pVideoInputFilter->Release();
if(VD->pVideoInputFilter)VD->pVideoInputFilter = NULL;
if(VD->pVideoInputFilter)VD->pVideoInputFilter = NULL;
...
@@ -2595,7 +2586,7 @@ int videoInput::start(int deviceID, videoDevice *VD){
...
@@ -2595,7 +2586,7 @@ int videoInput::start(int deviceID, videoDevice *VD){
//we do this because webcams don't have a preview mode
//we do this because webcams don't have a preview mode
hr
=
VD
->
pCaptureGraph
->
FindInterface
(
&
CAPTURE_MODE
,
&
MEDIATYPE_Video
,
VD
->
pVideoInputFilter
,
IID_IAMStreamConfig
,
(
void
**
)
&
VD
->
streamConf
);
hr
=
VD
->
pCaptureGraph
->
FindInterface
(
&
CAPTURE_MODE
,
&
MEDIATYPE_Video
,
VD
->
pVideoInputFilter
,
IID_IAMStreamConfig
,
(
void
**
)
&
VD
->
streamConf
);
if
(
FAILED
(
hr
)){
if
(
FAILED
(
hr
)
||
!
VD
->
streamConf
){
DebugPrintOut
(
"ERROR: Couldn't config the stream!
\n
"
);
DebugPrintOut
(
"ERROR: Couldn't config the stream!
\n
"
);
stopDevice
(
deviceID
);
stopDevice
(
deviceID
);
return
hr
;
return
hr
;
...
@@ -2737,14 +2728,8 @@ int videoInput::start(int deviceID, videoDevice *VD){
...
@@ -2737,14 +2728,8 @@ int videoInput::start(int deviceID, videoDevice *VD){
//lets try freeing our stream conf here too
//lets try freeing our stream conf here too
//this will fail if the device is already running
//this will fail if the device is already running
if
(
VD
->
streamConf
){
VD
->
streamConf
->
Release
();
VD
->
streamConf
->
Release
();
VD
->
streamConf
=
NULL
;
VD
->
streamConf
=
NULL
;
}
else
{
DebugPrintOut
(
"ERROR: connecting device - prehaps it is already being used?
\n
"
);
stopDevice
(
deviceID
);
return
S_FALSE
;
}
//NULL RENDERER//
//NULL RENDERER//
...
@@ -3093,7 +3078,7 @@ HRESULT videoInput::routeCrossbar(ICaptureGraphBuilder2 **ppBuild, IBaseFilter *
...
@@ -3093,7 +3078,7 @@ HRESULT videoInput::routeCrossbar(ICaptureGraphBuilder2 **ppBuild, IBaseFilter *
IAMCrossbar
*
pXBar1
=
NULL
;
IAMCrossbar
*
pXBar1
=
NULL
;
HRESULT
hr
=
pBuild
->
FindInterface
(
&
LOOK_UPSTREAM_ONLY
,
NULL
,
pVidFilter
,
HRESULT
hr
=
pBuild
->
FindInterface
(
&
LOOK_UPSTREAM_ONLY
,
NULL
,
pVidFilter
,
IID_IAMCrossbar
,
(
void
**
)
&
pXBar1
);
IID_IAMCrossbar
,
(
void
**
)
&
pXBar1
);
if
(
SUCCEEDED
(
hr
))
if
(
SUCCEEDED
(
hr
)
&&
pXBar1
)
{
{
bool
foundDevice
=
false
;
bool
foundDevice
=
false
;
...
@@ -3163,10 +3148,6 @@ HRESULT videoInput::routeCrossbar(ICaptureGraphBuilder2 **ppBuild, IBaseFilter *
...
@@ -3163,10 +3148,6 @@ HRESULT videoInput::routeCrossbar(ICaptureGraphBuilder2 **ppBuild, IBaseFilter *
//we were getting a crash otherwise
//we were getting a crash otherwise
//if(Crossbar)Crossbar->Release();
//if(Crossbar)Crossbar->Release();
//if(Crossbar)Crossbar = NULL;
//if(Crossbar)Crossbar = NULL;
if
(
pXBar1
)
pXBar1
->
Release
();
if
(
pXBar1
)
pXBar1
=
NULL
;
}
else
{
}
else
{
DebugPrintOut
(
"SETUP: You are a webcam or snazzy firewire cam! No Crossbar needed
\n
"
);
DebugPrintOut
(
"SETUP: You are a webcam or snazzy firewire cam! No Crossbar needed
\n
"
);
return
hr
;
return
hr
;
...
...
modules/videoio/src/cap_msmf.cpp
View file @
e031bada
...
@@ -91,7 +91,7 @@ static bool pMFCreateDXGIDeviceManager_initialized = false;
...
@@ -91,7 +91,7 @@ static bool pMFCreateDXGIDeviceManager_initialized = false;
static
FN_MFCreateDXGIDeviceManager
pMFCreateDXGIDeviceManager
=
NULL
;
static
FN_MFCreateDXGIDeviceManager
pMFCreateDXGIDeviceManager
=
NULL
;
static
void
init_MFCreateDXGIDeviceManager
()
static
void
init_MFCreateDXGIDeviceManager
()
{
{
HMODULE
h
=
LoadLibrary
A
(
"mfplat.dll"
);
HMODULE
h
=
LoadLibrary
ExA
(
"mfplat.dll"
,
NULL
,
LOAD_LIBRARY_SEARCH_SYSTEM32
);
if
(
h
)
if
(
h
)
{
{
pMFCreateDXGIDeviceManager
=
(
FN_MFCreateDXGIDeviceManager
)
GetProcAddress
(
h
,
"MFCreateDXGIDeviceManager"
);
pMFCreateDXGIDeviceManager
=
(
FN_MFCreateDXGIDeviceManager
)
GetProcAddress
(
h
,
"MFCreateDXGIDeviceManager"
);
...
@@ -1720,7 +1720,7 @@ bool CvCapture_MSMF::setProperty( int property_id, double value )
...
@@ -1720,7 +1720,7 @@ bool CvCapture_MSMF::setProperty( int property_id, double value )
return
setTime
(
duration
*
value
,
true
);
return
setTime
(
duration
*
value
,
true
);
break
;
break
;
case
CV_CAP_PROP_POS_FRAMES
:
case
CV_CAP_PROP_POS_FRAMES
:
if
(
getFramerate
(
nativeFormat
)
!=
0
)
if
(
std
::
fabs
(
getFramerate
(
nativeFormat
))
>
0
)
return
setTime
(
value
*
1e7
/
getFramerate
(
nativeFormat
),
false
);
return
setTime
(
value
*
1e7
/
getFramerate
(
nativeFormat
),
false
);
break
;
break
;
case
CV_CAP_PROP_POS_MSEC
:
case
CV_CAP_PROP_POS_MSEC
:
...
@@ -1978,7 +1978,17 @@ private:
...
@@ -1978,7 +1978,17 @@ private:
CvVideoWriter_MSMF
::
CvVideoWriter_MSMF
()
:
CvVideoWriter_MSMF
::
CvVideoWriter_MSMF
()
:
MF
(
Media_Foundation
::
getInstance
()),
MF
(
Media_Foundation
::
getInstance
()),
initiated
(
false
)
videoWidth
(
0
),
videoHeight
(
0
),
fps
(
0
),
bitRate
(
0
),
frameSize
(
0
),
encodingFormat
(),
inputFormat
(),
streamIndex
(
0
),
initiated
(
false
),
rtStart
(
0
),
rtDuration
(
0
)
{
{
}
}
...
...
modules/videoio/src/cap_vfw.cpp
View file @
e031bada
...
@@ -377,8 +377,8 @@ LRESULT PASCAL CvCaptureCAM_VFW::frameCallback( HWND hWnd, VIDEOHDR* hdr )
...
@@ -377,8 +377,8 @@ LRESULT PASCAL CvCaptureCAM_VFW::frameCallback( HWND hWnd, VIDEOHDR* hdr )
if
(
!
hWnd
)
return
FALSE
;
if
(
!
hWnd
)
return
FALSE
;
capture
=
(
CvCaptureCAM_VFW
*
)
capGetUserData
(
hWnd
);
capture
=
(
CvCaptureCAM_VFW
*
)
capGetUserData
(
hWnd
);
if
(
!
capture
)
return
(
LRESULT
)
FALSE
;
capture
->
hdr
=
hdr
;
capture
->
hdr
=
hdr
;
return
(
LRESULT
)
TRUE
;
return
(
LRESULT
)
TRUE
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment