Search code examples
matlabcomputer-visionmatlab-cvst

How to draw a line on a video frame in MATLAB


I am trying to draw a thin red line along the dark stick from edge to the moving part's green point which I found before on a video. I am handling the video frame by frame.

I can find the two points ( starting and ending points) but I am stuck how to make the two points and the points between them red linearly.

for example

for the current frame in the picture the top point coordinate is 45 down and 237 right from the top left(0,0) corner and the green point's coordinate is 231 down and 238 right from the top left corner.

So I need to draw a line from (237,45) to (231,238).

How I made the mid point green is substituting the pixel values in the current frame matrix. I am trying to make a similar approach but there could be more efficient way.

enter image description here


Solution

  • Unfortunately, you cannot use handle graphics commands on a vision.VideoPlayer. However, there is a function insertShape, which lets you draw directly into the image, before you display it.