Home > Back-end >  How do I integrate a python script into my WPF C# application?
How do I integrate a python script into my WPF C# application?

Time:04-16

I am currently building an app that displays the video feed of a webcam/external camera. I have written the GUI with C# and in WPF. I have been asked to integrate a python code which does image analysis of the displayed feed. I'm not sure exactly where to begin with this.

I have tried to look into IronPython but the documentation isn't too clear so I'm quite lost. If anyone can point me in the right direction, that would be greatly appreciated.

CodePudding user response:

There are at least two approaches you can take,

  1. Calling Python Script Using New Process Initialization
  2. Calling the Python Script Using IronPython Interpreter, Hosted in Your .NET Application

Check the below post for more information: https://betterprogramming.pub/running-python-script-from-c-and-working-with-the-results-843e68d230e5

Another option is just to separate your application to microservices, and use python as one.

check this: https://softwareengineering.stackexchange.com/questions/385936/how-can-i-integrate-python-code-with-c-code

CodePudding user response:

When it comes to using Python inside .NET applications so Python code can interact with .NET objects, Python.NET and IronPython are two popular choices.

We have implemented our code writing/scripting/debugging solutions for both of these engines, you may read a bit about pros and cons here

  • Related