简体   繁体   English

Lua脚本和C#

[英]Lua Scripting and C#

this is quite tricky for me and i'm hoping someone can help me out. 这对我来说很棘手,我希望有人能帮助我。

The situation: I'm currently working an application in C# 3.5 .NET , it interfaces with a DLL written in C++ using DLL Imports, that all works fine. 情况:我当前正在C#3.5 .NET中运行一个应用程序,它与使用DLL Imports用C ++编写的DLL交互,一切正常。 I also have a Lua script, this script is as follows: 我也有一个Lua脚本,这个脚本如下:

Width           = XCamera():GetWidth()
Height          = XCamera():GetHeight()
Img             = XSensorImage()

then for example, there is a function that calculates the temperature from Img by: 那么例如,有一个函数可以通过以下方式根据Img计算温度:

function OnFrame()
     local CoordsTable = { i, j }
     local PixelTable = Img:GetPixels( CoordsTable )
     PixelValue = FromLinearizedADU( PixelTable[1] or 0 )
end

what I want to be able to do, is return PixelValue to my application. 我想要做的是将PixelValue返回到我的应用程序。

XCamera() & XSensorImage() are instances created when the camera filters are initialized and the Lua script is active. XCamera()和XSensorImage()是在初始化相机滤镜并激活Lua脚本时创建的实例。

Is there anyway of accessing Pixel Value from this script when it is running? 无论如何,该脚本运行时是否可以从其访问像素值? I'm sorry if I'm not being detailed enough, please ask if you require more, your feedback is much appreciated. 很抱歉,如果我不够详细,请询问是否需要更多,我们非常感谢您的反馈意见。

您可以从函数返回PixelValue。

return PixelValue;

Is the C++ DLL hosting the Lua runtime, and not your C# app? 是C ++ DLL托管Lua运​​行时,而不是C#应用程序吗? Then, no, there's probably no easy way to do that. 然后,不,可能没有简单的方法可以做到这一点。 If the DLL is using a shared Lua DLL and doesn't have extensions locked down, you could potentially load a library that uses some form of interprocess communication to communicate back to the C# app. 如果DLL使用的是共享的Lua DLL,并且没有锁定扩展名,则可能会加载使用某种形式的进程间通信与C#应用通信的库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM