Renesas GR-PEACH OpenCV Development / gr-peach-opencv-project-sd-card_update

Fork of gr-peach-opencv-project-sd-card by the do

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers directx.hpp Source File

directx.hpp

00001 /*M///////////////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
00004 //
00005 //  By downloading, copying, installing or using the software you agree to this license.
00006 //  If you do not agree to this license, do not download, install,
00007 //  copy or use the software.
00008 //
00009 //
00010 //                           License Agreement
00011 //                For Open Source Computer Vision Library
00012 //
00013 // Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved.
00014 // Third party copyrights are property of their respective owners.
00015 //
00016 // Redistribution and use in source and binary forms, with or without modification,
00017 // are permitted provided that the following conditions are met:
00018 //
00019 //   * Redistribution's of source code must retain the above copyright notice,
00020 //     this list of conditions and the following disclaimer.
00021 //
00022 //   * Redistribution's in binary form must reproduce the above copyright notice,
00023 //     this list of conditions and the following disclaimer in the documentation
00024 //     and/or other materials provided with the distribution.
00025 //
00026 //   * The name of the copyright holders may not be used to endorse or promote products
00027 //     derived from this software without specific prior written permission.
00028 //
00029 // This software is provided by the copyright holders and contributors as is and
00030 // any express or implied warranties, including, but not limited to, the implied
00031 // warranties of merchantability and fitness for a particular purpose are disclaimed.
00032 // In no event shall the copyright holders or contributors be liable for any direct,
00033 // indirect, incidental, special, exemplary, or consequential damages
00034 // (including, but not limited to, procurement of substitute goods or services;
00035 // loss of use, data, or profits; or business interruption) however caused
00036 // and on any theory of liability, whether in contract, strict liability,
00037 // or tort (including negligence or otherwise) arising in any way out of
00038 // the use of this software, even if advised of the possibility of such damage.
00039 //
00040 //M*/
00041 
00042 #ifndef __OPENCV_CORE_DIRECTX_HPP__
00043 #define __OPENCV_CORE_DIRECTX_HPP__
00044 
00045 #include "mat.hpp"
00046 
00047 #ifdef HAVE_OPENCL
00048 #include "ocl.hpp"
00049 #endif
00050 
00051 #if !defined(__d3d11_h__)
00052 struct ID3D11Device;
00053 struct ID3D11Texture2D;
00054 #endif
00055 
00056 #if !defined(__d3d10_h__)
00057 struct ID3D10Device;
00058 struct ID3D10Texture2D;
00059 #endif
00060 
00061 #if !defined(_D3D9_H_)
00062 struct IDirect3DDevice9;
00063 struct IDirect3DDevice9Ex;
00064 struct IDirect3DSurface9;
00065 #endif
00066 
00067 
00068 namespace cv { namespace directx {
00069 
00070 #ifdef HAVE_OPENCL
00071 namespace ocl {
00072 using namespace cv::ocl;
00073 
00074 //! @addtogroup core_directx
00075 // This section describes OpenCL and DirectX interoperability.
00076 //
00077 // To enable DirectX support, configure OpenCV using CMake with WITH_DIRECTX=ON . Note, DirectX is
00078 // supported only on Windows.
00079 //
00080 // To use OpenCL functionality you should first initialize OpenCL context from DirectX resource.
00081 //
00082 //! @{
00083 
00084 // TODO static functions in the Context class
00085 //! @brief Creates OpenCL context from D3D11 device
00086 //
00087 //! @param pD3D11Device - pointer to D3D11 device
00088 //! @return Returns reference to OpenCL Context
00089 CV_EXPORTS Context& initializeContextFromD3D11Device(ID3D11Device* pD3D11Device);
00090 
00091 //! @brief Creates OpenCL context from D3D10 device
00092 //
00093 //! @param pD3D10Device - pointer to D3D10 device
00094 //! @return Returns reference to OpenCL Context
00095 CV_EXPORTS Context& initializeContextFromD3D10Device(ID3D10Device* pD3D10Device);
00096 
00097 //! @brief Creates OpenCL context from Direct3DDevice9Ex device
00098 //
00099 //! @param pDirect3DDevice9Ex - pointer to Direct3DDevice9Ex device
00100 //! @return Returns reference to OpenCL Context
00101 CV_EXPORTS Context& initializeContextFromDirect3DDevice9Ex(IDirect3DDevice9Ex* pDirect3DDevice9Ex);
00102 
00103 //! @brief Creates OpenCL context from Direct3DDevice9 device
00104 //
00105 //! @param pDirect3DDevice9 - pointer to Direct3Device9 device
00106 //! @return Returns reference to OpenCL Context
00107 CV_EXPORTS Context& initializeContextFromDirect3DDevice9(IDirect3DDevice9* pDirect3DDevice9);
00108 
00109 //! @}
00110 
00111 } // namespace cv::directx::ocl
00112 #endif
00113 
00114 //! @addtogroup core_directx
00115 //! @{
00116 
00117 //! @brief Converts InputArray to ID3D11Texture2D. If destination texture format is DXGI_FORMAT_NV12 then
00118 //!        input UMat expected to be in BGR format and data will be downsampled and color-converted to NV12.
00119 //
00120 //! @note Note: Destination texture must be allocated by application. Function does memory copy from src to
00121 //!             pD3D11Texture2D
00122 //
00123 //! @param src - source InputArray
00124 //! @param pD3D11Texture2D - destination D3D11 texture
00125 CV_EXPORTS void convertToD3D11Texture2D(InputArray src, ID3D11Texture2D* pD3D11Texture2D);
00126 
00127 //! @brief Converts ID3D11Texture2D to OutputArray. If input texture format is DXGI_FORMAT_NV12 then
00128 //!        data will be upsampled and color-converted to BGR format.
00129 //
00130 //! @note Note: Destination matrix will be re-allocated if it has not enough memory to match texture size.
00131 //!             function does memory copy from pD3D11Texture2D to dst
00132 //
00133 //! @param pD3D11Texture2D - source D3D11 texture
00134 //! @param dst             - destination OutputArray
00135 CV_EXPORTS void convertFromD3D11Texture2D(ID3D11Texture2D* pD3D11Texture2D, OutputArray dst);
00136 
00137 //! @brief Converts InputArray to ID3D10Texture2D
00138 //
00139 //! @note Note: function does memory copy from src to
00140 //!             pD3D10Texture2D
00141 //
00142 //! @param src             - source InputArray
00143 //! @param pD3D10Texture2D - destination D3D10 texture
00144 CV_EXPORTS void convertToD3D10Texture2D(InputArray src, ID3D10Texture2D* pD3D10Texture2D);
00145 
00146 //! @brief Converts ID3D10Texture2D to OutputArray
00147 //
00148 //! @note Note: function does memory copy from pD3D10Texture2D
00149 //!             to dst
00150 //
00151 //! @param pD3D10Texture2D - source D3D10 texture
00152 //! @param dst             - destination OutputArray
00153 CV_EXPORTS void convertFromD3D10Texture2D(ID3D10Texture2D* pD3D10Texture2D, OutputArray dst);
00154 
00155 //! @brief Converts InputArray to IDirect3DSurface9
00156 //
00157 //! @note Note: function does memory copy from src to
00158 //!             pDirect3DSurface9
00159 //
00160 //! @param src                 - source InputArray
00161 //! @param pDirect3DSurface9   - destination D3D10 texture
00162 //! @param surfaceSharedHandle - shared handle
00163 CV_EXPORTS void convertToDirect3DSurface9(InputArray src, IDirect3DSurface9* pDirect3DSurface9, void* surfaceSharedHandle = NULL);
00164 
00165 //! @brief Converts IDirect3DSurface9 to OutputArray
00166 //
00167 //! @note Note: function does memory copy from pDirect3DSurface9
00168 //!             to dst
00169 //
00170 //! @param pDirect3DSurface9   - source D3D10 texture
00171 //! @param dst                 - destination OutputArray
00172 //! @param surfaceSharedHandle - shared handle
00173 CV_EXPORTS void convertFromDirect3DSurface9(IDirect3DSurface9* pDirect3DSurface9, OutputArray dst, void* surfaceSharedHandle = NULL);
00174 
00175 //! @brief Get OpenCV type from DirectX type
00176 //! @param iDXGI_FORMAT - enum DXGI_FORMAT for D3D10/D3D11
00177 //! @return OpenCV type or -1 if there is no equivalent
00178 CV_EXPORTS int getTypeFromDXGI_FORMAT(const int iDXGI_FORMAT); // enum DXGI_FORMAT for D3D10/D3D11
00179 
00180 //! @brief Get OpenCV type from DirectX type
00181 //! @param iD3DFORMAT - enum D3DTYPE for D3D9
00182 //! @return OpenCV type or -1 if there is no equivalent
00183 CV_EXPORTS int getTypeFromD3DFORMAT(const int iD3DFORMAT); // enum D3DTYPE for D3D9
00184 
00185 //! @}
00186 
00187 } } // namespace cv::directx
00188 
00189 #endif // __OPENCV_CORE_DIRECTX_HPP__
00190