@ -86,7 +86,7 @@
# include <mferror.h>
# include <mferror.h>
# ifdef HAVE_ WINRT
# ifdef WINRT
// for ComPtr usage
// for ComPtr usage
# include <wrl/client.h>
# include <wrl/client.h>
# ifdef __cplusplus_winrt
# ifdef __cplusplus_winrt
@ -266,7 +266,7 @@ public:
# endif
# endif
struct IMFMediaType ;
struct IMFMediaType ;
# ifndef HAVE_ WINRT
# ifndef WINRT
struct IMFActivate ;
struct IMFActivate ;
struct IMFMediaSource ;
struct IMFMediaSource ;
# endif
# endif
@ -406,7 +406,7 @@ private:
ImageGrabberCallback & operator = ( const ImageGrabberCallback & ) ; // Declared to fix compilation warning.
ImageGrabberCallback & operator = ( const ImageGrabberCallback & ) ; // Declared to fix compilation warning.
} ;
} ;
# ifdef HAVE_ WINRT
# ifdef WINRT
extern const __declspec ( selectany ) WCHAR RuntimeClass_CV_ImageGrabberWinRT [ ] = L " cv.ImageGrabberWinRT " ;
extern const __declspec ( selectany ) WCHAR RuntimeClass_CV_ImageGrabberWinRT [ ] = L " cv.ImageGrabberWinRT " ;
class ImageGrabberWinRT :
class ImageGrabberWinRT :
@ -547,7 +547,7 @@ public:
CamParametrs getParametrs ( ) ;
CamParametrs getParametrs ( ) ;
void setParametrs ( CamParametrs parametrs ) ;
void setParametrs ( CamParametrs parametrs ) ;
void setEmergencyStopEvent ( void * userData , void ( * func ) ( int , void * ) ) ;
void setEmergencyStopEvent ( void * userData , void ( * func ) ( int , void * ) ) ;
# ifdef HAVE_ WINRT
# ifdef WINRT
long readInfoOfDevice ( MAKE_WRL_REF ( _IDeviceInformation ) pDevice , unsigned int Num ) ;
long readInfoOfDevice ( MAKE_WRL_REF ( _IDeviceInformation ) pDevice , unsigned int Num ) ;
void waitForDevice ( )
void waitForDevice ( )
{
{
@ -593,7 +593,7 @@ private:
std : : map < UINT64 , FrameRateMap > vd_CaptureFormats ;
std : : map < UINT64 , FrameRateMap > vd_CaptureFormats ;
std : : vector < MediaType > vd_CurrentFormats ;
std : : vector < MediaType > vd_CurrentFormats ;
IMFMediaSource * vd_pSource ;
IMFMediaSource * vd_pSource ;
# ifdef HAVE_ WINRT
# ifdef WINRT
MAKE_WRL_AGILE_REF ( _MediaCapture ) vd_pMedCap ;
MAKE_WRL_AGILE_REF ( _MediaCapture ) vd_pMedCap ;
EventRegistrationToken vd_cookie ;
EventRegistrationToken vd_cookie ;
ImageGrabberWinRT * vd_pImGr ;
ImageGrabberWinRT * vd_pImGr ;
@ -608,7 +608,7 @@ private:
long setDeviceFormat ( IMFMediaSource * pSource , unsigned long dwFormatIndex ) ;
long setDeviceFormat ( IMFMediaSource * pSource , unsigned long dwFormatIndex ) ;
void buildLibraryofTypes ( ) ;
void buildLibraryofTypes ( ) ;
int findType ( unsigned int size , unsigned int frameRate = 0 ) ;
int findType ( unsigned int size , unsigned int frameRate = 0 ) ;
# ifdef HAVE_ WINRT
# ifdef WINRT
HRESULT enumerateCaptureFormats ( MAKE_WRL_REF ( _MediaCapture ) pSource ) ;
HRESULT enumerateCaptureFormats ( MAKE_WRL_REF ( _MediaCapture ) pSource ) ;
long setDeviceFormat ( MAKE_WRL_REF ( _MediaCapture ) pSource , unsigned long dwFormatIndex , MAKE_WRL_REF ( _AsyncAction ) * pAction ) ;
long setDeviceFormat ( MAKE_WRL_REF ( _MediaCapture ) pSource , unsigned long dwFormatIndex , MAKE_WRL_REF ( _AsyncAction ) * pAction ) ;
long resetDevice ( MAKE_WRL_REF ( _IDeviceInformation ) pDevice ) ;
long resetDevice ( MAKE_WRL_REF ( _IDeviceInformation ) pDevice ) ;
@ -627,7 +627,7 @@ class videoDevices
{
{
public :
public :
~ videoDevices ( void ) ;
~ videoDevices ( void ) ;
# ifdef HAVE_ WINRT
# ifdef WINRT
long initDevices ( _DeviceClass devClass ) ;
long initDevices ( _DeviceClass devClass ) ;
void waitInit ( ) {
void waitInit ( ) {
if ( vds_enumTask ) {
if ( vds_enumTask ) {
@ -646,7 +646,7 @@ public:
void clearDevices ( ) ;
void clearDevices ( ) ;
private :
private :
UINT32 count ;
UINT32 count ;
# ifdef HAVE_ WINRT
# ifdef WINRT
MAKE_WRL_REF ( _AsyncAction ) vds_enumTask ;
MAKE_WRL_REF ( _AsyncAction ) vds_enumTask ;
# endif
# endif
std : : vector < videoDevice * > vds_Devices ;
std : : vector < videoDevice * > vds_Devices ;
@ -715,7 +715,7 @@ public:
bool setupDevice ( int deviceID , unsigned int w , unsigned int h , unsigned int idealFramerate = 30 ) ;
bool setupDevice ( int deviceID , unsigned int w , unsigned int h , unsigned int idealFramerate = 30 ) ;
// Checking of recivig of new frame from video device with deviceID
// Checking of recivig of new frame from video device with deviceID
bool isFrameNew ( int deviceID ) ;
bool isFrameNew ( int deviceID ) ;
# ifdef HAVE_ WINRT
# ifdef WINRT
void waitForDevice ( int deviceID ) ;
void waitForDevice ( int deviceID ) ;
# endif
# endif
// Writing of Raw Data pixels from video device with deviceID with correction of RedAndBlue flipping flipRedAndBlue and vertical flipping flipImage
// Writing of Raw Data pixels from video device with deviceID with correction of RedAndBlue flipping flipRedAndBlue and vertical flipping flipImage
@ -1237,7 +1237,7 @@ ImageGrabber::~ImageGrabber(void)
DebugPrintOut ( L " IMAGEGRABBER VIDEODEVICE %i: Destroying instance of the ImageGrabber class \n " , ig_DeviceID ) ;
DebugPrintOut ( L " IMAGEGRABBER VIDEODEVICE %i: Destroying instance of the ImageGrabber class \n " , ig_DeviceID ) ;
}
}
# ifdef HAVE_ WINRT
# ifdef WINRT
ImageGrabberWinRT : : ImageGrabberWinRT ( bool synchronous ) :
ImageGrabberWinRT : : ImageGrabberWinRT ( bool synchronous ) :
ImageGrabberCallback ( synchronous ) ,
ImageGrabberCallback ( synchronous ) ,
@ -1899,7 +1899,7 @@ Media_Foundation::~Media_Foundation(void)
bool Media_Foundation : : buildListOfDevices ( )
bool Media_Foundation : : buildListOfDevices ( )
{
{
HRESULT hr = S_OK ;
HRESULT hr = S_OK ;
# ifdef HAVE_ WINRT
# ifdef WINRT
videoDevices * vDs = & videoDevices : : getInstance ( ) ;
videoDevices * vDs = & videoDevices : : getInstance ( ) ;
hr = vDs - > initDevices ( WRL_ENUM_GET ( _DeviceClass , DeviceClass , VideoCapture ) ) ;
hr = vDs - > initDevices ( WRL_ENUM_GET ( _DeviceClass , DeviceClass , VideoCapture ) ) ;
# else
# else
@ -1987,7 +1987,7 @@ unsigned char * RawImage::getpPixels()
videoDevice : : videoDevice ( void ) : vd_IsSetuped ( false ) , vd_LockOut ( OpenLock ) , vd_pFriendlyName ( NULL ) ,
videoDevice : : videoDevice ( void ) : vd_IsSetuped ( false ) , vd_LockOut ( OpenLock ) , vd_pFriendlyName ( NULL ) ,
vd_Width ( 0 ) , vd_Height ( 0 ) , vd_FrameRate ( 0 ) , vd_pSource ( NULL ) , vd_pImGrTh ( NULL ) , vd_func ( NULL ) , vd_userData ( NULL )
vd_Width ( 0 ) , vd_Height ( 0 ) , vd_FrameRate ( 0 ) , vd_pSource ( NULL ) , vd_pImGrTh ( NULL ) , vd_func ( NULL ) , vd_userData ( NULL )
{
{
# ifdef HAVE_ WINRT
# ifdef WINRT
vd_pMedCap = nullptr ;
vd_pMedCap = nullptr ;
vd_cookie . value = 0 ;
vd_cookie . value = 0 ;
vd_pImGr = NULL ;
vd_pImGr = NULL ;
@ -2075,7 +2075,7 @@ CamParametrs videoDevice::getParametrs()
return out ;
return out ;
}
}
# ifdef HAVE_ WINRT
# ifdef WINRT
long videoDevice : : resetDevice ( MAKE_WRL_REF ( _IDeviceInformation ) pDevice )
long videoDevice : : resetDevice ( MAKE_WRL_REF ( _IDeviceInformation ) pDevice )
# else
# else
long videoDevice : : resetDevice ( IMFActivate * pActivate )
long videoDevice : : resetDevice ( IMFActivate * pActivate )
@ -2086,7 +2086,7 @@ long videoDevice::resetDevice(IMFActivate *pActivate)
if ( vd_pFriendlyName )
if ( vd_pFriendlyName )
CoTaskMemFree ( vd_pFriendlyName ) ;
CoTaskMemFree ( vd_pFriendlyName ) ;
vd_pFriendlyName = NULL ;
vd_pFriendlyName = NULL ;
# ifdef HAVE_ WINRT
# ifdef WINRT
if ( pDevice )
if ( pDevice )
{
{
ACTIVATE_OBJ ( RuntimeClass_Windows_Media_Capture_MediaCapture , _MediaCapture , pIMedCap , hr )
ACTIVATE_OBJ ( RuntimeClass_Windows_Media_Capture_MediaCapture , _MediaCapture , pIMedCap , hr )
@ -2157,7 +2157,7 @@ long videoDevice::resetDevice(IMFActivate *pActivate)
return hr ;
return hr ;
}
}
# ifdef HAVE_ WINRT
# ifdef WINRT
long videoDevice : : readInfoOfDevice ( MAKE_WRL_REF ( _IDeviceInformation ) pDevice , unsigned int Num )
long videoDevice : : readInfoOfDevice ( MAKE_WRL_REF ( _IDeviceInformation ) pDevice , unsigned int Num )
{
{
HRESULT hr = - 1 ;
HRESULT hr = - 1 ;
@ -2173,7 +2173,7 @@ long videoDevice::readInfoOfDevice(IMFActivate *pActivate, unsigned int Num)
}
}
# endif
# endif
# ifdef HAVE_ WINRT
# ifdef WINRT
# ifdef HAVE_CONCURRENCY
# ifdef HAVE_CONCURRENCY
long videoDevice : : checkDevice ( _DeviceClass devClass , DEFINE_TASK < void > * pTask , MAKE_WRL_REF ( _IDeviceInformation ) * ppDevice )
long videoDevice : : checkDevice ( _DeviceClass devClass , DEFINE_TASK < void > * pTask , MAKE_WRL_REF ( _IDeviceInformation ) * ppDevice )
{
{
@ -2273,7 +2273,7 @@ long videoDevice::initDevice()
{
{
HRESULT hr = S_OK ;
HRESULT hr = S_OK ;
CoInitialize ( NULL ) ;
CoInitialize ( NULL ) ;
# ifdef HAVE_ WINRT
# ifdef WINRT
# ifdef HAVE_CONCURRENCY
# ifdef HAVE_CONCURRENCY
Concurrency : : critical_section : : scoped_lock _LockHolder ( vd_lock ) ;
Concurrency : : critical_section : : scoped_lock _LockHolder ( vd_lock ) ;
MAKE_WRL_REF ( _AsyncAction ) pOldAction = vd_pAction ;
MAKE_WRL_REF ( _AsyncAction ) pOldAction = vd_pAction ;
@ -2381,7 +2381,7 @@ void videoDevice::closeDevice()
{
{
vd_IsSetuped = false ;
vd_IsSetuped = false ;
# ifdef HAVE_ WINRT
# ifdef WINRT
# ifdef HAVE_CONCURRENCY
# ifdef HAVE_CONCURRENCY
if ( DEREF_AGILE_WRL_OBJ ( vd_pMedCap ) ) {
if ( DEREF_AGILE_WRL_OBJ ( vd_pMedCap ) ) {
MAKE_WRL_REF ( _AsyncAction ) action ;
MAKE_WRL_REF ( _AsyncAction ) action ;
@ -2535,7 +2535,7 @@ void videoDevice::buildLibraryofTypes()
}
}
}
}
# ifdef HAVE_ WINRT
# ifdef WINRT
long videoDevice : : setDeviceFormat ( MAKE_WRL_REF ( _MediaCapture ) pSource , unsigned long dwFormatIndex , MAKE_WRL_REF ( _AsyncAction ) * pAction )
long videoDevice : : setDeviceFormat ( MAKE_WRL_REF ( _MediaCapture ) pSource , unsigned long dwFormatIndex , MAKE_WRL_REF ( _AsyncAction ) * pAction )
{
{
HRESULT hr ;
HRESULT hr ;
@ -2596,7 +2596,7 @@ bool videoDevice::isDeviceSetup()
RawImage * videoDevice : : getRawImageOut ( )
RawImage * videoDevice : : getRawImageOut ( )
{
{
if ( ! vd_IsSetuped ) return NULL ;
if ( ! vd_IsSetuped ) return NULL ;
# ifdef HAVE_ WINRT
# ifdef WINRT
if ( vd_pImGr ) return vd_pImGr - > getRawImage ( ) ;
if ( vd_pImGr ) return vd_pImGr - > getRawImage ( ) ;
# endif
# endif
if ( vd_pImGrTh )
if ( vd_pImGrTh )
@ -2618,7 +2618,7 @@ bool videoDevice::isFrameNew()
vd_LockOut = RawDataLock ;
vd_LockOut = RawDataLock ;
//must already be closed
//must already be closed
# ifdef HAVE_ WINRT
# ifdef WINRT
if ( DEREF_AGILE_WRL_OBJ ( vd_pMedCap ) ) {
if ( DEREF_AGILE_WRL_OBJ ( vd_pMedCap ) ) {
MAKE_WRL_REF ( _AsyncAction ) action ;
MAKE_WRL_REF ( _AsyncAction ) action ;
if ( FAILED ( ImageGrabberWinRT : : CreateInstance ( & vd_pImGr ) ) ) return false ;
if ( FAILED ( ImageGrabberWinRT : : CreateInstance ( & vd_pImGr ) ) ) return false ;
@ -2649,7 +2649,7 @@ bool videoDevice::isFrameNew()
vd_pImGrTh - > start ( ) ;
vd_pImGrTh - > start ( ) ;
return true ;
return true ;
}
}
# ifdef HAVE_ WINRT
# ifdef WINRT
if ( vd_pImGr )
if ( vd_pImGr )
return vd_pImGr - > getRawImage ( ) - > isNew ( ) ;
return vd_pImGr - > getRawImage ( ) - > isNew ( ) ;
# endif
# endif
@ -2678,7 +2678,7 @@ bool videoDevice::setupDevice(unsigned int id)
HRESULT hr = initDevice ( ) ;
HRESULT hr = initDevice ( ) ;
if ( SUCCEEDED ( hr ) )
if ( SUCCEEDED ( hr ) )
{
{
# ifdef HAVE_ WINRT
# ifdef WINRT
# ifdef HAVE_CONCURRENCY
# ifdef HAVE_CONCURRENCY
Concurrency : : critical_section : : scoped_lock _LockHolder ( vd_lock ) ;
Concurrency : : critical_section : : scoped_lock _LockHolder ( vd_lock ) ;
MAKE_WRL_REF ( _AsyncAction ) pOldAction = vd_pAction ;
MAKE_WRL_REF ( _AsyncAction ) pOldAction = vd_pAction ;
@ -2692,7 +2692,7 @@ bool videoDevice::setupDevice(unsigned int id)
vd_Height = vd_CurrentFormats [ id ] . height ;
vd_Height = vd_CurrentFormats [ id ] . height ;
vd_FrameRate = vd_CurrentFormats [ id ] . MF_MT_FRAME_RATE_NUMERATOR /
vd_FrameRate = vd_CurrentFormats [ id ] . MF_MT_FRAME_RATE_NUMERATOR /
vd_CurrentFormats [ id ] . MF_MT_FRAME_RATE_DENOMINATOR ;
vd_CurrentFormats [ id ] . MF_MT_FRAME_RATE_DENOMINATOR ;
# ifdef HAVE_ WINRT
# ifdef WINRT
# ifdef HAVE_CONCURRENCY
# ifdef HAVE_CONCURRENCY
if ( DEREF_AGILE_WRL_OBJ ( vd_pMedCap ) ) {
if ( DEREF_AGILE_WRL_OBJ ( vd_pMedCap ) ) {
DEFINE_TASK < void > _task ;
DEFINE_TASK < void > _task ;
@ -2710,7 +2710,7 @@ bool videoDevice::setupDevice(unsigned int id)
if ( vd_IsSetuped )
if ( vd_IsSetuped )
DebugPrintOut ( L " \n \n VIDEODEVICE %i: Device is setuped \n " , vd_CurrentNumber ) ;
DebugPrintOut ( L " \n \n VIDEODEVICE %i: Device is setuped \n " , vd_CurrentNumber ) ;
vd_PrevParametrs = getParametrs ( ) ;
vd_PrevParametrs = getParametrs ( ) ;
# ifdef HAVE_ WINRT
# ifdef WINRT
# ifdef HAVE_CONCURRENCY
# ifdef HAVE_CONCURRENCY
END_CREATE_ASYNC ( hr ) ) ;
END_CREATE_ASYNC ( hr ) ) ;
# endif
# endif
@ -2749,7 +2749,7 @@ wchar_t *videoDevice::getName()
videoDevice : : ~ videoDevice ( void )
videoDevice : : ~ videoDevice ( void )
{
{
closeDevice ( ) ;
closeDevice ( ) ;
# ifdef HAVE_ WINRT
# ifdef WINRT
RELEASE_WRL ( vd_pMedCap )
RELEASE_WRL ( vd_pMedCap )
# endif
# endif
SafeRelease ( & vd_pSource ) ;
SafeRelease ( & vd_pSource ) ;
@ -2757,7 +2757,7 @@ videoDevice::~videoDevice(void)
CoTaskMemFree ( vd_pFriendlyName ) ;
CoTaskMemFree ( vd_pFriendlyName ) ;
}
}
# ifdef HAVE_ WINRT
# ifdef WINRT
HRESULT videoDevice : : enumerateCaptureFormats ( MAKE_WRL_REF ( _MediaCapture ) pSource )
HRESULT videoDevice : : enumerateCaptureFormats ( MAKE_WRL_REF ( _MediaCapture ) pSource )
{
{
HRESULT hr ;
HRESULT hr ;
@ -2831,7 +2831,7 @@ done:
videoDevices : : videoDevices ( void ) : count ( 0 )
videoDevices : : videoDevices ( void ) : count ( 0 )
{
{
# ifdef HAVE_ WINRT
# ifdef WINRT
vds_enumTask = nullptr ;
vds_enumTask = nullptr ;
# endif
# endif
}
}
@ -2862,7 +2862,7 @@ videoDevice * videoDevices::getDevice(unsigned int i)
return vds_Devices [ i ] ;
return vds_Devices [ i ] ;
}
}
# ifdef HAVE_ WINRT
# ifdef WINRT
long videoDevices : : initDevices ( _DeviceClass devClass )
long videoDevices : : initDevices ( _DeviceClass devClass )
{
{
HRESULT hr = S_OK ;
HRESULT hr = S_OK ;
@ -3196,7 +3196,7 @@ bool videoInput::isFrameNew(int deviceID)
return false ;
return false ;
}
}
# ifdef HAVE_ WINRT
# ifdef WINRT
void videoInput : : waitForDevice ( int deviceID )
void videoInput : : waitForDevice ( int deviceID )
{
{
if ( deviceID < 0 )
if ( deviceID < 0 )
@ -3405,7 +3405,7 @@ unsigned int videoInput::listDevices(bool silent)
if ( accessToDevices )
if ( accessToDevices )
{
{
videoDevices * VDS = & videoDevices : : getInstance ( ) ;
videoDevices * VDS = & videoDevices : : getInstance ( ) ;
# ifdef HAVE_ WINRT
# ifdef WINRT
VDS - > waitInit ( ) ;
VDS - > waitInit ( ) ;
# endif
# endif
out = VDS - > getCount ( ) ;
out = VDS - > getCount ( ) ;
@ -3595,7 +3595,7 @@ protected:
int index , width , height , fourcc ;
int index , width , height , fourcc ;
IplImage * frame ;
IplImage * frame ;
videoInput VI ;
videoInput VI ;
# ifdef HAVE_ WINRT
# ifdef WINRT
# ifdef HAVE_CONCURRENCY
# ifdef HAVE_CONCURRENCY
DEFINE_TASK < bool > openTask ;
DEFINE_TASK < bool > openTask ;
Concurrency : : critical_section lock ;
Concurrency : : critical_section lock ;
@ -3643,7 +3643,7 @@ void CvCaptureCAM_MSMF::close()
// Initialize camera input
// Initialize camera input
bool CvCaptureCAM_MSMF : : open ( int _index )
bool CvCaptureCAM_MSMF : : open ( int _index )
{
{
# ifdef HAVE_ WINRT
# ifdef WINRT
# ifdef HAVE_CONCURRENCY
# ifdef HAVE_CONCURRENCY
SAVE_CURRENT_CONTEXT ( context ) ;
SAVE_CURRENT_CONTEXT ( context ) ;
auto func = [ _index , context , this ] ( DEFINE_RET_VAL ( bool ) ) - > DEFINE_RET_FORMAL ( bool ) {
auto func = [ _index , context , this ] ( DEFINE_RET_VAL ( bool ) ) - > DEFINE_RET_FORMAL ( bool ) {
@ -3656,14 +3656,14 @@ bool CvCaptureCAM_MSMF::open( int _index )
if ( devices = = 0 )
if ( devices = = 0 )
return false ;
return false ;
try_index = try_index < 0 ? 0 : ( try_index > devices - 1 ? devices - 1 : try_index ) ;
try_index = try_index < 0 ? 0 : ( try_index > devices - 1 ? devices - 1 : try_index ) ;
# ifdef HAVE_ WINRT
# ifdef WINRT
HRESULT hr ;
HRESULT hr ;
# ifdef HAVE_CONCURRENCY
# ifdef HAVE_CONCURRENCY
BEGIN_CALL_IN_CONTEXT ( hr , context , this , try_index )
BEGIN_CALL_IN_CONTEXT ( hr , context , this , try_index )
# endif
# endif
# endif
# endif
VI . setupDevice ( try_index , 0 , 0 , 0 ) ; // With maximum frame size.
VI . setupDevice ( try_index , 0 , 0 , 0 ) ; // With maximum frame size.
# ifdef HAVE_ WINRT
# ifdef WINRT
# ifdef HAVE_CONCURRENCY
# ifdef HAVE_CONCURRENCY
END_CALL_IN_CONTEXT_BASE
END_CALL_IN_CONTEXT_BASE
VI . waitForDevice ( try_index ) ;
VI . waitForDevice ( try_index ) ;
@ -3672,13 +3672,13 @@ bool CvCaptureCAM_MSMF::open( int _index )
# endif
# endif
# endif
# endif
if ( ! VI . isFrameNew ( try_index ) )
if ( ! VI . isFrameNew ( try_index ) )
# ifdef HAVE_ WINRT
# ifdef WINRT
hr = E_FAIL ;
hr = E_FAIL ;
# else
# else
return false ;
return false ;
# endif
# endif
index = try_index ;
index = try_index ;
# ifdef HAVE_ WINRT
# ifdef WINRT
# ifdef HAVE_CONCURRENCY
# ifdef HAVE_CONCURRENCY
END_CALL_IN_CONTEXT_BASE
END_CALL_IN_CONTEXT_BASE
RET_VAL ( true )
RET_VAL ( true )