资源简介
VOCdevkit2007开发包,不包含dataset。
代码片段和文件信息
% Creates segmentation results from detection results.
% CREATE_SEGMENTATIONS_FROM_DETECTIONS(ID) creates segmentations from
% the detection results with identifier ID e.g. ‘comp3‘. All detections
% will be used no matter what their confidence level.
%
% CREATE_SEGMENTATIONS_FROM_DETECTIONS(ID CONFIDENCE) as above but only
% detections above the specified confidence will be used.
function create_segmentations_from_detections(idconfidence)
if nargin<2
confidence = -inf;
end
% change this path if you install the VOC code elsewhere
addpath([cd ‘/VOCcode‘]);
% initialize VOC options
VOCinit;
% load detection results
tic;
imgids={};
for clsnum = 1:VOCopts.nclasses
resultsfile = sprintf(VOCopts.detrespathidVOCopts.classes{clsnum});
if ~exist(resultsfile‘file‘)
error(‘Could not find detection results file to use to create segmentations (%s not found)‘resultsfile);
end
[idsconfsb1b2b3b4]=textread(resultsfile‘%s %f %f %f %f %f‘);
BBOXS=[b1 b2 b3 b4];
previd=‘‘;
for j=1:numel(ids)
% display progress
if toc>1
fprintf(‘class %d/%d: load detections: %d/%d\n‘clsnumVOCopts.nclassesjnumel(ids));
drawnow;
tic;
end
imgid = ids{j};
conf = confs(j);
if ~strcmp(imgidprevid)
ind = strmatch(imgidimgids‘exact‘);
end
detinfo.clsnum = clsnum;
detinfo.conf = conf;
detinfo.bbox = BBOXS(j:);
if isempty(ind)
imgids{end+1}=imgid;
ind = numel(imgids);
detnum=1;
else
detnum = numel(im(ind).det)+1;
end
im(ind).det(detnum) = detinfo;
end
end
% Write out the segmentations
resultsdir = sprintf(VOCopts.seg.clsresdiridVOCopts.testset);
resultsdirinst = sprintf(VOCopts.seg.instresdiridVOCopts.testset);
if ~exist(resultsdir‘dir‘)
mkdir(resultsdir);
end
if ~exist(resultsdirinst‘dir‘)
mkdir(resultsdirinst);
end
cmap = VOClabelcolormap(255);
tic;
for j=1:numel(imgids)
% display progress
if toc>1
fprintf(‘make segmentation: %d/%d\n‘jnumel(imgids));
drawnow;
tic;
end
imname = imgids{j};
classlabelfile = sprintf(VOCopts.seg.clsrespathidVOCopts.testsetimname);
instlabelfile = sprintf(VOCopts.seg.instrespathidVOCopts.testsetimname);
imgfile = sprintf(VOCopts.imgpathimname);
imginfo = imfinfo(imgfile);
[instimclassim]= convert_dets_to_image(imginfo.Width imginfo.Heightim(j).detconfidence);
imwrite(instimcmapinstlabelfile);
imwrite(classimcmapclasslabelfile);
% Copy in ground truth - uncomment to copy ground truth segmentations in
% for comparison
% gtlabelfile = [VOCopts.root ‘/Segmentations(class)/‘ imname ‘.png‘];
% gtclasslabelfile = sprintf(‘%s/%d_gt.png‘resultsdirimnums(j));
% copyfile(gtlabelfilegtclasslabelfile);
end
% Converts a s
- 上一篇:ANSIX9.24 PART2-2006
- 下一篇:eil51.tsp.txt
评论
共有 条评论