I understand you might think this is a duplicated question, but so far I did not find solutions to my own problem.
Currently, I have a C program continuously producing streams of data. I hope there is a way for my python program can read those data so I don't have to finish everything in C.
The C program mainly feels like this:
int i = 0;
while(1){
printf("%d %d\n", i, i+1);
i++;
}
I read and tried the subprocess in Python, seems they all need to wait for command to complete.(for example this: Constantly print Subprocess output while process is running) I am hoping some buffer mechanism so I can record this bit stream and process it line by line. Thanks.
Several assumptions:
1) processed line can be discarded
2) buffer/queue size can be no problem since I can control the rate from source to match the processing speed of python program.
A little more background: The C program basicly drives a camera feed (and that's why it is written in C), does some OpenCV stuff and outputs an object position (x, y) int value. The python program needs the position to do some further processing.
Thanks.