you need a corresponding waitKey(20); after the imshow() , – else nothing gets rendered.
waitKey(20);
imshow()