Windows Phone 8和Windows 8是否支持OpenCV图形库。我在Google上进行了搜索,但没有找到任何与OpenCV相关的资源来连接Windows Phone 8 / Windows 8。如果有的话你对此有所了解,请帮助我,并提供一些链接到达图书馆。
答案 0 :(得分:4)
这是我从OpenCV团队获得的最新信息。
OpenCV开发团队正在为Windows RT开发端口。这是WinRT的当前开发分支(https://github.com/asmorkalov/opencv/tree/winrt)。您可以使用Visual Studio Express for Windows 8和Platform SDK为ARM构建它。
Open Visual Studio development console.
Setup environment for cross compilation by command "C:\Program Files(x86)\Microsoft
Visual Studio 11.0\VC\bin\x86_arm\vcvarsx86_arm.bat"
cd <opencv_source_dir>/platforms/winrt/
run scripts/cmake_winrt.cmd
run ninja
或者你可以使用nmake代替忍者。您需要编辑cmake_winrt.cmd并将项目生成器从-GNinja更改为-G“NMake Makefiles”。现在只支持库的算法部分,没有tbb,没有UI,没有视频IO。
请从更多详细信息中查看以下给定的网址。 http://answers.opencv.org/question/9847/opencv-for-windows-8-tablet/?answer=9851#post-id-9851
答案 1 :(得分:3)
通过windows-8,我猜你的意思是winRT? AFAIK,winRT没有官方端口。例如,您需要自己编译为Win8 Store DLL,以便可以从Win8 Store应用程序中引用它。
刚开始使用opencv-core,然后逐个添加你需要的lib,因为所有组件都无法编译(例如,opencv-highgui高度依赖于与之不完全兼容的Windows API Win8商店应用程序)。
您还需要自己编写一些OpenCV使用的Win32方法,而不能从Win8 App访问,如GetSystemInfo(),GetTempPathA(),GetTempFileNameA()以及与线程本地存储(TLS)相关的所有方法。
我已经能够通过编译opencv_core,opencv_imgproc和zlib作为3个单独的静态库来在WinRT中使用OpenCV的一小部分。我已经添加了另一个名为opencv_winrt的文件,它只包含以下两个文件:
<强> opencv_winrt.h 强>
#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)
<强> opencv_winrt.cpp 强>
#include "opencv_winrt.h"
#include <vector>
#include <set>
#include <mutex>
#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<void*> ThreadLocalData;
static __declspec(thread) ThreadLocalData* currentThreadData = nullptr;
static std::set<ThreadLocalData*> allThreadData;
static DWORD nextTlsIndex = 0;
static std::vector<DWORD> freeTlsIndices;
static std::mutex tlsAllocationLock;
DWORD WINAPI TlsAlloc()
{
std::lock_guard<std::mutex> 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<std::mutex> lock(tlsAllocationLock);
assert(dwTlsIndex < 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->size() > dwTlsIndex)
{
threadData->at(dwTlsIndex) = nullptr;
}
}
return true;
}
_Use_decl_annotations_ LPVOID WINAPI TlsGetValue(DWORD dwTlsIndex)
{
ThreadLocalData* threadData = currentThreadData;
if (threadData && threadData->size() > dwTlsIndex)
{
// Return the value of an allocated TLS slot.
return threadData->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<std::mutex> lock(tlsAllocationLock);
allThreadData.insert(threadData);
currentThreadData = threadData;
}
catch (...)
{
if (threadData)
delete threadData;
return false;
}
}
else if (threadData->size() <= dwTlsIndex)
{
// This thread already has a TLS data block, but it must be expanded to fit the specified slot.
try
{
std::lock_guard<std::mutex> lock(tlsAllocationLock);
threadData->resize(dwTlsIndex + 1, nullptr);
}
catch (...)
{
return false;
}
}
// Store the new value for this slot.
threadData->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<std::mutex> lock(tlsAllocationLock);
allThreadData.erase(threadData);
}
currentThreadData = nullptr;
delete threadData;
}
}
我修改了文件cvconfig.h:我已经注释掉除了PACKAGE *和VERSION之外的所有#define,最后我添加了#include“opencv_winrt.h”。
答案 2 :(得分:2)
只是一个提示 - 有一个名为EmguCV
(http://www.emgu.com/wiki/index.php/Main_Page)的OpenCV的C#包装器,通过查看论坛帖子,我看到在Windows 8上使用它有一些活动,但很难告诉它现在是否正常工作,因为声称问题的帖子已经很久了。我建议你试一试,看看这个C#包装器能否在Windows Phone 8上运行,我认为它绝对应该在Windows 8上运行。