How to draw a circle on moving video on matlab?
Show older comments
I would like to figure a circle on moving image by using a usb-camera. My simply-made code goes like this.
clc;
clear all;
vid=videoinput('winvideo',1,'YUY2_160x120');
preview(vid);
vid.ReturnedColorSpace='rgb';
for t=0:2*pi/400:2*pi
x=round(10*cos(t)+50);
y=round(15*sin(t)+50);
xx=round(10*cos(t)+50);
yy=round(15*sin(t)+110);
xxx=round(20*cos(t)+60);
yyy=round(15*sin(t)+80);
vid(x,y,1)=200;
vid(xx,yy,2)=200;
vid(xxx,yyy,3)=200;
end
imshow(vid);
but the error message says 'Video input objects can only be concatenated with other video input objects.'. how can I handle this thing?
Answers (1)
Image Analyst
on 28 May 2013
0 votes
Plot it in the overlay with plot(). See the FAQ: http://matlab.wikia.com/wiki/FAQ#How_do_I_create_a_circle.3F
4 Comments
seo
on 28 May 2013
Image Analyst
on 28 May 2013
I have stuff in the overlay above live video all the time. Like a circle in red and the live video moving underneath it. Is that what you're wanting to do? Or do you want to capture video and actually "burn" the circle into the pixels of each frame? Where each frame actually has pixels in a circle that are pure red and not the video colors they started out with?
seo
on 29 May 2013
Image Analyst
on 29 May 2013
You can't use imshow() because that will put an opaque image in the buffer, essentially covering up your live video. You need to use computer graphics. See the FAQ for how to create a N by 2 list of (x,y) coordinates, and then use plot(x, y, 'r-') to plot those coordinates over the live video.
Categories
Find more on Image Acquisition Support Packages for Hardware Adaptors (Generic Video Interface) in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!