{
HKEY hkey;
char szKey[1024];
- strcpy( szKey, icvWindowPosRootKey );
- strcat( szKey, name );
+ strcpy_s( szKey, 1024, icvWindowPosRootKey );
+ strcat_s( szKey, 1024, name );
rect.x = rect.y = CW_USEDEFAULT;
rect.width = rect.height = 320;
HKEY hkey;
char szKey[1024];
char rootKey[1024];
- strcpy( szKey, icvWindowPosRootKey );
- strcat( szKey, name );
+ strcpy_s( szKey, 1024, icvWindowPosRootKey );
+ strcat_s( szKey, 1024, name );
if( RegOpenKeyEx( HKEY_CURRENT_USER,szKey,0,KEY_READ,&hkey) != ERROR_SUCCESS )
{
char oldestKey[1024];
char currentKey[1024];
- strcpy( rootKey, icvWindowPosRootKey );
+ strcpy_s( rootKey, 1024, icvWindowPosRootKey );
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 )
//RegOpenKeyEx( HKEY_CURRENT_USER,rootKey,0,KEY_READ,&hroot) != ERROR_SUCCESS )
oldestTime.dwLowDateTime > accesstime.dwLowDateTime) )
{
oldestTime = accesstime;
- strcpy( oldestKey, currentKey );
+ strcpy_s( oldestKey, 1024, currentKey );
}
}
rgn = CreateRectRgn(0, 0, wrc.right, wrc.bottom);
rgn1 = CreateRectRgn(cr.left, cr.top, cr.right, cr.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, rgn2, RGN_DIFF);
IEnumPins *pins = NULL;
PIN_INFO pininfo;
HRESULT hr = pBF->EnumPins(&pins);
+ if (hr != S_OK || !pins)
+ return;
pins->Reset();
while (hr == NOERROR)
{
pP->Release();
}
}
- if (pins) pins->Release();
+ pins->Release();
}
(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);
}
IAMVideoProcAmp *pAMVideoProcAmp = NULL;
hr = VD->pVideoInputFilter->QueryInterface(IID_IAMVideoProcAmp, (void**)&pAMVideoProcAmp);
- if(FAILED(hr)){
+ if(FAILED(hr) || !pAMVideoProcAmp){
DebugPrintOut("setVideoSetting - QueryInterface Error\n");
#if 0
if(VD->pVideoInputFilter)VD->pVideoInputFilter->Release();
hr = pAMVideoProcAmp->Get(Property, ¤tValue, &flags);
}
- if(pAMVideoProcAmp)pAMVideoProcAmp->Release();
+ pAMVideoProcAmp->Release();
#if 0
if(VD->pVideoInputFilter)VD->pVideoInputFilter->Release();
if(VD->pVideoInputFilter)VD->pVideoInputFilter = NULL;
IAMCameraControl *pIAMCameraControl = NULL;
hr = VD->pVideoInputFilter->QueryInterface(IID_IAMCameraControl, (void**)&pIAMCameraControl);
- if(FAILED(hr)){
+ if(FAILED(hr) || !pIAMCameraControl){
DebugPrintOut("setVideoSetting - QueryInterface Error\n");
#if 0
if(VD->pVideoInputFilter)VD->pVideoInputFilter->Release();
hr = pIAMCameraControl->Get(Property, ¤tValue, &flags);
}
- if(pIAMCameraControl)pIAMCameraControl->Release();
+ pIAMCameraControl->Release();
#if 0
if(VD->pVideoInputFilter)VD->pVideoInputFilter->Release();
if(VD->pVideoInputFilter)VD->pVideoInputFilter = NULL;
//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);
- if(FAILED(hr)){
+ if(FAILED(hr) || !VD->streamConf){
DebugPrintOut("ERROR: Couldn't config the stream!\n");
stopDevice(deviceID);
return hr;
//lets try freeing our stream conf here too
//this will fail if the device is already running
- if(VD->streamConf){
- VD->streamConf->Release();
- VD->streamConf = NULL;
- }else{
- DebugPrintOut("ERROR: connecting device - prehaps it is already being used?\n");
- stopDevice(deviceID);
- return S_FALSE;
- }
+ VD->streamConf->Release();
+ VD->streamConf = NULL;
//NULL RENDERER//
IAMCrossbar *pXBar1 = NULL;
HRESULT hr = pBuild->FindInterface(&LOOK_UPSTREAM_ONLY, NULL, pVidFilter,
IID_IAMCrossbar, (void**)&pXBar1);
- if (SUCCEEDED(hr))
+ if (SUCCEEDED(hr) && pXBar1)
{
bool foundDevice = false;
//we were getting a crash otherwise
//if(Crossbar)Crossbar->Release();
//if(Crossbar)Crossbar = NULL;
-
- if(pXBar1)pXBar1->Release();
- if(pXBar1)pXBar1 = NULL;
-
}else{
DebugPrintOut("SETUP: You are a webcam or snazzy firewire cam! No Crossbar needed\n");
return hr;
static FN_MFCreateDXGIDeviceManager pMFCreateDXGIDeviceManager = NULL;
static void init_MFCreateDXGIDeviceManager()
{
- HMODULE h = LoadLibraryA("mfplat.dll");
+ HMODULE h = LoadLibraryExA("mfplat.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
if (h)
{
pMFCreateDXGIDeviceManager = (FN_MFCreateDXGIDeviceManager)GetProcAddress(h, "MFCreateDXGIDeviceManager");
return setTime(duration * value, true);
break;
case CV_CAP_PROP_POS_FRAMES:
- if (getFramerate(nativeFormat) != 0)
+ if (std::fabs(getFramerate(nativeFormat)) > 0)
return setTime(value * 1e7 / getFramerate(nativeFormat), false);
break;
case CV_CAP_PROP_POS_MSEC:
CvVideoWriter_MSMF::CvVideoWriter_MSMF():
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)
{
}
if (!hWnd) return FALSE;
capture = (CvCaptureCAM_VFW*)capGetUserData(hWnd);
+ if (!capture) return (LRESULT)FALSE;
capture->hdr = hdr;
-
return (LRESULT)TRUE;
}