Home > coding_tools > object_annotation > label_inhand > INHAND_PR_GUI.m

INHAND_PR_GUI

PURPOSE ^

INHAND_PR_GUI MATLAB code for INHAND_PR_GUI.fig

SYNOPSIS ^

function varargout = INHAND_PR_GUI(varargin)

DESCRIPTION ^

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

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

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

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

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