source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/BlueCCal/MultiCamSelfCal/showpoints.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 3.8 KB
Line 
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
11clear all;
12addpath ../CommonCfgAndIO
13
14SAVE_IMG           = 1;         % Do you want to save images?
15COMPOSE_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
21config = configdata(expname);
22
23im.dir = config.paths.img;
24im.ext = config.files.imgext;
25
26NoCams = size(config.files.idxcams,2);  % number of cameras
27
28% load image names
29for 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
44end
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
59loaded = loaddata(config);
60
61
62if ~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
82end
83
84% show the composed figures
85if 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
110end
111
Note: See TracBrowser for help on using the repository browser.