Akiresu
Akiresu

Reputation: 18

Running C++ Qt app from C#

Introduction: I have qt-opencv-multithreaded - Qt/OpenCv application writen in C++ (running on Windows). But I also have another application written in C#.

C++ app does analysis of video and identifies robots (position, rotation). And stores it in variable inside ProcessingThread. C# app receives these values and decides where should robots move.

I decided to use C# project as startup project. And I tried to create C++/cli wrapper for qt-opencv-multithreaded .

Questions: Now I have two questions:

  1. How do I run the Qt app from another project? I tried to add include MainWindow.h to wrapper project and create instance from it. I added also directory of qt-opencv-multithreaded to "Additional Include Directories" but it wants also qt directories and I am worried that it is not a right way to do it. So how should I do it?

  2. I know I need to use wrapper. But how do I sent data stored in list of robots in C++ project in processing thread to C# project? (where robot includes cv::Point2i position and cv::Point2i rotation and some other not important inner class) I tried to "pseudoserialize" values into string, send it to C#, and then "deserialize" it to prepared object. But it seems somehow wrong. Is there simple way to do what I need?

Thank you

Upvotes: 0

Views: 396

Answers (1)

Matt Kline
Matt Kline

Reputation: 10477

  1. If you want to run it as a stand-alone process, C# provides facilities for doing so.

  2. If you want to call individual functions of your C++ code from C#, look into P/Invoke

Upvotes: 2

Related Questions