在Unity程序中使用YOLOv4识别物体时报错CvException

04-13 594阅读

在某项目中使用OpenCV for Unity中YOLOv4识别物体,在Unity编辑环境下运行得好好的,发布出来一运行就报错。刚开始以为是显卡原因,换了几台电脑都报错,后来发现是中文路径的问题。

CvException: An error occurred on the C++ side, causing the class initialization to fail.Enclose the point where the error occurs in Utils.setDebugMode() method, and the error on the C++ side will be displayed on the console.

CvException: An error occurred on the C++ side, causing the class initialization to fail.Enclose the point where the error occurs in Utils.setDebugMode() method, and the error on the C++ side will be displayed on the console.
  at OpenCVForUnity.DisposableObject.ThrowIfNullIntPtr (System.IntPtr ptr) [0x0001f] in D:\Project\CdEnjoy\ShootProjects\RealTimeShootVideo\Assets\OpenCVForUnity\org\opencv\DisposableObject.cs:61 
  at OpenCVForUnity.DnnModule.DetectionModel..ctor (System.String model, System.String config) [0x00000] in D:\Project\CdEnjoy\ShootProjects\RealTimeShootVideo\Assets\OpenCVForUnity\org\opencv\dnn\DetectionModel.cs:63 
  at OpenCVForUnityExample.DnnModel.YOLOv4ObjectDetector..ctor (System.String modelFilepath, System.String configFilepath, System.String classesFilepath, OpenCVForUnity.CoreModule.Size inputSize, System.Single confThreshold, System.Single nmsThreshold, System.Int32 topK, System.Int32 backend, System.Int32 target) [0x0001e] in D:\Project\CdEnjoy\ShootProjects\RealTimeShootVideo\Assets\OpenCVForUnity\Examples\MainModules\dnn\ObjectDetectionYOLOv4Example\YOLOv4ObjectDetector.cs:46 
  at OpenCVForUnityExample.MyObjectDetection.Run () [0x0006a] in D:\Project\CdEnjoy\ShootProjects\RealTimeShootVideo\Assets\Scenes\MyObjectDetection.cs:100 
  at OpenCVForUnityExample.MyObjectDetection.Start () [0x00116] in D:\Project\CdEnjoy\ShootProjects\RealTimeShootVideo\Assets\Scenes\MyObjectDetection.cs:84 

在Unity程序中使用YOLOv4识别物体时报错CvException解决办法:

程序所在路径不要有中文,只能全英文。

VPS购买请点击我

文章版权声明:除非注明,否则均为主机测评原创文章,转载或复制请以超链接形式并注明出处。

目录[+]