-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvideoproc.m
More file actions
29 lines (25 loc) · 725 Bytes
/
videoproc.m
File metadata and controls
29 lines (25 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
v = VideoReader('example1.mp4');
for i = 1:v.NumFrames
frame = read(v,i);
I = rgb2gray(frame);
BW = imbinarize(I);
out = edge(I, 'Roberts');
[H,T,R] = hough(out);
P = houghpeaks(H, 3, 'threshold', ceil(0.3*max(H(:))));
lines = houghlines(BW, T, R, P, 'FillGap', 5, 'MinLength', 7);
imshow(out), hold on
for k = 1:length(lines)
xy = [lines(k).point1; lines(k).point2];
plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');
end
hold off
F(i) = getframe(gcf);
end
video = VideoWriter('myvideo.avi');
video.FrameRate = v.FrameRate;
open(video);
for i=1:length(F)
frame = F(i) ;
writeVideo(video, frame);
end
close(video);