how to insert a rectangle to a video preview

im using my webcam to take an image of the user. I want to insert a rectangle to the video preview so that user can put his face within that boundary.
cem=webcam('Lenovo EasyCam');
preview(cem);
img=snapshot(cem);
preview(img);
hold on
thisBB = [10 10 300 300];
rectangle('Position', [thisBB(1),thisBB(2),thisBB(3),thisBB(4)],'EdgeColor','r','LineWidth',2 );

댓글 수: 1

hervey he
hervey he 2019년 12월 1일
Hi man, have you resoluted this problem? I also want that fuction too.

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

답변 (2개)

Image Analyst
Image Analyst 2017년 4월 22일

0 개 추천

I don't think you want these lines:
img=snapshot(cem);
preview(img);
hold on
Getting a snapshot into a variable img is fine (not sure if it would freeze the video after that though) but then passing an image to preview instead of a video object will probably cause problems. Play around with hold on to see if you need to put it before or after rectangle or if you even need it at all.

댓글 수: 1

I want rectangle in the live video preview itself
cem=webcam('Lenovo EasyCam'); preview(cem); pause(); img=snapshot(cem); hold on thisBB = [10 10 300 300]; rectangle('Position',[thisBB(1),thisBB(2),thisBB(3),thisBB(4)],'EdgeColor','r','LineWidth',2 );

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

Thushar Praveen
Thushar Praveen 2017년 4월 27일

0 개 추천

I want rectangle in the live video preview itself
cem=webcam('Lenovo EasyCam');
preview(cem);
pause();
img=snapshot(cem);
hold on
thisBB = [10 10 300 300];
rectangle('Position',[thisBB(1),thisBB(2),thisBB(3),thisBB(4)],'EdgeColor','r','LineWidth',2 );

태그

질문:

2017년 4월 22일

댓글:

2020년 8월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by