-
Notifications
You must be signed in to change notification settings - Fork 93
/
lsdWrap.m
executable file
·41 lines (37 loc) · 1.32 KB
/
lsdWrap.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function [ edgeMap, edgeList ] = lsdWrap( img, cmdline )
%LSDWRAPPER Summary of this function goes here
% Detailed explanation goes here
global config
if ~exist('cmdline', 'var')
cmdline = '';
end
% rng('shuffle');
t= clock();
randomID = sprintf('%02d_%02d_%02d_%02d', randi(99,1), t(4), t(5), int32(t(6)*10000));
imgbuf = [config.bufferFolder 'buf_' randomID '.pgm'];
edgbuf = [config.bufferFolder 'buf_result_' randomID '.txt'];
%% line detection
while exist('imgbuf','file') || exist('edgbuf','file')
fprintf('buf name conflict\n');
pause(0.1);
end
imwrite( img, imgbuf, 'pgm');
% system(['D:\YINDA\SceneParsing\edgeDetection\lsd ' cmdline ' ' imgbuf ' ' edgbuf]);
% system(['./edgeDetection/lsd_1.6/lsd ' cmdline ' ' imgbuf ' ' edgbuf]);
system([config.lsdLocation cmdline ' ' imgbuf ' ' edgbuf]);
edgeList = load( edgbuf);
edgeNum = size(edgeList,1);
%% draw on image
[imgH, imgW, ~] = size(img);
edgeMap = zeros(imgH, imgW);
for i = 1:edgeNum
x = linspace( edgeList(i,1)+1, edgeList(i,3)+1, 1000);
y = linspace( edgeList(i,2)+1, edgeList(i,4)+1, 1000);
xx = max( min( round(x), imgW), 1);
yy = max( min( round(y), imgH), 1);
index = sub2ind( [imgH imgW], yy, xx);
edgeMap(index) = 1;%rand(1);
end
%% delete buffer files
delete( imgbuf );
delete( edgbuf );