我在这个使用emgucv(.net的opencv包装器)的程序中挣扎了大约2周。不幸的是,问题不是编程,而是以一种可行的方式设置emgucv。我没有为vb.net做到这一点,所以我尝试为ironpython这样做(因为我也知道python)。 Emgucv在使用ironpython时似乎可以完美地工作,因此我创建了一个函数,该函数将图像作为参数并按照我想要的方式对其进行分析,并返回其中包含结果的另一个图像。问题是我想调用此函数,从VB.net中给它提供图像参数(它可能是包含路径的字符串),并成为另一个包含结果图像作为返回值的字符串。稍后我计划将该项目打包在安装程序中,以便我可以重新分发它。
所以我问你们:您知道一种简单的方法来调用VB.net中的IronPython函数,这样我也可以打包整个项目并将其重新分发给人们吗?
非常感谢您阅读本文,如果您也可以帮助我解决我的问题,那就太好了! :)
最佳答案
虽然IronPython不是我的专长,但我对EMGU及其应用程序非常熟悉。如果您坚持使用IronPython,则以下网站清楚地说明了如何将字符串传递给IronPython Class.
以下代码是从链接中获取的,而不是我自己的:
Option Explicit On
Option Strict On
Imports Microsoft.Scripting.Hosting
Imports IronPython.Hosting
Imports IronPython.Runtime.Types
Module Module1
Sub Main()
Dim helloWorld As New HelloWorldVB()
Console.WriteLine(helloWorld.HelloWorld("Maurice"))
Dim runtime As ScriptRuntime = PythonEngine.CurrentEngine.Runtime
Dim scope As ScriptScope = runtime.ExecuteFile("HelloWorld.py")
Dim pythonType As PythonType = scope.GetVariable(Of PythonType)("HelloWorldIronPython")
helloWorld = CType(runtime.Operations.Call(pythonType), HelloWorldVB)
Console.WriteLine(helloWorld.HelloWorld("Maurice"))
Console.ReadLine()
End Sub
End Module
**Imports Microsoft.Scripting.Hosting
Imports IronPython.Hosting
Imports IronPython.Runtime.Types**
**Dim runtime As ScriptRuntime = PythonEngine.CurrentEngine.Runtime
Dim scope As ScriptScope = runtime.ExecuteFile("HelloWorld.py")
Dim pythonType As PythonType = scope.GetVariable(Of PythonType)("HelloWorldIronPython")
helloWorld = CType(runtime.Operations.Call(pythonType), HelloWorldVB)
Console.WriteLine(helloWorld.HelloWorld("Maurice"))**
https://stackoverflow.com/questions/7112024/
相关文章:
image-processing - 有关cvPerspectiveTransform的OpenCV
docker - chown : changing ownership of '/var/lib/m
opencv - 段错误 OpenCV/Facedetect.c/CentOS 6 64Bit
visual-studio-2010 - 如何在VS2010 Windows 7中安装tbb_ded
python - 'import cv' 之后的 `Fatal Python error: PyTh