Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>By windows-8, I guess you mean winRT ? AFAIK, there is no official port to winRT. You need to compile it by yourself as a Win8 Store DLL for instance, so that you can reference it from a Win8 Store Application.</p> <p>Just start by opencv-core, then add the lib you need, one by one, because all the components will not be able to compile (for instance, opencv-highgui is highly dependant on Windows API which is not fully compatible with Win8 Store Apps).</p> <p>You'll also need to code by yourself some Win32 methods used by OpenCV and not accessible from Win8 App like GetSystemInfo(), GetTempPathA(), GetTempFileNameA() and all methods related to thread local storage (TLS). </p> <p>I've been able to use a small subset of OpenCV in WinRT by compiling opencv_core, opencv_imgproc and zlib, as 3 seperate static libs. I've added one another, called opencv_winrt, that contains only the two following files:</p> <p><strong>opencv_winrt.h</strong></p> <pre><code>#pragma once #include "combaseapi.h" void WINAPI GetSystemInfo( _Out_ LPSYSTEM_INFO lpSystemInfo ); DWORD WINAPI GetTempPathA( _In_ DWORD nBufferLength, _Out_ char* lpBuffer ); UINT WINAPI GetTempFileNameA( _In_ const char* lpPathName, _In_ const char* lpPrefixString, _In_ UINT uUnique, _Out_ char* lpTempFileName ); DWORD WINAPI TlsAlloc(); BOOL WINAPI TlsFree( _In_ DWORD dwTlsIndex ); LPVOID WINAPI TlsGetValue( _In_ DWORD dwTlsIndex ); BOOL WINAPI TlsSetValue( _In_ DWORD dwTlsIndex, _In_opt_ LPVOID lpTlsValue ); void WINAPI TlsShutdown(); # define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF) </code></pre> <p><strong>opencv_winrt.cpp</strong></p> <pre><code>#include "opencv_winrt.h" #include &lt;vector&gt; #include &lt;set&gt; #include &lt;mutex&gt; #include "assert.h" void WINAPI GetSystemInfo(LPSYSTEM_INFO lpSystemInfo) { GetNativeSystemInfo(lpSystemInfo); } DWORD WINAPI GetTempPathA(DWORD nBufferLength, char* lpBuffer) { return 0; } UINT WINAPI GetTempFileNameA(const char* lpPathName, const char* lpPrefixString, UINT uUnique, char* lpTempFileName) { return 0; } // Thread local storage. typedef std::vector&lt;void*&gt; ThreadLocalData; static __declspec(thread) ThreadLocalData* currentThreadData = nullptr; static std::set&lt;ThreadLocalData*&gt; allThreadData; static DWORD nextTlsIndex = 0; static std::vector&lt;DWORD&gt; freeTlsIndices; static std::mutex tlsAllocationLock; DWORD WINAPI TlsAlloc() { std::lock_guard&lt;std::mutex&gt; lock(tlsAllocationLock); // Can we reuse a previously freed TLS slot? if (!freeTlsIndices.empty()) { DWORD result = freeTlsIndices.back(); freeTlsIndices.pop_back(); return result; } // Allocate a new TLS slot. return nextTlsIndex++; } _Use_decl_annotations_ BOOL WINAPI TlsFree(DWORD dwTlsIndex) { std::lock_guard&lt;std::mutex&gt; lock(tlsAllocationLock); assert(dwTlsIndex &lt; nextTlsIndex); assert(find(freeTlsIndices.begin(), freeTlsIndices.end(), dwTlsIndex) == freeTlsIndices.end()); // Store this slot for reuse by TlsAlloc. try { freeTlsIndices.push_back(dwTlsIndex); } catch (...) { return false; } // Zero the value for all threads that might be using this now freed slot. for each (auto threadData in allThreadData) { if (threadData-&gt;size() &gt; dwTlsIndex) { threadData-&gt;at(dwTlsIndex) = nullptr; } } return true; } _Use_decl_annotations_ LPVOID WINAPI TlsGetValue(DWORD dwTlsIndex) { ThreadLocalData* threadData = currentThreadData; if (threadData &amp;&amp; threadData-&gt;size() &gt; dwTlsIndex) { // Return the value of an allocated TLS slot. return threadData-&gt;at(dwTlsIndex); } else { // Default value for unallocated slots. return nullptr; } } _Use_decl_annotations_ BOOL WINAPI TlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue) { ThreadLocalData* threadData = currentThreadData; if (!threadData) { // First time allocation of TLS data for this thread. try { threadData = new ThreadLocalData(dwTlsIndex + 1, nullptr); std::lock_guard&lt;std::mutex&gt; lock(tlsAllocationLock); allThreadData.insert(threadData); currentThreadData = threadData; } catch (...) { if (threadData) delete threadData; return false; } } else if (threadData-&gt;size() &lt;= dwTlsIndex) { // This thread already has a TLS data block, but it must be expanded to fit the specified slot. try { std::lock_guard&lt;std::mutex&gt; lock(tlsAllocationLock); threadData-&gt;resize(dwTlsIndex + 1, nullptr); } catch (...) { return false; } } // Store the new value for this slot. threadData-&gt;at(dwTlsIndex) = lpTlsValue; return true; } // Called at thread exit to clean up TLS allocations. void WINAPI TlsShutdown() { ThreadLocalData* threadData = currentThreadData; if (threadData) { { std::lock_guard&lt;std::mutex&gt; lock(tlsAllocationLock); allThreadData.erase(threadData); } currentThreadData = nullptr; delete threadData; } } </code></pre> <p>And I modify the file cvconfig.h: I've commented out every #define, except PACKAGE* and VERSION, and I added #include "opencv_winrt.h" at the end. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload