问题描述
当前,我正在尝试转换一些用python编写的脚本,以便能够在Unity3d中运行。 我碰到了本教程https://mikalikes.men/use-python-with-unity-3d-the-definitive-guide/ 并且示例程序运行正常。 然而, 尝试使用OpenCV运行此脚本以流式传输视频时遇到了此错误。
using System.Collections;
using System.Collections.Generic;
using IronPython.Hosting;
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class StreamFromComputer: MonoBehavIoUr
{
public Button PIButton;
void Start()
{
Button btn = PIButton.GetComponent<Button>();
btn.onClick.AddListener(PIOnClick);
}
void PIOnClick()
{
Debug.Log("You have clicked the button!");
var engine = Python.CreateEngine();
ICollection<string> searchPaths = engine.GetSearchPaths();
//Path to the folder of greeter.py
searchPaths.Add(@"C:\Users\adam\.spyder-py3");
//Path to the Python standard library
searchPaths.Add(@"D:\ls_alpha\AdamsPlantProcessing\Assets\Plugins\Lib");
engine.SetSearchPaths(searchPaths);
dynamic py = engine.ExecuteFile(@"C:\Users\adam\.spyder-py3\streamfrompi.py");
Debug.Log("did that shit work");
}
}
-------
ImportException: No module named cv2
Microsoft.Scripting.Runtime.LightExceptions.ThrowException (Microsoft.Scripting.Runtime.LightExceptions+LightException lightEx) (at <6a70babe64d34e1b9136298538676a61>:0)
Microsoft.Scripting.Runtime.LightExceptions.CheckAndThrow (System.Object value) (at <6a70babe64d34e1b9136298538676a61>:0)
因此,我调查了IRonClad,但在使它在正在使用的系统中工作时遇到了麻烦。我提取到C:但是当我进入终端> python> import ironclad时,我最终得到了
>>> import ironclad
Traceback (most recent call last):
File "<stdin>",line 1,in <module>
File "C:\ironclad-v2.6.0rc1-bin\ironclad-v2.6.0rc1-bin\ironclad\__init__.py",line 42
except Exception,e:
^
SyntaxError: invalid Syntax
目前,我的统一3D场景有3个按钮,一个用于启动流,一个用于启动相机。 我正在使用python进行图像处理,并统一使用UI和系统。我想我要问的是如何正确安装它,这样我就不会收到错误消息。我想我也在问是否有更好的方法可以将python机器学习打包为统一或串联在Windows或Linux设备上。
编辑/更新9/2/2020
当前我处于停滞状态,因为Ironclad仅适用于python 2.7而不适用于3.7。无论我能否查看我的整个项目是否可以降级。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)