Have you called cvNamedWindow yet? It will not work without cvNamedWindow.
cvNamedWindow
http://stackoverflow.com/questions/7697819/why-cvwaitkey0-doesnt-work