diff options
| author | leochanj105 <leochanj@live.unc.edu> | 2020-10-19 23:09:30 -0400 |
|---|---|---|
| committer | leochanj105 <leochanj@live.unc.edu> | 2020-10-20 02:40:39 -0400 |
| commit | f618466c25d43f3bae9e40920273bf77de1e1149 (patch) | |
| tree | 460e739e2165b8a9c37a9c7ab1b60f5874903543 /SD-VBS/common/toolbox/lagrcv/test/test_lk.m | |
| parent | 47ced4e96bbb782b9e780e8f2cfc637b2c21ff44 (diff) | |
initial sd-vbs
initial sd-vbs
add sd-vbs
sd-vbs
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 | ||
