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_opencv.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_opencv.m')
| -rwxr-xr-x | SD-VBS/common/toolbox/lagrcv/test/test_lk_opencv.m | 47 |
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 @@ | |||
| 1 | addpath ~/Matlab/Toolbox/lagrcv/ | ||
| 2 | addpath ~/Matlab/Toolbox/toolbox_basic/filter | ||
| 3 | addpath ~/Matlab/Toolbox/ikkjin/ | ||
| 4 | |||
| 5 | IMAGE_DIR='/data/insecure/images/ants/Transport/' | ||
| 6 | filelist=dir(fullfile(IMAGE_DIR, '*.jpg')); | ||
| 7 | flen=length(filelist); | ||
| 8 | |||
| 9 | img_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 | %% | ||
| 16 | imgName=fullfile(IMAGE_DIR,filelist(img_idx_cur(1)).name); | ||
| 17 | Icur=imread(imgName); | ||
| 18 | %% | ||
| 19 | Icur=smooth(double(rgb2gray(Icur)), 4); | ||
| 20 | %% | ||
| 21 | Icur=Icur(1:2:end,1:2:end); | ||
| 22 | |||
| 23 | [ features numvalid ] = goodFeaturesToTrack(Icur, 0.3, 10); | ||
| 24 | features=features(:,1:numvalid); | ||
| 25 | |||
| 26 | figure(1); | ||
| 27 | imagesc(Icur);colormap gray | ||
| 28 | hold on;scatter(features(2,:), features(1,:), 'r+'); hold off; | ||
| 29 | |||
| 30 | %% | ||
| 31 | for 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; | ||
| 47 | end | ||
