1.在建立c++文件后导入插件https://github.com/Brandon-Wilson/OpenCV-Plugin
2.在ue4中edit->plugins中滑到最后勾选computer vision中的opencv中的enabled(这一步一定要先勾选好否则后面会报错)然后重启
3.在vs中编译,报错后把插件中的opencv.build.cs文件改成这样
// Some copyright should be here...
using UnrealBuildTool;
using System.IO;
public class OpenCV : ModuleRules
{
private string ThirdPartyPath
{
get { return Path.GetFullPath(Path.Combine(ModuleDirectory, "../../../../ThirdParty/")); }
}
public OpenCV(ReadOnlyTargetRules Target) : base(Target)
{
// Startard Module Dependencies
PublicDependencyModuleNames.AddRange(new string[] { "Core", "RHI", "RenderCore" });
PrivateDependencyModuleNames.AddRange(new string[] { "CoreUObject", "Engine", "Slate", "SlateCore" });
// Start OpenCV linking here!
bool isLibrarySupported = false;
// Create OpenCV Path
s