Ok I could solve the problem... I use
frameWithFlow = getframe(gca);
imshow(frameWithFlow.cdata)
now I am getting the optical flow over each frame.
But still, there is one problem the video gets very slow how can I make it run with normal video speed? (or at least faster than the current one)