将图像对象作为参数从C#传递到Python

问题描述 投票:1回答:2

我想将图像对象从我的C#项目传递到我的python脚本,但是据我了解,无论参数中有什么,它都被认为是字符串,而且当我在python中尝试type(passedImage)时,即使将其识别为字符串,即使我尝试输入数字而不是图像变量。

ProcessStartInfo start = new ProcessStartInfo();
            start.FileName = @"C:\Python\Python36\python.exe";
            start.Arguments = string.Format("{0} {1}", @"C:\OCRonImage2.py", image );
            start.UseShellExecute = false;
            start.RedirectStandardOutput = true;
            start.CreateNoWindow = true;
            using (Process process = Process.Start(start))
            {

            }
c# python parameter-passing
2个回答
0
投票

我认为通过IMAGE作为Argument会很不好。

不错的选择:


0
投票

您可以将图像另存为文件,放在本地计算机的某个位置,并为python程序提供读取图像的路径。

这是我认为您可以做的最简单的方法。

© www.soinside.com 2019 - 2024. All rights reserved.