Plotting ROI
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
[EDIT: 20110620 16:25 CDT - reformat - WDR]
Hi
I am working with video on matlab.
I want to mention ROI(one or more) in the frames.
I get the starting and the ending macro block numbers and I make a rectangle and plot the ROI.
The problem with my code is, I am able to plot the box on the image if I have one ROI, but I am not able to mention two ROI, it gets updated to the new set:)
I want to plot two ROIs on a frame.
(I have the code I have written , can any one help em with that)
Thank you in advance.
clc;
close all;
clear all;
frames = yuv2mov('coastguard_dec.yuv',352,288,'420');
MB_map = importdata('roiOutput.dat');
PicWidthInMbs = 22;
ROI = 2;
I=vec2mat(MB_map,2);
[r1 c1]=size(frames);
disp(I);
[r c]=size(I);
for i=1: %framenumber
for j=1:ROI
top_left(j) = I(j,1);%+1;
bottom_right(j) = I(j,2);%+1;
fprintf('topleft=%d bottomright =%d \n',top_left(j),bottom_right(j));
yTopLeft(j) =
xTopLeft(j) =
yBottomRight(j) =
xBottomRight(j) =
xstart(j) = xTopLeft(j)*16+1;
ystart(j) = yTopLeft(j)*16+1;
yend(j) = yBottomRight(j)*16+16+1;
xend(j) = xBottomRight(j)*16+16+1;
frame1 = frames(i).cdata(:,:,:);
frame1(ystart(j),xstart(j):xend(j),:)=0;
frame1(yend(j),xstart(j):xend(j),:)=0;
frame1(ystart(j):yend(j),xstart(j),:)=0;
frame1(ystart(j):yend(j),xend(j),:)=0;
%hold on
figure(i)
hold on
imshow(frame1),title(i);
hold on
end
end
0 comentarios
Respuestas (1)
Walter Roberson
el 20 de Jun. de 2011
Move the line
frame1 = frames(i).cdata(:,:,:);
to be between the "for i" and "for j" loops.
3 comentarios
Walter Roberson
el 20 de Jun. de 2011
http://www.mathworks.com/help/techdoc/ref/videowriter.writevideo.html
VideoWriter is the recommended method these days, but if you have older software then you may need to use movie2avi()
Ver también
Categorías
Más información sobre Computer Vision with Simulink en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!