Using OpenCV in Python via a C# application [closed]

asked 2019-04-04 05:58:46 -0600

droog_the_droog gravatar image


I'm looking to build a demo for a program that I've written using the Python bindings for OpenCV. I'm writing the demo in C#, and am wondering if anyone has any tips and tricks for when it comes to running a Python script from C#? Currently am defining a process like

            ProcessStartInfo myProcessStartInfo = new ProcessStartInfo();
            myProcessStartInfo.FileName = "C:\...path to my python.exe";
            myProcessStartInfo.Arguments = relevantArguments;
            myProcessStartInfo.UseShellExecute = false;
            myProcessStartInfo.UseShellExecute = false;
            myProcessStartInfo.CreateNoWindow = true;
            myProcessStartInfo.RedirectStandardOutput = true;
            myProcessStartInfo.RedirectStandardError = true;

and then I run a process like

            using (Process process = Process.Start(start))
                using (StreamReader reader = process.StandardOutput)
                    string stderr = process.StandardError.ReadToEnd(); 
                    string result = reader.ReadToEnd();

Problems arise when I start doing feature detection in my script, in particular I run .detectAndCompute on an image, and the application just breaks. I'm rather new to C#, so any ideas or hints are helpful.

Thanks, Nik

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant by berak
close date 2019-04-04 05:59:18.954854