-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvideoCornerDetector.m
71 lines (63 loc) · 1.86 KB
/
videoCornerDetector.m
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
load('BW1.mat','BW');
load('threshold.mat','threshold');
reader = vision.VideoFileReader('video1.avi');
videoPlayer = vision.DeployableVideoPlayer();
frame1 = reader.step();
for i =1:10
frame2 = reader.step();
end
imwrite(frame1,'C:\Group Detection Project\Vignesh BG Substract\BGsubtract\output\frame1.jpg');
imwrite(frame2,'C:\Group Detection Project\Vignesh BG Substract\BGsubtract\output\frame2.jpg');
figure
hold on
while ~isDone(reader)
I = reader.step();
I =rgb2gray(I);
C = corner(I,320);
noOfCorners = size(C);
noOfCorners = noOfCorners(1);
r = [];
c = [];
for i=1:noOfCorners
if (BW(C(i,2),C(i,1))==1)
r = [r; C(i,2)];
c = [c; C(i,1)];
end
end
cr = [];
cc = [];
noOfCorners = length(r);
isAllocated = zeros(1,noOfCorners);
for i=1:noOfCorners
if (isAllocated(i) ~= 1)
isAllocated(i) = 1;
count = 1;
cenR = r(i); cenC = c(i);
for j=1:noOfCorners
if (i~=j)
distance = (r(i)-r(j))^2+(c(i)-c(j))^2
if distance<threshold(ceil((r(j)+r(i))/2)) %3000
isAllocated(j) = 1;
count = count + 1;
cenR = cenR + r(j);
cenC = cenC + c(j);
end
end
end
cenR = cenR /count;
cenC = cenC /count;
cr = [cr; cenR];
cc = [cc; cenC];
end
end
radii =25*ones(1,length(cc));
centers = [cc,cr];
for i=1:length(cc)
I=insertShape(I,'circle',[cc(i),cr(i),radii(i)],'LineWidth',2);
end
%I=insertShape(I,'circle',[50 50 30],'LineWidth',2);
imshow(I);
%hold on
%plot(c, r, 'r*');
%viscircles(centers,radii);
end