Acquire an image from a live video while projecting on it a rectangle
3 次查看(过去 30 天)
显示 更早的评论
Hi, I have the image acquisition toolbox and I've tried several ways to do this but I can't figure it out.
My goal is to use the getsnapshot function (idk if there is another way) manually when I place a checkerboard near from a rectangle that I have projected on the camera laptop preview (by using patch funtion e.g. to make the rectangle).
I've tried this by making a GUI or AppDesigner but my problem is that after executing getsnaphot I have to save the image on the Matlab's workspace but idk how to this.
This is an example of what I am trying to do:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/234008/image.png)
But I only need to project the borders and not all the grid
I tried it with this code:
vid = videoinput('winvideo');
set(vid,'FramesPerTrigger',inf);
set(vid,'ReturnedColorspace','rgb');
vid.FrameGrabInterval = 2; %cada 5 frames cogemos uno nuevo
start(vid);
while (vid.FramesAcquired <= 200)
data = getsnapshot(vid);
imshow(data);
hold on;
axis ij;
patch('Faces',face,'Vertices',vert,'FaceAlpha',0);
hold off
end
stop(vid);
flushdata(vid);
delete(vid);
clear vid
The rectangle projects well, and the effect of live video is working by taking and showing multiple frames by imshow.
However, the problem here is that in order to do this, I am constantly taking snapshots but I have to save only one (when the checkerboard is close enough to the projected rectangle and I decide to save it) by pushing a button from a GUI or AppDesigner e.g. (Idk if there is another possibility).
Any help would be appreciated,
Thanks
0 个评论
回答(1 个)
Sid Singh
2019-10-23
Hi, you are using the patch command to draw the grid. There is a way to avoid Face colors by using
v = [0 0; 1 0; 1 1];
f = [1 2 3];
figure
patch('Faces',f,'Vertices',v,...
'EdgeColor','green','FaceColor','none','LineWidth',2);
You can refer this documentation for more details under Polygon Edges Without Faces.
0 个评论
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!