Itseez/opencv — pull request #1490 by alalek (2013-09-22 10:29:00+00:00)
Title: Proposals for OpenCV_Init()/OpenCV_Shutdown()

We need some functionality for properly library shutdown to release resources and terminate own thread pools.
But approaches with `atexit()` or destructors for global objects don't work inside **DLLs implementations**. Problem is: "callbacks" are usually called on `DLL_PROCESS_DETACH` message after `ExitProcess()` call (see http://msdn.microsoft.com/en-us/library/windows/desktop/ms682658(v=vs.85).aspx )

Many libraries uses schemes like this:
```
// user application
int main(...)
{
cv::core::OpenCV_Init();
...
cv::core::OpenCV_Shutdown();
return 0;
}
```
But we should not break compatibility with the existed user code, so users should not insert these calls into `main()`.

This proposals require to include `opencv2/core/core.hpp` (that includes `opencv2/core/init.hpp`) from any source file of application. There are no restrictions to one or several source files (`inline` and `template` resolves this issue).
**But it works for C++ code only, not C. Also I have no idea how it will work with Python/Java/etc bindings.**

These commits contain implementation and usage example.
Let's discuss. Any comments are welcome.