iOS與unity互動、opencv開發教程,unityopencv
iOS與unity互動、opencv開發教程。
遇到的問題
1,
問題一:enum { NO, GAIN, GAIN_BLOCKS };Expected identifier
只要把NO修改成NO_EXPOSURE_COMPENSATOR 或 NO_EXPOSURE_COMPENSATOR = 0
問題二:core.hpp header must be compiled as C++ 或base.hpp header must be compiled as C++
解決:把調用了OpenCV檔案的.m檔案修改為.mm,以及viewController.m修改為viewController.mm
2,報錯:找不到 #import
改為 #import
3,在iphone上運行時報錯:
This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app’s Info.plist must contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data.
在info.plist以源碼開啟後加入:
NSCameraUsageDescription
此 App 需要您的同意才能讀取相機
有時候這個檔案並不叫這個名,可能是工程名+info.plist,比如OpenCV Tutorial-Info.plist
總之是有的
4,編譯panorama.framework時報錯找不到ovx.hpp,直接注釋掉那一行
5,調用opencvFace Service,提示找不到haarcascade_frontalface_default.xml檔案,把這個檔案從網上下載下來拖進工程即可
pchFile:
#ifdef __cplusplus
#import
#endif
#import
#ifndef __IPHONE_5_0
#warning "This project uses features only available in iOS SDK 5.0 and later."
#endif
#ifdef __OBJC__
#import
#import
#endif
//匯入OpenCV核心檔案
#import
//匯入支援iOS平台標頭檔
#import
//匯入CC++的命名空間
using namespacecv;
/usr/local/include
/usr/local/include/opencv
/usr/local/lib
應用:
kcf目標跟蹤