Q: Running opencv program in background without opening a cv window terminates instantly I am running a opencv program to get some x and y coordinates from a live video. Running the program in background without opening any cv2 window to just get the co-ordinates doesn't works and the program terminates instantly. When I run by opening any cv2 window the program runs perfectly.

A: I'd second iGian's answer. Please post some code.
From what you describe I'd assume your OpenCV calculation somehow runs in a separate thread that doesn't block the main thread. So what happens is:
- main thread -> start calculation thread
- main thread -> I'm finished, shut everything down including the calculation thread

When you now do something like cv.imshow() and cv.waitkey() from your main thread it looks like this:
- main thread -> start calculation thread
- main thread -> wait for a key to be pressed
- calculation thread -> keep calculating
- ...
- ...
- main thread -> "a key has been pressed"
- main thread -> I'm finished, shut everything down including the calculation thread

But that's a pretty blind guess since we need your code to see what really happens. A solution to the scenario above would be to make the main thread wait until a condition has been fulfilled - e.g. the calculation thread sends an event or writes into a condition variable.
