summaryrefslogtreecommitdiffstats
path: root/SD-VBS/common/toolbox/lagrcv/test/test_lk_disp.m
diff options
context:
space:
mode:
authorleochanj105 <leochanj@live.unc.edu>2020-10-19 23:09:30 -0400
committerleochanj105 <leochanj@live.unc.edu>2020-10-20 02:40:39 -0400
commitf618466c25d43f3bae9e40920273bf77de1e1149 (patch)
tree460e739e2165b8a9c37a9c7ab1b60f5874903543 /SD-VBS/common/toolbox/lagrcv/test/test_lk_disp.m
parent47ced4e96bbb782b9e780e8f2cfc637b2c21ff44 (diff)
initial sd-vbs
initial sd-vbs add sd-vbs sd-vbs
Diffstat (limited to 'SD-VBS/common/toolbox/lagrcv/test/test_lk_disp.m')
-rwxr-xr-xSD-VBS/common/toolbox/lagrcv/test/test_lk_disp.m49
1 files changed, 49 insertions, 0 deletions
diff --git a/SD-VBS/common/toolbox/lagrcv/test/test_lk_disp.m b/SD-VBS/common/toolbox/lagrcv/test/test_lk_disp.m
new file mode 100755
index 0000000..2d55fe3
--- /dev/null
+++ b/SD-VBS/common/toolbox/lagrcv/test/test_lk_disp.m
@@ -0,0 +1,49 @@
1addpath /u/ikkjin/Matlab/Toolbox/lagrcv
2
3%Iprev=imread('/Projects/LAGR/logs/Test5/left_APIrun530-1/l24Aug05-abacination-1124876208.403311.ppm');
4%Icur=imread('/Projects/LAGR/logs/Test5/left_APIrun530-1/l24Aug05-abacination-1124876208.670013.ppm');
5Iprev=imread('img0.ppm');
6Icur=imread('img1.ppm');
7
8Iprev=rgb2gray(Iprev);
9Icur=rgb2gray(Icur);
10
11tic
12 [ features numvalid ] = goodFeaturesToTrack(Iprev, 0.3, 10);
13toc
14subplot(1,2,1);imshow(Iprev)
15hold on
16scatter(features(2,:),features(1,:),'r')
17
18Ipyr=getPyramid(Iprev, 3);
19Jpyr=getPyramid(Icur, 3);
20tic
21[dxPyr2 dyPyr2]=calcGradientPyrMex(Ipyr,3);
22toc
23tic
24[dxPyr dyPyr]=calcSobelPyrMex(Ipyr,3);
25toc
26
27features=features(:,1:211);
28for i=20
29 features2=[features(2,:); features(1,:)];
30tic
31 [ newpoints status pyr1 ] = calcOpticalFlowPyrLK(Iprev,Icur,features, i);
32toc
33tic
34 [newpoints2 status]=calcOptFlowLKPyrMex(Ipyr, dxPyr, dyPyr, Jpyr, double(features2), 4, 0.03, i);
35toc
36 newpoints2=[newpoints2(2,:); newpoints2(1,:)];
37features_out=features(:,find(status));
38newpoints=newpoints(:,find(status));
39newpoints2=newpoints2(:,find(status));
40subplot(1,2,1);imshow(Iprev);hold on
41quiver(features_out(2,:),features_out(1,:), newpoints(2,:)-features_out(2,:), newpoints(1,:)-features_out(1,:),0,'r');hold off
42subplot(1,2,2);imshow(Iprev);hold on
43quiver(features_out(2,:),features_out(1,:), newpoints2(2,:)-features_out(2,:), newpoints2(1,:)-features_out(1,:),0,'r');hold off
44%subplot(1,2,2);imshow(Icur);hold on
45%scatter(newpoints2(2,:),newpoints2(1,:),'r');hold off
46%sum(sum((newpoints-newpoints2).^2))
47
48pause
49end