-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlibsvmTest.m
More file actions
47 lines (40 loc) · 1.24 KB
/
libsvmTest.m
File metadata and controls
47 lines (40 loc) · 1.24 KB
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
function [is_need] = libsvmTest(flow,model)
%UNTITLED2 �˴���ʾ�йش˺����ժҪ
% �˴���ʾ��ϸ˵��
u = flow(:,:,1);
v = flow(:,:,2);
params.blockNum = 5;
imageRow = size(u,1);
imageCol = size(v,2);
if mod(imageRow,params.blockNum) == 0
windowSize(1) = imageRow/params.blockNum;
else
rowMore = mod(imageRow,params.blockNum);
imageRow = imageRow - rowMore;
windowSize(1) = imageRow/params.blockNum;
end
if mod(imageCol,params.blockNum) == 0
windowSize(2) = imageCol/params.blockNum;
else
colMore = mod(imageCol,params.blockNum);
imageCol = imageCol - colMore;
windowSize(2) = imageCol/params.blockNum;
end
% ws = min(windowSize);
wi = windowSize(1);
wj = windowSize(2);
for i = 1:5
for j = 1:5
vx(i,j) = sum(sum(u((wi*(i-1)+1):(wi*i),(wj*(j-1)+1):(wj*j))))/(wi*wj);
vy(i,j) = sum(sum(v((wi*(i-1)+1):(wi*i),(wj*(j-1)+1):(wj*j))))/(wi*wj);
% vx(i,j) = mean(u((wi*(i-1)+1):(wi*i),(wj*(j-1)+1):(wj*j)));
% vy(i,j) = mean(v((wi*(i-1)+1):(wi*i),(wj*(j-1)+1):(wj*j)));
end
end
rad = sqrt(vx.^2+vy.^2);
rad = reshape(rad,25,1);
angle = atan(vy./vx);
angle = reshape(angle,25,1);
Vector = [rad;angle]';
is_need = svmpredict([1], Vector, model,'-q');
end