1

I have a script in C++ done by someone else which is doing online (realtime) analysis from video. In the running code there is a switch case. Each case depend of what is detect in the online video analysis, the frequency of event should be close to 20Hz.

Inside each "case" I would like to send "something" to a python script I am building. The python script is going, online, to count the events and after a threshold value write on a serial port. And do this forever.

My problem is the "online" comminication between both script...
The "already built" software in c++ already send many different cout, so I can't separate the information i want from the other cout. I would like to find an other "output" or a way to distinguish my relevant information... So I want to send from C++ to python

What should I use ? Can I create a pipe from the c++ script to the python script ? how can I do this to make it work "online" ?

Thanks a lot

Dadep
  • 2,796
  • 5
  • 27
  • 40
  • Possible duplicate of [Calling python script from C++ and using its output](http://stackoverflow.com/questions/16962430/calling-python-script-from-c-and-using-its-output) – Johan Lundberg Jul 21 '16 at 22:12
  • If the c++ is using `cout`, then send the data through an anonymous pipe and read stdin in the python. – cdarke Jul 21 '16 at 22:13
  • my problem is to separate de relevant cout information from the others – Dadep Jul 22 '16 at 11:16
  • If the C++ program sends everything to cout, then your only solution is to read the whole output and try to find relevant messages. – Valentin Lorentz Jul 22 '16 at 17:33
  • I'll try to do that, but I can't find a way to read it "online", In everything I have tried, I had to wait for the C++ script end to get the output (like with subprocess.check_output() for example)... – Dadep Jul 22 '16 at 19:44

1 Answers1

0

I found a way using "pipe" in a shell script :

./scriptc++ | ./script2.py

the standard output of my C++ a redirected to the standard input of my puthon script It work !

Dadep
  • 2,796
  • 5
  • 27
  • 40