clear
clc
close all;
addpath('cppmex');
addpath('LSDlines');
addpath('func');

img_style='.png';
folder='example\';
write_folder=[folder 'process\'];

names=get_pair_2(write_folder);
%Intersection distance
disthres1=20;
%angle threshold to speed up (not necessary)
angthre1=0.86;
% mimnum line length
linelen=25;

%load datas
for i=1:length(names)
    i
    savename=[write_folder names{i}];
    img{i}=imread([folder 'images\' names{i} img_style]);
    if size(img{i},3)==3
        img{i}=rgb2gray(img{i});
    end
    
    [rs,cs,~]=size(img{i});
    %lines
    lines=getLSDl([folder 'images\' names{i} img_style],linelen);
    %construct grids
    callGrid(lines',size(lines,1),20,cs,rs,write_folder,names{i});
    save([savename '.lines'],'lines','-ascii');
    %points
    points = detectSURFFeatures(img{i});
    points=double(points.Location);
    
    save([savename '.points'],'points','-ascii');
    % initial line pairs
    crossMatlab(lines,size(lines,1),angthre1,disthres1);
    CC=load('cross.txt');
    save([savename '.cross'],'CC','-ascii');
end



