Based on https://www.mathworks.com/help/vision/ref/opticalflowhs.estimateflow.html I am able to get the optical flow vectors. I want to use this flow information to compute a bounding box over my image, so I took the maximum of the returned matrix to fit them into a bounding box. However no bounding box is being printed.
nFrames = 0;
while (nFrames<100)
frameRGB = vidDevice();
% Compute optical flow for frame.
flow = estimateFlow(opticFlow,rgb2gray(frameRGB));
maxFlowVx = max(flow.Vx);
maxFlowVy = max(flow.Vy);
bbox = [maxFlowVx(1:2), maxFlowVy(1:2)];
annotatedImage = insertShape(frameRGB,"rectangle",bbox,"LineWidth",8);
imshow(annotatedImage)
hold on
plot(flow,'DecimationFactor',[5 5],'ScaleFactor',25)
hold off
% Increment frame count
nFrames = nFrames + 1;
end