Home > coding_tools > object_annotation > label_inhand > INHAND_CL_GUI.m

INHAND_CL_GUI

PURPOSE ^

INHAND_CL_GUI MATLAB code for INHAND_CL_GUI.fig

SYNOPSIS ^

function varargout = INHAND_CL_GUI(varargin)

DESCRIPTION ^

 INHAND_CL_GUI MATLAB code for INHAND_CL_GUI.fig
      INHAND_CL_GUI, by itself, creates a new INHAND_CL_GUI or raises the existing
      singleton*.

      H = INHAND_CL_GUI returns the handle to a new INHAND_CL_GUI or the handle to
      the existing singleton*.

      INHAND_CL_GUI('CALLBACK',hObject,eventData,handles,...) calls the local
      function named CALLBACK in INHAND_CL_GUI.M with the given input arguments.

      INHAND_CL_GUI('Property','Value',...) creates a new INHAND_CL_GUI or raises the
      existing singleton*.  Starting from the left, property value pairs are
      applied to the GUI before INHAND_CL_GUI_OpeningFcn gets called.  An
      unrecognized property name or invalid value makes property application
      stop.  All inputs are passed to INHAND_CL_GUI_OpeningFcn via varargin.

      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
      instance to run (singleton)".

 See also: GUIDE, GUIDATA, GUIHANDLES

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = INHAND_CL_GUI(varargin)
0002 % INHAND_CL_GUI MATLAB code for INHAND_CL_GUI.fig
0003 %      INHAND_CL_GUI, by itself, creates a new INHAND_CL_GUI or raises the existing
0004 %      singleton*.
0005 %
0006 %      H = INHAND_CL_GUI returns the handle to a new INHAND_CL_GUI or the handle to
0007 %      the existing singleton*.
0008 %
0009 %      INHAND_CL_GUI('CALLBACK',hObject,eventData,handles,...) calls the local
0010 %      function named CALLBACK in INHAND_CL_GUI.M with the given input arguments.
0011 %
0012 %      INHAND_CL_GUI('Property','Value',...) creates a new INHAND_CL_GUI or raises the
0013 %      existing singleton*.  Starting from the left, property value pairs are
0014 %      applied to the GUI before INHAND_CL_GUI_OpeningFcn gets called.  An
0015 %      unrecognized property name or invalid value makes property application
0016 %      stop.  All inputs are passed to INHAND_CL_GUI_OpeningFcn via varargin.
0017 %
0018 %      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
0019 %      instance to run (singleton)".
0020 %
0021 % See also: GUIDE, GUIDATA, GUIHANDLES
0022 
0023 % Edit the above text to modify the response to help INHAND_CL_GUI
0024 
0025 % Last Modified by GUIDE v2.5 18-Nov-2015 11:35:53
0026 
0027 % Begin initialization code - DO NOT EDIT
0028 gui_Singleton = 1;
0029 gui_State = struct('gui_Name',       mfilename, ...
0030                    'gui_Singleton',  gui_Singleton, ...
0031                    'gui_OpeningFcn', @INHAND_CL_GUI_OpeningFcn, ...
0032                    'gui_OutputFcn',  @INHAND_CL_GUI_OutputFcn, ...
0033                    'gui_LayoutFcn',  [] , ...
0034                    'gui_Callback',   []);
0035 if nargin && ischar(varargin{1})
0036     gui_State.gui_Callback = str2func(varargin{1});
0037 end
0038 
0039 if nargout
0040     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0041 else
0042     gui_mainfcn(gui_State, varargin{:});
0043 end
0044 % End initialization code - DO NOT EDIT
0045 
0046 
0047 % --- Executes just before INHAND_CL_GUI is made visible.
0048 function INHAND_CL_GUI_OpeningFcn(hObject, eventdata, handles, varargin)
0049 % This function has no output args, see OutputFcn.
0050 % hObject    handle to figure
0051 % eventdata  reserved - to be defined in a future version of MATLAB
0052 % handles    structure with handles and user data (see GUIDATA)
0053 % varargin   command line arguments to INHAND_CL_GUI (see VARARGIN)
0054 
0055 % Choose default command line output for INHAND_CL_GUI
0056 handles.output = hObject;
0057 
0058 % Update handles structure
0059 guidata(hObject, handles);
0060 
0061 % UIWAIT makes INHAND_CL_GUI wait for user response (see UIRESUME)
0062 % uiwait(handles.figure1);
0063 
0064 if length(varargin) > 0
0065     setappdata(handles.frame_1, 'CODER_NAME', varargin{1});
0066 else
0067     setappdata(handles.frame_1, 'CODER_NAME', '');
0068 end
0069 
0070 
0071 % --- Outputs from this function are returned to the command line.
0072 function varargout = INHAND_CL_GUI_OutputFcn(hObject, eventdata, handles) 
0073 % varargout  cell array for returning output args (see VARARGOUT);
0074 % hObject    handle to figure
0075 % eventdata  reserved - to be defined in a future version of MATLAB
0076 % handles    structure with handles and user data (see GUIDATA)
0077 
0078 % Get default command line output from handles structure
0079 varargout{1} = handles.output;
0080 
0081 % SET GUI VARIABLES
0082 setappdata(handles.frame_1, 'SAFE_MODE', 0);
0083 
0084 % turn off ugly figure axis
0085 set(handles.frame_1,'xcolor',get(gcf,'color'));
0086 set(handles.frame_1,'ycolor',get(gcf,'color'));
0087 set(handles.frame_1,'ytick',[]);
0088 set(handles.frame_1,'xtick',[]);
0089 set(handles.frame_2,'xcolor',get(gcf,'color'));
0090 set(handles.frame_2,'ycolor',get(gcf,'color'));
0091 set(handles.frame_2,'ytick',[]);
0092 set(handles.frame_2,'xtick',[]);
0093 set(handles.frame_3,'xcolor',get(gcf,'color'));
0094 set(handles.frame_3,'ycolor',get(gcf,'color'));
0095 set(handles.frame_3,'ytick',[]);
0096 set(handles.frame_3,'xtick',[]);
0097 set(handles.frame_2,'xcolor',get(gcf,'color'));
0098 set(handles.frame_2,'ycolor',get(gcf,'color'));
0099 set(handles.frame_2,'ytick',[]);
0100 set(handles.frame_2,'xtick',[]);
0101 
0102 set(handles.edit_frame_number, 'Enable', 'off');
0103 
0104 % create toy thumbnail imags
0105 thumbnails = cell(26, 1);
0106 for i = 1:length(thumbnails)-2
0107     thumbnails{i} = imread(['toys/' num2str(i) '.jpg']);
0108 end
0109 thumbnails{25} = imread(['toys/none.jpg']);
0110 thumbnails{26} = imread(['toys/face.jpg']);
0111 thumbnails{27} = imread(['toys/other.jpg']);
0112 imshow(thumbnails{1}, 'Parent', handles.img_1);
0113 imshow(thumbnails{2}, 'Parent', handles.img_2);
0114 imshow(thumbnails{3}, 'Parent', handles.img_3);
0115 imshow(thumbnails{4}, 'Parent', handles.img_4);
0116 imshow(thumbnails{5}, 'Parent', handles.img_5);
0117 imshow(thumbnails{6}, 'Parent', handles.img_6);
0118 imshow(thumbnails{7}, 'Parent', handles.img_7);
0119 imshow(thumbnails{8}, 'Parent', handles.img_8);
0120 imshow(thumbnails{9}, 'Parent', handles.img_9);
0121 imshow(thumbnails{10}, 'Parent', handles.img_10);
0122 imshow(thumbnails{11}, 'Parent', handles.img_11);
0123 imshow(thumbnails{12}, 'Parent', handles.img_12);
0124 imshow(thumbnails{13}, 'Parent', handles.img_13);
0125 imshow(thumbnails{14}, 'Parent', handles.img_14);
0126 imshow(thumbnails{15}, 'Parent', handles.img_15);
0127 imshow(thumbnails{16}, 'Parent', handles.img_16);
0128 imshow(thumbnails{17}, 'Parent', handles.img_17);
0129 imshow(thumbnails{18}, 'Parent', handles.img_18);
0130 imshow(thumbnails{19}, 'Parent', handles.img_19);
0131 imshow(thumbnails{20}, 'Parent', handles.img_20);
0132 imshow(thumbnails{21}, 'Parent', handles.img_21);
0133 imshow(thumbnails{22}, 'Parent', handles.img_22);
0134 imshow(thumbnails{23}, 'Parent', handles.img_23);
0135 imshow(thumbnails{24}, 'Parent', handles.img_24);
0136 imshow(thumbnails{25}, 'Parent', handles.img_none);
0137 %imshow(thumbnails{26}, 'Parent', handles.img_face);
0138 imshow(thumbnails{27}, 'Parent', handles.img_other);
0139 
0140 
0141 % --- Executes on button press in pushbutton1.
0142 function button_none_Callback(hObject, eventdata, handles)
0143 % hObject    handle to pushbutton1 (see GCBO)
0144 % eventdata  reserved - to be defined in a future version of MATLAB
0145 % handles    structure with handles and user data (see GUIDATA)
0146 resetButtonColors(handles);
0147 set(handles.button_none, 'BackgroundColor','green');
0148 setappdata(handles.frame_1, 'INHAND', 0);
0149 update_INHAND_DATA(handles);
0150 
0151 % --- Executes on button press in button_1.
0152 function button_1_Callback(hObject, eventdata, handles)
0153 % hObject    handle to button_1 (see GCBO)
0154 % eventdata  reserved - to be defined in a future version of MATLAB
0155 % handles    structure with handles and user data (see GUIDATA)
0156 resetButtonColors(handles);
0157 set(handles.button_1, 'BackgroundColor','green');
0158 setappdata(handles.frame_1, 'INHAND', 1);
0159 update_INHAND_DATA(handles);
0160 
0161 % --- Executes on button press in button_2.
0162 function button_2_Callback(hObject, eventdata, handles)
0163 % hObject    handle to button_2 (see GCBO)
0164 % eventdata  reserved - to be defined in a future version of MATLAB
0165 % handles    structure with handles and user data (see GUIDATA)
0166 resetButtonColors(handles);
0167 set(handles.button_2, 'BackgroundColor','green');
0168 setappdata(handles.frame_1, 'INHAND', 2);
0169 update_INHAND_DATA(handles);
0170 
0171 % --- Executes on button press in button_3.
0172 function button_3_Callback(hObject, eventdata, handles)
0173 % hObject    handle to button_3 (see GCBO)
0174 % eventdata  reserved - to be defined in a future version of MATLAB
0175 % handles    structure with handles and user data (see GUIDATA)
0176 resetButtonColors(handles);
0177 set(handles.button_3, 'BackgroundColor','green');
0178 setappdata(handles.frame_1, 'INHAND', 3);
0179 update_INHAND_DATA(handles);
0180 
0181 % --- Executes on button press in button_4.
0182 function button_4_Callback(hObject, eventdata, handles)
0183 % hObject    handle to button_4 (see GCBO)
0184 % eventdata  reserved - to be defined in a future version of MATLAB
0185 % handles    structure with handles and user data (see GUIDATA)
0186 resetButtonColors(handles);
0187 set(handles.button_4, 'BackgroundColor','green');
0188 setappdata(handles.frame_1, 'INHAND', 4);
0189 update_INHAND_DATA(handles);
0190 
0191 % --- Executes on button press in button_5.
0192 function button_5_Callback(hObject, eventdata, handles)
0193 % hObject    handle to button_5 (see GCBO)
0194 % eventdata  reserved - to be defined in a future version of MATLAB
0195 % handles    structure with handles and user data (see GUIDATA)
0196 resetButtonColors(handles);
0197 set(handles.button_5, 'BackgroundColor','green');
0198 setappdata(handles.frame_1, 'INHAND', 5);
0199 update_INHAND_DATA(handles);
0200 
0201 % --- Executes on button press in button_6.
0202 function button_6_Callback(hObject, eventdata, handles)
0203 % hObject    handle to button_6 (see GCBO)
0204 % eventdata  reserved - to be defined in a future version of MATLAB
0205 % handles    structure with handles and user data (see GUIDATA)
0206 resetButtonColors(handles);
0207 set(handles.button_6, 'BackgroundColor','green');
0208 setappdata(handles.frame_1, 'INHAND', 6);
0209 update_INHAND_DATA(handles);
0210 
0211 % --- Executes on button press in button_7.
0212 function button_7_Callback(hObject, eventdata, handles)
0213 % hObject    handle to button_7 (see GCBO)
0214 % eventdata  reserved - to be defined in a future version of MATLAB
0215 % handles    structure with handles and user data (see GUIDATA)
0216 resetButtonColors(handles);
0217 set(handles.button_7, 'BackgroundColor','green');
0218 setappdata(handles.frame_1, 'INHAND', 7);
0219 update_INHAND_DATA(handles);
0220 
0221 % --- Executes on button press in button_8.
0222 function button_8_Callback(hObject, eventdata, handles)
0223 % hObject    handle to button_8 (see GCBO)
0224 % eventdata  reserved - to be defined in a future version of MATLAB
0225 % handles    structure with handles and user data (see GUIDATA)
0226 resetButtonColors(handles);
0227 set(handles.button_8, 'BackgroundColor','green');
0228 setappdata(handles.frame_1, 'INHAND', 8);
0229 update_INHAND_DATA(handles);
0230 
0231 % --- Executes on button press in button_9.
0232 function button_9_Callback(hObject, eventdata, handles)
0233 % hObject    handle to button_9 (see GCBO)
0234 % eventdata  reserved - to be defined in a future version of MATLAB
0235 % handles    structure with handles and user data (see GUIDATA)
0236 resetButtonColors(handles);
0237 set(handles.button_9, 'BackgroundColor','green');
0238 setappdata(handles.frame_1, 'INHAND', 9);
0239 update_INHAND_DATA(handles);
0240 
0241 % --- Executes on button press in button_10.
0242 function button_10_Callback(hObject, eventdata, handles)
0243 % hObject    handle to button_10 (see GCBO)
0244 % eventdata  reserved - to be defined in a future version of MATLAB
0245 % handles    structure with handles and user data (see GUIDATA)
0246 resetButtonColors(handles);
0247 set(handles.button_10, 'BackgroundColor','green');
0248 setappdata(handles.frame_1, 'INHAND', 10);
0249 update_INHAND_DATA(handles);
0250 
0251 % --- Executes on button press in button_11.
0252 function button_11_Callback(hObject, eventdata, handles)
0253 % hObject    handle to button_11 (see GCBO)
0254 % eventdata  reserved - to be defined in a future version of MATLAB
0255 % handles    structure with handles and user data (see GUIDATA)
0256 resetButtonColors(handles);
0257 set(handles.button_11, 'BackgroundColor','green');
0258 setappdata(handles.frame_1, 'INHAND', 11);
0259 update_INHAND_DATA(handles);
0260 
0261 % --- Executes on button press in button_12.
0262 function button_12_Callback(hObject, eventdata, handles)
0263 % hObject    handle to button_12 (see GCBO)
0264 % eventdata  reserved - to be defined in a future version of MATLAB
0265 % handles    structure with handles and user data (see GUIDATA)
0266 resetButtonColors(handles);
0267 set(handles.button_12, 'BackgroundColor','green');
0268 setappdata(handles.frame_1, 'INHAND', 12);
0269 update_INHAND_DATA(handles);
0270 
0271 % % --- Executes on button press in button_face.
0272 % function button_face_Callback(hObject, eventdata, handles)
0273 % % hObject    handle to button_face (see GCBO)
0274 % % eventdata  reserved - to be defined in a future version of MATLAB
0275 % % handles    structure with handles and user data (see GUIDATA)
0276 % resetButtonColors(handles);
0277 % set(handles.button_face, 'BackgroundColor','green');
0278 % setappdata(handles.frame_1, 'INHAND', 25);
0279 % update_INHAND_DATA(handles);
0280 
0281 % --- Executes on button press in button_13.
0282 function button_13_Callback(hObject, eventdata, handles)
0283 % hObject    handle to button_13 (see GCBO)
0284 % eventdata  reserved - to be defined in a future version of MATLAB
0285 % handles    structure with handles and user data (see GUIDATA)
0286 resetButtonColors(handles);
0287 set(handles.button_13, 'BackgroundColor','green');
0288 setappdata(handles.frame_1, 'INHAND', 13);
0289 update_INHAND_DATA(handles);
0290 
0291 % --- Executes on button press in button_14.
0292 function button_14_Callback(hObject, eventdata, handles)
0293 % hObject    handle to button_14 (see GCBO)
0294 % eventdata  reserved - to be defined in a future version of MATLAB
0295 % handles    structure with handles and user data (see GUIDATA)
0296 resetButtonColors(handles);
0297 set(handles.button_14, 'BackgroundColor','green');
0298 setappdata(handles.frame_1, 'INHAND', 14);
0299 update_INHAND_DATA(handles);
0300 
0301 
0302 % --- Executes on button press in button_15.
0303 function button_15_Callback(hObject, eventdata, handles)
0304 % hObject    handle to button_15 (see GCBO)
0305 % eventdata  reserved - to be defined in a future version of MATLAB
0306 % handles    structure with handles and user data (see GUIDATA)
0307 resetButtonColors(handles);
0308 set(handles.button_15, 'BackgroundColor','green');
0309 setappdata(handles.frame_1, 'INHAND', 15);
0310 update_INHAND_DATA(handles);
0311 
0312 % --- Executes on button press in button_16.
0313 function button_16_Callback(hObject, eventdata, handles)
0314 % hObject    handle to button_16 (see GCBO)
0315 % eventdata  reserved - to be defined in a future version of MATLAB
0316 % handles    structure with handles and user data (see GUIDATA)
0317 resetButtonColors(handles);
0318 set(handles.button_16, 'BackgroundColor','green');
0319 setappdata(handles.frame_1, 'INHAND', 16);
0320 update_INHAND_DATA(handles);
0321 
0322 % --- Executes on button press in button_17.
0323 function button_17_Callback(hObject, eventdata, handles)
0324 % hObject    handle to button_17 (see GCBO)
0325 % eventdata  reserved - to be defined in a future version of MATLAB
0326 % handles    structure with handles and user data (see GUIDATA)
0327 resetButtonColors(handles);
0328 set(handles.button_17, 'BackgroundColor','green');
0329 setappdata(handles.frame_1, 'INHAND', 17);
0330 update_INHAND_DATA(handles);
0331 
0332 % --- Executes on button press in button_18.
0333 function button_18_Callback(hObject, eventdata, handles)
0334 % hObject    handle to button_18 (see GCBO)
0335 % eventdata  reserved - to be defined in a future version of MATLAB
0336 % handles    structure with handles and user data (see GUIDATA)
0337 resetButtonColors(handles);
0338 set(handles.button_18, 'BackgroundColor','green');
0339 setappdata(handles.frame_1, 'INHAND', 18);
0340 update_INHAND_DATA(handles);
0341 
0342 % --- Executes on button press in button_19.
0343 function button_19_Callback(hObject, eventdata, handles)
0344 % hObject    handle to button_19 (see GCBO)
0345 % eventdata  reserved - to be defined in a future version of MATLAB
0346 % handles    structure with handles and user data (see GUIDATA)
0347 resetButtonColors(handles);
0348 set(handles.button_19, 'BackgroundColor','green');
0349 setappdata(handles.frame_1, 'INHAND', 19);
0350 update_INHAND_DATA(handles);
0351 
0352 % --- Executes on button press in button_20.
0353 function button_20_Callback(hObject, eventdata, handles)
0354 % hObject    handle to button_20 (see GCBO)
0355 % eventdata  reserved - to be defined in a future version of MATLAB
0356 % handles    structure with handles and user data (see GUIDATA)
0357 resetButtonColors(handles);
0358 set(handles.button_20, 'BackgroundColor','green');
0359 setappdata(handles.frame_1, 'INHAND', 20);
0360 update_INHAND_DATA(handles);
0361 
0362 % --- Executes on button press in button_21.
0363 function button_21_Callback(hObject, eventdata, handles)
0364 % hObject    handle to button_21 (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 resetButtonColors(handles);
0368 set(handles.button_21, 'BackgroundColor','green');
0369 setappdata(handles.frame_1, 'INHAND', 21);
0370 update_INHAND_DATA(handles);
0371 
0372 % --- Executes on button press in button_22.
0373 function button_22_Callback(hObject, eventdata, handles)
0374 % hObject    handle to button_22 (see GCBO)
0375 % eventdata  reserved - to be defined in a future version of MATLAB
0376 % handles    structure with handles and user data (see GUIDATA)
0377 resetButtonColors(handles);
0378 set(handles.button_22, 'BackgroundColor','green');
0379 setappdata(handles.frame_1, 'INHAND', 22);
0380 update_INHAND_DATA(handles);
0381 
0382 % --- Executes on button press in button_23.
0383 function button_23_Callback(hObject, eventdata, handles)
0384 % hObject    handle to button_23 (see GCBO)
0385 % eventdata  reserved - to be defined in a future version of MATLAB
0386 % handles    structure with handles and user data (see GUIDATA)
0387 resetButtonColors(handles);
0388 set(handles.button_23, 'BackgroundColor','green');
0389 setappdata(handles.frame_1, 'INHAND', 23);
0390 update_INHAND_DATA(handles);
0391 
0392 % --- Executes on button press in button_24.
0393 function button_24_Callback(hObject, eventdata, handles)
0394 % hObject    handle to button_24 (see GCBO)
0395 % eventdata  reserved - to be defined in a future version of MATLAB
0396 % handles    structure with handles and user data (see GUIDATA)
0397 resetButtonColors(handles);
0398 set(handles.button_24, 'BackgroundColor','green');
0399 setappdata(handles.frame_1, 'INHAND', 24);
0400 update_INHAND_DATA(handles);
0401 
0402 % --- Executes on button press in button_other.
0403 function button_other_Callback(hObject, eventdata, handles)
0404 % hObject    handle to button_other (see GCBO)
0405 % eventdata  reserved - to be defined in a future version of MATLAB
0406 % handles    structure with handles and user data (see GUIDATA)
0407 resetButtonColors(handles);
0408 set(handles.button_other, 'BackgroundColor','green');
0409 setappdata(handles.frame_1, 'INHAND', 26);
0410 update_INHAND_DATA(handles);
0411 
0412 % --- Executes on button press in button_load.
0413 function button_load_Callback(hObject, eventdata, handles)
0414 % hObject    handle to button_load (see GCBO)
0415 % eventdata  reserved - to be defined in a future version of MATLAB
0416 % handles    structure with handles and user data (see GUIDATA)
0417 
0418 [subject_dir] = uigetdir('/raid/projects/multiwork/experiment_12/included', 'Select a Subject Directory');
0419 [~, subject, ~] = fileparts(subject_dir);
0420 frames = dir([subject_dir '/cam07_frames_p/*.jpg']);
0421 num_frames = length(frames);
0422 % DEBUG
0423 %num_frames = min(num_frames, 6000);
0424 
0425 % SET ALL IMPORTANT GUI VARIABLES
0426 setappdata(handles.frame_1, 'NUM_FRAMES', num_frames);
0427 setappdata(handles.frame_1, 'SUBJECT_DIR', subject_dir);
0428 setappdata(handles.frame_1, 'SUBJECT', subject);
0429 
0430 % CECK IF DATA EXISTS
0431 coder_name = getappdata(handles.frame_1, 'CODER_NAME');
0432 if isempty(coder_name)
0433     existing_data = [subject_dir '/extra_p/' subject '_CL_INHAND.mat'];
0434 else
0435     existing_data = [subject_dir '/extra_p/' subject '_CL_INHAND_' coder_name '.mat'];
0436 end
0437 if exist(existing_data) == 2
0438     load(existing_data); % INHAND_DATA
0439     setappdata(handles.frame_1, 'INHAND_DATA', INHAND_DATA);
0440     last_coded = get_last_frame_coded(handles);
0441     setappdata(handles.frame_1, 'CURRENT_FRAME', last_coded);
0442     setappdata(handles.frame_1, 'INHAND', INHAND_DATA(last_coded).INHAND);
0443     highlightButton(handles, INHAND_DATA(last_coded).INHAND);
0444 else
0445     % SET UP DATA VARIABLE
0446     INHAND_DATA = struct();
0447     for f = 1:num_frames
0448       INHAND_DATA(f).frame_name = ['img_' num2str(f) '.jpg'];
0449       INHAND_DATA(f).INHAND = 0;
0450       INHAND_DATA(f).is_coded = 0;
0451     end
0452     setappdata(handles.frame_1, 'INHAND_DATA', INHAND_DATA);
0453     setappdata(handles.frame_1, 'CURRENT_FRAME', 1);
0454     setappdata(handles.frame_1, 'INHAND', 0);
0455 end
0456 assignin('base', 'INHAND_DATA', INHAND_DATA);
0457 
0458 initialize_image_objects(handles);
0459 
0460 update_GUI_controlls(handles);
0461 update_GUI_views(handles);
0462 
0463 % --- Executes on button press in button_next.
0464 function button_next_Callback(hObject, eventdata, handles)
0465 % hObject    handle to button_next (see GCBO)
0466 % eventdata  reserved - to be defined in a future version of MATLAB
0467 % handles    structure with handles and user data (see GUIDATA)
0468 current_frame = getappdata(handles.frame_1, 'CURRENT_FRAME');
0469 num_frames = getappdata(handles.frame_1, 'NUM_FRAMES');
0470 if current_frame < num_frames
0471     setappdata(handles.frame_1, 'CURRENT_FRAME', current_frame+1);
0472     update_INHAND_DATA(handles, current_frame:current_frame+1);
0473 
0474     update_GUI_controlls(handles);
0475     update_GUI_views(handles);
0476 end
0477 
0478 
0479 % --- Executes on button press in button_next_3.
0480 function button_next_3_Callback(hObject, eventdata, handles)
0481 % hObject    handle to button_next_3 (see GCBO)
0482 % eventdata  reserved - to be defined in a future version of MATLAB
0483 % handles    structure with handles and user data (see GUIDATA)
0484 current_frame = getappdata(handles.frame_1, 'CURRENT_FRAME');
0485 num_frames = getappdata(handles.frame_1, 'NUM_FRAMES');
0486 if current_frame + 10 <= num_frames
0487   setappdata(handles.frame_1, 'CURRENT_FRAME', current_frame+10);
0488   update_INHAND_DATA(handles, current_frame:current_frame+10);
0489 else
0490   setappdata(handles.frame_1, 'CURRENT_FRAME', num_frames);
0491   update_INHAND_DATA(handles, current_frame:num_frames);
0492 end
0493 update_GUI_controlls(handles);
0494 update_GUI_views(handles);
0495 
0496 % --- Executes on button press in button_prev.
0497 function button_prev_Callback(hObject, eventdata, handles)
0498 % hObject    handle to button_prev (see GCBO)
0499 % eventdata  reserved - to be defined in a future version of MATLAB
0500 % handles    structure with handles and user data (see GUIDATA)
0501 current_frame = getappdata(handles.frame_1, 'CURRENT_FRAME');
0502 if current_frame > 1
0503     setappdata(handles.frame_1, 'CURRENT_FRAME', current_frame-1);
0504     current_frame = getappdata(handles.frame_1, 'CURRENT_FRAME');
0505     INHAND_DATA = getappdata(handles.frame_1, 'INHAND_DATA');
0506     roi = INHAND_DATA(current_frame).INHAND;
0507     setappdata(handles.frame_1, 'INHAND', roi);
0508     update_GUI_controlls(handles);
0509     update_GUI_views(handles);
0510 end
0511 
0512 % --- Executes on button press in button_prev_3.
0513 function button_prev_3_Callback(hObject, eventdata, handles)
0514 % hObject    handle to button_prev_3 (see GCBO)
0515 % eventdata  reserved - to be defined in a future version of MATLAB
0516 % handles    structure with handles and user data (see GUIDATA)
0517 current_frame = getappdata(handles.frame_1, 'CURRENT_FRAME');
0518 if current_frame - 10 >= 1
0519   setappdata(handles.frame_1, 'CURRENT_FRAME', current_frame-10);
0520 else
0521   setappdata(handles.frame_1, 'CURRENT_FRAME', 1);
0522 end
0523 current_frame = getappdata(handles.frame_1, 'CURRENT_FRAME');
0524 INHAND_DATA = getappdata(handles.frame_1, 'INHAND_DATA');
0525 roi = INHAND_DATA(current_frame).INHAND;
0526 setappdata(handles.frame_1, 'INHAND', roi);
0527 update_GUI_controlls(handles);
0528 update_GUI_views(handles);
0529 
0530 
0531 function [] = update_GUI_controlls(handles)
0532 % update subject info
0533 subject = getappdata(handles.frame_1, 'SUBJECT');
0534 s = sprintf('Loaded: %s', subject);
0535 set(handles.text_loaded, 'String', s);
0536 % update frame info
0537 current_frame = getappdata(handles.frame_1, 'CURRENT_FRAME');
0538 num_frames = getappdata(handles.frame_1, 'NUM_FRAMES');
0539 s = sprintf('Frame %d/%d (%d%%)', current_frame, num_frames, round(100*current_frame/num_frames));
0540 set(handles.text_frame_info, 'String', s);
0541 set(handles.edit_frame_number, 'String', num2str(current_frame));
0542 % show laste coded frame
0543 s = sprintf('Coded until frame: %d', get_last_frame_coded(handles));
0544 set(handles.text_last_coded, 'String', s);
0545 % highlight ROI button
0546 INHAND_DATA = getappdata(handles.frame_1, 'INHAND_DATA');
0547 roi = INHAND_DATA(current_frame).INHAND;
0548 highlightButton(handles, roi);
0549 % if I'm in safe mode and beyond the last coded frame, disable buttons
0550 save_mode = getappdata(handles.frame_1, 'SAFE_MODE');
0551 if save_mode && current_frame > get_last_frame_coded(handles)
0552     toggleButtons(handles, 'off');
0553 else
0554     toggleButtons(handles, 'on');
0555 end
0556 
0557 function [] = update_GUI_views(handles)
0558 subject_dir = getappdata(handles.frame_1, 'SUBJECT_DIR');
0559 current_frame = getappdata(handles.frame_1, 'CURRENT_FRAME');
0560 img_child = imread([subject_dir '/cam07_frames_p/img_' num2str(current_frame) '.jpg']);
0561 img_third = imread([subject_dir '/cam03_frames_p/img_' num2str(current_frame) '.jpg']);
0562 img_third = img_third(60:420, :, :); % crop black bars
0563 img_parent = imread([subject_dir '/cam08_frames_p/img_' num2str(current_frame) '.jpg']);
0564 
0565 s = getappdata(handles.frame_1, 's');
0566 v = getappdata(handles.frame_1, 'v');
0567 e = getappdata(handles.frame_1, 'e');
0568 
0569 set(s,'CData', img_child);
0570 set(v,'CData', img_parent);
0571 set(e,'CData', img_third);
0572 
0573 
0574 function [] = resetButtonColors(handles)
0575 grey = [0.941 0.941 0.941];
0576 set(handles.button_1, 'BackgroundColor', grey); %240 240 240
0577 set(handles.button_2, 'BackgroundColor', grey);
0578 set(handles.button_3, 'BackgroundColor', grey);
0579 set(handles.button_4, 'BackgroundColor', grey);
0580 set(handles.button_5, 'BackgroundColor', grey);
0581 set(handles.button_6, 'BackgroundColor', grey);
0582 set(handles.button_7, 'BackgroundColor', grey);
0583 set(handles.button_8, 'BackgroundColor', grey);
0584 set(handles.button_9, 'BackgroundColor', grey);
0585 set(handles.button_10, 'BackgroundColor', grey);
0586 set(handles.button_11, 'BackgroundColor', grey);
0587 set(handles.button_12, 'BackgroundColor', grey);
0588 set(handles.button_13, 'BackgroundColor', grey);
0589 set(handles.button_14, 'BackgroundColor', grey);
0590 set(handles.button_15, 'BackgroundColor', grey);
0591 set(handles.button_16, 'BackgroundColor', grey);
0592 set(handles.button_17, 'BackgroundColor', grey);
0593 set(handles.button_18, 'BackgroundColor', grey);
0594 set(handles.button_19, 'BackgroundColor', grey);
0595 set(handles.button_20, 'BackgroundColor', grey);
0596 set(handles.button_21, 'BackgroundColor', grey);
0597 set(handles.button_22, 'BackgroundColor', grey);
0598 set(handles.button_23, 'BackgroundColor', grey);
0599 set(handles.button_24, 'BackgroundColor', grey);
0600 set(handles.button_none, 'BackgroundColor', grey);
0601 %set(handles.button_face, 'BackgroundColor', grey);
0602 set(handles.button_other, 'BackgroundColor', grey);
0603 
0604 function [] = update_INHAND_DATA(handles, frames);
0605 safe_mode = getappdata(handles.frame_1, 'SAFE_MODE');
0606 % safe mode only allows changing current frame, i.e. calls where frames argument is empty
0607 if nargin < 2
0608     f = getappdata(handles.frame_1, 'CURRENT_FRAME');
0609     INHAND_DATA = getappdata(handles.frame_1, 'INHAND_DATA');
0610     ROI = getappdata(handles.frame_1, 'INHAND');
0611     INHAND_DATA(f).INHAND = ROI;
0612 else
0613     INHAND_DATA = getappdata(handles.frame_1, 'INHAND_DATA');
0614     if ~safe_mode
0615         ROI = getappdata(handles.frame_1, 'INHAND');
0616         num_frames = getappdata(handles.frame_1, 'NUM_FRAMES');
0617         for f = frames
0618             INHAND_DATA(f).INHAND = ROI;
0619             INHAND_DATA(f).is_coded = 1;
0620         end
0621         % reset future frames in normal mode
0622         for f = frames(end)+1:num_frames
0623             INHAND_DATA(f).INHAND = 0;
0624             INHAND_DATA(f).is_coded = 0;
0625         end
0626     end
0627 end
0628 % update data internally
0629 assignin('base', 'INHAND_DATA', INHAND_DATA);
0630 setappdata(handles.frame_1, 'INHAND_DATA', INHAND_DATA);
0631 % ... and save file
0632 coder_name = getappdata(handles.frame_1, 'CODER_NAME');
0633 subject_name = getappdata(handles.frame_1, 'SUBJECT');
0634 subject_dir = getappdata(handles.frame_1, 'SUBJECT_DIR');
0635 cstream_inhand = data_to_cstream(INHAND_DATA);
0636 if isempty(coder_name)
0637     save([subject_dir '/extra_p/' subject_name '_CL_INHAND.mat'], 'INHAND_DATA');
0638   % save([subject_dir '/derived/cstream_inhand_child_left.mat'], 'cstream_inhand');
0639   record_variable(get_subject_id_from_folder(handles), 'cstream_inhand_child_left', cstream_inhand);
0640 else
0641     save([subject_dir '/extra_p/' subject_name '_CL_INHAND_' coder_name '.mat'], 'INHAND_DATA');
0642   % save([subject_dir '/extra_p/cstream_inhand_child_left_' coder_name '.mat'], 'cstream_inhand');
0643   record_variable_into_specified_directory(get_subject_id_from_folder(handles), 'extra_p', ['cstream_inhand_child_left_' coder_name], cstream_inhand);
0644 end
0645 
0646 % DEBUG
0647 % roi = [INHAND_DATA(:).INHAND];
0648 % coded = logical([INHAND_DATA(:).is_coded]);
0649 % roi = roi(coded);
0650 % [1:length(roi); roi]
0651 
0652 function figure1_WindowKeyPressFcn(hObject, eventdata, handles)
0653 % hObject    handle to figure1 (see GCBO)
0654 % eventdata  structure with the following fields (see MATLAB.UI.FIGURE)
0655 %    Key: name of the key that was pressed, in lower case
0656 %    Character: character interpretation of the key(s) that was pressed
0657 %    Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
0658 % handles    structure with handles and user data (see GUIDATA)
0659 switch eventdata.Key
0660   case 'rightarrow'
0661     button_next_3_Callback(hObject, eventdata, handles);
0662   case 'leftarrow'
0663     button_prev_3_Callback(hObject, eventdata, handles);
0664   case 'uparrow'
0665     button_prev_Callback(hObject, eventdata, handles);
0666   case 'downarrow'
0667     button_next_Callback(hObject, eventdata, handles);
0668 end
0669 
0670 
0671 
0672 function edit_frame_number_Callback(hObject, eventdata, handles)
0673 % hObject    handle to edit_frame_number (see GCBO)
0674 % eventdata  reserved - to be defined in a future version of MATLAB
0675 % handles    structure with handles and user data (see GUIDATA)
0676 
0677 % Hints: get(hObject,'String') returns contents of edit_frame_number as text
0678 %        str2double(get(hObject,'String')) returns contents of edit_frame_number as a double
0679 jump_to = str2double(get(hObject,'String'));
0680 num_frames = getappdata(handles.frame_1, 'NUM_FRAMES');
0681 
0682 if isnumeric(jump_to) && ~isempty(num_frames) && jump_to >= 1 && jump_to <= num_frames
0683   setappdata(handles.frame_1, 'CURRENT_FRAME', jump_to);
0684   update_GUI_controlls(handles);
0685   update_GUI_views(handles);
0686 end
0687 
0688 % --- Executes during object creation, after setting all properties.
0689 function edit_frame_number_CreateFcn(hObject, eventdata, handles)
0690 % hObject    handle to edit_frame_number (see GCBO)
0691 % eventdata  reserved - to be defined in a future version of MATLAB
0692 % handles    empty - handles not created until after all CreateFcns called
0693 
0694 % Hint: edit controls usually have a white background on Windows.
0695 %       See ISPC and COMPUTER.
0696 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0697     set(hObject,'BackgroundColor','white');
0698 end
0699 
0700 % --- Executes on button press in safe_mode_box.
0701 function safe_mode_box_Callback(hObject, eventdata, handles)
0702 % hObject    handle to safe_mode_box (see GCBO)
0703 % eventdata  reserved - to be defined in a future version of MATLAB
0704 % handles    structure with handles and user data (see GUIDATA)
0705 
0706 % Hint: get(hObject,'Value') returns toggle state of safe_mode_box
0707 safe_mode = get(hObject,'Value');
0708 
0709 if safe_mode
0710     %toggleButtons(handles, 'off');
0711     setappdata(handles.frame_1, 'SAFE_MODE', 1);
0712     set(handles.edit_frame_number, 'Enable', 'on');
0713 else
0714     set(handles.edit_frame_number, 'Enable', 'off');
0715     %toggleButtons(handles, 'on');
0716     setappdata(handles.frame_1, 'SAFE_MODE', 0);
0717 
0718     % if current frame > last coded frame, go to last coded frame automatically
0719     %once save mode is turned 'off'
0720     last_coded = get_last_frame_coded(handles);
0721     current_frame = getappdata(handles.frame_1, 'CURRENT_FRAME');
0722     if current_frame > last_coded
0723         setappdata(handles.frame_1, 'CURRENT_FRAME', last_coded);
0724         INHAND_DATA = getappdata(handles.frame_1, 'INHAND_DATA');
0725         setappdata(handles.frame_1, 'INHAND', INHAND_DATA(last_coded).INHAND);
0726         update_GUI_views(handles);
0727         update_GUI_controlls(handles);
0728     end
0729 end
0730 
0731 function [] = toggleButtons(handles, state)
0732 set(handles.button_1, 'Enable', state); 
0733 set(handles.button_2, 'Enable', state); 
0734 set(handles.button_3, 'Enable', state); 
0735 set(handles.button_4, 'Enable', state); 
0736 set(handles.button_5, 'Enable', state); 
0737 set(handles.button_6, 'Enable', state); 
0738 set(handles.button_7, 'Enable', state); 
0739 set(handles.button_8, 'Enable', state); 
0740 set(handles.button_9, 'Enable', state);
0741 set(handles.button_10, 'Enable', state);
0742 set(handles.button_11, 'Enable', state); 
0743 set(handles.button_12, 'Enable', state); 
0744 set(handles.button_13, 'Enable', state); 
0745 set(handles.button_14, 'Enable', state); 
0746 set(handles.button_15, 'Enable', state); 
0747 set(handles.button_16, 'Enable', state); 
0748 set(handles.button_17, 'Enable', state); 
0749 set(handles.button_18, 'Enable', state); 
0750 set(handles.button_19, 'Enable', state); 
0751 set(handles.button_20, 'Enable', state); 
0752 set(handles.button_21, 'Enable', state); 
0753 set(handles.button_22, 'Enable', state); 
0754 set(handles.button_23, 'Enable', state); 
0755 set(handles.button_24, 'Enable', state); 
0756 set(handles.button_none, 'Enable', state); 
0757 %set(handles.button_face, 'Enable', state);
0758 set(handles.button_other, 'Enable', state);
0759 
0760 function [] = highlightButton(handles, toy_id)
0761 resetButtonColors(handles);
0762 switch toy_id
0763     case 0
0764         set(handles.button_none, 'BackgroundColor','green');
0765     case 1
0766         set(handles.button_1, 'BackgroundColor','green');
0767     case 2
0768         set(handles.button_2, 'BackgroundColor','green');
0769     case 3
0770         set(handles.button_3, 'BackgroundColor','green');
0771     case 4
0772         set(handles.button_4, 'BackgroundColor','green');
0773     case 5
0774         set(handles.button_5, 'BackgroundColor','green');
0775     case 6
0776         set(handles.button_6, 'BackgroundColor','green');
0777     case 7
0778         set(handles.button_7, 'BackgroundColor','green');
0779     case 8
0780         set(handles.button_8, 'BackgroundColor','green');
0781     case 9
0782         set(handles.button_9, 'BackgroundColor','green');
0783     case 10
0784         set(handles.button_10, 'BackgroundColor','green');
0785     case 11
0786         set(handles.button_11, 'BackgroundColor','green');
0787     case 12
0788         set(handles.button_12, 'BackgroundColor','green');
0789     case 13
0790         set(handles.button_13, 'BackgroundColor','green');
0791     case 14
0792         set(handles.button_14, 'BackgroundColor','green');
0793     case 15
0794         set(handles.button_15, 'BackgroundColor','green');
0795     case 16
0796         set(handles.button_16, 'BackgroundColor','green');
0797     case 17
0798         set(handles.button_17, 'BackgroundColor','green');
0799     case 18
0800         set(handles.button_18, 'BackgroundColor','green');
0801     case 19
0802         set(handles.button_19, 'BackgroundColor','green');
0803     case 20
0804         set(handles.button_20, 'BackgroundColor','green');
0805     case 21
0806         set(handles.button_21, 'BackgroundColor','green');
0807     case 22
0808         set(handles.button_22, 'BackgroundColor','green');
0809     case 23
0810         set(handles.button_23, 'BackgroundColor','green');
0811     case 24
0812         set(handles.button_24, 'BackgroundColor','green');
0813     % case 25
0814     %     set(handles.button_face, 'BackgroundColor','green');
0815     otherwise
0816         set(handles.button_other, 'BackgroundColor','green');
0817 end
0818 
0819 function last_coded = get_last_frame_coded(handles)
0820 INHAND_DATA = getappdata(handles.frame_1, 'INHAND_DATA');
0821 % HACK WHILE PEOPE ARE TESTING PROGRAM (!)
0822 % last_coded = length(find([INHAND_DATA(:).is_coded] == 1));
0823 last_coded = max(find([INHAND_DATA(:).is_coded] == 1));
0824 if last_coded == 0
0825     last_coded = 1;
0826 end
0827 
0828 function [] = initialize_image_objects(handles)
0829 subject_dir = getappdata(handles.frame_1, 'SUBJECT_DIR');
0830 current_frame = getappdata(handles.frame_1, 'CURRENT_FRAME');
0831 img_child = imread([subject_dir '/cam07_frames_p/img_' num2str(current_frame) '.jpg']);
0832 img_third = imread([subject_dir '/cam03_frames_p/img_' num2str(current_frame) '.jpg']);
0833 img_third = img_third(60:420, :, :); % crop black bars
0834 img_parent = imread([subject_dir '/cam08_frames_p/img_' num2str(current_frame) '.jpg']);
0835 
0836 s = imshow(img_child, 'Parent', handles.frame_1);
0837 v = imshow(img_parent, 'Parent', handles.frame_2);
0838 e = imshow(img_third, 'Parent', handles.frame_3);
0839 % set(s,'EraseMode','none');
0840 % set(e,'EraseMode','none');
0841 % set(n,'EraseMode','none');
0842 setappdata(handles.frame_1, 's', s);
0843 setappdata(handles.frame_1, 'v', v);
0844 setappdata(handles.frame_1, 'e', e);
0845 
0846 function [cstream_inhand] = data_to_cstream(INHAND_DATA)
0847 is_coded = [INHAND_DATA(:).is_coded] == 1;
0848 index = 1:length(find(is_coded));
0849 time = (index-1) * 1/30 + 30;
0850 inhand = [INHAND_DATA(is_coded).INHAND];
0851 cstream_inhand = [time' inhand'];
0852 
0853 function subject_id = get_subject_id_from_folder(handles)
0854 folder = getappdata(handles.frame_1, 'SUBJECT');
0855 tempy = strsplit(folder, '_');
0856 s_date = str2num(tempy{2});
0857 s_id = str2num(tempy{3});
0858 table = read_subject_table();
0859 s_r = find(table(:,3) == s_date & table(:,4) == s_id);
0860 if isempty(s_r)
0861   error('Cannot find subject id in subject table');
0862 else
0863   subject_id = table(s_r, 1)
0864 end

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