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

4 篇文章 0 订阅

在某项目中使用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 

解决办法:

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

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值