clc;
clear;
%imgpath='D:\dd\tu\ff\';%图像存放文件夹
imgpath='E:\..\fasterrcnn\testing\image_2\';%图像存放文件夹
txtpath='D:\dd\1.txt';%txt文件
fidin=fopen(txtpath,'r');
while ~feof(fidin) %文件指针到达文件末尾时 该表达式值为“假”;否则为“真”
tline=fgetl(fidin); %fget1:从文件中读取一行数据
str = regexp(tline, ',','split'); %分割,str:待分割的字符串,' ':分隔符的字符,S:分割结果
if( str2double(str{6})>0.5)
t=str2double(str{1})-1;
%filepath=sprintf('tu\\ff\\%06d.png',t);
filepath=sprintf('E:\\备份\\mscnn\\testing\\image_2\\%06d.png',t);
%filepath=[imgpath,str{1},'.png']; %filepath:拼接的文件名
img=imread(filepath); %读取图片
imshow(img);
title(str(1));
%rectangle('Position',[x,y,w,h]),LineWidth:线条粗细4,EdgeColor:边框颜色是红色
rectangle('Position',[str2double(str{2}),str2double(str{3}),str2double(str{4}),str2double(str{5})],'LineWidth',4,'EdgeColor','r');
pause(0.3); %pause(n):程序暂停n秒后继续
end
end
fclose(fidin);
同时显示:
clc;
clear all;
%imgpath='D:\dd\tu\ff\';%图像存放文件夹
%imgpath='E:\备份\mscnn\data\testing\image_2\';%图像存放文件夹
imgpath='D:\2012b\dd\ee\';%图像存放文件夹
txtpath='D:\2012b\dd\detections\kitti_8s_768_35k_test_ped.txt';%txt文件
%txtpath='D:\dd\p.txt';%txt文件
fidin=fopen(txtpath,'r');
temp =-1;
while ~feof(fidin) %文件指针到达文件末尾时 该表达式值为“假”;否则为“真”
tline=fgetl(fidin); %fget1:从文件中读取一行数据
str = regexp(tline, ',','split'); %分割,str:待分割的字符串,' ':分隔符的字符,S:分割结果
if( str2double(str{6})>0.6)
t=str2double(str{1})-1;
%filepath=sprintf('tu\\ff\\%06d.png',t);
filepath=sprintf('E:\\备份\\ssss\\data\\testing\\image_2\\%06d.png',t);
%filepath=[imgpath,str{1},'.png']; %filepath:拼接的文件名
if temp ~= t
img=imread(filepath); %读取图片
imshow(img);
end
temp =t;
%rectangle('Position',[x,y,w,h]),LineWidth:线条粗细4,EdgeColor:边框颜色是红色
rectangle('Position',[str2double(str{2}),str2double(str{3}),str2double(str{4}),str2double(str{5})],'LineWidth',4,'EdgeColor','r');
title(t);
pause(.2); %pause(n):程序暂停n秒后继续
end
end
fclose(fidin);