summaryrefslogtreecommitdiffstats
path: root/SD-VBS/common/toolbox/lagrcv/test/test_lk_opencv.m
diff options
context:
space:
mode:
authorLeo Chan <leochanj@live.unc.edu>2020-10-22 01:53:21 -0400
committerJoshua Bakita <jbakita@cs.unc.edu>2020-10-22 01:56:35 -0400
commitd17b33131c14864bd1eae275f49a3f148e21cf29 (patch)
tree0d8f77922e8d193cb0f6edab83018f057aad64a0 /SD-VBS/common/toolbox/lagrcv/test/test_lk_opencv.m
parent601ed25a4c5b66cb75315832c15613a727db2c26 (diff)
Squashed commit of the sb-vbs branch.
Includes the SD-VBS benchmarks modified to: - Use libextra to loop as realtime jobs - Preallocate memory before starting their main computation - Accept input via stdin instead of via argc Does not include the SD-VBS matlab code. Fixes libextra execution in LITMUS^RT.
Diffstat (limited to 'SD-VBS/common/toolbox/lagrcv/test/test_lk_opencv.m')
-rwxr-xr-xSD-VBS/common/toolbox/lagrcv/test/test_lk_opencv.m47
1 files changed, 47 insertions, 0 deletions
diff --git a/SD-VBS/common/toolbox/lagrcv/test/test_lk_opencv.m b/SD-VBS/common/toolbox/lagrcv/test/test_lk_opencv.m
new file mode 100755
index 0000000..9cfd1ae
--- /dev/null
+++ b/SD-VBS/common/toolbox/lagrcv/test/test_lk_opencv.m
@@ -0,0 +1,47 @@
1addpath ~/Matlab/Toolbox/lagrcv/
2addpath ~/Matlab/Toolbox/toolbox_basic/filter
3addpath ~/Matlab/Toolbox/ikkjin/
4
5IMAGE_DIR='/data/insecure/images/ants/Transport/'
6filelist=dir(fullfile(IMAGE_DIR, '*.jpg'));
7flen=length(filelist);
8
9img_idx_cur=[1:flen];
10
11%subplot(1,2,1);imshow(Iprev)
12%/hold on
13%//scatter(features(2,:),features(1,:),'r')
14%Iprev=imread(fullfile(IMAGE_DIR,filelist(img_idx_prev(1)).name));
15%%
16imgName=fullfile(IMAGE_DIR,filelist(img_idx_cur(1)).name);
17Icur=imread(imgName);
18%%
19Icur=smooth(double(rgb2gray(Icur)), 4);
20%%
21Icur=Icur(1:2:end,1:2:end);
22
23[ features numvalid ] = goodFeaturesToTrack(Icur, 0.3, 10);
24features=features(:,1:numvalid);
25
26figure(1);
27imagesc(Icur);colormap gray
28hold on;scatter(features(2,:), features(1,:), 'r+'); hold off;
29
30%%
31for iter=img_idx_cur
32 Iprev=Icur;
33 Icur=imread(fullfile(IMAGE_DIR,filelist(img_idx_cur(iter)).name));
34 Icur=calcImgBlurMex(rgb2gray(Icur));
35
36 tic
37 [ newpoints status pyr1 ] = calcOpticalFlowPyrLK(Iprev,Icur,features);
38 toc
39 newpoints=newpoints(:,find(status));
40 figure(1);
41 imagesc(Icur);colormap gray
42 hold on;scatter(newpoints(2,:), newpoints(1,:), 'r+'); hold off;
43 drawnow
44 print('-djpeg', sprintf('result/result_%03d', iter))
45 %pause
46 features=newpoints;
47end