From d17b33131c14864bd1eae275f49a3f148e21cf29 Mon Sep 17 00:00:00 2001 From: Leo Chan Date: Thu, 22 Oct 2020 01:53:21 -0400 Subject: 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. --- SD-VBS/common/toolbox/lagrcv/test/test_lk_opencv.m | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 SD-VBS/common/toolbox/lagrcv/test/test_lk_opencv.m (limited to 'SD-VBS/common/toolbox/lagrcv/test/test_lk_opencv.m') 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 @@ +addpath ~/Matlab/Toolbox/lagrcv/ +addpath ~/Matlab/Toolbox/toolbox_basic/filter +addpath ~/Matlab/Toolbox/ikkjin/ + +IMAGE_DIR='/data/insecure/images/ants/Transport/' +filelist=dir(fullfile(IMAGE_DIR, '*.jpg')); +flen=length(filelist); + +img_idx_cur=[1:flen]; + +%subplot(1,2,1);imshow(Iprev) +%/hold on +%//scatter(features(2,:),features(1,:),'r') +%Iprev=imread(fullfile(IMAGE_DIR,filelist(img_idx_prev(1)).name)); +%% +imgName=fullfile(IMAGE_DIR,filelist(img_idx_cur(1)).name); +Icur=imread(imgName); +%% +Icur=smooth(double(rgb2gray(Icur)), 4); +%% +Icur=Icur(1:2:end,1:2:end); + +[ features numvalid ] = goodFeaturesToTrack(Icur, 0.3, 10); +features=features(:,1:numvalid); + +figure(1); +imagesc(Icur);colormap gray +hold on;scatter(features(2,:), features(1,:), 'r+'); hold off; + +%% +for iter=img_idx_cur + Iprev=Icur; + Icur=imread(fullfile(IMAGE_DIR,filelist(img_idx_cur(iter)).name)); + Icur=calcImgBlurMex(rgb2gray(Icur)); + + tic + [ newpoints status pyr1 ] = calcOpticalFlowPyrLK(Iprev,Icur,features); + toc + newpoints=newpoints(:,find(status)); + figure(1); + imagesc(Icur);colormap gray + hold on;scatter(newpoints(2,:), newpoints(1,:), 'r+'); hold off; + drawnow + print('-djpeg', sprintf('result/result_%03d', iter)) + %pause + features=newpoints; +end -- cgit v1.2.2