diff options
| author | Leo Chan <leochanj@live.unc.edu> | 2020-10-22 01:53:21 -0400 |
|---|---|---|
| committer | Joshua Bakita <jbakita@cs.unc.edu> | 2020-10-22 01:56:35 -0400 |
| commit | d17b33131c14864bd1eae275f49a3f148e21cf29 (patch) | |
| tree | 0d8f77922e8d193cb0f6edab83018f057aad64a0 /SD-VBS/common/toolbox/lagrcv/test/test_lk.m | |
| parent | 601ed25a4c5b66cb75315832c15613a727db2c26 (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.m')
| -rwxr-xr-x | SD-VBS/common/toolbox/lagrcv/test/test_lk.m | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/SD-VBS/common/toolbox/lagrcv/test/test_lk.m b/SD-VBS/common/toolbox/lagrcv/test/test_lk.m new file mode 100755 index 0000000..c6ca701 --- /dev/null +++ b/SD-VBS/common/toolbox/lagrcv/test/test_lk.m | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | addpath ~/Matlab/Toolbox/lagrcv/ | ||
| 2 | addpath ~/Matlab/Toolbox/toolbox_basic/filter | ||
| 3 | addpath ~/Matlab/Toolbox/ikkjin/ | ||
| 4 | |||
| 5 | N_FEA=1600; | ||
| 6 | WINSZ=8; %size of sum-up window | ||
| 7 | NO_PYR=2; | ||
| 8 | SUPPRESION_RADIUS=10; | ||
| 9 | LK_ITER=20; | ||
| 10 | IMAGE_DIR='~/backup/Research/ant/Transport/' | ||
| 11 | filelist=dir(fullfile(IMAGE_DIR, '*.jpg')); | ||
| 12 | flen=length(filelist); | ||
| 13 | |||
| 14 | img_idx_cur=[1:flen]; | ||
| 15 | |||
| 16 | %subplot(1,2,1);imshow(Iprev) | ||
| 17 | %/hold on | ||
| 18 | %//scatter(features(2,:),features(1,:),'r') | ||
| 19 | %% | ||
| 20 | imgName=fullfile(IMAGE_DIR,filelist(img_idx_cur(1)).name); | ||
| 21 | Icur=imread(imgName); | ||
| 22 | Icur=rgb2gray(Icur); | ||
| 23 | Icur=calcImgBlurMex(double(Icur)); | ||
| 24 | %% | ||
| 25 | |||
| 26 | Jpyr=getPyramid(Icur, 2); | ||
| 27 | |||
| 28 | [lambda tr det c_xx c_xy c_yy] =calcTextureMex(double(Icur), WINSZ); | ||
| 29 | imgsz=size(lambda); | ||
| 30 | lambda([1:8 end-8:end],:)=0; | ||
| 31 | lambda(:,[1:8 end-8:end])=0; | ||
| 32 | [temp idx]=sort(lambda(:), 'descend'); | ||
| 33 | |||
| 34 | %% | ||
| 35 | featureIdx=idx(1:N_FEA); | ||
| 36 | features=zeros(3, N_FEA); | ||
| 37 | features(1,:)=ceil(featureIdx/imgsz(1)); | ||
| 38 | features(2,:)=featureIdx'-(features(1,:)-1)*imgsz(1); | ||
| 39 | features(3,:)=lambda(featureIdx); | ||
| 40 | |||
| 41 | imagesc(lambda); hold on | ||
| 42 | scatter(features(1,:), features(2,:), 'r+');hold off | ||
| 43 | %% | ||
| 44 | interestPnt=getANMS(features(1,:)', features(2,:)', features(3,:)', SUPPRESION_RADIUS); | ||
| 45 | interestPnt=interestPnt'; | ||
| 46 | scatter(interestPnt(1,:), interestPnt(2,:), 'g+') | ||
| 47 | %% | ||
| 48 | features=interestPnt(1:2,:); | ||
| 49 | %% | ||
| 50 | |||
| 51 | for iter=img_idx_cur | ||
| 52 | Iprev=Icur; | ||
| 53 | Icur=imread(fullfile(IMAGE_DIR,filelist(img_idx_cur(iter)).name)); | ||
| 54 | Icur=rgb2gray(Icur); | ||
| 55 | Icur=calcImgBlurMex(double(Icur)); | ||
| 56 | |||
| 57 | Ipyr=Jpyr; | ||
| 58 | Jpyr=getPyramid(Icur, 2); | ||
| 59 | |||
| 60 | [dxPyr dyPyr]=calcSobelPyrMex(Ipyr,2); | ||
| 61 | |||
| 62 | [lambda tr det c_xx c_xy c_yy] = calcTexturePyrMex(dxPyr, dyPyr, WINSZ, NO_PYR); | ||
| 63 | |||
| 64 | [newpoints status]=calcOptFlowLKPyrMex(Ipyr, dxPyr, dyPyr, Jpyr, double(features), 4, 0.03, LK_ITER, c_xx, c_xy, c_yy); | ||
| 65 | |||
| 66 | newpoints=newpoints(:,find(status)); | ||
| 67 | figure(1); | ||
| 68 | imagesc(Icur);colormap gray | ||
| 69 | hold on;scatter(newpoints(1,:), newpoints(2,:), 'r+'); hold off; | ||
| 70 | drawnow | ||
| 71 | %print('-djpeg', sprintf('result/result_%03d', iter)) | ||
| 72 | %pause | ||
| 73 | features=newpoints; | ||
| 74 | end | ||
