Home > coding_tools > hand_annotation > label_hands.m

label_hands

PURPOSE ^

LABEL_HANDS MATLAB code for label_hands.fig

SYNOPSIS ^

function varargout = label_hands(varargin)

DESCRIPTION ^

 LABEL_HANDS MATLAB code for label_hands.fig
 Begin initialization code - DO NOT EDIT

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = label_hands(varargin)
0002 % LABEL_HANDS MATLAB code for label_hands.fig
0003     % Begin initialization code - DO NOT EDIT
0004     gui_Singleton = 1;
0005     gui_State = struct('gui_Name',       mfilename, ...
0006                        'gui_Singleton',  gui_Singleton, ...
0007                        'gui_OpeningFcn', @label_hands_OpeningFcn, ...
0008                        'gui_OutputFcn',  @label_hands_OutputFcn, ...
0009                        'gui_LayoutFcn',  [] , ...
0010                        'gui_Callback',   []);
0011     if nargin && ischar(varargin{1})
0012         gui_State.gui_Callback = str2func(varargin{1});
0013     end
0014 
0015     if nargout
0016         [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0017     else
0018         gui_mainfcn(gui_State, varargin{:});
0019     end
0020     % End initialization code - DO NOT EDIT
0021 
0022 
0023 % --- Executes just before label_hands is made visible.
0024 function label_hands_OpeningFcn(hObject, eventdata, handles, varargin)
0025 % This function has no output args, see OutputFcn.
0026 % hObject    handle to figure
0027 % eventdata  reserved - to be defined in a future version of MATLAB
0028 % handles    structure with handles and user data (see GUIDATA)
0029 % varargin   command line arguments to label_hands (see VARARGIN)
0030 
0031     % Choose default command line output for label_hands
0032     handles.output = hObject;
0033 
0034     % Update handles structure
0035     guidata(hObject, handles);
0036 
0037     % UIWAIT makes label_hands wait for user response (see UIRESUME)
0038     % uiwait(handles.figure1);
0039 
0040 
0041 % --- Outputs from this function are returned to the command line.
0042 function varargout = label_hands_OutputFcn(hObject, eventdata, handles) 
0043 % varargout  cell array for returning output args (see VARARGOUT);
0044 % hObject    handle to figure
0045 % eventdata  reserved - to be defined in a future version of MATLAB
0046 % handles    structure with handles and user data (see GUIDATA)
0047 
0048     % Get default command line output from handles structure
0049     varargout{1} = handles.output;
0050 
0051 
0052 % --- Executes on button press in yourLEft.
0053 function yourLeft_Callback(hObject, eventdata, handles)
0054 % hObject    handle to yourLEft (see GCBO)
0055 % eventdata  reserved - to be defined in a future version of MATLAB
0056 % handles    structure with handles and user data (see GUIDATA)
0057     h = imrect(handles.frame);
0058     fcn = makeConstrainToRectFcn('imrect', get(handles.frame, 'Xlim'), get(handles.frame, 'Ylim'));
0059     setPositionConstraintFcn(h,fcn);
0060     setResizable(h, false);
0061     setColor(h, 'red');
0062     box = xywh2xyxy(h.getPosition);
0063     box = truncate_box_to_img_boundaries(box, handles);
0064 
0065     index = getappdata(handles.frame, 'framenum');
0066     GT = getappdata(handles.frame, 'GT');
0067     frame_nr = get_frame_number(handles);
0068 
0069     GT.yleft(index, :) = [frame_nr box];
0070     setappdata(handles.frame, 'GT', GT);
0071     
0072 
0073 % --- Executes on button press in yourRight.
0074 function yourRight_Callback(hObject, eventdata, handles)
0075 % hObject    handle to yourRight (see GCBO)
0076 % eventdata  reserved - to be defined in a future version of MATLAB
0077 % handles    structure with handles and user data (see GUIDATA)
0078     h = imrect(handles.frame);
0079     fcn = makeConstrainToRectFcn('imrect', get(handles.frame, 'Xlim'), get(handles.frame, 'Ylim'));
0080     setPositionConstraintFcn(h,fcn);
0081     setResizable(h, false);
0082     setColor(h, 'green');
0083     box = xywh2xyxy(h.getPosition);
0084     box = truncate_box_to_img_boundaries(box, handles);
0085 
0086     index = getappdata(handles.frame, 'framenum');
0087     GT = getappdata(handles.frame, 'GT');
0088     frame_nr = get_frame_number(handles);
0089 
0090     GT.yright(index, :) = [frame_nr box];
0091     setappdata(handles.frame, 'GT', GT);
0092 
0093     
0094 % --- Executes on button press in myLeft.
0095 function myLeft_Callback(hObject, eventdata, handles)
0096 % hObject    handle to myLeft (see GCBO)
0097 % eventdata  reserved - to be defined in a future version of MATLAB
0098 % handles    structure with handles and user data (see GUIDATA)
0099     h = imrect(handles.frame);
0100     fcn = makeConstrainToRectFcn('imrect', get(handles.frame, 'Xlim'), get(handles.frame, 'Ylim'));
0101     setPositionConstraintFcn(h,fcn);
0102     setResizable(h, false);
0103     setColor(h, 'blue');
0104     box = xywh2xyxy(h.getPosition);
0105     box = truncate_box_to_img_boundaries(box, handles);
0106 
0107     index = getappdata(handles.frame, 'framenum');
0108     GT = getappdata(handles.frame, 'GT');
0109     frame_nr = get_frame_number(handles);
0110 
0111     GT.mleft(index, :) = [frame_nr box];
0112     setappdata(handles.frame, 'GT', GT);
0113 
0114 % --- Executes on button press in myRight.
0115 function myRight_Callback(hObject, eventdata, handles)
0116 % hObject    handle to myRight (see GCBO)
0117 % eventdata  reserved - to be defined in a future version of MATLAB
0118 % handles    structure with handles and user data (see GUIDATA)
0119     h = imrect(handles.frame);
0120     fcn = makeConstrainToRectFcn('imrect', get(handles.frame, 'Xlim'), get(handles.frame, 'Ylim'));
0121     setPositionConstraintFcn(h,fcn);
0122     setResizable(h, false);
0123     setColor(h, 'yellow');
0124     box = xywh2xyxy(h.getPosition);
0125     box = truncate_box_to_img_boundaries(box, handles);
0126 
0127     index = getappdata(handles.frame, 'framenum');
0128     GT = getappdata(handles.frame, 'GT');
0129     frame_nr = get_frame_number(handles);
0130 
0131     GT.mright(index, :) = [frame_nr box];
0132     setappdata(handles.frame, 'GT', GT);
0133 
0134 % --- Executes on button press in head.
0135 function head_Callback(hObject, eventdata, handles)
0136 % hObject    handle to head (see GCBO)
0137 % eventdata  reserved - to be defined in a future version of MATLAB
0138 % handles    structure with handles and user data (see GUIDATA)
0139     h = imrect(handles.frame);
0140     fcn = makeConstrainToRectFcn('imrect', get(handles.frame, 'Xlim'), get(handles.frame, 'Ylim'));
0141     setPositionConstraintFcn(h,fcn);
0142     setResizable(h, false);
0143     setColor(h, 'cyan');
0144     box = xywh2xyxy(h.getPosition);
0145     box = truncate_box_to_img_boundaries(box, handles);
0146 
0147     index = getappdata(handles.frame, 'framenum');
0148     GT = getappdata(handles.frame, 'GT');
0149     frame_nr = get_frame_number(handles);
0150 
0151     GT.head(index, :) = [frame_nr box];
0152     setappdata(handles.frame, 'GT', GT);
0153 
0154     
0155 % --- Executes on button press in load.
0156 function load_Callback(hObject, eventdata, handles)
0157 % hObject    handle to load (see GCBO)
0158 % eventdata  reserved - to be defined in a future version of MATLAB
0159 % handles    structure with handles and user data (see GUIDATA)
0160 
0161     % read image list from dir
0162     data_dir = uigetdir('/cantor/space/sbambach/');
0163     files = dir([data_dir '/*.jpg']);
0164     file_names = {};
0165     for f = 1:numel(files)
0166         file_names = [file_names, {files(f).name}];
0167     end
0168     file_names = sort_nat(file_names);
0169     num_frames = size(file_names, 2);
0170 
0171     set(handles.frame_info,'String',['Frame 1/' num2str(num_frames) ' (' file_names{1} ')']);
0172     set(handles.editNumber,'String', num2str(1));
0173 
0174     index = 1;
0175     setappdata(handles.frame, 'names', file_names);
0176     setappdata(handles.frame, 'framenum', index);
0177     setappdata(handles.frame, 'maxframes', num_frames);
0178     setappdata(handles.frame, 'data_dir', data_dir);
0179     trial_number = num2str(data_dir(end));
0180     setappdata(handles.frame, 'trial_number', trial_number);
0181 
0182     if exist([data_dir '/../gt_tr' num2str(trial_number) '.mat'], 'file') == 2
0183         load([data_dir '/../gt_tr' num2str(trial_number) '.mat']); %polygons
0184         assignin('base','GT', GT);
0185         setappdata(handles.frame, 'GT', GT);
0186         %show_existing_polygons(handles);
0187         %show_existing_masks(handles, img);
0188         %img = overlay_existing_masks(img, polygons, index, 0.33);
0189         render_image_with_boxes(handles);
0190         %imshow(img);
0191     else
0192         % create struct to hold GT coordinates
0193         GT = struct('head', -1*ones(num_frames, 5), 'mleft', -1*ones(num_frames, 5),'mright', -1*ones(num_frames, 5), 'yleft', -1*ones(num_frames, 5), 'yright', -1*ones(num_frames, 5));
0194 
0195         GT.head(:,1) = get_all_frame_numbers(handles);
0196         GT.mleft(:,1) = get_all_frame_numbers(handles);
0197         GT.mright(:,1) = get_all_frame_numbers(handles);
0198         GT.yleft(:,1) = get_all_frame_numbers(handles);
0199         GT.yright(:,1) = get_all_frame_numbers(handles);
0200 
0201         assignin('base','GT', GT);
0202         setappdata(handles.frame, 'GT', GT);        
0203     end
0204 
0205     render_image_with_boxes(handles);
0206     
0207 function img = overlay_existing_masks(img, polygons, index, opacity)
0208     if nargin < 4
0209         opacity = 0.33;
0210     end
0211     %index = getappdata(handles.frame, 'framenum');
0212     %polygons = getappdata(handles.frame, 'polygons');
0213     if index <= length(polygons)
0214         if ~isempty(polygons(index).yourright)
0215             shape = reshapeAreaCoords(polygons(index).yourright);
0216             img = insertShape(img, 'FilledPolygon', shape, 'Color', {'green'}, 'Opacity', opacity);
0217         end
0218         if ~isempty(polygons(index).yourleft)
0219             shape = reshapeAreaCoords(polygons(index).yourleft);
0220             img = insertShape(img, 'FilledPolygon', shape, 'Color', {'red'}, 'Opacity', opacity);
0221         end
0222         if ~isempty(polygons(index).myright)
0223             shape = reshapeAreaCoords(polygons(index).myright);
0224             img = insertShape(img, 'FilledPolygon', shape, 'Color', {'yellow'}, 'Opacity', opacity);
0225         end
0226         if ~isempty(polygons(index).myleft)
0227             shape = reshapeAreaCoords(polygons(index).myleft);
0228             img = insertShape(img, 'FilledPolygon', shape, 'Color', {'blue'}, 'Opacity', opacity);
0229         end
0230         %imshow(img);
0231     end
0232     
0233 function shape2 = reshapeAreaCoords(shape)
0234     shape2 = zeros(1, 2*length(shape));
0235     shape2(1:2:end) = shape(:,1)';
0236     shape2(2:2:end) = shape(:,2)';
0237         
0238     
0239 % --- Executes on button press in next.
0240 function next_Callback(hObject, eventdata, handles)
0241 % hObject    handle to next (see GCBO)
0242 % eventdata  reserved - to be defined in a future version of MATLAB
0243 % handles    structure with handles and user data (see GUIDATA)
0244 
0245     index = getappdata(handles.frame, 'framenum');
0246     data_dir = getappdata(handles.frame, 'data_dir');
0247     file_names = getappdata(handles.frame, 'names');
0248     num_frames = getappdata(handles.frame, 'maxframes');
0249 
0250     % get most up to date masks and update .mat file
0251 %     masks = getappdata(handles.frame, 'masks');
0252 %     assignin('base','masks', masks);
0253 %     save([data_dir '/masks.mat'], 'masks');
0254 %     % write a png containing the mask for the current frame
0255 %     mask_name = [data_dir '/' strrep(file_names{index}, '.jpg', '.png')];
0256 %     imwrite(masks(:,:,:, index), mask_name);
0257 
0258     % get most up to date polygons and update .mat file
0259     GT = getappdata(handles.frame, 'GT');
0260     trial_number = getappdata(handles.frame, 'trial_number');
0261     assignin('base','GT', GT);
0262     save([data_dir '/../gt_tr' trial_number '.mat'], 'GT');
0263 
0264     if index < getappdata(handles.frame, 'maxframes')
0265         index = index + 1;
0266         setappdata(handles.frame, 'framenum', index);
0267         set(handles.frame_info,'String',['Frame ' num2str(index) '/' num2str(num_frames)  ' (' file_names{index} ')']);
0268         set(handles.editNumber,'String', num2str(index));
0269         render_image_with_boxes(handles)
0270     end
0271 
0272 
0273 % --- Executes on key press with focus on figure1 and none of its controls.
0274 function figure1_KeyPressFcn(hObject, eventdata, handles)
0275 % hObject    handle to figure1 (see GCBO)
0276 % eventdata  structure with the following fields (see FIGURE)
0277 %    Key: name of the key that was pressed, in lower case
0278 %    Character: character interpretation of the key(s) that was pressed
0279 %    Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
0280 % handles    structure with handles and user data (see GUIDATA)
0281 
0282     % disp(eventdata.Key);
0283 
0284     switch eventdata.Key
0285         case 'q'
0286             head_Callback(hObject, eventdata, handles);
0287         case 'w'
0288             yourLeft_Callback(hObject, eventdata, handles);
0289         case 'e'
0290             yourRight_Callback(hObject, eventdata, handles);
0291         case 'r'
0292             myLeft_Callback(hObject, eventdata, handles);
0293         case 't'
0294             myRight_Callback(hObject, eventdata, handles);
0295         case 'rightarrow'
0296             next_Callback(hObject, eventdata, handles);
0297         case 'leftarrow'
0298             prev_Callback(hObject, eventdata, handles);
0299 
0300     end
0301 
0302     
0303 % --- Executes on button press in prev.
0304 function prev_Callback(hObject, eventdata, handles)
0305 % hObject    handle to prev (see GCBO)
0306 % eventdata  reserved - to be defined in a future version of MATLAB
0307 % handles    structure with handles and user data (see GUIDATA)
0308 
0309     index = getappdata(handles.frame, 'framenum');
0310     data_dir = getappdata(handles.frame, 'data_dir');
0311     file_names = getappdata(handles.frame, 'names');
0312     num_frames = getappdata(handles.frame, 'maxframes');
0313 
0314     % get most up to date polygons and update .mat file
0315     GT = getappdata(handles.frame, 'GT');
0316     trial_number = getappdata(handles.frame, 'trial_number');
0317     assignin('base','GT', GT);
0318     save([data_dir '/../gt_tr' trial_number '.mat'], 'GT');
0319 
0320     if index > 1
0321         index = index - 1;
0322         setappdata(handles.frame, 'framenum', index);
0323         set(handles.frame_info,'String',['Frame ' num2str(index) '/' num2str(num_frames)  ' (' file_names{index} ')']);
0324         set(handles.editNumber,'String', num2str(index));
0325         render_image_with_boxes(handles);
0326     end
0327 
0328 
0329 % --- Executes on button press in clearYL.
0330 function clearYL_Callback(hObject, eventdata, handles)
0331 % hObject    handle to clearYL (see GCBO)
0332 % eventdata  reserved - to be defined in a future version of MATLAB
0333 % handles    structure with handles and user data (see GUIDATA)
0334     data_dir = getappdata(handles.frame, 'data_dir');
0335     file_names = getappdata(handles.frame, 'names');
0336     GT = getappdata(handles.frame, 'GT');
0337     index = getappdata(handles.frame, 'framenum');
0338     
0339     GT.yleft(index, 2:5) = [-1 -1 -1 -1];
0340     setappdata(handles.frame, 'GT', GT);
0341 
0342     render_image_with_boxes(handles);
0343     
0344 
0345 
0346 % --- Executes on button press in clearYR.
0347 function clearYR_Callback(hObject, eventdata, handles)
0348 % hObject    handle to clearYR (see GCBO)
0349 % eventdata  reserved - to be defined in a future version of MATLAB
0350 % handles    structure with handles and user data (see GUIDATA)
0351     data_dir = getappdata(handles.frame, 'data_dir');
0352     file_names = getappdata(handles.frame, 'names');
0353     GT = getappdata(handles.frame, 'GT');
0354     index = getappdata(handles.frame, 'framenum');
0355     
0356     GT.yright(index, 2:5) = [-1 -1 -1 -1];
0357     setappdata(handles.frame, 'GT', GT);
0358 
0359     render_image_with_boxes(handles);
0360 
0361 
0362 % --- Executes on button press in clearML.
0363 function clearML_Callback(hObject, eventdata, handles)
0364 % hObject    handle to clearML (see GCBO)
0365 % eventdata  reserved - to be defined in a future version of MATLAB
0366 % handles    structure with handles and user data (see GUIDATA)
0367     data_dir = getappdata(handles.frame, 'data_dir');
0368     file_names = getappdata(handles.frame, 'names');
0369     GT = getappdata(handles.frame, 'GT');
0370     index = getappdata(handles.frame, 'framenum');
0371     
0372     GT.mleft(index, 2:5) = [-1 -1 -1 -1];
0373     setappdata(handles.frame, 'GT', GT);
0374 
0375     render_image_with_boxes(handles);
0376 
0377 
0378 % --- Executes on button press in clearMR.
0379 function clearMR_Callback(hObject, eventdata, handles)
0380 % hObject    handle to clearMR (see GCBO)
0381 % eventdata  reserved - to be defined in a future version of MATLAB
0382 % handles    structure with handles and user data (see GUIDATA)
0383     data_dir = getappdata(handles.frame, 'data_dir');
0384     file_names = getappdata(handles.frame, 'names');
0385     GT = getappdata(handles.frame, 'GT');
0386     index = getappdata(handles.frame, 'framenum');
0387     
0388     GT.mright(index, 2:5) = [-1 -1 -1 -1];
0389     setappdata(handles.frame, 'GT', GT);
0390 
0391     render_image_with_boxes(handles);
0392 
0393 
0394 
0395 function editNumber_Callback(hObject, eventdata, handles)
0396 % hObject    handle to editNumber (see GCBO)
0397 % eventdata  reserved - to be defined in a future version of MATLAB
0398 % handles    structure with handles and user data (see GUIDATA)
0399 
0400 % Hints: get(hObject,'String') returns contents of editNumber as text
0401 %        str2double(get(hObject,'String')) returns contents of editNumber as a double
0402 
0403     index = str2double(get(hObject,'String'));
0404     num_frames = getappdata(handles.frame, 'maxframes');
0405     
0406     if isnumeric(index) && ~isempty(num_frames) && index >= 1 && index <= num_frames
0407 
0408         %index = getappdata(handles.frame, 'framenum');
0409         data_dir = getappdata(handles.frame, 'data_dir');
0410         file_names = getappdata(handles.frame, 'names');
0411         num_frames = getappdata(handles.frame, 'maxframes');
0412 
0413         % get most up to date polygons and update .mat file
0414         GT = getappdata(handles.frame, 'GT');
0415         trial_number = getappdata(handles.frame, 'trial_number');
0416         assignin('base','GT', GT);
0417         save([data_dir '/../gt_tr' trial_number '.mat'], 'GT');
0418 
0419         setappdata(handles.frame, 'framenum', index);
0420         set(handles.frame_info,'String',['Frame ' num2str(index) '/' num2str(num_frames)  ' (' file_names{index} ')']);
0421         render_image_with_boxes(handles);
0422 
0423     end
0424 
0425 
0426 % --- Executes during object creation, after setting all properties.
0427 function editNumber_CreateFcn(hObject, eventdata, handles)
0428 % hObject    handle to editNumber (see GCBO)
0429 % eventdata  reserved - to be defined in a future version of MATLAB
0430 % handles    empty - handles not created until after all CreateFcns called
0431 
0432 % Hint: edit controls usually have a white background on Windows.
0433 %       See ISPC and COMPUTER.
0434 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0435     set(hObject,'BackgroundColor','white');
0436 end
0437 
0438 % --- Executes on button press in pushbutton18.
0439 function pushbutton18_Callback(hObject, eventdata, handles)
0440 % hObject    handle to pushbutton18 (see GCBO)
0441 % eventdata  reserved - to be defined in a future version of MATLAB
0442 % handles    structure with handles and user data (see GUIDATA)
0443     data_dir = getappdata(handles.frame, 'data_dir');
0444     file_names = getappdata(handles.frame, 'names');
0445     GT = getappdata(handles.frame, 'GT');
0446     index = getappdata(handles.frame, 'framenum');
0447     
0448     GT.head(index, 2:5) = [-1 -1 -1 -1];
0449     setappdata(handles.frame, 'GT', GT);
0450 
0451     render_image_with_boxes(handles);
0452 
0453 
0454 
0455 function [] = render_image_with_boxes(handles)
0456 
0457 
0458     file_names = getappdata(handles.frame, 'names');
0459     index = getappdata(handles.frame, 'framenum');
0460     data_dir = getappdata(handles.frame, 'data_dir');
0461     GT = getappdata(handles.frame, 'GT');
0462 
0463     img = imread([data_dir,'/' file_names{index}]);
0464     img_size = size(img);
0465     setappdata(handles.frame, 'img_size', img_size);
0466     %imshow(img);
0467 
0468     % show image
0469     imshow(img, 'Parent', handles.frame);
0470     
0471     % overlay boxes
0472     if GT.head(index, 2) >= 0
0473         pos = xyxy2xywh(GT.head(index, 2:5));
0474         color = [0 1 1];
0475         rectangle('Position', pos,...
0476               'LineWidth',2,...
0477               'EdgeColor', color, ...
0478               'LineStyle','-', 'Parent', handles.frame);
0479     end
0480     if GT.mleft(index, 2) >= 0
0481         pos = xyxy2xywh(GT.mleft(index, 2:5));
0482         color = [0 0 1];
0483         rectangle('Position', pos,...
0484               'LineWidth',2,...
0485               'EdgeColor', color, ...
0486               'LineStyle','-', 'Parent', handles.frame);
0487     end
0488     if GT.mright(index, 2) >= 0
0489     pos = xyxy2xywh(GT.mright(index, 2:5));
0490     color = [1 1 0];
0491     rectangle('Position', pos,...
0492           'LineWidth',2,...
0493           'EdgeColor', color, ...
0494           'LineStyle','-', 'Parent', handles.frame);
0495     end
0496     if GT.yright(index, 2) >= 0
0497     pos = xyxy2xywh(GT.yright(index, 2:5));
0498     color = [0 1 0];
0499     rectangle('Position', pos,...
0500           'LineWidth',2,...
0501           'EdgeColor', color, ...
0502           'LineStyle','-', 'Parent', handles.frame);
0503     end
0504     if GT.yleft(index, 2) >= 0
0505     pos = xyxy2xywh(GT.yleft(index, 2:5));
0506     color = [1 0 0];
0507     rectangle('Position', pos,...
0508           'LineWidth',2,...
0509           'EdgeColor', color, ...
0510           'LineStyle','-', 'Parent', handles.frame);
0511     end
0512         
0513 
0514 function box = truncate_box_to_img_boundaries(box, handles)
0515     box = round(box);
0516     % assumes xyxy coords
0517     img_size = getappdata(handles.frame, 'img_size');
0518     n_rows = img_size(1);
0519     n_cols = img_size(2);
0520     box(1) = max(1, box(1));
0521     box(2) = max(1, box(2));
0522     box(3) = min(n_cols, box(3));
0523     box(4) = min(n_rows, box(4));
0524 
0525 function box = xyxy2xywh(box)
0526     box(3) = box(3)-box(1)+1;
0527     box(4) = box(4)-box(2)+1;
0528 
0529 function box = xywh2xyxy(box)
0530     box(3) = box(1)+box(3)-1;
0531     box(4) = box(2)+box(4)-1;
0532 
0533 function frame_nr = get_frame_number(handles)
0534     file_names = getappdata(handles.frame, 'names');
0535     index = getappdata(handles.frame, 'framenum');
0536     file = file_names{index};
0537     frame_nr = strrep(file, 'img_', '');
0538     frame_nr = strrep(frame_nr, '.jpg', '');
0539     frame_nr = str2num(frame_nr);
0540 
0541 function frame_numbers = get_all_frame_numbers(handles)
0542     file_names = getappdata(handles.frame, 'names');
0543     frame_numbers = zeros(length(file_names), 1);
0544     for f = 1:length(frame_numbers)
0545         file = file_names{f};
0546         frame_nr = strrep(file, 'img_', '');
0547         frame_nr = strrep(frame_nr, '.jpg', '');
0548         frame_numbers(f) = str2num(frame_nr);
0549     end
0550 
0551 
0552 % --- Executes when user attempts to close figure1.
0553 function figure1_CloseRequestFcn(hObject, eventdata, handles)
0554 % hObject    handle to figure1 (see GCBO)
0555 % eventdata  reserved - to be defined in a future version of MATLAB
0556 % handles    structure with handles and user data (see GUIDATA)
0557 
0558 % Hint: delete(hObject) closes the figure
0559 delete(hObject);
0560 exit();

Generated on Wed 24-May-2017 00:00:56 by m2html © 2005