From 0efc775370d2ff91927d1b383a99eab78dc5538f Mon Sep 17 00:00:00 2001 From: leochanj Date: Wed, 21 Oct 2020 01:52:54 -0400 Subject: debug libextra and remove matlab FLUSH_CACHES --- SD-VBS/benchmarks/stitch/src/matlab/calculateH.m | 24 --------- SD-VBS/benchmarks/stitch/src/matlab/dist2.m | 31 ------------ .../benchmarks/stitch/src/matlab/extractFeatures.m | 56 --------------------- SD-VBS/benchmarks/stitch/src/matlab/getANMS.m | 25 --------- .../stitch/src/matlab/getDirParamLocal.m | 4 -- SD-VBS/benchmarks/stitch/src/matlab/harris.m | 37 -------------- SD-VBS/benchmarks/stitch/src/matlab/main.m | 47 ----------------- .../benchmarks/stitch/src/matlab/matchFeatures.m | 13 ----- .../stitch/src/matlab/pics/matched_base_cur.jpg | Bin 22688 -> 0 bytes .../stitch/src/matlab/pics/ransaced_feat.jpg | Bin 19198 -> 0 bytes SD-VBS/benchmarks/stitch/src/matlab/printImage.m | 2 - SD-VBS/benchmarks/stitch/src/matlab/ransac.m | 19 ------- SD-VBS/benchmarks/stitch/src/matlab/readData.m | 9 ---- .../stitch/src/matlab/script_run_profile.m | 38 -------------- .../stitch/src/matlab/showInterestPoints.m | 7 --- SD-VBS/benchmarks/stitch/src/matlab/transformH.m | 13 ----- 16 files changed, 325 deletions(-) delete mode 100755 SD-VBS/benchmarks/stitch/src/matlab/calculateH.m delete mode 100755 SD-VBS/benchmarks/stitch/src/matlab/dist2.m delete mode 100755 SD-VBS/benchmarks/stitch/src/matlab/extractFeatures.m delete mode 100755 SD-VBS/benchmarks/stitch/src/matlab/getANMS.m delete mode 100755 SD-VBS/benchmarks/stitch/src/matlab/getDirParamLocal.m delete mode 100755 SD-VBS/benchmarks/stitch/src/matlab/harris.m delete mode 100755 SD-VBS/benchmarks/stitch/src/matlab/main.m delete mode 100755 SD-VBS/benchmarks/stitch/src/matlab/matchFeatures.m delete mode 100644 SD-VBS/benchmarks/stitch/src/matlab/pics/matched_base_cur.jpg delete mode 100644 SD-VBS/benchmarks/stitch/src/matlab/pics/ransaced_feat.jpg delete mode 100755 SD-VBS/benchmarks/stitch/src/matlab/printImage.m delete mode 100755 SD-VBS/benchmarks/stitch/src/matlab/ransac.m delete mode 100755 SD-VBS/benchmarks/stitch/src/matlab/readData.m delete mode 100755 SD-VBS/benchmarks/stitch/src/matlab/script_run_profile.m delete mode 100755 SD-VBS/benchmarks/stitch/src/matlab/showInterestPoints.m delete mode 100755 SD-VBS/benchmarks/stitch/src/matlab/transformH.m (limited to 'SD-VBS/benchmarks/stitch/src') diff --git a/SD-VBS/benchmarks/stitch/src/matlab/calculateH.m b/SD-VBS/benchmarks/stitch/src/matlab/calculateH.m deleted file mode 100755 index caefd74..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/calculateH.m +++ /dev/null @@ -1,24 +0,0 @@ -function retH=calculateH(pnt1, pnt2) - -[n temp]=size(pnt1); - -X=zeros(0,8); -b=zeros(0,1); - -for i=1:n - X=[X; pnt1(i,1) pnt1(i,2) 1 0 0 0 -pnt2(i,1)*pnt1(i,1) -pnt2(i,1)*pnt1(i,2);0, 0, 0, pnt1(i,1), pnt1(i,2), 1, -pnt2(i,2)*pnt1(i,1), -pnt2(i,2)*pnt1(i,2)]; - b=[b; pnt2(i,1); pnt2(i,2)]; -end - -if n==4 - %if abs(det(X)~=0 - H=X^(-1)*b; - %else - % H=[0 0 0; 0 0 0; 0 0 1]; - %end -else - Xt = X'; - H=(Xt*X)^(-1)*Xt*b; -end - -retH=[H(1) H(2) H(3);H(4) H(5) H(6);H(7) H(8) 1]; diff --git a/SD-VBS/benchmarks/stitch/src/matlab/dist2.m b/SD-VBS/benchmarks/stitch/src/matlab/dist2.m deleted file mode 100755 index 89116ac..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/dist2.m +++ /dev/null @@ -1,31 +0,0 @@ -function n2 = dist2(x, c) -%DIST2 Calculates squared distance between two sets of points. -% -% Description -% D = DIST2(X, C) takes two matrices of vectors and calculates the -% squared Euclidean distance between them. Both matrices must be of -% the same column dimension. If X has M rows and N columns, and C has -% L rows and N columns, then the result has M rows and L columns. The -% I, Jth entry is the squared distance from the Ith row of X to the -% Jth row of C. -% -% See also -% GMMACTIV, KMEANS, RBFFWD -% - -% Copyright (c) Christopher M Bishop, Ian T Nabney (1996, 1997) - -[ndata, dimx] = size(x); -[ncentres, dimc] = size(c); -if dimx ~= dimc - error('Data dimension does not match dimension of centres') -end - -ct = c'; -opt = (x.^2)'; -op2t = (x.^2)'; -tempT = (ones(ncentres, 1) * sum(opt, 1))'; -n2 = tempT + ones(ndata, 1) * sum(op2t,1) - 2.*(x*ct); - - - diff --git a/SD-VBS/benchmarks/stitch/src/matlab/extractFeatures.m b/SD-VBS/benchmarks/stitch/src/matlab/extractFeatures.m deleted file mode 100755 index 38d2f7c..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/extractFeatures.m +++ /dev/null @@ -1,56 +0,0 @@ -function vecF=extractFeatures(I, x, y, dataDir) - -Igray = I; -w = (1/16)*[1 4 6 4 1]; -[n temp]=size(x); - -%SUB sample rate s=5 -wt = w'; -Iconv=conv2(w, wt, Igray, 'same'); -Iconv=conv2(w, wt, Iconv, 'same'); -Isub=Iconv(1:5:end,1:5:end); -[nr nc]=size(Isub); - -Xsub=min(floor(x/5)+1, nc-4); -Ysub=min(floor(y/5)+1, nr-4); - -if(length(Xsub) < 6 || length(Ysub) < 10) - vecF = [Xsub Ysub]; - return; -end - -newSize = 4; -[rows, cols] = size(I); -if(rows > 32 & cols >32) - newSize = 64; -end - -for i=1:n - - minValy = 3; - minValx = 3; - if( Ysub(i) < 4) - Ysub(i) = 4; - end - if( Xsub(i) < 4) - Xsub(i) = 4; - end - - if( Ysub(i) > size(Isub,1)-4) - Ysub(i) = size(Isub,1)-4; - end - if( Xsub(i) > size(Isub,2)-4) - Xsub(i) = size(Isub,2)-4; - end - - vecF(i,:)=reshape(Isub(Ysub(i)-minValy:Ysub(i)+4,Xsub(i)-minValx:Xsub(i)+4),1,newSize); - - %normalization - vecF(i,:)=vecF(i,:)-mean(vecF(i,:)); - vecF(i,:)=vecF(i,:)/std(vecF(i,:)); - %imagesc(reshape(vecF(i,:),8,8)); colormap gray - %drawnow - %pause -end - - diff --git a/SD-VBS/benchmarks/stitch/src/matlab/getANMS.m b/SD-VBS/benchmarks/stitch/src/matlab/getANMS.m deleted file mode 100755 index caece31..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/getANMS.m +++ /dev/null @@ -1,25 +0,0 @@ -function [interestPnts]=getANMS(x, y, v, r, dataDir) -%interestPnts=[x y v] -MAX_LIMIT=100000000; -C_ROBUST=0.9; -r_sq=r^2; -points=[x y v]; -[n temp]=size(v); -[srtdV srtdVIdx]=sort(v,'descend'); -srtdPnts=points(srtdVIdx,:); - -interestPnts=zeros(0,3); - -suppressR=ones(n,1)*MAX_LIMIT; -supId=find(suppressR>r_sq); - -iter = 0; -while length(supId)>0 - interestPnts=[interestPnts; srtdPnts(supId(1),:)]; - srtdPnts=srtdPnts(supId(2:end),:); - suppressR=suppressR(supId(2:end),:); - - suppressR=min(suppressR,(C_ROBUST*interestPnts(end,3)>srtdPnts(:,3)).*((srtdPnts(:,1)-interestPnts(end,1)).^2 + (srtdPnts(:,2)-interestPnts(end,2)).^2)+(C_ROBUST*interestPnts(end,3)<=srtdPnts(:,3))*MAX_LIMIT); - supId=find(suppressR>r_sq); - iter = iter + 1; -end diff --git a/SD-VBS/benchmarks/stitch/src/matlab/getDirParamLocal.m b/SD-VBS/benchmarks/stitch/src/matlab/getDirParamLocal.m deleted file mode 100755 index 7b36886..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/getDirParamLocal.m +++ /dev/null @@ -1,4 +0,0 @@ -function DIR_PARAM=getDirParam -DIR_PARAM.main_dir=pwd; -DIR_PARAM.data_dir=fullfile(DIR_PARAM.main_dir,'data'); -DIR_PARAM.report_dir=fullfile(DIR_PARAM.main_dir,'report'); diff --git a/SD-VBS/benchmarks/stitch/src/matlab/harris.m b/SD-VBS/benchmarks/stitch/src/matlab/harris.m deleted file mode 100755 index 423330e..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/harris.m +++ /dev/null @@ -1,37 +0,0 @@ - -% Sample code for detecting Harris corners, following -% Brown et al, CVPR 2005 -% by Alyosha Efros, so probably buggy... - -function [x,y,v] = harris(im, dataDir); - -g1 = [1,4,6,4,1; 4,16,24,16,4;6,24,36,24,6;4,16,24,16,4;1,4,6,4,1]/256; -g2 = [1,2,1;2,4,2;1,2,1]/16; - -img1 = conv2(im,g1,'same'); % blur image with sigma_d - -Ix = conv2(img1,[-0.5 0 0.5],'same'); % take x derivative -Iy = conv2(img1,[-0.5;0;0.5],'same'); % take y derivative - -% Compute elements of the Harris matrix H -%%% we can use blur instead of the summing window -Ix2 = conv2(Ix.*Ix,g2,'same'); -Iy2 = conv2(Iy.*Iy,g2,'same'); -IxIy = conv2(Ix.*Iy,g2,'same'); - -R = (Ix2.*Iy2 - IxIy.*IxIy) ... % det(H) - ./ (Ix2 + Iy2 + eps); % trace(H) + epsilon - -% don't want corners close to image border -[rows, cols] = size(im); - -% non-maxima supression within 3x3 windows -nonmax = inline('max(x)'); -Rmax = colfilt(R,[3 3],'sliding',nonmax); % find neighbrhood max -Rnm = R.*(R == Rmax); % supress non-max - -% extract all interest points -[y,x,v] = find(Rnm); - - - diff --git a/SD-VBS/benchmarks/stitch/src/matlab/main.m b/SD-VBS/benchmarks/stitch/src/matlab/main.m deleted file mode 100755 index 9be8504..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/main.m +++ /dev/null @@ -1,47 +0,0 @@ -Icur_list=readData('capitol'); -Icur=Icur_list{1}; -%Icur=Icur(1:150,:,:); -[x y v]=harris(Icur); -interestPntsCur=getANMS(x, y, v, 24); -Fcur=extractFeatures(Icur, interestPntsCur(:,1), interestPntsCur(:,2)); - -for id=2:length(Icur_list) - Iprev=Icur; - Fprev=Fcur; - interestPntsPrev=interestPntsCur; - Icur=Icur_list{id}; - %Icur=Icur(1:150,:,:); - [x y v]=harris(Icur); - %showInterestPoints(I, x, y) - interestPntsCur=getANMS(x, y, v, 16); - %showInterestPoints(I, interestPnts(:,1), interestPnts(:,2)) - Fcur=extractFeatures(Icur, interestPntsCur(:,1), interestPntsCur(:,2)); - matchedPntsIdx=matchFeatures(Fprev, Fcur); - matchedPntsPrev=interestPntsPrev(matchedPntsIdx(:,1),:); - matchedPntsCur=interestPntsCur(matchedPntsIdx(:,2),:); - - %subplot(1,2,1);showInterestPoints(Iprev, matchedPntsPrev(:,1), matchedPntsPrev(:,2));axis image - %subplot(1,2,2);showInterestPoints(Icur, matchedPntsCur(:,1), matchedPntsCur(:,2));axis image - %drawnow - %pause; - %printImage(['featureMatching' int2str(id-1) '_' int2str(id)]); - [retH retPntsIdx]=ransac(matchedPntsPrev, matchedPntsCur, 10000, 100); - subplot(2,2,1);showInterestPoints(Iprev, matchedPntsPrev(retPntsIdx,1), matchedPntsPrev(retPntsIdx,2));axis image - subplot(2,2,2);showInterestPoints(Icur, matchedPntsCur(retPntsIdx,1), matchedPntsCur(retPntsIdx,2));axis image - T=maketform('projective', retH'); - Tfn_Mat=T; - [nr nc nd]=size(Iprev); - Itrans=imtransform(Iprev,T,'XData', [1 nc], 'YData', [1 nr],'FillValues',[0;0;0]); - subplot(2,2,3);imshow(Itrans) - subplot(2,2,4);imagesc(rgb2gray(abs(Icur-Itrans))) - drawnow - pause; - printImage(['ransac' int2str(id-1) '_' int2str(id)]); -end - - %[Itrans2 XData YData]=imtransform(Iprev,T,'FillValues',[0;0;0]); - %for the fast iteration - %[Itrans2 XData2 YData2]=imtransform(Iprev,T,'XData', [-2*nc 2*nc], 'YData', [-2*nr 2*nr],'FillValues',[0;0;0]); - - %h=imshow(Itrans); - diff --git a/SD-VBS/benchmarks/stitch/src/matlab/matchFeatures.m b/SD-VBS/benchmarks/stitch/src/matlab/matchFeatures.m deleted file mode 100755 index 7af77e0..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/matchFeatures.m +++ /dev/null @@ -1,13 +0,0 @@ -function retMatch=matchFeatures(vecF1, vecF2) -[n1 temp]=size(vecF1); -[n2 temp]=size(vecF2); - -retMatch=zeros(0,2); - -for i=1:n1 - [val id]=sort(dist2(vecF1(i,:),vecF2)); - if val(2)~=0 & val(1)/val(2)<0.65 - retMatch=[retMatch; i id(1)]; - end -end - diff --git a/SD-VBS/benchmarks/stitch/src/matlab/pics/matched_base_cur.jpg b/SD-VBS/benchmarks/stitch/src/matlab/pics/matched_base_cur.jpg deleted file mode 100644 index a4bd68b..0000000 Binary files a/SD-VBS/benchmarks/stitch/src/matlab/pics/matched_base_cur.jpg and /dev/null differ diff --git a/SD-VBS/benchmarks/stitch/src/matlab/pics/ransaced_feat.jpg b/SD-VBS/benchmarks/stitch/src/matlab/pics/ransaced_feat.jpg deleted file mode 100644 index 821ca11..0000000 Binary files a/SD-VBS/benchmarks/stitch/src/matlab/pics/ransaced_feat.jpg and /dev/null differ diff --git a/SD-VBS/benchmarks/stitch/src/matlab/printImage.m b/SD-VBS/benchmarks/stitch/src/matlab/printImage.m deleted file mode 100755 index 82e74f0..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/printImage.m +++ /dev/null @@ -1,2 +0,0 @@ -function printImage(fname, DIR_PARAM) -print('-djpeg', fullfile(DIR_PARAM, [fname '.jpg'])); diff --git a/SD-VBS/benchmarks/stitch/src/matlab/ransac.m b/SD-VBS/benchmarks/stitch/src/matlab/ransac.m deleted file mode 100755 index 4a3c364..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/ransac.m +++ /dev/null @@ -1,19 +0,0 @@ -function [retH retPntsIdx]=ransac(pntsPrev, pntsCur, k, epsilon) -[n temp]=size(pntsPrev); -pntsPrev=[pntsPrev(:,1:2) ones(n,1)]; -pntsCur=[pntsCur(:,1:2) ones(n,1)]; - -inlierIdx=cell(k,1); -inlierNum=zeros(k,1); -for i=1:k - seed=randperm(n); - H=calculateH(pntsPrev(seed(1:4),:), pntsCur(seed(1:4),:)); - err=(pntsCur-transformH(H,pntsPrev)); - inlierIdx{i}=find(sum(err(:,1:2).^2,2) < epsilon); - inlierNum=length(inlierIdx{i}); -end - -[v maxIdx]=max(inlierNum); -retPntsIdx=inlierIdx{maxIdx}; -retH=calculateH(pntsPrev(retPntsIdx,:), pntsCur(retPntsIdx,:)); - diff --git a/SD-VBS/benchmarks/stitch/src/matlab/readData.m b/SD-VBS/benchmarks/stitch/src/matlab/readData.m deleted file mode 100755 index 19643bb..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/readData.m +++ /dev/null @@ -1,9 +0,0 @@ -function retImgs=readData(imgName, dataDir) -fn=fullfile(dataDir, imgName, '*.jpg'); -filelist=dir(fn); - -retImgs=cell(length(filelist),1); -for i=1:length(filelist) - retImgs{i}=imread(fullfile(dataDir, imgName, filelist(i).name)); -end - diff --git a/SD-VBS/benchmarks/stitch/src/matlab/script_run_profile.m b/SD-VBS/benchmarks/stitch/src/matlab/script_run_profile.m deleted file mode 100755 index f2ca68b..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/script_run_profile.m +++ /dev/null @@ -1,38 +0,0 @@ -function script_run_profile(dataDir, resultDir, type, common, toolDir) - -path(path, common); -image_list = 1; - -elapsed = zeros(1,2); -for i=1:image_list - Icur = readImage([dataDir, '/', num2str(i) ,'.bmp']); - rows = size(Icur,1); - cols = size(Icur,2); - fprintf(1,'Input size\t\t- (%dx%d)\n', rows, cols); - - %% Self check params - tol = 1; - - %% Timing - start = photonStartTiming; - - [x y v]=harris(Icur,dataDir); - interestPntsCur=getANMS(x, y, v, 24, dataDir); - Fcur=extractFeatures(Icur, interestPntsCur(:,1), interestPntsCur(:,2), dataDir); - - %% Timing - stop = photonEndTiming; - - temp = photonReportTiming(start, stop); - elapsed(1) = elapsed(1) + temp(1); - elapsed(2) = elapsed(2) + temp(2); - - -end - -%% Self checking -fWriteMatrix(Fcur, dataDir); - -%% Timing -photonPrintTiming(elapsed); - diff --git a/SD-VBS/benchmarks/stitch/src/matlab/showInterestPoints.m b/SD-VBS/benchmarks/stitch/src/matlab/showInterestPoints.m deleted file mode 100755 index 487cae4..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/showInterestPoints.m +++ /dev/null @@ -1,7 +0,0 @@ -function showInterestPoints(im, x, y) -% show 'em -imagesc(im); -colormap(gray); -hold on; -plot(x,y,'r.'); -hold off; \ No newline at end of file diff --git a/SD-VBS/benchmarks/stitch/src/matlab/transformH.m b/SD-VBS/benchmarks/stitch/src/matlab/transformH.m deleted file mode 100755 index 7a22eb8..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/transformH.m +++ /dev/null @@ -1,13 +0,0 @@ -function retPnts=transformH(H, pnts) -MAX_LIMIT=10000000; -[n temp]=size(pnts); - -pntsT = pnts'; -retPnts=(H*pntsT)'; -for i=1:n - if retPnts(i,3)~=0 - retPnts(i,:)=retPnts(i,:)./retPnts(i,3); - else - retPnts(i,:)=[MAX_LIMIT MAX_LIMIT 1]; - end -end -- cgit v1.2.2