Cell array menu image acquisition error

Hello,
I wrote a cell array menu because I wanted to use themenu style that the image acquisition toolbox uses. It looks like this:
function main(~)
cell_list = {};
fig_number = 1;
title_figure = 'Test';
cell_list{1,1} = {'1.Calibration','calib_gui;'};
cell_list{2,1} = {'2.Stereo Calibration','stereo_gui;'};
cell_list{3,1} = {'3.Choose/Rename Images','rename_images;'};
cell_list{4,1} = {'4.Record','record;'};
cell_list{5,1} = {'Exit',['disp(''Goodbye.''); close(' num2str(fig_number) ');']};
show_window(cell_list,fig_number,title_figure,290,18,0,'clean',12);
end
Now if I click on 4.Record, it calls the function and then it should ceate another figure, containing two side by side previews of my two cameras. But I can't get it to work and I think its because of the show_window command? Right now Im using this:
start(vid1);
start(vid2);
preview(vid1);
preview(vid2);
But if I want to get a good menu, do I have to use something like GUIDE?

5 comentarios

Adam
Adam el 21 de Ag. de 2017
What is show_window? It's not a Matlab function so far as I can see.
Marcel Liphardt
Marcel Liphardt el 21 de Ag. de 2017
Hey Adam,
this function is inside the Camera Calibration Toolbox for Matlab if you download this zip package.
function show_window(cell_list,fig_number,title_figure,x_size,y_size,gap_x,font_name,font_size)
if ~exist('cell_list')
error('No description of the functions');
end
if ~exist('fig_number')
fig_number = 1;
end
if ~exist('title_figure')
title_figure = '';
end
if ~exist('x_size')
x_size = 85;
end
if ~exist('y_size')
y_size = 14;
end
if ~exist('gap_x')
gap_x = 0;
end
if ~exist('font_name')
font_name = 'clean';
end
if ~exist('font_size')
font_size = 8;
end
figure(fig_number); clf;
pos = get(fig_number,'Position');
[n_row,n_col] = size(cell_list);
fig_size_x = x_size*n_col+(n_col+1)*gap_x;
fig_size_y = y_size*n_row+(n_row+1)*gap_x;
set(fig_number,'Units','points', ...
'BackingStore','off', ...
'Color',[0.8 0.8 0.8], ...
'MenuBar','none', ...
'Resize','off', ...
'Name',title_figure, ...
'Position',[pos(1) pos(2) fig_size_x fig_size_y], ...
'NumberTitle','off'); %,'WindowButtonMotionFcn',['figure(' num2str(fig_number) ');']);
h_mat = zeros(n_row,n_col);
posx = zeros(n_row,n_col);
posy = zeros(n_row,n_col);
for i=n_row:-1:1
for j = n_col:-1:1
posx(i,j) = gap_x+(j-1)*(x_size+gap_x);
posy(i,j) = fig_size_y - i*(gap_x+y_size);
end
end
for i=n_row:-1:1
for j = n_col:-1:1
if ~isempty(cell_list{i,j})
if ~isempty(cell_list{i,j}{1}) && ~isempty(cell_list{i,j}{2})
h_mat(i,j) = uicontrol('Parent',fig_number, ...
'Units','points', ...
'Callback',cell_list{i,j}{2}, ...
'ListboxTop',0, ...
'Position',[posx(i,j) posy(i,j) x_size y_size], ...
'String',cell_list{i,j}{1}, ...
'fontsize',font_size,...
'fontname',font_name,...
'Tag','Pushbutton1');
end
end
end
end
%------ END PROTECTED REGION ----------------%
The shown code is prone to bugs: ~exist('cell_list') checks for M- and Mex-files anywhere in the path, java classes and files and folders in the current directory. I would not rely on such code.
But if I want to get a good menu, do I have to use something like GUIDE?
What exactly is a "good" menu?
Marcel Liphardt
Marcel Liphardt el 22 de Ag. de 2017
Hey Jan,
well you kniów, if I push this button: cell_list{4,1} = {'4.Record','record;'};
Then I would like to get a menu containing two camera previews, one on the left and one on the right and some buttons.
And therefore I don't know the best way to do so.

Iniciar sesión para comentar.

Respuestas (0)

Preguntada:

el 21 de Ag. de 2017

Comentada:

el 22 de Ag. de 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by