Plot on top of a Live Image Preview

조회 수: 34 (최근 30일)
Allison Liu
Allison Liu 2019년 1월 23일
댓글: Allison Liu 2019년 2월 7일
Hello,
I am trying to plot a few points on top of a live image preview, but my code returns an error of "Line cannot be a child of Image." Does anyone know of a way to plot on top of a Live Image, similar to the imageMarker function?
vidRes1 = handles.vid1.VideoResolution;
imWidth1 = vidRes1(1);
imHeight1 = vidRes1(2);
nBands1 = handles.vid1.NumberOfBands;
hImage = image(zeros(imHeight1, imWidth1, nBands1), 'Parent', handles.axes1);
preview(handles.vid1, hImage);
plot(hImage, 250, 300, 'bo');
Thanks,
Allison

채택된 답변

Andrei
Andrei 2019년 2월 1일
Allison,
This approach might work for you:
vid = videoinput('winvideo', 1);
vidInfo = imaqhwinfo(vid);
vidRes = vid.VideoResolution;
imWidth = vidRes(1);
imHeight = vidRes(2);
numBands = vid.NumberOfBands;
hFig = figure;
hAxes = axes(hFig);
hImage = image(hAxes, zeros(imHeight, imWidth, numBands, vidInfo.NativeDataType));
preview(vid, hImage);
hLine = line(hAxes, round([0.25*imWidth, 0.75*imWidth]),...
round([0.5*imHeight, 0.5*imHeight]),...
'Marker', 'o',...
'LineStyle', 'none');
Andrei
  댓글 수: 1
Allison Liu
Allison Liu 2019년 2월 7일
Yes! This worked great, thank you.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by