opencv on mbed

Dependencies:   mbed

Committer:
joeverbout
Date:
Thu Mar 31 21:16:38 2016 +0000
Revision:
0:ea44dc9ed014
OpenCV on mbed attempt

Who changed what in which revision?

UserRevisionLine numberNew contents of line
joeverbout 0:ea44dc9ed014 1 /*M///////////////////////////////////////////////////////////////////////////////////////
joeverbout 0:ea44dc9ed014 2 //
joeverbout 0:ea44dc9ed014 3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
joeverbout 0:ea44dc9ed014 4 //
joeverbout 0:ea44dc9ed014 5 // By downloading, copying, installing or using the software you agree to this license.
joeverbout 0:ea44dc9ed014 6 // If you do not agree to this license, do not download, install,
joeverbout 0:ea44dc9ed014 7 // copy or use the software.
joeverbout 0:ea44dc9ed014 8 //
joeverbout 0:ea44dc9ed014 9 //
joeverbout 0:ea44dc9ed014 10 // License Agreement
joeverbout 0:ea44dc9ed014 11 // For Open Source Computer Vision Library
joeverbout 0:ea44dc9ed014 12 //
joeverbout 0:ea44dc9ed014 13 // Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved.
joeverbout 0:ea44dc9ed014 14 // Third party copyrights are property of their respective owners.
joeverbout 0:ea44dc9ed014 15 //
joeverbout 0:ea44dc9ed014 16 // Redistribution and use in source and binary forms, with or without modification,
joeverbout 0:ea44dc9ed014 17 // are permitted provided that the following conditions are met:
joeverbout 0:ea44dc9ed014 18 //
joeverbout 0:ea44dc9ed014 19 // * Redistribution's of source code must retain the above copyright notice,
joeverbout 0:ea44dc9ed014 20 // this list of conditions and the following disclaimer.
joeverbout 0:ea44dc9ed014 21 //
joeverbout 0:ea44dc9ed014 22 // * Redistribution's in binary form must reproduce the above copyright notice,
joeverbout 0:ea44dc9ed014 23 // this list of conditions and the following disclaimer in the documentation
joeverbout 0:ea44dc9ed014 24 // and/or other materials provided with the distribution.
joeverbout 0:ea44dc9ed014 25 //
joeverbout 0:ea44dc9ed014 26 // * The name of the copyright holders may not be used to endorse or promote products
joeverbout 0:ea44dc9ed014 27 // derived from this software without specific prior written permission.
joeverbout 0:ea44dc9ed014 28 //
joeverbout 0:ea44dc9ed014 29 // This software is provided by the copyright holders and contributors as is and
joeverbout 0:ea44dc9ed014 30 // any express or implied warranties, including, but not limited to, the implied
joeverbout 0:ea44dc9ed014 31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
joeverbout 0:ea44dc9ed014 32 // In no event shall the copyright holders or contributors be liable for any direct,
joeverbout 0:ea44dc9ed014 33 // indirect, incidental, special, exemplary, or consequential damages
joeverbout 0:ea44dc9ed014 34 // (including, but not limited to, procurement of substitute goods or services;
joeverbout 0:ea44dc9ed014 35 // loss of use, data, or profits; or business interruption) however caused
joeverbout 0:ea44dc9ed014 36 // and on any theory of liability, whether in contract, strict liability,
joeverbout 0:ea44dc9ed014 37 // or tort (including negligence or otherwise) arising in any way out of
joeverbout 0:ea44dc9ed014 38 // the use of this software, even if advised of the possibility of such damage.
joeverbout 0:ea44dc9ed014 39 //
joeverbout 0:ea44dc9ed014 40 //M*/
joeverbout 0:ea44dc9ed014 41
joeverbout 0:ea44dc9ed014 42 #ifndef __OPENCV_CORE_DIRECTX_HPP__
joeverbout 0:ea44dc9ed014 43 #define __OPENCV_CORE_DIRECTX_HPP__
joeverbout 0:ea44dc9ed014 44
joeverbout 0:ea44dc9ed014 45 #include "mat.hpp"
joeverbout 0:ea44dc9ed014 46 #include "ocl.hpp"
joeverbout 0:ea44dc9ed014 47
joeverbout 0:ea44dc9ed014 48 #if !defined(__d3d11_h__)
joeverbout 0:ea44dc9ed014 49 struct ID3D11Device;
joeverbout 0:ea44dc9ed014 50 struct ID3D11Texture2D;
joeverbout 0:ea44dc9ed014 51 #endif
joeverbout 0:ea44dc9ed014 52
joeverbout 0:ea44dc9ed014 53 #if !defined(__d3d10_h__)
joeverbout 0:ea44dc9ed014 54 struct ID3D10Device;
joeverbout 0:ea44dc9ed014 55 struct ID3D10Texture2D;
joeverbout 0:ea44dc9ed014 56 #endif
joeverbout 0:ea44dc9ed014 57
joeverbout 0:ea44dc9ed014 58 #if !defined(_D3D9_H_)
joeverbout 0:ea44dc9ed014 59 struct IDirect3DDevice9;
joeverbout 0:ea44dc9ed014 60 struct IDirect3DDevice9Ex;
joeverbout 0:ea44dc9ed014 61 struct IDirect3DSurface9;
joeverbout 0:ea44dc9ed014 62 #endif
joeverbout 0:ea44dc9ed014 63
joeverbout 0:ea44dc9ed014 64
joeverbout 0:ea44dc9ed014 65 namespace cv { namespace directx {
joeverbout 0:ea44dc9ed014 66
joeverbout 0:ea44dc9ed014 67 namespace ocl {
joeverbout 0:ea44dc9ed014 68 using namespace cv::ocl;
joeverbout 0:ea44dc9ed014 69
joeverbout 0:ea44dc9ed014 70 //! @addtogroup core_directx
joeverbout 0:ea44dc9ed014 71 // This section describes OpenCL and DirectX interoperability.
joeverbout 0:ea44dc9ed014 72 //
joeverbout 0:ea44dc9ed014 73 // To enable DirectX support, configure OpenCV using CMake with WITH_DIRECTX=ON . Note, DirectX is
joeverbout 0:ea44dc9ed014 74 // supported only on Windows.
joeverbout 0:ea44dc9ed014 75 //
joeverbout 0:ea44dc9ed014 76 // To use OpenCL functionality you should first initialize OpenCL context from DirectX resource.
joeverbout 0:ea44dc9ed014 77 //
joeverbout 0:ea44dc9ed014 78 //! @{
joeverbout 0:ea44dc9ed014 79
joeverbout 0:ea44dc9ed014 80 // TODO static functions in the Context class
joeverbout 0:ea44dc9ed014 81 //! @brief Creates OpenCL context from D3D11 device
joeverbout 0:ea44dc9ed014 82 //
joeverbout 0:ea44dc9ed014 83 //! @param pD3D11Device - pointer to D3D11 device
joeverbout 0:ea44dc9ed014 84 //! @return Returns reference to OpenCL Context
joeverbout 0:ea44dc9ed014 85 CV_EXPORTS Context& initializeContextFromD3D11Device(ID3D11Device* pD3D11Device);
joeverbout 0:ea44dc9ed014 86
joeverbout 0:ea44dc9ed014 87 //! @brief Creates OpenCL context from D3D10 device
joeverbout 0:ea44dc9ed014 88 //
joeverbout 0:ea44dc9ed014 89 //! @param pD3D10Device - pointer to D3D10 device
joeverbout 0:ea44dc9ed014 90 //! @return Returns reference to OpenCL Context
joeverbout 0:ea44dc9ed014 91 CV_EXPORTS Context& initializeContextFromD3D10Device(ID3D10Device* pD3D10Device);
joeverbout 0:ea44dc9ed014 92
joeverbout 0:ea44dc9ed014 93 //! @brief Creates OpenCL context from Direct3DDevice9Ex device
joeverbout 0:ea44dc9ed014 94 //
joeverbout 0:ea44dc9ed014 95 //! @param pDirect3DDevice9Ex - pointer to Direct3DDevice9Ex device
joeverbout 0:ea44dc9ed014 96 //! @return Returns reference to OpenCL Context
joeverbout 0:ea44dc9ed014 97 CV_EXPORTS Context& initializeContextFromDirect3DDevice9Ex(IDirect3DDevice9Ex* pDirect3DDevice9Ex);
joeverbout 0:ea44dc9ed014 98
joeverbout 0:ea44dc9ed014 99 //! @brief Creates OpenCL context from Direct3DDevice9 device
joeverbout 0:ea44dc9ed014 100 //
joeverbout 0:ea44dc9ed014 101 //! @param pDirect3DDevice9 - pointer to Direct3Device9 device
joeverbout 0:ea44dc9ed014 102 //! @return Returns reference to OpenCL Context
joeverbout 0:ea44dc9ed014 103 CV_EXPORTS Context& initializeContextFromDirect3DDevice9(IDirect3DDevice9* pDirect3DDevice9);
joeverbout 0:ea44dc9ed014 104
joeverbout 0:ea44dc9ed014 105 //! @}
joeverbout 0:ea44dc9ed014 106
joeverbout 0:ea44dc9ed014 107 } // namespace cv::directx::ocl
joeverbout 0:ea44dc9ed014 108
joeverbout 0:ea44dc9ed014 109 //! @addtogroup core_directx
joeverbout 0:ea44dc9ed014 110 //! @{
joeverbout 0:ea44dc9ed014 111
joeverbout 0:ea44dc9ed014 112 //! @brief Converts InputArray to ID3D11Texture2D. If destination texture format is DXGI_FORMAT_NV12 then
joeverbout 0:ea44dc9ed014 113 //! input UMat expected to be in BGR format and data will be downsampled and color-converted to NV12.
joeverbout 0:ea44dc9ed014 114 //
joeverbout 0:ea44dc9ed014 115 //! @note Note: Destination texture must be allocated by application. Function does memory copy from src to
joeverbout 0:ea44dc9ed014 116 //! pD3D11Texture2D
joeverbout 0:ea44dc9ed014 117 //
joeverbout 0:ea44dc9ed014 118 //! @param src - source InputArray
joeverbout 0:ea44dc9ed014 119 //! @param pD3D11Texture2D - destination D3D11 texture
joeverbout 0:ea44dc9ed014 120 CV_EXPORTS void convertToD3D11Texture2D(InputArray src, ID3D11Texture2D* pD3D11Texture2D);
joeverbout 0:ea44dc9ed014 121
joeverbout 0:ea44dc9ed014 122 //! @brief Converts ID3D11Texture2D to OutputArray. If input texture format is DXGI_FORMAT_NV12 then
joeverbout 0:ea44dc9ed014 123 //! data will be upsampled and color-converted to BGR format.
joeverbout 0:ea44dc9ed014 124 //
joeverbout 0:ea44dc9ed014 125 //! @note Note: Destination matrix will be re-allocated if it has not enough memory to match texture size.
joeverbout 0:ea44dc9ed014 126 //! function does memory copy from pD3D11Texture2D to dst
joeverbout 0:ea44dc9ed014 127 //
joeverbout 0:ea44dc9ed014 128 //! @param pD3D11Texture2D - source D3D11 texture
joeverbout 0:ea44dc9ed014 129 //! @param dst - destination OutputArray
joeverbout 0:ea44dc9ed014 130 CV_EXPORTS void convertFromD3D11Texture2D(ID3D11Texture2D* pD3D11Texture2D, OutputArray dst);
joeverbout 0:ea44dc9ed014 131
joeverbout 0:ea44dc9ed014 132 //! @brief Converts InputArray to ID3D10Texture2D
joeverbout 0:ea44dc9ed014 133 //
joeverbout 0:ea44dc9ed014 134 //! @note Note: function does memory copy from src to
joeverbout 0:ea44dc9ed014 135 //! pD3D10Texture2D
joeverbout 0:ea44dc9ed014 136 //
joeverbout 0:ea44dc9ed014 137 //! @param src - source InputArray
joeverbout 0:ea44dc9ed014 138 //! @param pD3D10Texture2D - destination D3D10 texture
joeverbout 0:ea44dc9ed014 139 CV_EXPORTS void convertToD3D10Texture2D(InputArray src, ID3D10Texture2D* pD3D10Texture2D);
joeverbout 0:ea44dc9ed014 140
joeverbout 0:ea44dc9ed014 141 //! @brief Converts ID3D10Texture2D to OutputArray
joeverbout 0:ea44dc9ed014 142 //
joeverbout 0:ea44dc9ed014 143 //! @note Note: function does memory copy from pD3D10Texture2D
joeverbout 0:ea44dc9ed014 144 //! to dst
joeverbout 0:ea44dc9ed014 145 //
joeverbout 0:ea44dc9ed014 146 //! @param pD3D10Texture2D - source D3D10 texture
joeverbout 0:ea44dc9ed014 147 //! @param dst - destination OutputArray
joeverbout 0:ea44dc9ed014 148 CV_EXPORTS void convertFromD3D10Texture2D(ID3D10Texture2D* pD3D10Texture2D, OutputArray dst);
joeverbout 0:ea44dc9ed014 149
joeverbout 0:ea44dc9ed014 150 //! @brief Converts InputArray to IDirect3DSurface9
joeverbout 0:ea44dc9ed014 151 //
joeverbout 0:ea44dc9ed014 152 //! @note Note: function does memory copy from src to
joeverbout 0:ea44dc9ed014 153 //! pDirect3DSurface9
joeverbout 0:ea44dc9ed014 154 //
joeverbout 0:ea44dc9ed014 155 //! @param src - source InputArray
joeverbout 0:ea44dc9ed014 156 //! @param pDirect3DSurface9 - destination D3D10 texture
joeverbout 0:ea44dc9ed014 157 //! @param surfaceSharedHandle - shared handle
joeverbout 0:ea44dc9ed014 158 CV_EXPORTS void convertToDirect3DSurface9(InputArray src, IDirect3DSurface9* pDirect3DSurface9, void* surfaceSharedHandle = NULL);
joeverbout 0:ea44dc9ed014 159
joeverbout 0:ea44dc9ed014 160 //! @brief Converts IDirect3DSurface9 to OutputArray
joeverbout 0:ea44dc9ed014 161 //
joeverbout 0:ea44dc9ed014 162 //! @note Note: function does memory copy from pDirect3DSurface9
joeverbout 0:ea44dc9ed014 163 //! to dst
joeverbout 0:ea44dc9ed014 164 //
joeverbout 0:ea44dc9ed014 165 //! @param pDirect3DSurface9 - source D3D10 texture
joeverbout 0:ea44dc9ed014 166 //! @param dst - destination OutputArray
joeverbout 0:ea44dc9ed014 167 //! @param surfaceSharedHandle - shared handle
joeverbout 0:ea44dc9ed014 168 CV_EXPORTS void convertFromDirect3DSurface9(IDirect3DSurface9* pDirect3DSurface9, OutputArray dst, void* surfaceSharedHandle = NULL);
joeverbout 0:ea44dc9ed014 169
joeverbout 0:ea44dc9ed014 170 //! @brief Get OpenCV type from DirectX type
joeverbout 0:ea44dc9ed014 171 //! @param iDXGI_FORMAT - enum DXGI_FORMAT for D3D10/D3D11
joeverbout 0:ea44dc9ed014 172 //! @return OpenCV type or -1 if there is no equivalent
joeverbout 0:ea44dc9ed014 173 CV_EXPORTS int getTypeFromDXGI_FORMAT(const int iDXGI_FORMAT); // enum DXGI_FORMAT for D3D10/D3D11
joeverbout 0:ea44dc9ed014 174
joeverbout 0:ea44dc9ed014 175 //! @brief Get OpenCV type from DirectX type
joeverbout 0:ea44dc9ed014 176 //! @param iD3DFORMAT - enum D3DTYPE for D3D9
joeverbout 0:ea44dc9ed014 177 //! @return OpenCV type or -1 if there is no equivalent
joeverbout 0:ea44dc9ed014 178 CV_EXPORTS int getTypeFromD3DFORMAT(const int iD3DFORMAT); // enum D3DTYPE for D3D9
joeverbout 0:ea44dc9ed014 179
joeverbout 0:ea44dc9ed014 180 //! @}
joeverbout 0:ea44dc9ed014 181
joeverbout 0:ea44dc9ed014 182 } } // namespace cv::directx
joeverbout 0:ea44dc9ed014 183
joeverbout 0:ea44dc9ed014 184 #endif // __OPENCV_CORE_DIRECTX_HPP__
joeverbout 0:ea44dc9ed014 185