Matlab手动绘制bounding box,并获取其坐标

研究需要,写了一段手动标注bounding box的Matlab代码。

trainImgStr = 'trainImg';
trainImgDir = dir([trainImgStr,'\*']);
structGT = {};
for i = 1:length(trainImgDir)
    if(strcmp(trainImgDir(i).name,'.') || strcmp(trainImgDir(i).name,'..'))
        continue;
    else
        im = imread([trainImgStr,'\',trainImgDir(i).name]);
        h1 = imshow(im);
        h2 = imrect(gca);
        position = wait(h2);
        position = round(position);
        GT.boxes = position;
        GT.img = trainImgDir(i).name;
        close();
        structGT = [structGT,GT];
    end
end
save('structGT','structGT');


你可能感兴趣的:(图像相关)