2015-08-26 11:19:38 -0600 | commented question | highgui and fork() Thanks @berak, I've researched a bit about select() and I think I can adapt my program for it, your response was really helpful. But maybe in future I'll need to use fork() again. I still wanna know why does imshow() and waitKey() behaves this way when a call to fork() was issued. Thanks again! |
2015-08-26 09:13:40 -0600 | asked a question | highgui and fork() Hi all! I'm using OpenCV in a project at work, I won't enter in details because the algorithm is irrelevant for my problem. The thing is, my program uses one or more processes as it listens on a socket and then accept incoming connections by fork()-ing to dispatch clients into child programs. After the call to fork() trying to display an image with imshow() just doesn't work. Calling to imshow() and then waitKey(0) doesn't display anything and then the window hangs (on Ubuntu, it becomes "shadowed" which means that window isn't responding to the WM anymore). As I need to be able to see some images (results of my algorithm), I need to be able to successfully display some images that a child program generates. I also noticed that some errors appears when calling waitKey(), imshow() by itself doesn't show errors neither works as expected. 1) Is it possible to call imshow() and waitKey() from a child after fork()? 2) Is it possible to do the same from the parent after calling fork()? It seems to be problematic too. 3) Is there another way to display images from the child? 4) Why does this happens? I want to know because I want to get a deeper understanding in this and why this fails to avoid future problems and well... to learn :) In case it helps, I'm attaching some code that I used to reproduce this issue. Program output is this:
|