[37] | 1 | % script for demonstrating the localized points |
---|
| 2 | % it load the input images and the matrix with found points |
---|
| 3 | % and it denotes the position of the detected LED |
---|
| 4 | % and it saves the augmented images on the disk if required |
---|
| 5 | |
---|
| 6 | % $Author: svoboda $ |
---|
| 7 | % $Revision: 2.2 $ |
---|
| 8 | % $Id: showpoints.m,v 2.2 2005/05/20 12:54:51 svoboda Exp $ |
---|
| 9 | % $State: Exp $ |
---|
| 10 | |
---|
| 11 | clear all; |
---|
| 12 | addpath ../CommonCfgAndIO |
---|
| 13 | |
---|
| 14 | SAVE_IMG = 1; % Do you want to save images? |
---|
| 15 | COMPOSE_IMGS = 1; % Do you want to see composed images? |
---|
| 16 | % the function getframe which is used here is not really robust |
---|
| 17 | % no window can overlay the most active figure(1) |
---|
| 18 | % otherwise it will not work correctly |
---|
| 19 | |
---|
| 20 | % load the confidata |
---|
| 21 | config = configdata(expname); |
---|
| 22 | |
---|
| 23 | im.dir = config.paths.img; |
---|
| 24 | im.ext = config.files.imgext; |
---|
| 25 | |
---|
| 26 | NoCams = size(config.files.idxcams,2); % number of cameras |
---|
| 27 | |
---|
| 28 | % load image names |
---|
| 29 | for i=1:NoCams, |
---|
| 30 | seq(i).camId = config.files.idxcams(i); |
---|
| 31 | if seq(i).camId > -1 |
---|
| 32 | if findstr(expname,'oscar') |
---|
| 33 | seq(i).data = dir([sprintf(im.dir,seq(i).camId),config.files.imnames,'*.',im.ext]); |
---|
| 34 | else |
---|
| 35 | seq(i).data = dir([sprintf(im.dir,seq(i).camId),sprintf(config.files.imnames,seq(i).camId),im.ext]); |
---|
| 36 | end |
---|
| 37 | else |
---|
| 38 | seq(i).data = dir([im.dir,sprintf(config.files.imnames),im.ext]); |
---|
| 39 | end |
---|
| 40 | seq(i).size = size(seq(i).data,1); |
---|
| 41 | if seq(i).size<4 |
---|
| 42 | error('Not enough images found. Wrong image path or name pattern?'); |
---|
| 43 | end |
---|
| 44 | end |
---|
| 45 | |
---|
| 46 | % for i=1:NoCams, |
---|
| 47 | % seq(i).camId = config.files.idxcams(i); |
---|
| 48 | % if seq(i).camId > -1 |
---|
| 49 | % seq(i).data = dir([sprintf(im.dir,seq(i).camId),sprintf(config.files.imnames,seq(i).camId),im.ext]); |
---|
| 50 | % else |
---|
| 51 | % seq(i).data = dir([im.dir,sprintf(config.files.imnames),im.ext]); |
---|
| 52 | % end |
---|
| 53 | % seq(i).size = size(seq(i).data,1); |
---|
| 54 | % if seq(i).size<4 |
---|
| 55 | % error('Not enough images found. Wrong image path or name pattern?'); |
---|
| 56 | % end |
---|
| 57 | % end |
---|
| 58 | |
---|
| 59 | loaded = loaddata(config); |
---|
| 60 | |
---|
| 61 | |
---|
| 62 | if ~COMPOSE_IMGS |
---|
| 63 | % load images and show the results |
---|
| 64 | for i=1:NoCams, |
---|
| 65 | for j=1:size(loaded.IdMat,2), |
---|
| 66 | IM= imread([sprintf(im.dir,seq(i).camId),seq(i).data(j).name]); |
---|
| 67 | figure(1), clf, axes('Position',[0 0 1 1]), axis off |
---|
| 68 | imshow(IM), hold on, |
---|
| 69 | text(15,20,sprintf('Camera: %0.2d Frame: %0.3d',config.files.idxcams(i),j),'Color','green','FontWeight','bold','FontSize',12,'EraseMode','back'); |
---|
| 70 | if loaded.IdMat(i,j)>0 |
---|
| 71 | plot(loaded.Ws(3*i-2,j),loaded.Ws(3*i-1,j),'go','MarkerSize',25,'LineWidth',2,'EraseMode','back'); |
---|
| 72 | plot(loaded.Ws(3*i-2,j),loaded.Ws(3*i-1,j),'r+','MarkerSize',15,'LineWidth',1,'EraseMode','back'); |
---|
| 73 | else |
---|
| 74 | text(15,40,'No point found','Color','green','FontWeight','bold','FontSize',12,'EraseMode','back'); |
---|
| 75 | end |
---|
| 76 | if SAVE_IMG |
---|
| 77 | eval(sprintf('print -djpeg -r72 %spoint.cam%d.%d.jpg',config.paths.data, config.files.idxcams(i),j)) |
---|
| 78 | end |
---|
| 79 | hold off |
---|
| 80 | end |
---|
| 81 | end |
---|
| 82 | end |
---|
| 83 | |
---|
| 84 | % show the composed figures |
---|
| 85 | if COMPOSE_IMGS |
---|
| 86 | for j=1:size(loaded.IdMat,2), |
---|
| 87 | % IMcomposed = uint8(zeros(size(IM,1),size(IM,2),3,NoCams)); |
---|
| 88 | for i=1:NoCams, |
---|
| 89 | IM= imread([sprintf(im.dir,seq(i).camId),seq(i).data(j).name]); |
---|
| 90 | fig1 = figure(1); clf, axes('Position',[0 0 1 1]), axis off |
---|
| 91 | imshow(IM), hold on, |
---|
| 92 | text(15,20,sprintf('Camera: %0.2d Frame: %0.3d',config.files.idxcams(i),j),'Color','green','FontWeight','bold','FontSize',12,'EraseMode','back'); |
---|
| 93 | if loaded.IdMat(i,j)>0 |
---|
| 94 | plot(loaded.Ws(3*i-2,j),loaded.Ws(3*i-1,j),'go','MarkerSize',25,'LineWidth',2,'EraseMode','back'); |
---|
| 95 | plot(loaded.Ws(3*i-2,j),loaded.Ws(3*i-1,j),'r+','MarkerSize',15,'LineWidth',1,'EraseMode','back'); |
---|
| 96 | else |
---|
| 97 | text(15,40,'No point found','Color','green','FontWeight','bold','FontSize',12,'EraseMode','back'); |
---|
| 98 | end |
---|
| 99 | IMannotated = getframe(gcf); |
---|
| 100 | IMcomposed(:,:,:,i) = IMannotated.cdata; |
---|
| 101 | hold off |
---|
| 102 | end |
---|
| 103 | fig2 = figure(2); clf, axes('Position',[0 0 1 1]), axis off, |
---|
| 104 | montage(IMcomposed); |
---|
| 105 | if SAVE_IMG |
---|
| 106 | % eval(sprintf('print -djpeg -r152 %spoints.composed.%d.jpg',config.paths.data, j)) |
---|
| 107 | eval(sprintf('print -depsc %spoints.composed.%04d.eps',config.paths.data, j)) |
---|
| 108 | end |
---|
| 109 | end |
---|
| 110 | end |
---|
| 111 | |
---|