diff --git a/3DFrImager.prj b/3DFrImager.prj new file mode 100644 index 0000000..a18457c --- /dev/null +++ b/3DFrImager.prj @@ -0,0 +1,117 @@ + + + 3DFrImager + Biswajit Medhi + biswajit.jun@gmail.com + ShanMukha Innovations Pvt. Ltd. + ${PROJECT_ROOT}\3DFrImager_resources\icon_24.png + + ${PROJECT_ROOT}\3DFrImager_resources\icon_48.png + ${PROJECT_ROOT}\3DFrImager_resources\icon_24.png + ${PROJECT_ROOT}\3DFrImager_resources\icon_16.png + + It performs 3D scanning of an object through Fringe projection technique + It performs 3D scanning of an object through Fringe projection technique + ${PROJECT_ROOT}\src\images\height11.png + 2.0 + + + + + C:\Users\Biki\Desktop + 732be1db-793e-4845-afa1-364e59ffd2fb + + + + + + + + ${PROJECT_ROOT}\src\dfp\Scanner_3D_v2.m + + + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\Doc\Help_3DFrImager.pdf + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\dfp\dis_peak.m + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\dfp\GetComPort.m + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\dfp\gui_ask_cal_KNOWN_Point.m + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\dfp\gui_calibration_1.m + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\dfp\gui_CompleteCalib_Msg.m + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\dfp\gui_confirm_EXIT.m + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\dfp\gui_set_destination.m + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\dfp\gui_StartProfiling.m + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\dfp\gui_WantCalibration.m + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\dfp\phase_unwrap.m + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\dfp\processImage1.m + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\dfp\processImage2.m + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\dfp\WFT2.m + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\images\iisc_logo.png + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\images\im0.tif + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\images\im00.tif + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\images\p1.png + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\images\Shan_Logo4.png + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\txt\calibration.txt + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\txt\camset.txt + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\txt\CropCordinate.txt + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\txt\selectCamera.txt + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\txt\SessionConst.txt + + + ${PROJECT_ROOT}\3DFrImager_resources + ${PROJECT_ROOT}\Doc + ${PROJECT_ROOT}\src + ${PROJECT_ROOT}\src\dfp + ${PROJECT_ROOT}\src\images + ${PROJECT_ROOT}\src\txt + ${PROJECT_ROOT}\src\ui + + + + C:\Users\Biki\Desktop + + + + C:\Program Files\MATLAB\R2016b + + + + + + + + + true + + + + + true + + + + + true + + + + + true + + + + + false + false + true + false + false + false + false + false + 6.1 + false + true + win64 + true + + + \ No newline at end of file diff --git a/Cal_3dFrImager.prj b/Cal_3dFrImager.prj new file mode 100644 index 0000000..4d81af9 --- /dev/null +++ b/Cal_3dFrImager.prj @@ -0,0 +1,119 @@ + + + Cal_3dFrImager + Biswajit Medhi + biswajit.jun@gmail.com + ShanMukha Innovations Pvt. Ltd. + ${PROJECT_ROOT}\Cal_3dFrImager_resources\icon_24.png + + ${PROJECT_ROOT}\Cal_3dFrImager_resources\icon_48.png + ${PROJECT_ROOT}\Cal_3dFrImager_resources\icon_24.png + ${PROJECT_ROOT}\Cal_3dFrImager_resources\icon_16.png + + It performs 3D scanning of an object through Fringe projection technique + It performs 3D scanning of an object through Fringe projection technique + ${PROJECT_ROOT}\src\images\CalibrationIcon.png + 1.0 + + + + + C:\Users\Biki\Desktop\outPut App + 0509b206-b2cf-43a9-956f-9ae7c5132345 + + + + + + + + + ${PROJECT_ROOT}\src\dfp\Calibration_Scanner_3D_v2.m + + + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\Doc\Help_3DFrImager.pdf + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\dfp\dis_peak.m + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\dfp\GetComPort.m + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\dfp\gui_ask_cal_KNOWN_Point.m + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\dfp\gui_calibration_1.m + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\dfp\gui_CompleteCalib_Msg.m + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\dfp\gui_confirm_EXIT.m + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\dfp\gui_set_destination.m + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\dfp\gui_StartProfiling.m + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\dfp\gui_WantCalibration.m + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\dfp\phase_unwrap.m + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\dfp\processImage1.m + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\dfp\processImage2.m + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\dfp\WFT2.m + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\images\iisc_logo.png + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\images\im0.tif + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\images\im00.tif + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\images\p1.png + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\images\Shan_Logo4.png + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\txt\calibration.txt + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\txt\CaliObject.txt + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\txt\camset.txt + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\txt\CropCordinate.txt + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\txt\selectCamera.txt + C:\Users\Biki\Documents\MATLAB\Add-Ons\Apps\x3DFrImager\code\Desktop\New folder (5)\src\txt\SessionConst.txt + + + ${PROJECT_ROOT}\Cal_3dFrImager_resources + ${PROJECT_ROOT}\Doc + ${PROJECT_ROOT}\src + ${PROJECT_ROOT}\src\dfp + ${PROJECT_ROOT}\src\images + ${PROJECT_ROOT}\src\txt + ${PROJECT_ROOT}\src\ui + + + + C:\Users\Biki\Desktop\outPut App + + + + C:\Program Files\MATLAB\R2016b + + + + + + + + + true + + + + + true + + + + + true + + + + + true + + + + + false + false + true + false + false + false + false + false + 6.1 + false + true + win64 + true + + + \ No newline at end of file diff --git a/Cal_3dFrImager_resources/icon_16.png b/Cal_3dFrImager_resources/icon_16.png new file mode 100644 index 0000000..98565c9 Binary files /dev/null and b/Cal_3dFrImager_resources/icon_16.png differ diff --git a/Cal_3dFrImager_resources/icon_24.png b/Cal_3dFrImager_resources/icon_24.png new file mode 100644 index 0000000..2ee005b Binary files /dev/null and b/Cal_3dFrImager_resources/icon_24.png differ diff --git a/Cal_3dFrImager_resources/icon_48.png b/Cal_3dFrImager_resources/icon_48.png new file mode 100644 index 0000000..5f57b82 Binary files /dev/null and b/Cal_3dFrImager_resources/icon_48.png differ diff --git a/Doc/Help_3DFrImager.pdf b/Doc/Help_3DFrImager.pdf new file mode 100644 index 0000000..049ed5e Binary files /dev/null and b/Doc/Help_3DFrImager.pdf differ diff --git a/app/3DFrImager.mlappinstall b/app/3DFrImager.mlappinstall new file mode 100644 index 0000000..e745eb9 Binary files /dev/null and b/app/3DFrImager.mlappinstall differ diff --git a/app/Cal_3dFrImager.mlappinstall b/app/Cal_3dFrImager.mlappinstall new file mode 100644 index 0000000..fbb6a54 Binary files /dev/null and b/app/Cal_3dFrImager.mlappinstall differ diff --git a/src/dfp/Calibration_Scanner_3D_v2.m b/src/dfp/Calibration_Scanner_3D_v2.m new file mode 100644 index 0000000..14dfb8f --- /dev/null +++ b/src/dfp/Calibration_Scanner_3D_v2.m @@ -0,0 +1,698 @@ +function varargout = Calibration_Scanner_3D_v2(varargin) +% CALIBRATION_SCANNER_3D_V2 MATLAB code for Calibration_Scanner_3D_v2.fig +% CALIBRATION_SCANNER_3D_V2, by itself, creates a new CALIBRATION_SCANNER_3D_V2 or raises the existing +% singleton*. +% +% H = CALIBRA5TION_SCANNER_3D_V2 returns the handle to a new CALIBRATION_SCANNER_3D_V2 or the handle to +% the existing singleton*. +% +% CALIBRATION_SCANNER_3D_V2('CALLBACK',hObject,eventData,handles,...) calls the local +% function named CALLBACK in CALIBRATION_SCANNER_3D_V2.M with the given input arguments. +% +% CALIBRATION_SCANNER_3D_V2('Property','Value',...) creates a new CALIBRATION_SCANNER_3D_V2 or raises the +% existing singleton*. Starting from the left, property value pairs are +% applied to the GUI before Calibration_Scanner_3D_v2_OpeningFcn gets called. An +% unrecognized property name or invalid value makes property application +% stop. All inputs are passed to Calibration_Scanner_3D_v2_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 + +% Edit the above text to modify the response to help Calibration_Scanner_3D_v2 + +% Last Modified by GUIDE v2.5 03-Jan-2019 18:45:47 + +% Begin initialization code - DO NOT EDIT +gui_Singleton = 1; +gui_State = struct('gui_Name', mfilename, ... + 'gui_Singleton', gui_Singleton, ... + 'gui_OpeningFcn', @Calibration_Scanner_3D_v2_OpeningFcn, ... + 'gui_OutputFcn', @Calibration_Scanner_3D_v2_OutputFcn, ... + 'gui_LayoutFcn', [] , ... + 'gui_Callback', []); +if nargin && ischar(varargin{1}) + gui_State.gui_Callback = str2func(varargin{1}); +end + +if nargout + [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); +else + gui_mainfcn(gui_State, varargin{:}); +end +% End initialization code - DO NOT EDIT + + +% --- Executes just before Calibration_Scanner_3D_v2 is made visible. +function Calibration_Scanner_3D_v2_OpeningFcn(hObject, eventdata, handles, varargin) +% This function has no output args, see OutputFcn. +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +% varargin command line arguments to Calibration_Scanner_3D_v2 (see VARARGIN) + +% Choose default command line output for Calibration_Scanner_3D_v2 +handles.output = hObject; + +axes(handles.axes3);cla;imshow(imread('Shan_Logo4.png'),[]); +axes(handles.axes4);cla;imshow(imread('iisc_logo.png'),[]); +axes(handles.axes1);cla;imshow(imread('p1.png'),[]); + +% set(handles.check_EnableCali, 'Value',0); +% % set(handles.push_calibrate, 'Enable','off'); +% % set(handles.check_Laser, 'Enable','off'); +% % set(handles.check_Projector, 'Enable','off'); +% % set(handles.check_CabinLamp, 'Enable','off'); +% % set(handles.check_CabinLamp, 'Value',1); +% % set(handles.check_Projector, 'Enable','off'); +% % set(handles.push_SaveExit, 'Enable','off'); + +seting_buttons_state(hObject, eventdata, handles,0) +set(handles.push_SaveExit, 'Enable','off'); +set(handles.check_CabinLamp, 'Value',1); + + + + + + +tic + +wbar = waitbar(0.1,'Connecting Hardware...'); + +imaqreset; +aa=imaqhwinfo('winvideo'); +size(aa.DeviceInfo) +cnt= size(aa.DeviceInfo,2); +a=aa.DeviceInfo; +% a=webcamlist; + +waitbar(0.3,wbar); + + + + +if cnt~=0 + s1=cell((cnt+1),1); + s1(1)={'Select'}; + cnt2=0; + for ii=1:cnt + if strcmp(a(ii).DeviceName, 'USB Camera') + a(ii).DeviceName={'3dFrImager'}; + s1(ii+1)={'3dFrImager'} + cnt2=1; + else + a(ii).DeviceName={(a(ii).DeviceName)}; + s1(ii+1)=(a(ii).DeviceName) + end + end + + set(handles.popup_cameraSelect,'String',s1); +else + f=errordlg('Camera is Not found','Camera Error'); + waitfor(f); + seting_buttons_state(hObject, eventdata, handles,0) ; +% delete(handles.figure1); +end + + +delete(instrfind); +nam = GetComPort; + +LASER = serial(nam ,'BaudRate', 9600); +handles.LASERRR=LASER; +waitbar(0.6,wbar); + + +try + fopen(LASER); + pause(2) + fprintf(LASER,'%c','p'); + pause(1) + try close(wbar), catch, end +catch + try close(wbar), catch, end + seting_buttons_state(hObject, eventdata, handles,0) + pause(.5) + f=errordlg('Hardware not found','Hardware Error'); + waitfor(f); +% delete(handles.figure1); +end + + + +handles.SelectOption = 'NewAcq'; % 'NewAcq' 'OldAcq' +handles.scal=1; + + + + +handles.window=30; + +handles.Contrast = 50; +handles.Brightness = 12; +handles.ExposureMode = 'manual'; +handles.Exposure = -4; +handles.WhiteBalance = 5710; + + +handles.NN =5; + + + + +handles.destination_NEW =strcat(pwd,'\Result11'); + + + + + +handles.NN =10; + +set(handles.push_SaveExit, 'Enable','on'); +set(handles.popup_cameraSelect, 'Enable','on'); +% Update handles structure +guidata(hObject, handles); + +% UIWAIT makes Calibration_Scanner_3D_v2 wait for user response (see UIRESUME) +% uiwait(handles.figure1); + + +% --- Outputs from this function are returned to the command line. +function varargout = Calibration_Scanner_3D_v2_OutputFcn(hObject, eventdata, handles) +% varargout cell array for returning output args (see VARARGOUT); +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Get default command line output from handles structure +varargout{1} = handles.output; + + + + + + + + + + +% --- Executes on selection change in popup_cameraSelect. +function popup_cameraSelect_Callback(hObject, eventdata, handles) +% hObject handle to popup_cameraSelect (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: contents = cellstr(get(hObject,'String')) returns popup_cameraSelect contents as cell array +% contents{get(hObject,'Value')} returns selected item from popup_cameraSelect +contents = cellstr(get(hObject,'String')); +val = contents{get(hObject,'Value')} ; +seting_buttons_state(hObject, eventdata, handles,0); +set(handles.push_SaveExit, 'Enable','off'); + +wbar = waitbar(0.1,'Connecting Camera...'); +wbar .CloseRequestFcn = ''; + +filePh = fopen('selectCamera.txt','w'); +fprintf(filePh,'%s\n',val); +fclose(filePh); + +waitbar(0.3,wbar); + + +if strcmp(val, '3dFrImager') + val='USB Camera'; + + try + obj = videoinput('winvideo', val, 'YUY2_3264x2448'); + handles.obj =obj; + end + + hsrc = getselectedsource(obj); + obj.FramesPerTrigger = 1; + hsrc.Contrast = handles.Contrast ; + hsrc.Brightness = handles.Brightness ; + hsrc.ExposureMode = handles.ExposureMode ; + hsrc.Exposure = handles.Exposure ; + hsrc.WhiteBalance = handles.WhiteBalance; + + + + + vidRes = get(obj, 'VideoResolution'); + nBands = get(obj, 'NumberOfBands'); + axes(handles.axes1);cla; + hImage = image( zeros(vidRes(2), vidRes(1), nBands) ); + preview(obj, hImage); axis equal; + handles.hImage=hImage; + seting_buttons_state(hObject, eventdata, handles,1) + set(handles.push_SaveExit, 'Enable','on'); + + waitbar(0.8,wbar); + pause(1) + try delete(wbar), catch, end +else + try delete(wbar), catch, end + pause(.5) + f=errordlg('Select "3dFrImager" from Camera List','Select Camera'); + waitfor(f); + seting_buttons_state(hObject, eventdata, handles,0) + set(handles.popup_cameraSelect, 'Enable','on'); +end + + + + + +guidata(hObject, handles); + + + + + + + + + + + + + +% --- Executes during object creation, after setting all properties. +function popup_cameraSelect_CreateFcn(hObject, eventdata, handles) +% hObject handle to popup_cameraSelect (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: popupmenu controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in push_calibrate. +function push_calibrate_Callback(hObject, eventdata, handles) +% hObject handle to push_calibrate (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +tmp1=gui_WantCalibration(); + +if strcmp(tmp1,'Yes') + + try + wbar=waitbar(0.1,'Calibrating System...','windowstyle', 'modal'); + frames = java.awt.Frame.getFrames(); + frames(end).setAlwaysOnTop(1); + wbar .CloseRequestFcn = ''; + catch + wbar = waitbar(0.1,'Calibrating System...'); + wbar .CloseRequestFcn = ''; + end + + if strcmp(handles.SelectOption, 'NewAcq') % 'NewAcq' 'OldAcq' + + set(handles.check_Laser, 'Value',0); + try + + fprintf(handles.LASERRR,'%c','o'); + fprintf(handles.LASERRR,'%c','b'); + fprintf(handles.LASERRR,'%c','y'); + pause(1) + seting_buttons_state(hObject, eventdata, handles,0) ; + set(handles.push_SaveExit, 'Enable','off'); + catch + f=errordlg('Connection Problem','Hardware Error'); + waitfor(f); + seting_buttons_state(hObject, eventdata, handles,0) + end + + + waitbar(0.3,wbar); + + + + + obj= handles.obj; + hsrc = getselectedsource(obj ); + obj.FramesPerTrigger = 1; + obj.ROIPosition = [0 ,0 3264,2448]; + + hsrc.Contrast = handles.Contrast ; + hsrc.Brightness = handles.Brightness ; + hsrc.ExposureMode = handles.ExposureMode ; + hsrc.Exposure = handles.Exposure ; + hsrc.WhiteBalance = handles.WhiteBalance; + +% pause(2) + + vidRes = get(obj, 'VideoResolution'); + nBands = get(obj, 'NumberOfBands'); + axes(handles.axes1);cla; + hImage = image( zeros(vidRes(2), vidRes(1), nBands) ); + preview(obj, hImage); axis equal; + guidata(hObject, handles); + +% stoppreview(obj); + + waitbar(0.4,wbar); + pause(2) + + % Capture Image + tmp1=0; + + for jj=1:(1) + frame = getsnapshot(obj); + tmp= double(ycbcr2rgb(frame)); + pause(0.5); + tmp1 = tmp1+tmp; + end + tmp1=uint8(tmp1); + + % frame = getsnapshot(obj); + handles.im0=tmp1; + waitbar(0.6,wbar); + imwrite(handles.im0,'im00.tif'); +% axes(handles.axes1);cla; +% hImage = image( zeros(vidRes(2), vidRes(1), nBands) ); +% preview(obj, hImage); axis equal; + + + waitbar(0.8,wbar); +% pause(2) + + try delete(wbar);catch; end + + + + + [handles.CalStatus, handles.theta, handles.a4, handles.a5, CaliState]... + =gui_calibration_1(); + + +if strcmp(handles.CalStatus, 'Done') + + try + wbar=waitbar(0.8,'Calibrating System...','windowstyle', 'modal'); + frames = java.awt.Frame.getFrames(); + frames(end).setAlwaysOnTop(1); + wbar .CloseRequestFcn = ''; + catch + wbar = waitbar(0.8,'Calibrating System...'); + wbar .CloseRequestFcn = ''; + end + + + + + yD=dlmread('CropCordinate.txt'); + +% stoppreview(obj); + + obj.ROIPosition = yD; + hsrc.Contrast = handles.Contrast ; + hsrc.Brightness = handles.Brightness ; + hsrc.ExposureMode = handles.ExposureMode ; + hsrc.Exposure = handles.Exposure ; + hsrc.WhiteBalance = handles.WhiteBalance; + +% pause(2) + + vidRes = get(obj, 'VideoResolution'); + nBands = get(obj, 'NumberOfBands'); + axes(handles.axes1);cla; + hImage = image( zeros(vidRes(2), vidRes(1), nBands) ); + preview(obj, hImage); axis equal; + pause(2) + % Capture Image + tmp1=0; + for jj=1:(handles.NN) + frame = getsnapshot(obj); + tmp= double(ycbcr2rgb(frame)); + pause(0.5); + tmp1 = tmp1+tmp; + end + tmp1=uint8(tmp1/(handles.NN)); + + + +% % tmp1=tmp1( yD(2):yD(2)+yD(4)-1,yD(1):yD(1)+yD(3)-1,:); + handles.im0 =tmp1; + waitbar(0.88,wbar); + imwrite(handles.im0,'im0.tif'); + + + + axes(handles.axes1);cla; + hImage_NEW = image( zeros(size(tmp1,2), size(tmp1,2), nBands) ); + preview(obj,hImage_NEW ); axis tight,axis equal; + + try delete(wbar), catch, end + + handles.scal = handles.a4/ handles.a5; + + seting_buttons_state(hObject, eventdata, handles,0) + + + if strcmp(CaliState,'Auto') + 12345 + uiwait(msgbox('Place the Calibration Object within FOV','Place Calibration Object','non-modal')); + + + tmp1=0; + for jj=1:(handles.NN) + frame = getsnapshot(obj); + tmp= double(ycbcr2rgb(frame)); + pause(0.5); + tmp1 = tmp1+tmp; + end + tmp1=uint8(tmp1/(handles.NN)); + handles.cal =tmp1; +% waitbar(0.88,wbar); + imwrite(handles.cal,'calib.tif'); + + [data_Org,dataSX]= processImage2(double(rgb2gray(handles.im0)), double(rgb2gray(handles.cal)), 53, 'All Pass'); + + figure(199), imshow(data_Org,[]); title('Right Click the MOUSE at the centre of the Obect'), + + +% % figure(199), imshow(rand(500)); title('Right Click the MOUSE at the centre of the Obect'), + while 1 + [x, y, button]=ginput(1); + if button==3 + x=round(x); y=round(y); + break; + end + end + + mHi= mean(mean(data_Org(x-10:x+10,y-10:y+10))); + + [calHi]=dlmread('CaliObject.txt'); + [a4a5]=dlmread('SessionConst.txt'); + theta_new= atan(mHi/calHi *tan(a4a5(1))); + a4a5(1)=theta_new; + dlmwrite('SessionConst.txt',a4a5); + + sconst=dlmread('calibration.txt'); + sconst(1)=tan(theta_new)*sconst(2); + + dlmwrite('calibration.txt',sconst); + + + + close(199); + axes(handles.axes1);cla;imagesc(data_Org); + + + + + end + +end + + gui_CompleteCalib_Msg + end + + end + +% % seting_buttons_state(hObject, eventdata, handles,0) +set(handles.push_SaveExit, 'Enable','on'); + +guidata(hObject, handles); + + + + + + + +% --- Executes on button press in check_Laser. +function check_Laser_Callback(hObject, eventdata, handles) +% hObject handle to check_Laser (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of check_Laser +c = get(hObject,'Value') ; + +if c==1 + try + fprintf(handles.LASERRR,'%c','z'); + pause(1) + catch + f=errordlg('Connection Problem','Hardware Error'); + waitfor(f); + seting_buttons_state(hObject, eventdata, handles,0) + + end +end + +if c==0 + try + +% fprintf(LASER,'%c','a'); + pause(1) + fprintf(handles.LASERRR,'%c','y'); + pause(1) + catch + f=errordlg('Connection Problem','Hardware Error'); + waitfor(f); + seting_buttons_state(hObject, eventdata, handles,0) + end +end + + +% --- Executes on button press in check_Projector. +function check_Projector_Callback(hObject, eventdata, handles) +% hObject handle to check_Projector (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of check_Projector +c = get(hObject,'Value') ; + +if c==1 + try + pause(.2) + % fprintf(LASER,'%c','b'); + fprintf(handles.LASERRR,'%c','b'); + pause(1) + catch + f=errordlg('Connection Problem','Hardware Error'); + waitfor(f); + seting_buttons_state(hObject, eventdata, handles,0) + end +end + +if c==0 + try + + fprintf(handles.LASERRR,'%c','a'); + pause(1) + catch + f=errordlg('Connection Problem','Hardware Error'); + waitfor(f); + seting_buttons_state(hObject, eventdata, handles,0) + end +end + + +% --- Executes on button press in push_SaveExit. +function push_SaveExit_Callback(hObject, eventdata, handles) +% hObject handle to push_SaveExit (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + + +try + fprintf(handles.LASERRR,'%c','y'); + fprintf(handles.LASERRR,'%c','a'); + fprintf(handles.LASERRR,'%c','o'); + pause(1) +catch +end + +try delete(handles.figure1);catch; end + +% --- Executes on button press in check_CabinLamp. +function check_CabinLamp_Callback(hObject, eventdata, handles) +% hObject handle to check_CabinLamp (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of check_CabinLamp +c = get(hObject,'Value') ; +if c==1 + try + fprintf(handles.LASERRR,'%c','p'); + pause(1) + catch + f=errordlg('Connection Problem','Hardware Error'); + waitfor(f); + seting_buttons_state(hObject, eventdata, handles,0) + end +end + +if c==0 + try + fprintf(handles.LASERRR,'%c','o'); + pause(1) + catch + f=errordlg('Connection Problem','Hardware Error'); + waitfor(f); + seting_buttons_state(hObject, eventdata, handles,0) + end +end + + + + + + function seting_buttons_state(hObject, eventdata, handles,flg) +%seting_buttons_state(hObject, eventdata, handles,0) + button_list1 =[ handles.check_Laser handles.check_Projector handles.check_CabinLamp]; + button_list2 =[ handles.push_calibrate handles.popup_cameraSelect ]; + + + if flg==0 + set(button_list1, 'Enable','off'); + set(button_list2, 'Enable','off'); end + if flg==1 + set(button_list1, 'Enable','on'); + set(button_list2, 'Enable','on'); end + + + guidata(hObject, handles); + + +% --- Executes on selection change in popup_cameraSelect. +function popupmenu2_Callback(hObject, eventdata, handles) +% hObject handle to popup_cameraSelect (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: contents = cellstr(get(hObject,'String')) returns popup_cameraSelect contents as cell array +% contents{get(hObject,'Value')} returns selected item from popup_cameraSelect + + +% --- Executes during object creation, after setting all properties. +function popupmenu2_CreateFcn(hObject, eventdata, handles) +% hObject handle to popup_cameraSelect (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: popupmenu controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in push_Help. +function push_Help_Callback(hObject, eventdata, handles) +% hObject handle to push_Help (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +open('Help_3DFrImager.pdf'); diff --git a/src/dfp/GetComPort.m b/src/dfp/GetComPort.m new file mode 100644 index 0000000..b14f0fe --- /dev/null +++ b/src/dfp/GetComPort.m @@ -0,0 +1,40 @@ +function lCOM_Port = GetComPort() +% function lCOM_Port = GetComPort() +% Return a Cell Array of COM port names available on your computer +try + s=serial('IMPOSSIBLE_NAME_ON_PORT');fopen(s); +catch + lErrMsg = lasterr; +end +fclose(s); +delete(s); +%Start of the COM available port +lIndex1 = findstr(lErrMsg,'COM'); +%End of COM available port +lIndex2 = findstr(lErrMsg,'Use')-3; +lComStr = lErrMsg(lIndex1:lIndex2); +%Parse the resulting string +lIndexDot = findstr(lComStr,','); +% If no Port are available +if isempty(lIndex1) + lCOM_Port{1}=''; + return; +end +% If only one Port is available +if isempty(lIndexDot) + lCOM_Port{1}=lComStr; + return; +end +lCOM_Port{1} = lComStr(1:lIndexDot(1)-1); +for i=1:numel(lIndexDot)+1 + % First One + if (i==1) + lCOM_Port{1,1} = lComStr(1:lIndexDot(i)-1); + % Last One + elseif (i==numel(lIndexDot)+1) + lCOM_Port{i,1} = lComStr(lIndexDot(i-1)+2:end); + % Others + else + lCOM_Port{i,1} = lComStr(lIndexDot(i-1)+2:lIndexDot(i)-1); + end +end \ No newline at end of file diff --git a/src/dfp/Scanner_3D_v2.m b/src/dfp/Scanner_3D_v2.m new file mode 100644 index 0000000..b8410ba --- /dev/null +++ b/src/dfp/Scanner_3D_v2.m @@ -0,0 +1,1307 @@ +function varargout = Scanner_3D_v2(varargin) +% SCANNER_3D_V2 MATLAB code for Scanner_3D_v2.fig +% SCANNER_3D_V2, by itself, creates a new SCANNER_3D_V2 or raises the existing +% singleton*. +% +% H = SCANNER_3D_V2 returns the handle to a new SCANNER_3D_V2 or the handle to +% the existing singleton*. +% +% SCANNER_3D_V2('CALLBACK',hObject,eventData,handles,...) calls the local +% function named CALLBACK in SCANNER_3D_V2.M with the given input arguments. +% +% SCANNER_3D_V2('Property','Value',...) creates a new SCANNER_3D_V2 or raises the +% existing singleton*. Starting from the left, property value pairs are +% applied to the GUI before Scanner_3D_v2_OpeningFcn gets called. An +% unrecognized property name or invalid value makes property application +% stop. All inputs are passed to Scanner_3D_v2_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 + +% Edit the above text to modify the response to help Scanner_3D_v2 + +% Last Modified by GUIDE v2.5 03-Jan-2019 18:25:00 + +% Begin initialization code - DO NOT EDIT +gui_Singleton = 1; +gui_State = struct('gui_Name', mfilename, ... + 'gui_Singleton', gui_Singleton, ... + 'gui_OpeningFcn', @Scanner_3D_v2_OpeningFcn, ... + 'gui_OutputFcn', @Scanner_3D_v2_OutputFcn, ... + 'gui_LayoutFcn', [] , ... + 'gui_Callback', []); +if nargin && ischar(varargin{1}) + gui_State.gui_Callback = str2func(varargin{1}); +end + +if nargout + [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); +else + gui_mainfcn(gui_State, varargin{:}); +end +% End initialization code - DO NOT EDIT + + +% --- Executes just before Scanner_3D_v2 is made visible. +function Scanner_3D_v2_OpeningFcn(hObject, eventdata, handles, varargin) +% This function has no output args, see OutputFcn. +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +% varargin command line arguments to Scanner_3D_v2 (see VARARGIN) + +% Choose default command line output for Scanner_3D_v2 + +handles.output =1; +tic + + +axes(handles.axes3);cla;imshow(imread('Shan_Logo4.png'),[]); +axes(handles.axes4);cla;imshow(imread('iisc_logo.png'),[]); +axes(handles.axes1);cla;imshow(imread('p1.png'),[]); + +seting_buttons_state(hObject, eventdata, handles,{'off','off','off','off','off','off','off'}); + +set(handles.popup_FilterSelect, 'Enable','off'); +set(handles.check_Enable, 'Value',0); +set(handles.radio_2D, 'Value',1); +set(handles.radio_3D, 'Value',0); + +set(handles.sliderY,'Enable','off'); +set(handles.sliderX,'Enable','off'); + + +handles.destination_NEW =strcat(pwd,'\Result11'); + +handles.Save_2d3d_Contour=0; +handles.Save_1D=0; +handles.Save_Processdata=0; +handles.spectra = 'All Pass'; + + + +try + fid = fopen('selectCamera.txt');sd = textscan(fid, '%s'); fclose(fid); + val = sd{1}; +catch + f=errordlg('Camera not found 1','Camera Error'); + waitfor(f); + try delete(handles.figure1); catch; end +end + + +try + [a4a5]=dlmread('SessionConst.txt'); + handles.scal=a4a5(2)/a4a5(3); +catch + errordlg('Perform Calibration Again','Calibration Error'); + try delete(handles.figure1); catch; end +end + + +wbar = waitbar(0.1,'Connecting Hardware...'); +wbar .CloseRequestFcn = ''; + +imaqreset; +aa=imaqhwinfo('winvideo'); +size(aa.DeviceInfo); +cnt= size(aa.DeviceInfo,2); +a=aa.DeviceInfo; +waitbar(0.3,wbar); + +s1=cell((cnt+1),1); +s1(1)={'Select'}; +cnt2=0; + for ii=1:cnt + if strcmp(a(ii).DeviceName, 'USB Camera') + a(ii).DeviceName={'3dFrImager'}; + s1(ii+1)={'3dFrImager'}; + cnt2=1; + else + a(ii).DeviceName={(a(ii).DeviceName)}; + s1(ii+1)=(a(ii).DeviceName); + end + end + + +%=============================================================== +handles.ExposureMode = 'manual'; +cset=dlmread('camset.txt'); +handles.Contrast = cset(1); +handles.Brightness = cset(2); +handles.Exposure = cset(3); +handles.WhiteBalance = cset(4); +%=============================================================== + +waitbar(0.5,wbar); + +if cnt2==0 + try delete(wbar), catch, end; + pause(.1) + f=errordlg('Camera not found','Camera Error'); + waitfor(f); + try delete(handles.figure1); catch; end + + +else + try + yD=dlmread('CropCordinate.txt'); + catch + errordlg('Calibration Error','Calibration Error'); + try delete(handles.figure1); catch; end + end + + + if strcmp(val, '3dFrImager') + val='USB Camera'; + end + + obj = videoinput('winvideo', val, 'YUY2_3264x2448'); + handles.obj =obj; + obj.ROIPosition = yD; + hsrc = getselectedsource(obj ); + obj.FramesPerTrigger = 1; + + hsrc.Contrast = handles.Contrast ; + hsrc.Brightness = handles.Brightness ; + hsrc.ExposureMode = handles.ExposureMode ; + hsrc.Exposure = handles.Exposure ; + hsrc.WhiteBalance = handles.WhiteBalance; + + pause(2) + vidRes = get(obj, 'VideoResolution'); + nBands = get(obj, 'NumberOfBands'); + + tmp1=zeros( yD(4),yD(3),nBands); + hImage_NEW = zeros(size(tmp1,2), size(tmp1,2), nBands); + + waitbar(0.7,wbar); + + axes(handles.axes1); cla; + hImage = image(hImage_NEW ); + preview((obj), hImage ); axis tight; axis equal; + + handles.hImage=hImage_NEW ; + % + handles.st_r = 1; + handles.st_c = 1; + handles.mx_r =vidRes(2); + handles.mx_c =vidRes(1); + set(handles.sliderX,'value',handles.st_r); % + set(handles.sliderX,'max',handles.mx_r); % + set(handles.sliderX,'min',1); + + set(handles.sliderY,'value',handles.st_c); % + set(handles.sliderY,'max',handles.mx_c); % + set(handles.sliderY,'min',1); + + delete(instrfind); + nam = GetComPort; + + LASER = serial(nam ,'BaudRate', 9600); + handles.LASERRR=LASER; + + + try + fopen(LASER); + waitbar(0.8,wbar); + pause(2) + fprintf(LASER,'%c','p'); + pause(1) + + handles.SelectOption = 'NewAcq'; % 'NewAcq' 'OldAcq' + handles.plotAxis = 'X'; + handles.stateCheck_X='on'; + + handles.window=43; + handles.NN =10; + handles.iter=1; + handles.VALUEXY=1; + handles.D2D3 = '2D'; + + mkdir Result11 + handles.cntLoop=1; + + try delete(wbar), catch, end + uiwait(msgbox('Place the Object within FOV','Place Object','non-modal')); + + + + set(handles.radio_Disp_Results, 'Enable','off'); + set(handles.radio_Disp_LiveView, 'Enable','on'); + set(handles.radio_Disp_LiveView, 'Value',1); + set(handles.push_EXIT,'Enable','on'); + + set(handles.push_startProfileing, 'Enable','on'); + set(handles.check_CabinLamp, 'Enable','on'); + set(handles.check_Projector, 'Enable','on'); + set(handles.check_CabinLamp, 'Value',1); + + guidata(hObject, handles); + + catch + try delete(wbar), catch, end; + pause(.5) + f=errordlg('Hardware not found','Hardware Error'); + waitfor(f); + try delete(handles.figure1); catch; end + end +% Update handles structure +% guidata(hObject, handles); +end + +% UIWAIT makes Scanner_3D_v2 wait for user response (see UIRESUME) +% uiwait(handles.figure1); + + +% --- Outputs from this function are returned to the command line. +function varargout = Scanner_3D_v2_OutputFcn(hObject, eventdata, handles) +% varargout cell array for returning output args (see VARARGOUT); +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Get default command line output from handles structure +varargout{1} = 1;%handles.output; + + +% --- Executes on slider movement. +function sliderX_Callback(hObject, eventdata, handles) +% hObject handle to sliderX (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'Value') returns position of slider +% get(hObject,'Min') and get(hObject,'Max') to determine range of slider +Valuex= get(hObject,'Value'); +valuex=round(handles.mx_r-Valuex); +if valuex ==0; valuex =1; end +handles.VALUEX=valuex; +handles.VALUEXY=valuex; +guidata(hObject, handles); +MyGraphPlot(hObject, eventdata, handles); + + +% --- Executes during object creation, after setting all properties. +function sliderX_CreateFcn(hObject, eventdata, handles) +% hObject handle to sliderX (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: slider controls usually have a light gray background. +if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor',[.9 .9 .9]); +end + + +% --- Executes on slider movement. +function sliderY_Callback(hObject, eventdata, handles) +% hObject handle to sliderY (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'Value') returns position of slider +% get(hObject,'Min') and get(hObject,'Max') to determine range of slider +Valuex= get(hObject,'Value'); +valuex=round(Valuex); +if valuex ==0; valuex =1; end +handles.VALUEY=valuex; +handles.VALUEXY=valuex; +guidata(hObject, handles); +MyGraphPlot(hObject, eventdata, handles) + + +% --- Executes during object creation, after setting all properties. +function sliderY_CreateFcn(hObject, eventdata, handles) +% hObject handle to sliderY (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: slider controls usually have a light gray background. +if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor',[.9 .9 .9]); +end + + +% --- Executes on button press in check_Projector. +function check_Projector_Callback(hObject, eventdata, handles) +% hObject handle to check_Projector (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of check_Projector +c = get(hObject,'Value') ; + +if c==1 + try + fprintf(handles.LASERRR,'%c','b'); + pause(1) + catch + f=errordlg('Hardware Connection Problem','Hardware Error'); + waitfor(f); + end +end + +if c==0 + try + fprintf(handles.LASERRR,'%c','a'); + pause(1) + catch + f=errordlg('Hardware Connection Problem','Hardware Error'); + waitfor(f); + end +end +guidata(hObject, handles); + + +% --- Executes on button press in checkbox15. +function checkbox15_Callback(hObject, eventdata, handles) +% hObject handle to checkbox15 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of checkbox15 + + +% --- Executes on button press in check_CabinLamp. +function check_CabinLamp_Callback(hObject, eventdata, handles) +% hObject handle to check_CabinLamp (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of check_CabinLamp + +c = get(hObject,'Value') ; + +if c==1 + try + fprintf(handles.LASERRR,'%c','p'); + pause(1) + catch + f=errordlg('Hardware Connection Problem','Hardware Error'); + waitfor(f); + end +end + +if c==0 + try + fprintf(handles.LASERRR,'%c','o'); + pause(1) + catch + f=errordlg('Hardware Connection Problem','Hardware Error'); + waitfor(f); + end +end +guidata(hObject, handles); + + + + + + + +% --- Executes on button press in push_Postprocess. +function push_Postprocess_Callback(hObject, eventdata, handles) +% hObject handle to push_Postprocess (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +wbar = waitbar(0,'Please wait...'); +pause(.25) + +try close(wbar), catch, end + +seting_buttons_state(hObject, eventdata, handles,{'off','off','off','off','inactive','off','off'}); +set(handles.push_saveAll, 'Enable','off'); +seting_buttons_state(hObject, eventdata, handles,{'on','on','off','on','on','on','on'}); +set(handles.popup_FilterSelect, 'Enable','off'); +set(handles.radio_2D, 'Value',1); +set(handles.radio_Disp_Results, 'Value',1); +set(handles.check_Enable, 'Enable','on'); +set(handles.check_Enable, 'Value',0); +[data_Org,dataSX]= processImage1(handles.I1, handles.I2, handles.window, handles.spectra); + + + try close(wbar), catch, end + wbar = waitbar(.8,'Processing...'); + wbar .CloseRequestFcn = ''; + + handles.data=data_Org; + handles.dataSX = dataSX; + + handles.D2D3 = '2D'; + guidata(hObject, handles); + + set(handles.radio_3D, 'Enable','on'); + set(handles.radio_2D, 'Enable','on'); + set(handles.radio_2D, 'Value',1); + guidata(hObject, handles); + + + + try delete(wbar), catch, end + wbar = waitbar(1,'Finishing'); + pause(0.1) + + set(handles.radio_3D, 'Enable','on'); + set(handles.radio_2D, 'Enable','on'); + + set(handles.check_X, 'Enable','on'); + set(handles.check_Y, 'Enable','on'); + set(handles.push_saveAll, 'Enable','on'); + + tmp= round(size(handles.data,1)/2); + axes(handles.axes2);cla; plot(handles.data(tmp,:)); + + set(handles.sliderX, 'Enable','on'); + handles.size_r=size(handles.data,1); + handles.st_r = round(handles.size_r/2); + handles.mx_r = round(handles.size_r); + handles.mx_c = round(handles.size_c); + + + set(handles.sliderX,'value',handles.st_r); % + set(handles.sliderX,'max',handles.mx_r); % + set(handles.sliderX,'min',1); + + + + set(handles.sliderY,'value',handles.st_c); % + set(handles.sliderY,'max',handles.mx_c); % + set(handles.sliderY,'min',1); + + + set(handles.check_X, 'Value',1); + set(handles.check_Y, 'Value',0); + handles.plotAxis ='X'; + + try close(wbar), catch, end + + set(handles.push_saveAll,'Enable','off'); + if(handles.Save_2d3d_Contour+handles.Save_1D+handles.Save_Processdata)>0 + set(handles.push_saveAll,'Enable','on'); + end + + + guidata(hObject, handles); + + + MyGraphPlot(hObject, eventdata, handles); + + + +% --- Executes on button press in check_Enable. +function check_Enable_Callback(hObject, eventdata, handles) +% hObject handle to check_Enable (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of check_Enable + +if get(hObject,'Value') ==1 + set(handles.edit_windo_size, 'Enable','on'); + set(handles.push_Postprocess, 'Enable','on'); + set(handles.popup_FilterSelect, 'Enable','on'); +else + set(handles.edit_windo_size, 'Enable','off'); + set(handles.push_Postprocess, 'Enable','off'); + set(handles.popup_FilterSelect, 'Enable','off'); +end +guidata(hObject, handles); + + + + + +function edit_windo_size_Callback(hObject, eventdata, handles) +% hObject handle to edit_windo_size (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_windo_size as text +% str2double(get(hObject,'String')) returns contents of edit_windo_size as a double + +handles.window= str2double(get(hObject,'String')) ; +guidata(hObject, handles); + + + + +% --- Executes during object creation, after setting all properties. +function edit_windo_size_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_windo_size (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in push_startProfileing. +function push_startProfileing_Callback(hObject, eventdata, handles) +% hObject handle to push_startProfileing (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + + +handles.cntLoop = handles.cntLoop +1; +askProfile ='Yes'; +if handles.cntLoop>2 + % ASK Question + askProfile= gui_StartProfiling; + guidata(hObject, handles); + +end + +if strcmp(askProfile, 'Yes') + + set(handles.push_startProfileing, 'Enable','off'); + set(handles.push_EXIT, 'Enable','off'); + set(handles.check_Projector, 'Enable','off'); + set(handles.check_CabinLamp, 'Enable','off'); + + wbar = waitbar(0,'Starting Process...'); + wbar .CloseRequestFcn = ''; + + if strcmp(handles.SelectOption, 'NewAcq') % 'NewAcq' 'OldAcq' + + try + fprintf(handles.LASERRR,'%c','o'); + fprintf(handles.LASERRR,'%c','b'); + fprintf(handles.LASERRR,'%c','y'); + set(handles.check_CabinLamp, 'Value',0); + + pause(1) + catch + 789; + end + + pause(2) + + + yD=dlmread('CropCordinate.txt'); + + obj= handles.obj; + hsrc = getselectedsource(obj ); + obj.FramesPerTrigger = 1; + obj.ROIPosition = yD; + % handles.hImage=hImage; + hsrc.Contrast = handles.Contrast ; + hsrc.Brightness = handles.Brightness ; + hsrc.ExposureMode = handles.ExposureMode ; + hsrc.Exposure = handles.Exposure ; + hsrc.WhiteBalance = handles.WhiteBalance; + + vidRes = get(obj, 'VideoResolution'); + nBands = get(obj, 'NumberOfBands'); +% hImage = image( zeros(vidRes(2), vidRes(1), nBands) ); +% axes(handles.axes1);cla; preview(obj, hImage); axis equal; + + pause(1) + + try delete(wbar), catch; end + wbar = waitbar(0.3,'Processing...'); + wbar .CloseRequestFcn = ''; + + + tmp1=0; + for jj=1:handles.NN + frame = getsnapshot(obj); + tmp= double(ycbcr2rgb(frame)); + pause(0.5); + tmp1 = tmp1+tmp; + end + tmp1=uint8(tmp1/handles.NN); + + handles.im1=tmp1; + imwrite(handles.im1,'im1.tif'); + axes(handles.axes1);cla; image(tmp1); axis equal; + pause(2) + + try + im1 =handles.im0; + catch + im1 =imread('im0.tif'); + end + im2 =handles.im1; + + try + fprintf(handles.LASERRR,'%c','a'); + fprintf(handles.LASERRR,'%c','y'); + pause(1) + catch + 789; + end + + + wbar = waitbar(0.5,wbar); + + end + + if strcmp(handles.SelectOption, 'OldAcq') % 'NewAcq' 'OldAcq' + im1 =handles.im0; + im2 =handles.im1; + end + +im2= double(rgb2gray(im2)); +im1= double(rgb2gray(im1)); +try delete(wbar), catch, end + +I1 = im1; +I2 = im2; + +handles.I1 =I1; +handles.I2 =I2; + +guidata(hObject, handles); + +try delete(wbar), catch, end +[data_Org,dataSX]= processImage1(handles.I1, handles.I2, 30, 'All Pass'); +handles.data = data_Org; +handles.dataSX = dataSX; +handles.D2D3 = '2D'; +handles.VALUEXY=round(size(handles.data,1)/2); + +tmp= round(size(handles.data,1)/2); +axes(handles.axes2);cla; plot(handles.data(tmp,:)); + +set(handles.sliderX, 'Enable','on'); +handles.size_r=size(handles.data,1); +handles.st_r = round(handles.size_r/2); +handles.mx_r = round(handles.size_r); + + +set(handles.sliderX,'value',handles.st_r); % +set(handles.sliderX,'max',handles.mx_r); % +set(handles.sliderX,'min',1); + +set(handles.check_X, 'Value',1); + + +set(handles.sliderY, 'Enable','off'); +handles.size_c=size(handles.data,2); +handles.st_c = round(handles.size_c/2); +handles.mx_c = round(handles.size_c); + +set(handles.sliderY,'value',handles.st_c); % +set(handles.sliderY,'max',handles.mx_c); % +set(handles.sliderY,'min',1); + +seting_buttons_state(hObject, eventdata, handles,{'on','on','off','on','on','on','on'}); +set(handles.radio_2D, 'Value',1); +set(handles.radio_Disp_Results, 'Value',1); +set(handles.check_Enable, 'Enable','on'); +set(handles.check_Projector, 'Value',0); + +set(handles.push_saveAll,'Enable','off'); +if(handles.Save_2d3d_Contour+handles.Save_1D+handles.Save_Processdata)>0 + set(handles.push_saveAll,'Enable','on'); +end + +end +guidata(hObject, handles); + + + MyGraphPlot(hObject, eventdata, handles); + + +% guidata(hObject, handles); + + + + + + +% --- Executes on button press in check_X. +function check_X_Callback(hObject, eventdata, handles) +% hObject handle to check_X (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of check_X +c = get(hObject,'Value'); + +if c==1 + set(handles.check_Y, 'Value',0); + handles.plotAxis = 'X'; + set(handles.sliderY, 'Enable','off'); + set(handles.sliderX, 'Enable','on'); + + handles.VALUEXY=round(handles.mx_r/2); + set(handles.sliderX,'value',handles.st_r); % + MyGraphPlot(hObject, eventdata, handles); + +end + +if c==0 + set(handles.check_Y, 'Value',1); + handles.plotAxis = 'Y'; + set(handles.sliderY, 'Enable','on'); + set(handles.sliderX, 'Enable','off'); + + + handles.VALUEXY=round(handles.mx_c/2); + set(handles.sliderX,'value',handles.st_c); % + MyGraphPlot(hObject, eventdata, handles); + +end + + + +guidata(hObject, handles); + + + +% --- Executes on button press in check_wholePlane. +function check_wholePlane_Callback(hObject, eventdata, handles) +% hObject handle to check_wholePlane (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of check_wholePlane + + +% --- Executes on button press in check_Y. +function check_Y_Callback(hObject, eventdata, handles) +% hObject handle to check_Y (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of check_Y +c = get(hObject,'Value'); + +if c==1 + set(handles.check_X, 'Value',0); + handles.plotAxis = 'Y'; + set(handles.sliderY, 'Enable','on'); + set(handles.sliderX, 'Enable','off'); + + handles.VALUEXY=round(handles.mx_c/2); + + set(handles.sliderY,'value',handles.st_c); % + MyGraphPlot(hObject, eventdata, handles); + +end + +if c==0 + set(handles.check_X, 'Value',1); + handles.plotAxis = 'X'; + set(handles.sliderY, 'Enable','off'); + set(handles.sliderX, 'Enable','on'); + + handles.VALUEXY=round(handles.mx_r/2); + set(handles.sliderX,'value',handles.st_r); % + MyGraphPlot(hObject, eventdata, handles); + +end + +guidata(hObject, handles); + + + + +function MyGraphPlot(hObject, eventdata, handles) + +valuex=handles.VALUEXY; +DATA =handles.data; + +if strcmp(handles.D2D3,'2D') + + +switch handles.plotAxis + case 'X' + xX = (1:numel(handles.data(valuex,:)))*handles.scal; + x = (1:size(handles.data,2))*handles.scal; + y = (1:size(handles.data,1))*handles.scal; + axes(handles.axes1);cla; + imagesc(x,y,handles.data); +% imagesc(handles.data); + colormap jet; colorbar; axis equal, xlabel('Distance(m)'), ylabel('Distance(m)') +% hold on; line([1, size(DATA,2)], [valuex, valuex], 'LineWidth',2, 'color', 'red') + hold on; line([handles.scal, size(DATA,2)*handles.scal], [valuex*handles.scal, valuex*handles.scal], 'LineWidth',2, 'color', 'red') + hold off; + axes(handles.axes2);cla; plot(xX,handles.data(valuex,:)),xlabel('Distance(m)'), ylabel('Height(m)') ; + handles.axis_Plot =xX; + handles.data_Plot=handles.data(valuex,:); + case 'Y' + yY = (1:numel(handles.data(:,valuex)))*handles.scal; + + x = (1:size(handles.data,2))*handles.scal; + y = (1:size(handles.data,1))*handles.scal; + + axes(handles.axes1);cla; +% imagesc(handles.data); + imagesc(x,y,handles.data); + colormap jet; colorbar; axis equal, xlabel('Distance(m)'), ylabel('Distance(m)') +% hold on; line([valuex, valuex], [1, size(DATA,1)], 'LineWidth',2, 'color', 'red') + hold on; line([valuex*handles.scal, valuex*handles.scal], [handles.scal, size(DATA,1)*handles.scal], 'LineWidth',2, 'color', 'red') + hold off + axes(handles.axes2);cla; plot(yY,handles.data(:,valuex)); xlabel('Distance(m)'), ylabel('Height(m)') ; + + handles.axis_Plot =yY; + handles.data_Plot=handles.data(:,valuex); + + otherwise + set(handles.check_X, 'Value',1); + set(handles.check_Y, 'Value',0); + axes(handles.axes1);cla; imagesc(handles.data); axis equal; + hold on; line([1, size(DATA,2)], [valuex, valuex], 'LineWidth',2, 'color', 'red') + hold off +end + +guidata(hObject, handles); + +elseif(strcmp(handles.D2D3,'3D')) + axes(handles.axes1);cla; +% data_crop=handles.data_crop; + data_crop=flipud(handles.data(11:10:end,11:10:end)); + [xx, yy]=(meshgrid(1:size(data_crop,2), 1:size(data_crop,1))); + xx=xx*handles.scal; yy=yy*handles.scal; +% xx=handles.xx*10*handles.scal; yy= handles.yy*10*handles.scal; + % hh=mesh( data_crop); + hh=mesh(xx, yy, data_crop); + % hh=mesh(fliplr(handles.data(11:10:end,11:10:end))); + set(hh,'FaceColor','interp') + colormap jet; colorbar; + rotate3d on + +end + + + + + +% --- Executes on button press in radio_2D. +function radio_2D_Callback(hObject, eventdata, handles) +% hObject handle to radio_2D (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of radio_2D + axes(handles.axes1); cla; + imagesc(handles.data); + colormap jet; colorbar; axis equal + handles.VALUEXY=round(handles.mx_r/2); + set(handles.sliderX,'value',handles.st_r); + handles.stateCheck_X ='on'; + guidata(hObject, handles); + MyGraphPlot(hObject, eventdata, handles); + + +% --- Executes on button press in radio_3D. +function radio_3D_Callback(hObject, eventdata, handles) +% hObject handle to radio_3D (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of radio_3D + + handles.stateCheck_X ='off'; + axes(handles.axes1);cla; + data_crop=flipud(handles.data(11:10:end,11:10:end)); + [xx, yy]=(meshgrid(1:size(data_crop,2), 1:size(data_crop,1))); + xx=xx*10*handles.scal; yy= yy*10*handles.scal; + hh=mesh(xx, yy, data_crop); + set(hh,'FaceColor','interp') + colormap jet; colorbar; + rotate3d on + guidata(hObject, handles); + + + + + MyGraphPlot(hObject, eventdata, handles); + + +% --- Executes during object creation, after setting all properties. +function uibuttongroup1_CreateFcn(hObject, eventdata, handles) +% hObject handle to uibuttongroup1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + + +% --- Executes when selected object is changed in uibuttongroup1. + +function uibuttongroup1_SelectionChangedFcn(hObject, eventdata, handles) +% hObject handle to the selected object in uibuttongroup1 +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +c= get(hObject,'String'); +%%%%%%%%%%%seting_buttons_state(hObject, eventdata, handles,0); +handles.D2D3=c; + switch c + + case {'2D'} + set(handles.check_Y, 'Value',0); + set(handles.check_X, 'Value',0); + handles.plotAxis = 'X'; + set(handles.check_X, 'Enable','on'); + set(handles.check_Y, 'Enable','on'); + set(handles.sliderX, 'Enable','on'); + set(handles.sliderY, 'Enable','off'); + + axes(handles.axes1);cla; imagesc(handles.data);axis equal; + rotate3d off + tmp= round(size(handles.data,1)/2); + axes(handles.axes2);cla; plot(handles.data(tmp,:)); + + handles.st_r = round(handles.size_r/2); + handles.mx_r = round(handles.size_r); + + set(handles.sliderX,'value',handles.st_r); % + set(handles.sliderX,'max',handles.mx_r); % + set(handles.sliderX,'min',1); + + set(handles.sliderY,'value',handles.st_c); % + set(handles.sliderY,'max',handles.mx_c); % + set(handles.sliderY,'min',1); + set(handles.check_X, 'Value',1); + +% guidata(hObject, handles); + case {'3D'} + set(handles.check_X, 'Enable','off'); + set(handles.check_Y, 'Enable','off'); + set(handles.sliderX, 'Enable','off'); + set(handles.sliderY, 'Enable','off'); +% % handles.scal + data_crop=flipud(handles.data(11:10:end,11:10:end)); + handles.data_crop=data_crop; + [handles.xx, handles.yy]=(meshgrid(1:size(data_crop,2), 1:size(data_crop,1))); + +% data_crop=flipud(handles.data(11:10:end,11:10:end)); + [xx, yy]=(meshgrid(1:size(data_crop,2), 1:size(data_crop,1))); + xx=xx*10*handles.scal; yy= yy*10*handles.scal; + axes(handles.axes1);cla; + hh=mesh(xx, yy, data_crop); + set(hh,'FaceColor','interp') + colormap jet; colorbar; + rotate3d on + end + size(handles.data) +guidata(hObject, handles); + + + +% --- Executes on button press in radio_Disp_Results. +function radio_Disp_Results_Callback(hObject, eventdata, handles) +% hObject handle to radio_Disp_Results (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of radio_Disp_Results + + +% --- Executes on button press in radio_Disp_LiveView. +function radio_Disp_LiveView_Callback(hObject, eventdata, handles) +% hObject handle to radio_Disp_LiveView (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of radio_Disp_LiveView +if get(hObject,'Value') + set(handles.sliderX, 'Enable','off'); + set(handles.sliderY, 'Enable','off'); +else + set(handles.sliderX, 'Enable','on'); + set(handles.sliderY, 'Enable','on'); +end + + + + + +% --- Executes on button press in push_EXIT. +function push_EXIT_Callback(hObject, eventdata, handles) +% hObject handle to push_EXIT (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +if strcmp(gui_confirm_EXIT, 'Yes') + try + fprintf(handles.LASERRR,'%c','y'); + fprintf(handles.LASERRR,'%c','a'); + fprintf(handles.LASERRR,'%c','o'); + pause(1) + catch + end + try delete(handles.figure1); catch; end +end + + + + +% --- Executes when selected object is changed in uibuttongroup7. +function uibuttongroup7_SelectionChangedFcn(hObject, eventdata, handles) +% hObject handle to the selected object in uibuttongroup7 +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +c= get(hObject,'String'); +switch c + case {'Results'} + + wbar = waitbar(0.5,'Loading...'); + + set(handles.radio_2D, 'Enable','on'); + set(handles.radio_3D, 'Enable','on'); + set(handles.check_X, 'Enable',handles.stateCheck_X); + set(handles.check_Y, 'Enable',handles.stateCheck_X); + + guidata(hObject, handles); + MyGraphPlot(hObject, eventdata, handles); + try close(wbar), catch, end + + + case {'Live'} + wbar = waitbar(0.1,'Connecting Camera...'); + set(handles.radio_2D, 'Enable','off'); + set(handles.radio_3D, 'Enable','off'); + set(handles.check_X, 'Enable','off'); + set(handles.check_Y, 'Enable','off'); + set(handles.check_CabinLamp, 'Value',1); + + % % % set(handles.sliderX, 'Enable','off'); + % % % set(handles.sliderY, 'Enable','off'); + + obj= handles.obj; + axes(handles.axes1);cla; + hImage = image(handles.hImage); + preview(obj,hImage); axis equal; + + waitbar(0.5,wbar); + + try + pause( 1) + fprintf(handles.LASERRR,'%c','p'); + pause(1) + + catch + 123; + end + pause(2) + try close(wbar), catch, end + + end + + + + + function seting_buttons_state(hObject, eventdata, handles,flg) +%seting_buttons_state(hObject, eventdata, handles,0) + button_list1 =[ handles.check_Projector handles.check_CabinLamp]; + button_list2 =[ handles.push_startProfileing]; + button_list3 =[ handles.check_Enable handles.edit_windo_size handles.push_Postprocess]; + + button_list4 =[ handles.radio_2D handles.radio_3D handles.check_X handles.check_Y]; + + button_list5 =[ handles.Check_Save_ProcessData handles.Check_Save_1D handles.Check_Save_2d3d_Contour... + handles.push_saveAll]; + + button_list6 =[ handles.push_EXIT]; + button_list7 =[ handles.radio_Disp_Results handles.radio_Disp_LiveView]; + + + set(button_list1, 'Enable',flg{1}); + set(button_list2, 'Enable',flg{2}); + set(button_list3, 'Enable',flg{3}); + set(button_list4, 'Enable',flg{4}); + set(button_list5, 'Enable',flg{5}); + set(button_list6, 'Enable',flg{6}); + set(button_list7, 'Enable',flg{7}); + + guidata(hObject, handles); + + + + + + + +% --- Executes when selected object is changed in uibuttongroup8. +function uibuttongroup8_SelectionChangedFcn(hObject, eventdata, handles) +% hObject handle to the selected object in uibuttongroup8 +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + + + + +% --- Executes on button press in Check_Save_RawImage. +function Check_Save_RawImage_Callback(hObject, eventdata, handles) +% hObject handle to Check_Save_RawImage (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of Check_Save_RawImage + + +% --- Executes on button press in Check_Save_ProcessData. +function Check_Save_ProcessData_Callback(hObject, eventdata, handles) +% hObject handle to Check_Save_ProcessData (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of Check_Save_ProcessData +handles.Save_Processdata= get(hObject,'Value') +% set(handles.push_saveAll,'Enable','on'); +set(handles.push_saveAll,'Enable','off'); +if(handles.Save_2d3d_Contour+handles.Save_1D+handles.Save_Processdata)>0 + set(handles.push_saveAll,'Enable','on'); +end + +guidata(hObject, handles); + + + + +% --- Executes on button press in Check_Save_2d3d_Contour. +function Check_Save_2d3d_Contour_Callback(hObject, eventdata, handles) +% hObject handle to Check_Save_2d3d_Contour (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of Check_Save_2d3d_Contour +handles.Save_2d3d_Contour= get(hObject,'Value') +% set(handles.push_saveAll,'Enable','on'); +set(handles.push_saveAll,'Enable','off'); +if(handles.Save_2d3d_Contour+handles.Save_1D+handles.Save_Processdata)>0 + set(handles.push_saveAll,'Enable','on'); +end + + +guidata(hObject, handles); + + + +% --- Executes on button press in Check_Save_1D. +function Check_Save_1D_Callback(hObject, eventdata, handles) +% hObject handle to Check_Save_1D (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of Check_Save_1D +handles.Save_1D = get(hObject,'Value'); +set(handles.push_saveAll,'Enable','off'); +if(handles.Save_2d3d_Contour+handles.Save_1D+handles.Save_Processdata)>0 + set(handles.push_saveAll,'Enable','on'); +end + + +guidata(hObject, handles); + + + +% --- Executes on button press in push_saveAll. +function push_saveAll_Callback(hObject, eventdata, handles) +% hObject handle to push_saveAll (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + + +if(handles.Save_2d3d_Contour+handles.Save_1D+handles.Save_Processdata)>0 + +seting_buttons_state(hObject, eventdata, handles,{'off','off','off','off','inactive','off','off'}); +set(handles.push_saveAll, 'Enable','off'); + +destination = handles.destination_NEW; +[user_response, destination ] = gui_set_destination(destination); + +if strcmp(user_response, 'Yes') + + handles.destination_NEW= destination ; + handles.iter=handles.iter+1; + + filename4 = strcat(destination,'\', '2D3D_',num2str(handles.iter),'.tif' ); + filename3 = strcat(destination,'\', '1D_',num2str(handles.iter),'.tif' ); + guidata(hObject, handles); + + wbar=waitbar(0.1,'Saving Files...'); + wbar .CloseRequestFcn = ''; + + waitbar(0.3, wbar); + + if handles.Check_Save_ProcessData== 1 + + end + + waitbar(0.4, wbar); + + if handles.Save_1D ==1 + % Fig2 = figure('units','normalized','outerposition',[0 0 1 1]); + Fig2 = figure('pos',[10 10 900 300]); + set(Fig2, 'Visible', 'off'); + plot(handles.axis_Plot , handles.data_Plot, 'b','LineWidth',2); + xlabel('Distance (m)') + ylabel('Height (m)') + print(Fig2,filename3,'-dtiff','-r300') + close(Fig2) + end + + waitbar(0.7, wbar); + + + + if handles.Save_2d3d_Contour==1 + Fig1 = figure('units','normalized','outerposition',[0 0 1 1]); + set(Fig1, 'Visible', 'off'); + copyobj(handles.axes1, Fig1); + colormap(jet), + hcb=colorbar('eastoutside');title(hcb,'Height(m)'), + xlabel('Distance (m)') + ylabel('Distance (m)') + print(Fig1,filename4,'-dtiff','-r300') + close(Fig1) + waitbar(0.9, wbar); + end + +try delete(wbar), catch, end + +end + +seting_buttons_state(hObject, eventdata, handles,{'on','on','off','on','on','on','on'}); +% set(handles.radio_2D, 'Value',1); +set(handles.radio_Disp_Results, 'Value',1); +set(handles.check_Enable, 'Enable','on'); +set(handles.check_Enable, 'Value',0); +set(handles.check_X, 'Enable',handles.stateCheck_X); +set(handles.check_Y, 'Enable',handles.stateCheck_X); +end + + +% --- Executes on selection change in popup_FilterSelect. +function popup_FilterSelect_Callback(hObject, eventdata, handles) +% hObject handle to popup_FilterSelect (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: contents = cellstr(get(hObject,'String')) returns popup_FilterSelect contents as cell array +% contents{get(hObject,'Value')} returns selected item from popup_FilterSelect +% handles.spectra +contents= cellstr(get(hObject,'String')); +handles.spectra= contents{get(hObject,'Value')}; +guidata(hObject, handles); + + +% --- Executes during object creation, after setting all properties. +function popup_FilterSelect_CreateFcn(hObject, eventdata, handles) +% hObject handle to popup_FilterSelect (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: popupmenu controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in push_help. +function push_help_Callback(hObject, eventdata, handles) +% hObject handle to push_help (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +open('Help_3DFrImager.pdf'); diff --git a/src/dfp/WFT2.m b/src/dfp/WFT2.m new file mode 100644 index 0000000..a95dc22 --- /dev/null +++ b/src/dfp/WFT2.m @@ -0,0 +1,47 @@ +function g=WFT2(f,sigmax,wxl,wxi,wxh,sigmay,wyl,wyi,wyh) + +sx=round(3*sigmax); +sy=round(3*sigmay); + + + +[m n]=size(f); +mm=m+2*sx;nn=n+2*sy; +f=fexpand(f,mm,nn); +Ff=fft2(f); +[y x]=meshgrid(-sy:sy,-sx:sx); +w0=exp(-x.*x/2/sigmax/sigmax-y.*y/2/sigmay/sigmay); +w0=w0/sqrt(sum(sum(w0.*w0))); + +g.wx=zeros(m,n); g.wy=zeros(m,n); g.phase=zeros(m,n); g.r=zeros(m,n); + for wyt=wyl:wyi:wyh + for wxt=wxl:wxi:wxh + %WFT basis + w=w0.*exp(j*wxt*x+j*wyt*y); + %expand w to size [mm nn] + w=fexpand(w,mm,nn); + %spectrum of w + Fw=fft2(w); + %implement of WFT: conv2(f,w)=ifft2(Ff*Fw); + sf=ifft2(Ff.*Fw); + %cut to get desired data size + sf=sf(1+sx:m+sx,1+sy:n+sy); + %indicate where to update + t=(abs(sf)>g.r); + %update r + g.r=g.r.*(1-t)+abs(sf).*t; + %update wx + g.wx=g.wx.*(1-t)+wxt*t; + %update wy + g.wy=g.wy.*(1-t)+wyt*t; + %update phase + g.phase=g.phase.*(1-t)+angle(sf).*t; + end + end + +function f=fexpand(f,mm,nn) + [m n]=size(f); + f0=f; + f=zeros(mm,nn); + f(1:m,1:n)=f0; + diff --git a/src/dfp/dis_peak.m b/src/dfp/dis_peak.m new file mode 100644 index 0000000..d247db0 --- /dev/null +++ b/src/dfp/dis_peak.m @@ -0,0 +1,29 @@ +function [dis]= dis_peak(I1) +I = abs(I1); +pvt=5; + + +[r, c]=find(I==max(I(:))); + +r =r(1); c=c(1); +r1=r; c1= c; + + +I(r-pvt:r+pvt, c-pvt:c+pvt)=0; + + +[r, c]=find(I==max(I(:))); +r =r(1); c=c(1); +r2=r; c2= c; +I(r-pvt:r+pvt, c-pvt:c+pvt)=0; + + +[r, c]=find(I==max(I(:))); +r =r(1); c=c(1); +r3=r; c3= c; +I(r-pvt:r+pvt, c-pvt:c+pvt)=0; + +[r1, c1, r2, c2, r3, c3] +dis=sqrt((r2-r3)^2+(c2-c3)^2) + +dis= size(I1,2)*2/dis diff --git a/src/dfp/gui_CompleteCalib_Msg.m b/src/dfp/gui_CompleteCalib_Msg.m new file mode 100644 index 0000000..9cd57e3 --- /dev/null +++ b/src/dfp/gui_CompleteCalib_Msg.m @@ -0,0 +1,206 @@ +function varargout = gui_CompleteCalib_Msg(varargin) +% GUI_COMPLETECALIB_MSG MATLAB code for gui_CompleteCalib_Msg.fig +% GUI_COMPLETECALIB_MSG by itself, creates a new GUI_COMPLETECALIB_MSG or raises the +% existing singleton*. +% +% H = GUI_COMPLETECALIB_MSG returns the handle to a new GUI_COMPLETECALIB_MSG or the handle to +% the existing singleton*. +% +% GUI_COMPLETECALIB_MSG('CALLBACK',hObject,eventData,handles,...) calls the local +% function named CALLBACK in GUI_COMPLETECALIB_MSG.M with the given input arguments. +% +% GUI_COMPLETECALIB_MSG('Property','Value',...) creates a new GUI_COMPLETECALIB_MSG or raises the +% existing singleton*. Starting from the left, property value pairs are +% applied to the GUI before gui_CompleteCalib_Msg_OpeningFcn gets called. An +% unrecognized property name or invalid value makes property application +% stop. All inputs are passed to gui_CompleteCalib_Msg_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 + +% Edit the above text to modify the response to help gui_CompleteCalib_Msg + +% Last Modified by GUIDE v2.5 04-Dec-2018 16:57:10 + +% Begin initialization code - DO NOT EDIT +gui_Singleton = 1; +gui_State = struct('gui_Name', mfilename, ... + 'gui_Singleton', gui_Singleton, ... + 'gui_OpeningFcn', @gui_CompleteCalib_Msg_OpeningFcn, ... + 'gui_OutputFcn', @gui_CompleteCalib_Msg_OutputFcn, ... + 'gui_LayoutFcn', [] , ... + 'gui_Callback', []); +if nargin && ischar(varargin{1}) + gui_State.gui_Callback = str2func(varargin{1}); +end + +if nargout + [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); +else + gui_mainfcn(gui_State, varargin{:}); +end +% End initialization code - DO NOT EDIT + +% --- Executes just before gui_CompleteCalib_Msg is made visible. +function gui_CompleteCalib_Msg_OpeningFcn(hObject, eventdata, handles, varargin) +% This function has no output args, see OutputFcn. +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +% varargin command line arguments to gui_CompleteCalib_Msg (see VARARGIN) + +% Choose default command line output for gui_CompleteCalib_Msg +handles.output = 'Yes'; + +% Update handles structure +guidata(hObject, handles); + +% Insert custom Title and Text if specified by the user +% Hint: when choosing keywords, be sure they are not easily confused +% with existing figure properties. See the output of set(figure) for +% a list of figure properties. +if(nargin > 3) + for index = 1:2:(nargin-3), + if nargin-3==index, break, end + switch lower(varargin{index}) + case 'title' + set(hObject, 'Name', varargin{index+1}); + case 'string' + set(handles.text1, 'String', varargin{index+1}); + end + end +end + +% Determine the position of the dialog - centered on the callback figure +% if available, else, centered on the screen +FigPos=get(0,'DefaultFigurePosition'); +OldUnits = get(hObject, 'Units'); +set(hObject, 'Units', 'pixels'); +OldPos = get(hObject,'Position'); +FigWidth = OldPos(3); +FigHeight = OldPos(4); +if isempty(gcbf) + ScreenUnits=get(0,'Units'); + set(0,'Units','pixels'); + ScreenSize=get(0,'ScreenSize'); + set(0,'Units',ScreenUnits); + + FigPos(1)=1/2*(ScreenSize(3)-FigWidth); + FigPos(2)=2/3*(ScreenSize(4)-FigHeight); +else + GCBFOldUnits = get(gcbf,'Units'); + set(gcbf,'Units','pixels'); + GCBFPos = get(gcbf,'Position'); + set(gcbf,'Units',GCBFOldUnits); + FigPos(1:2) = [(GCBFPos(1) + GCBFPos(3) / 2) - FigWidth / 2, ... + (GCBFPos(2) + GCBFPos(4) / 2) - FigHeight / 2]; +end +FigPos(3:4)=[FigWidth FigHeight]; +set(hObject, 'Position', FigPos); +set(hObject, 'Units', OldUnits); + +% Show a question icon from dialogicons.mat - variables questIconData +% and questIconMap +load dialogicons.mat + +IconData=questIconData; +questIconMap(256,:) = get(handles.figure1, 'Color'); +IconCMap=questIconMap; + +Img=image(IconData, 'Parent', handles.axes1); +set(handles.figure1, 'Colormap', IconCMap); + +set(handles.axes1, ... + 'Visible', 'off', ... + 'YDir' , 'reverse' , ... + 'XLim' , get(Img,'XData'), ... + 'YLim' , get(Img,'YData') ... + ); + +% Make the GUI modal +set(handles.figure1,'WindowStyle','modal') + +% UIWAIT makes gui_CompleteCalib_Msg wait for user response (see UIRESUME) +uiwait(handles.figure1); + +% --- Outputs from this function are returned to the command line. +function varargout = gui_CompleteCalib_Msg_OutputFcn(hObject, eventdata, handles) +% varargout cell array for returning output args (see VARARGOUT); +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Get default command line output from handles structure +varargout{1} = handles.output; + +% The figure can be deleted now +delete(handles.figure1); + +% --- Executes on button press in pushbutton1. +function pushbutton1_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +handles.output = get(hObject,'String'); + +% Update handles structure +guidata(hObject, handles); + +% Use UIRESUME instead of delete because the OutputFcn needs +% to get the updated handles structure. +uiresume(handles.figure1); + +% --- Executes on button press in pushbutton2. +function pushbutton2_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton2 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +handles.output = get(hObject,'String'); + +% Update handles structure +guidata(hObject, handles); + +% Use UIRESUME instead of delete because the OutputFcn needs +% to get the updated handles structure. +uiresume(handles.figure1); + + +% --- Executes when user attempts to close figure1. +function figure1_CloseRequestFcn(hObject, eventdata, handles) +% hObject handle to figure1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +if isequal(get(hObject, 'waitstatus'), 'waiting') + % The GUI is still in UIWAIT, us UIRESUME + uiresume(hObject); +else + % The GUI is no longer waiting, just close it + delete(hObject); +end + + +% --- Executes on key press over figure1 with no controls selected. +function figure1_KeyPressFcn(hObject, eventdata, handles) +% hObject handle to figure1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Check for "enter" or "escape" +if isequal(get(hObject,'CurrentKey'),'escape') + % User said no by hitting escape + handles.output = 'No'; + + % Update handles structure + guidata(hObject, handles); + + uiresume(handles.figure1); +end + +if isequal(get(hObject,'CurrentKey'),'return') + uiresume(handles.figure1); +end diff --git a/src/dfp/gui_StartProfiling.m b/src/dfp/gui_StartProfiling.m new file mode 100644 index 0000000..50e1a37 --- /dev/null +++ b/src/dfp/gui_StartProfiling.m @@ -0,0 +1,206 @@ +function varargout = gui_StartProfiling(varargin) +% GUI_STARTPROFILING MATLAB code for gui_StartProfiling.fig +% GUI_STARTPROFILING by itself, creates a new GUI_STARTPROFILING or raises the +% existing singleton*. +% +% H = GUI_STARTPROFILING returns the handle to a new GUI_STARTPROFILING or the handle to +% the existing singleton*. +% +% GUI_STARTPROFILING('CALLBACK',hObject,eventData,handles,...) calls the local +% function named CALLBACK in GUI_STARTPROFILING.M with the given input arguments. +% +% GUI_STARTPROFILING('Property','Value',...) creates a new GUI_STARTPROFILING or raises the +% existing singleton*. Starting from the left, property value pairs are +% applied to the GUI before gui_StartProfiling_OpeningFcn gets called. An +% unrecognized property name or invalid value makes property application +% stop. All inputs are passed to gui_StartProfiling_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 + +% Edit the above text to modify the response to help gui_StartProfiling + +% Last Modified by GUIDE v2.5 03-Dec-2018 13:58:53 + +% Begin initialization code - DO NOT EDIT +gui_Singleton = 1; +gui_State = struct('gui_Name', mfilename, ... + 'gui_Singleton', gui_Singleton, ... + 'gui_OpeningFcn', @gui_StartProfiling_OpeningFcn, ... + 'gui_OutputFcn', @gui_StartProfiling_OutputFcn, ... + 'gui_LayoutFcn', [] , ... + 'gui_Callback', []); +if nargin && ischar(varargin{1}) + gui_State.gui_Callback = str2func(varargin{1}); +end + +if nargout + [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); +else + gui_mainfcn(gui_State, varargin{:}); +end +% End initialization code - DO NOT EDIT + +% --- Executes just before gui_StartProfiling is made visible. +function gui_StartProfiling_OpeningFcn(hObject, eventdata, handles, varargin) +% This function has no output args, see OutputFcn. +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +% varargin command line arguments to gui_StartProfiling (see VARARGIN) + +% Choose default command line output for gui_StartProfiling +handles.output = 'Yes'; + +% Update handles structure +guidata(hObject, handles); + +% Insert custom Title and Text if specified by the user +% Hint: when choosing keywords, be sure they are not easily confused +% with existing figure properties. See the output of set(figure) for +% a list of figure properties. +if(nargin > 3) + for index = 1:2:(nargin-3), + if nargin-3==index, break, end + switch lower(varargin{index}) + case 'title' + set(hObject, 'Name', varargin{index+1}); + case 'string' + set(handles.text1, 'String', varargin{index+1}); + end + end +end + +% Determine the position of the dialog - centered on the callback figure +% if available, else, centered on the screen +FigPos=get(0,'DefaultFigurePosition'); +OldUnits = get(hObject, 'Units'); +set(hObject, 'Units', 'pixels'); +OldPos = get(hObject,'Position'); +FigWidth = OldPos(3); +FigHeight = OldPos(4); +if isempty(gcbf) + ScreenUnits=get(0,'Units'); + set(0,'Units','pixels'); + ScreenSize=get(0,'ScreenSize'); + set(0,'Units',ScreenUnits); + + FigPos(1)=1/2*(ScreenSize(3)-FigWidth); + FigPos(2)=2/3*(ScreenSize(4)-FigHeight); +else + GCBFOldUnits = get(gcbf,'Units'); + set(gcbf,'Units','pixels'); + GCBFPos = get(gcbf,'Position'); + set(gcbf,'Units',GCBFOldUnits); + FigPos(1:2) = [(GCBFPos(1) + GCBFPos(3) / 2) - FigWidth / 2, ... + (GCBFPos(2) + GCBFPos(4) / 2) - FigHeight / 2]; +end +FigPos(3:4)=[FigWidth FigHeight]; +set(hObject, 'Position', FigPos); +set(hObject, 'Units', OldUnits); + +% Show a question icon from dialogicons.mat - variables questIconData +% and questIconMap +load dialogicons.mat + +IconData=questIconData; +questIconMap(256,:) = get(handles.figure1, 'Color'); +IconCMap=questIconMap; + +Img=image(IconData, 'Parent', handles.axes1); +set(handles.figure1, 'Colormap', IconCMap); + +set(handles.axes1, ... + 'Visible', 'off', ... + 'YDir' , 'reverse' , ... + 'XLim' , get(Img,'XData'), ... + 'YLim' , get(Img,'YData') ... + ); + +% Make the GUI modal +set(handles.figure1,'WindowStyle','modal') + +% UIWAIT makes gui_StartProfiling wait for user response (see UIRESUME) +uiwait(handles.figure1); + +% --- Outputs from this function are returned to the command line. +function varargout = gui_StartProfiling_OutputFcn(hObject, eventdata, handles) +% varargout cell array for returning output args (see VARARGOUT); +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Get default command line output from handles structure +varargout{1} = handles.output; + +% The figure can be deleted now +delete(handles.figure1); + +% --- Executes on button press in pushbutton1. +function pushbutton1_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +handles.output = get(hObject,'String'); + +% Update handles structure +guidata(hObject, handles); + +% Use UIRESUME instead of delete because the OutputFcn needs +% to get the updated handles structure. +uiresume(handles.figure1); + +% --- Executes on button press in pushbutton2. +function pushbutton2_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton2 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +handles.output = get(hObject,'String'); + +% Update handles structure +guidata(hObject, handles); + +% Use UIRESUME instead of delete because the OutputFcn needs +% to get the updated handles structure. +uiresume(handles.figure1); + + +% --- Executes when user attempts to close figure1. +function figure1_CloseRequestFcn(hObject, eventdata, handles) +% hObject handle to figure1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +if isequal(get(hObject, 'waitstatus'), 'waiting') + % The GUI is still in UIWAIT, us UIRESUME + uiresume(hObject); +else + % The GUI is no longer waiting, just close it + delete(hObject); +end + + +% --- Executes on key press over figure1 with no controls selected. +function figure1_KeyPressFcn(hObject, eventdata, handles) +% hObject handle to figure1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Check for "enter" or "escape" +if isequal(get(hObject,'CurrentKey'),'escape') + % User said no by hitting escape + handles.output = 'No'; + + % Update handles structure + guidata(hObject, handles); + + uiresume(handles.figure1); +end + +if isequal(get(hObject,'CurrentKey'),'return') + uiresume(handles.figure1); +end diff --git a/src/dfp/gui_WantCalibration.m b/src/dfp/gui_WantCalibration.m new file mode 100644 index 0000000..1832145 --- /dev/null +++ b/src/dfp/gui_WantCalibration.m @@ -0,0 +1,206 @@ +function varargout = gui_WantCalibration(varargin) +% GUI_WANTCALIBRATION MATLAB code for gui_WantCalibration.fig +% GUI_WANTCALIBRATION by itself, creates a new GUI_WANTCALIBRATION or raises the +% existing singleton*. +% +% H = GUI_WANTCALIBRATION returns the handle to a new GUI_WANTCALIBRATION or the handle to +% the existing singleton*. +% +% GUI_WANTCALIBRATION('CALLBACK',hObject,eventData,handles,...) calls the local +% function named CALLBACK in GUI_WANTCALIBRATION.M with the given input arguments. +% +% GUI_WANTCALIBRATION('Property','Value',...) creates a new GUI_WANTCALIBRATION or raises the +% existing singleton*. Starting from the left, property value pairs are +% applied to the GUI before gui_WantCalibration_OpeningFcn gets called. An +% unrecognized property name or invalid value makes property application +% stop. All inputs are passed to gui_WantCalibration_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 + +% Edit the above text to modify the response to help gui_WantCalibration + +% Last Modified by GUIDE v2.5 02-Dec-2018 18:48:33 + +% Begin initialization code - DO NOT EDIT +gui_Singleton = 1; +gui_State = struct('gui_Name', mfilename, ... + 'gui_Singleton', gui_Singleton, ... + 'gui_OpeningFcn', @gui_WantCalibration_OpeningFcn, ... + 'gui_OutputFcn', @gui_WantCalibration_OutputFcn, ... + 'gui_LayoutFcn', [] , ... + 'gui_Callback', []); +if nargin && ischar(varargin{1}) + gui_State.gui_Callback = str2func(varargin{1}); +end + +if nargout + [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); +else + gui_mainfcn(gui_State, varargin{:}); +end +% End initialization code - DO NOT EDIT + +% --- Executes just before gui_WantCalibration is made visible. +function gui_WantCalibration_OpeningFcn(hObject, eventdata, handles, varargin) +% This function has no output args, see OutputFcn. +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +% varargin command line arguments to gui_WantCalibration (see VARARGIN) + +% Choose default command line output for gui_WantCalibration +handles.output = 'Yes'; + +% Update handles structure +guidata(hObject, handles); + +% Insert custom Title and Text if specified by the user +% Hint: when choosing keywords, be sure they are not easily confused +% with existing figure properties. See the output of set(figure) for +% a list of figure properties. +if(nargin > 3) + for index = 1:2:(nargin-3), + if nargin-3==index, break, end + switch lower(varargin{index}) + case 'title' + set(hObject, 'Name', varargin{index+1}); + case 'string' + set(handles.text1, 'String', varargin{index+1}); + end + end +end + +% Determine the position of the dialog - centered on the callback figure +% if available, else, centered on the screen +FigPos=get(0,'DefaultFigurePosition'); +OldUnits = get(hObject, 'Units'); +set(hObject, 'Units', 'pixels'); +OldPos = get(hObject,'Position'); +FigWidth = OldPos(3); +FigHeight = OldPos(4); +if isempty(gcbf) + ScreenUnits=get(0,'Units'); + set(0,'Units','pixels'); + ScreenSize=get(0,'ScreenSize'); + set(0,'Units',ScreenUnits); + + FigPos(1)=1/2*(ScreenSize(3)-FigWidth); + FigPos(2)=2/3*(ScreenSize(4)-FigHeight); +else + GCBFOldUnits = get(gcbf,'Units'); + set(gcbf,'Units','pixels'); + GCBFPos = get(gcbf,'Position'); + set(gcbf,'Units',GCBFOldUnits); + FigPos(1:2) = [(GCBFPos(1) + GCBFPos(3) / 2) - FigWidth / 2, ... + (GCBFPos(2) + GCBFPos(4) / 2) - FigHeight / 2]; +end +FigPos(3:4)=[FigWidth FigHeight]; +set(hObject, 'Position', FigPos); +set(hObject, 'Units', OldUnits); + +% Show a question icon from dialogicons.mat - variables questIconData +% and questIconMap +load dialogicons.mat + +IconData=questIconData; +questIconMap(256,:) = get(handles.figure1, 'Color'); +IconCMap=questIconMap; + +Img=image(IconData, 'Parent', handles.axes1); +set(handles.figure1, 'Colormap', IconCMap); + +set(handles.axes1, ... + 'Visible', 'off', ... + 'YDir' , 'reverse' , ... + 'XLim' , get(Img,'XData'), ... + 'YLim' , get(Img,'YData') ... + ); + +% Make the GUI modal +set(handles.figure1,'WindowStyle','modal') + +% UIWAIT makes gui_WantCalibration wait for user response (see UIRESUME) +uiwait(handles.figure1); + +% --- Outputs from this function are returned to the command line. +function varargout = gui_WantCalibration_OutputFcn(hObject, eventdata, handles) +% varargout cell array for returning output args (see VARARGOUT); +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Get default command line output from handles structure +varargout{1} = handles.output; + +% The figure can be deleted now +delete(handles.figure1); + +% --- Executes on button press in pushbutton1. +function pushbutton1_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +handles.output = get(hObject,'String'); + +% Update handles structure +guidata(hObject, handles); + +% Use UIRESUME instead of delete because the OutputFcn needs +% to get the updated handles structure. +uiresume(handles.figure1); + +% --- Executes on button press in pushbutton2. +function pushbutton2_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton2 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +handles.output = get(hObject,'String'); + +% Update handles structure +guidata(hObject, handles); + +% Use UIRESUME instead of delete because the OutputFcn needs +% to get the updated handles structure. +uiresume(handles.figure1); + + +% --- Executes when user attempts to close figure1. +function figure1_CloseRequestFcn(hObject, eventdata, handles) +% hObject handle to figure1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +if isequal(get(hObject, 'waitstatus'), 'waiting') + % The GUI is still in UIWAIT, us UIRESUME + uiresume(hObject); +else + % The GUI is no longer waiting, just close it + delete(hObject); +end + + +% --- Executes on key press over figure1 with no controls selected. +function figure1_KeyPressFcn(hObject, eventdata, handles) +% hObject handle to figure1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Check for "enter" or "escape" +if isequal(get(hObject,'CurrentKey'),'escape') + % User said no by hitting escape + handles.output = 'No'; + + % Update handles structure + guidata(hObject, handles); + + uiresume(handles.figure1); +end + +if isequal(get(hObject,'CurrentKey'),'return') + uiresume(handles.figure1); +end diff --git a/src/dfp/gui_ask_cal_KNOWN_Point.m b/src/dfp/gui_ask_cal_KNOWN_Point.m new file mode 100644 index 0000000..a9d9620 --- /dev/null +++ b/src/dfp/gui_ask_cal_KNOWN_Point.m @@ -0,0 +1,338 @@ +function varargout = gui_ask_cal_KNOWN_Point(varargin) +% GUI_ASK_CAL_KNOWN_POINT MATLAB code for gui_ask_cal_KNOWN_Point.fig +% GUI_ASK_CAL_KNOWN_POINT by itself, creates a new GUI_ASK_CAL_KNOWN_POINT or raises the +% existing singleton*. +% +% H = GUI_ASK_CAL_KNOWN_POINT returns the handle to a new GUI_ASK_CAL_KNOWN_POINT or the handle to +% the existing singleton*. +% +% GUI_ASK_CAL_KNOWN_POINT('CALLBACK',hObject,eventData,handles,...) calls the local +% function named CALLBACK in GUI_ASK_CAL_KNOWN_POINT.M with the given input arguments. +% +% GUI_ASK_CAL_KNOWN_POINT('Property','Value',...) creates a new GUI_ASK_CAL_KNOWN_POINT or raises the +% existing singleton*. Starting from the left, property value pairs are +% applied to the GUI before gui_ask_cal_KNOWN_Point_OpeningFcn gets called. An +% unrecognized property name or invalid value makes property application +% stop. All inputs are passed to gui_ask_cal_KNOWN_Point_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 + +% Edit the above text to modify the response to help gui_ask_cal_KNOWN_Point + +% Last Modified by GUIDE v2.5 03-Aug-2018 03:25:03 + +% Begin initialization code - DO NOT EDIT +gui_Singleton = 1; +gui_State = struct('gui_Name', mfilename, ... + 'gui_Singleton', gui_Singleton, ... + 'gui_OpeningFcn', @gui_ask_cal_KNOWN_Point_OpeningFcn, ... + 'gui_OutputFcn', @gui_ask_cal_KNOWN_Point_OutputFcn, ... + 'gui_LayoutFcn', [] , ... + 'gui_Callback', []); +if nargin && ischar(varargin{1}) + gui_State.gui_Callback = str2func(varargin{1}); +end + +if nargout + [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); +else + gui_mainfcn(gui_State, varargin{:}); +end +% End initialization code - DO NOT EDIT + +% --- Executes just before gui_ask_cal_KNOWN_Point is made visible. +function gui_ask_cal_KNOWN_Point_OpeningFcn(hObject, eventdata, handles, varargin) +% This function has no output args, see OutputFcn. +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +% varargin command line arguments to gui_ask_cal_KNOWN_Point (see VARARGIN) + +% Choose default command line output for gui_ask_cal_KNOWN_Point +handles.output = 'Cancel'; + +% Update handles structure +guidata(hObject, handles); + +% Insert custom Title and Text if specified by the user +% Hint: when choosing keywords, be sure they are not easily confused +% with existing figure properties. See the output of set(figure) for +% a list of figure properties. +if(nargin > 3) + for index = 1:2:(nargin-3), + if nargin-3==index, break, end + switch lower(varargin{index}) + case 'title' + set(hObject, 'Name', varargin{index+1}); + case 'string' + set(handles.text1, 'String', varargin{index+1}); + end + end +end + +% Determine the position of the dialog - centered on the callback figure +% if available, else, centered on the screen +FigPos=get(0,'DefaultFigurePosition'); +OldUnits = get(hObject, 'Units'); +set(hObject, 'Units', 'pixels'); +OldPos = get(hObject,'Position'); +FigWidth = OldPos(3); +FigHeight = OldPos(4); +if isempty(gcbf) + ScreenUnits=get(0,'Units'); + set(0,'Units','pixels'); + ScreenSize=get(0,'ScreenSize'); + set(0,'Units',ScreenUnits); + + FigPos(1)=1/2*(ScreenSize(3)-FigWidth); + FigPos(2)=2/3*(ScreenSize(4)-FigHeight); +else + GCBFOldUnits = get(gcbf,'Units'); + set(gcbf,'Units','pixels'); + GCBFPos = get(gcbf,'Position'); + set(gcbf,'Units',GCBFOldUnits); + FigPos(1:2) = [(GCBFPos(1) + GCBFPos(3) / 2) - FigWidth / 2, ... + (GCBFPos(2) + GCBFPos(4) / 2) - FigHeight / 2]; +end +FigPos(3:4)=[FigWidth FigHeight]; +set(hObject, 'Position', FigPos); +set(hObject, 'Units', OldUnits); + +% Show a question icon from dialogicons.mat - variables questIconData +% and questIconMap +% load dialogicons.mat +% +% IconData=questIconData; +% questIconMap(256,:) = get(handles.figure1, 'Color'); +% IconCMap=questIconMap; +% +% % Img=image(IconData, 'Parent', handles.axes1); +% set(handles.figure1, 'Colormap', IconCMap); +% +% set(handles.axes1, ... +% 'Visible', 'off', ... +% 'YDir' , 'reverse' , ... +% 'XLim' , get(Img,'XData'), ... +% 'YLim' , get(Img,'YData') ... +% ); + +% Make the GUI modal +set(handles.figure1,'WindowStyle','modal') + +set(handles.push_SET, 'Enable','off'); +set(handles.edit1, 'Enable','off'); +set(handles.push_CANCEL, 'Enable','off'); + +handles.value=0; +handles.image=varargin{1}; +guidata(hObject, handles); + +axes(handles.axes3); imshow(handles.image,[]); +get_coordinates1(hObject, eventdata, handles); + + + + + +% UIWAIT makes gui_ask_cal_KNOWN_Point wait for user response (see UIRESUME) +uiwait(handles.figure1); + + +function get_coordinates1(hObject, eventdata, handles) + +xx=[]; +yy=[]; +iter=0; + +% clf +% axes(handles.axes1); imshow(handles.image,[]); + + + while 1 + + + + [x y button]=ginput(1); + +% if button==27 +% xx=[]; +% yy=[]; +% iter=0; +% end +% + + if button==3 + + + + if iter==2, + xx=xx(end); yy=yy(end); + iter=1; + end + + + xx=[xx;x]; + yy=[yy;y]; + iter=iter+1; + + + imshow(handles.image,[]), + h=line(xx,yy); + h.LineWidth=2; + h.Color=[1 0 0]; + pause(0.2) + + if iter==2, break; end + + end + + end + + set(handles.push_SET, 'Enable','on'); + set(handles.edit1, 'Enable','on'); + set(handles.push_CANCEL, 'Enable','on'); + set(handles.text_DISPLAY, 'String',num2str(handles.value)); + + + handles.xx=xx(end-1:end); + handles.yy=yy(end-1:end); + varargout{2}=handles.xx; + varargout{3}=handles.yy; + +guidata(hObject, handles); + + +% --- Outputs from this function are returned to the command line. +function varargout = gui_ask_cal_KNOWN_Point_OutputFcn(hObject, eventdata, handles) +% varargout cell array for returning output args (see VARARGOUT); +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Get default command line output from handles structure +varargout{1} = handles.output; +varargout{2}=handles.xx; +varargout{3}=handles.yy; +varargout{4}=handles.value; +% The figure can be deleted now +delete(handles.figure1); + +% --- Executes on button press in push_SET. +function push_SET_Callback(hObject, eventdata, handles) +% hObject handle to push_SET (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +handles.output = get(hObject,'String'); + +% Update handles structure +guidata(hObject, handles); + +% Use UIRESUME instead of delete because the OutputFcn needs +% to get the updated handles structure. +uiresume(handles.figure1); + +% --- Executes on button press in push_CANCEL. +function push_CANCEL_Callback(hObject, eventdata, handles) +% hObject handle to push_CANCEL (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +handles.output = get(hObject,'String'); + +% Update handles structure +guidata(hObject, handles); + +% Use UIRESUME instead of delete because the OutputFcn needs +% to get the updated handles structure. +uiresume(handles.figure1); + + +% --- Executes when user attempts to close figure1. +function figure1_CloseRequestFcn(hObject, eventdata, handles) +% hObject handle to figure1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +if isequal(get(hObject, 'waitstatus'), 'waiting') + % The GUI is still in UIWAIT, us UIRESUME + uiresume(hObject); +else + % The GUI is no longer waiting, just close it + delete(hObject); +end + + +% --- Executes on key press over figure1 with no controls selected. +function figure1_KeyPressFcn(hObject, eventdata, handles) +% hObject handle to figure1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Check for "enter" or "escape" +if isequal(get(hObject,'CurrentKey'),'escape') + % User said no by hitting escape + handles.output = 'No'; + + % Update handles structure + guidata(hObject, handles); + + uiresume(handles.figure1); +end + +if isequal(get(hObject,'CurrentKey'),'return') + uiresume(handles.figure1); +end + + + +function edit1_Callback(hObject, eventdata, handles) +% hObject handle to edit1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit1 as text +% str2double(get(hObject,'String')) returns contents of edit1 as a double +value = str2double(get(hObject,'String')) ; + +if(isnan(value)), handles.value=0; end +if(~isnan(value)), handles.value=value; end +set(handles.text_DISPLAY, 'String',num2str(handles.value)); + +guidata(hObject, handles); + + +% --- Executes during object creation, after setting all properties. +function edit1_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in push_RESET. +function push_RESET_Callback(hObject, eventdata, handles) +% hObject handle to push_RESET (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +set(handles.push_SET, 'Enable','off'); +set(handles.edit1, 'Enable','off'); + +imshow(handles.image,[]), +get_coordinates1(hObject, eventdata, handles) + + +% --- Executes during object creation, after setting all properties. +function text_DISPLAY_CreateFcn(hObject, eventdata, handles) +% hObject handle to text_DISPLAY (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called diff --git a/src/dfp/gui_calibration_1.m b/src/dfp/gui_calibration_1.m new file mode 100644 index 0000000..d764472 --- /dev/null +++ b/src/dfp/gui_calibration_1.m @@ -0,0 +1,409 @@ +function varargout = gui_calibration_1(varargin) +% GUI_CALIBRATION_1 MATLAB code for gui_calibration_1.fig +% GUI_CALIBRATION_1 by itself, creates a new GUI_CALIBRATION_1 or raises the +% existing singleton*. +% +% H = GUI_CALIBRATION_1 returns the handle to a new GUI_CALIBRATION_1 or the handle to +% the existing singleton*. +% +% GUI_CALIBRATION_1('CALLBACK',hObject,eventData,handles,...) calls the local +% function named CALLBACK in GUI_CALIBRATION_1.M with the given input arguments. +% +% GUI_CALIBRATION_1('Property','Value',...) creates a new GUI_CALIBRATION_1 or raises the +% existing singleton*. Starting from the left, property value pairs are +% applied to the GUI before gui_calibration_1_OpeningFcn gets called. An +% unrecognized property name or invalid value makes property application +% stop. All inputs are passed to gui_calibration_1_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 + +% Edit the above text to modify the response to help gui_calibration_1 + +% Last Modified by GUIDE v2.5 02-Jan-2019 13:23:58 + +% Begin initialization code - DO NOT EDIT +gui_Singleton = 1; +gui_State = struct('gui_Name', mfilename, ... + 'gui_Singleton', gui_Singleton, ... + 'gui_OpeningFcn', @gui_calibration_1_OpeningFcn, ... + 'gui_OutputFcn', @gui_calibration_1_OutputFcn, ... + 'gui_LayoutFcn', [] , ... + 'gui_Callback', []); +if nargin && ischar(varargin{1}) + gui_State.gui_Callback = str2func(varargin{1}); +end + +if nargout + [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); +else + gui_mainfcn(gui_State, varargin{:}); +end +% End initialization code - DO NOT EDIT + +% --- Executes just before gui_calibration_1 is made visible. +function gui_calibration_1_OpeningFcn(hObject, eventdata, handles, varargin) +% This function has no output args, see OutputFcn. +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +% varargin command line arguments to gui_calibration_1 (see VARARGIN) + +% Choose default command line output for gui_calibration_1 +handles.output = 'Yes'; + +% Update handles structure +guidata(hObject, handles); + +% Insert custom Title and Text if specified by the user +% Hint: when choosing keywords, be sure they are not easily confused +% with existing figure properties. See the output of set(figure) for +% a list of figure properties. +if(nargin > 3) + for index = 1:2:(nargin-3), + if nargin-3==index, break, end + switch lower(varargin{index}) + case 'title' + set(hObject, 'Name', varargin{index+1}); + case 'string' + set(handles.text1, 'String', varargin{index+1}); + end + end +end + +% Determine the position of the dialog - centered on the callback figure +% if available, else, centered on the screen +FigPos=get(0,'DefaultFigurePosition'); +OldUnits = get(hObject, 'Units'); +set(hObject, 'Units', 'pixels'); +OldPos = get(hObject,'Position'); +FigWidth = OldPos(3); +FigHeight = OldPos(4); +if isempty(gcbf) + ScreenUnits=get(0,'Units'); + set(0,'Units','pixels'); + ScreenSize=get(0,'ScreenSize'); + set(0,'Units',ScreenUnits); + + FigPos(1)=1/2*(ScreenSize(3)-FigWidth); + FigPos(2)=2/3*(ScreenSize(4)-FigHeight); +else + GCBFOldUnits = get(gcbf,'Units'); + set(gcbf,'Units','pixels'); + GCBFPos = get(gcbf,'Position'); + set(gcbf,'Units',GCBFOldUnits); + FigPos(1:2) = [(GCBFPos(1) + GCBFPos(3) / 2) - FigWidth / 2, ... + (GCBFPos(2) + GCBFPos(4) / 2) - FigHeight / 2]; +end +FigPos(3:4)=[FigWidth FigHeight]; +set(hObject, 'Position', FigPos); +set(hObject, 'Units', OldUnits); + +% Show a question icon from dialogicons.mat - variables questIconData +% and questIconMap +load dialogicons.mat + +IconData=questIconData; +questIconMap(256,:) = get(handles.figure1, 'Color'); +IconCMap=questIconMap; + +Img=image(IconData, 'Parent', handles.axes1); +set(handles.figure1, 'Colormap', IconCMap); + +set(handles.axes1, ... + 'Visible', 'off', ... + 'YDir' , 'reverse' , ... + 'XLim' , get(Img,'XData'), ... + 'YLim' , get(Img,'YData') ... + ); + +% Make the GUI modal +set(handles.figure1,'WindowStyle','modal') + + + +handles.Y=1; +handles.X=1; + +handles.check = 0; +handles.theta= 0; +handles.a4=0; +handles.a5=0; + + + +try + z=dlmread('calibration.txt'); + handles.Y=z(2); + handles.X=z(1); + handles.a4=z(3); + handles.a5=z(4); + tmp = handles.a4/handles.a5; + set(handles.edit_X, 'String',num2str(handles.X)); + set(handles.edit_Y, 'String',num2str(handles.Y)); + set(handles.edit_Resolition, 'String',num2str(tmp)); +catch + 1234 +end + + +handles.state ='No'; + + +guidata(hObject, handles); + + + + + + + + + +% UIWAIT makes gui_calibration_1 wait for user response (see UIRESUME) +uiwait(handles.figure1); + +% --- Outputs from this function are returned to the command line. +function varargout = gui_calibration_1_OutputFcn(hObject, eventdata, handles) +% varargout cell array for returning output args (see VARARGOUT); +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Get default command line output from handles structure +varargout{1} = handles.output; +if handles.check ==1; varargout{1} ='Cancel'; end +% The figure can be deleted now +varargout{2} = handles.theta; +varargout{3} = handles.a4; +varargout{4} = handles.a5; +varargout{5} = handles.state; + +dlmwrite('SessionConst.txt',[handles.theta, handles.a4, handles.a5]); + +guidata(hObject, handles); +delete(handles.figure1); + +% --- Executes on button press in push_done. +function push_done_Callback(hObject, eventdata, handles) +% hObject handle to push_done (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +handles.output = get(hObject,'String'); + +tmp =atan(handles.X/handles.Y); + handles.theta = tmp; + + +dlmwrite('calibration.txt',[handles.X,handles.Y, handles.a4, handles.a5]) +% Update handles structure +guidata(hObject, handles); + +% Use UIRESUME instead of delete because the OutputFcn needs +% to get the updated handles structure. +uiresume(handles.figure1); + +% --- Executes on button press in push_cancel. +function push_cancel_Callback(hObject, eventdata, handles) +% hObject handle to push_cancel (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +handles.output = get(hObject,'String'); + +% Update handles structure +guidata(hObject, handles); + +% Use UIRESUME instead of delete because the OutputFcn needs +% to get the updated handles structure. +uiresume(handles.figure1); + + +% --- Executes when user attempts to close figure1. +function figure1_CloseRequestFcn(hObject, eventdata, handles) +% hObject handle to figure1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +if isequal(get(hObject, 'waitstatus'), 'waiting') + % The GUI is still in UIWAIT, us UIRESUME + uiresume(hObject); +else + % The GUI is no longer waiting, just close it + delete(hObject); +end + + +% --- Executes on key press over figure1 with no controls selected. +function figure1_KeyPressFcn(hObject, eventdata, handles) +% hObject handle to figure1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Check for "enter" or "escape" +if isequal(get(hObject,'CurrentKey'),'escape') + % User said no by hitting escape + handles.output = 'No'; + + % Update handles structure + guidata(hObject, handles); + + uiresume(handles.figure1); +end + +if isequal(get(hObject,'CurrentKey'),'return') + uiresume(handles.figure1); +end + + + +function edit_Y_Callback(hObject, eventdata, handles) +% hObject handle to edit_Y (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_Y as text +% str2double(get(hObject,'String')) returns contents of edit_Y as a double +tmpY= str2double(get(hObject,'String')); +handles.Y =tmpY; +guidata(hObject, handles); + + +% --- Executes during object creation, after setting all properties. +function edit_Y_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_Y (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit_X_Callback(hObject, eventdata, handles) +% hObject handle to edit_X (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_X as text +% str2double(get(hObject,'String')) returns contents of edit_X as a double +tmpX = str2double(get(hObject,'String')); +handles.X =tmpX; +guidata(hObject, handles); + + +% --- Executes during object creation, after setting all properties. +function edit_X_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_X (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes when selected object is changed in uibuttongroup1. +function uibuttongroup1_SelectionChangedFcn(hObject, eventdata, handles) +% hObject handle to the selected object in uibuttongroup1 +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +c=get(hObject,'String'); + +switch(c) + case{'Set X and Y values (in cm)'} + set(handles.edit_X, 'Enable','on'); + set(handles.edit_Y, 'Enable','on'); + + + case{'Auto'} + handles.check = 2; %1 for Cancel + handles.state='Auto'; + set(handles.edit_X, 'Enable','off'); + set(handles.edit_Y, 'Enable','off'); + + +% Update handles structure +guidata(hObject, handles); +end + + + +function edit_Resolition_Callback(hObject, eventdata, handles) +% hObject handle to edit_Resolition (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit_Resolition as text +% str2double(get(hObject,'String')) returns contents of edit_Resolition as a double + + +% --- Executes during object creation, after setting all properties. +function edit_Resolition_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit_Resolition (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in check_Calculate_RES. +function check_Calculate_RES_Callback(hObject, eventdata, handles) +% hObject handle to check_Calculate_RES (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of check_Calculate_RES + +if (get(hObject,'Value') )==1 + i11= imread('im00.tif'); + [a1,a2,a3,a4]=gui_ask_cal_KNOWN_Point(i11); + handles.a5=sqrt((((a3(2)-a3(1))+(a2(2)-a2(1))).^2)); + handles.a4=a4; +end + +set(handles.edit_Resolition, 'String',num2str(handles.a4/handles.a5)); + +guidata(hObject, handles); + + +% --- Executes on button press in check_SetROI. +function check_SetROI_Callback(hObject, eventdata, handles) +% hObject handle to check_SetROI (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of check_SetROI + +if (get(hObject,'Value') )==1 + i11= imread('im00.tif'); + figure(99), + h = imshow(i11,[]); + title('Crop the ROI') + [~, yD ]= imcrop(h); + + if ~isempty(yD) + yD= round(yD); +% % im1 = im1( yD(2):yD(2)+yD(4),yD(1):yD(1)+yD(3),:); +% % im2 = im2( yD(2):yD(2)+yD(4),yD(1):yD(1)+yD(3),:); + dlmwrite('CropCordinate.txt',yD); + end + figure(99), + imshow(i11( yD(2):yD(2)+yD(4)-1,yD(1):yD(1)+yD(3)-1,:),[]); + pause(0.5); close(99); pause(0.5) + + +end +guidata(hObject, handles); diff --git a/src/dfp/gui_confirm_EXIT.m b/src/dfp/gui_confirm_EXIT.m new file mode 100644 index 0000000..16f6cc1 --- /dev/null +++ b/src/dfp/gui_confirm_EXIT.m @@ -0,0 +1,206 @@ +function varargout = gui_confirm_EXIT(varargin) +% GUI_CONFIRM_EXIT MATLAB code for gui_confirm_EXIT.fig +% GUI_CONFIRM_EXIT by itself, creates a new GUI_CONFIRM_EXIT or raises the +% existing singleton*. +% +% H = GUI_CONFIRM_EXIT returns the handle to a new GUI_CONFIRM_EXIT or the handle to +% the existing singleton*. +% +% GUI_CONFIRM_EXIT('CALLBACK',hObject,eventData,handles,...) calls the local +% function named CALLBACK in GUI_CONFIRM_EXIT.M with the given input arguments. +% +% GUI_CONFIRM_EXIT('Property','Value',...) creates a new GUI_CONFIRM_EXIT or raises the +% existing singleton*. Starting from the left, property value pairs are +% applied to the GUI before gui_confirm_EXIT_OpeningFcn gets called. An +% unrecognized property name or invalid value makes property application +% stop. All inputs are passed to gui_confirm_EXIT_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 + +% Edit the above text to modify the response to help gui_confirm_EXIT + +% Last Modified by GUIDE v2.5 09-Dec-2018 16:23:20 + +% Begin initialization code - DO NOT EDIT +gui_Singleton = 1; +gui_State = struct('gui_Name', mfilename, ... + 'gui_Singleton', gui_Singleton, ... + 'gui_OpeningFcn', @gui_confirm_EXIT_OpeningFcn, ... + 'gui_OutputFcn', @gui_confirm_EXIT_OutputFcn, ... + 'gui_LayoutFcn', [] , ... + 'gui_Callback', []); +if nargin && ischar(varargin{1}) + gui_State.gui_Callback = str2func(varargin{1}); +end + +if nargout + [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); +else + gui_mainfcn(gui_State, varargin{:}); +end +% End initialization code - DO NOT EDIT + +% --- Executes just before gui_confirm_EXIT is made visible. +function gui_confirm_EXIT_OpeningFcn(hObject, eventdata, handles, varargin) +% This function has no output args, see OutputFcn. +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +% varargin command line arguments to gui_confirm_EXIT (see VARARGIN) + +% Choose default command line output for gui_confirm_EXIT +handles.output = 'No'; + +% Update handles structure +guidata(hObject, handles); + +% Insert custom Title and Text if specified by the user +% Hint: when choosing keywords, be sure they are not easily confused +% with existing figure properties. See the output of set(figure) for +% a list of figure properties. +if(nargin > 3) + for index = 1:2:(nargin-3), + if nargin-3==index, break, end + switch lower(varargin{index}) + case 'title' + set(hObject, 'Name', varargin{index+1}); + case 'string' + set(handles.text1, 'String', varargin{index+1}); + end + end +end + +% Determine the position of the dialog - centered on the callback figure +% if available, else, centered on the screen +FigPos=get(0,'DefaultFigurePosition'); +OldUnits = get(hObject, 'Units'); +set(hObject, 'Units', 'pixels'); +OldPos = get(hObject,'Position'); +FigWidth = OldPos(3); +FigHeight = OldPos(4); +if isempty(gcbf) + ScreenUnits=get(0,'Units'); + set(0,'Units','pixels'); + ScreenSize=get(0,'ScreenSize'); + set(0,'Units',ScreenUnits); + + FigPos(1)=1/2*(ScreenSize(3)-FigWidth); + FigPos(2)=2/3*(ScreenSize(4)-FigHeight); +else + GCBFOldUnits = get(gcbf,'Units'); + set(gcbf,'Units','pixels'); + GCBFPos = get(gcbf,'Position'); + set(gcbf,'Units',GCBFOldUnits); + FigPos(1:2) = [(GCBFPos(1) + GCBFPos(3) / 2) - FigWidth / 2, ... + (GCBFPos(2) + GCBFPos(4) / 2) - FigHeight / 2]; +end +FigPos(3:4)=[FigWidth FigHeight]; +set(hObject, 'Position', FigPos); +set(hObject, 'Units', OldUnits); + +% Show a question icon from dialogicons.mat - variables questIconData +% and questIconMap +load dialogicons.mat + +IconData=questIconData; +questIconMap(256,:) = get(handles.figure1, 'Color'); +IconCMap=questIconMap; + +Img=image(IconData, 'Parent', handles.axes1); +set(handles.figure1, 'Colormap', IconCMap); + +set(handles.axes1, ... + 'Visible', 'off', ... + 'YDir' , 'reverse' , ... + 'XLim' , get(Img,'XData'), ... + 'YLim' , get(Img,'YData') ... + ); + +% Make the GUI modal +set(handles.figure1,'WindowStyle','modal') + +% UIWAIT makes gui_confirm_EXIT wait for user response (see UIRESUME) +uiwait(handles.figure1); + +% --- Outputs from this function are returned to the command line. +function varargout = gui_confirm_EXIT_OutputFcn(hObject, eventdata, handles) +% varargout cell array for returning output args (see VARARGOUT); +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Get default command line output from handles structure +varargout{1} = handles.output; + +% The figure can be deleted now +delete(handles.figure1); + +% --- Executes on button press in pushbutton1. +function pushbutton1_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +handles.output = get(hObject,'String'); + +% Update handles structure +guidata(hObject, handles); + +% Use UIRESUME instead of delete because the OutputFcn needs +% to get the updated handles structure. +uiresume(handles.figure1); + +% --- Executes on button press in pushbutton2. +function pushbutton2_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton2 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +handles.output = get(hObject,'String'); + +% Update handles structure +guidata(hObject, handles); + +% Use UIRESUME instead of delete because the OutputFcn needs +% to get the updated handles structure. +uiresume(handles.figure1); + + +% --- Executes when user attempts to close figure1. +function figure1_CloseRequestFcn(hObject, eventdata, handles) +% hObject handle to figure1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +if isequal(get(hObject, 'waitstatus'), 'waiting') + % The GUI is still in UIWAIT, us UIRESUME + uiresume(hObject); +else + % The GUI is no longer waiting, just close it + delete(hObject); +end + + +% --- Executes on key press over figure1 with no controls selected. +function figure1_KeyPressFcn(hObject, eventdata, handles) +% hObject handle to figure1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Check for "enter" or "escape" +if isequal(get(hObject,'CurrentKey'),'escape') + % User said no by hitting escape + handles.output = 'No'; + + % Update handles structure + guidata(hObject, handles); + + uiresume(handles.figure1); +end + +if isequal(get(hObject,'CurrentKey'),'return') + uiresume(handles.figure1); +end diff --git a/src/dfp/gui_set_destination.m b/src/dfp/gui_set_destination.m new file mode 100644 index 0000000..9aab6a2 --- /dev/null +++ b/src/dfp/gui_set_destination.m @@ -0,0 +1,232 @@ +function varargout = gui_set_destination(varargin) +% GUI_SET_DESTINATION MATLAB code for gui_set_destination.fig +% GUI_SET_DESTINATION by itself, creates a new GUI_SET_DESTINATION or raises the +% existing singleton*. +% +% H = GUI_SET_DESTINATION returns the handle to a new GUI_SET_DESTINATION or the handle to +% the existing singleton*. +% +% GUI_SET_DESTINATION('CALLBACK',hObject,eventData,handles,...) calls the local +% function named CALLBACK in GUI_SET_DESTINATION.M with the given input arguments. +% +% GUI_SET_DESTINATION('Property','Value',...) creates a new GUI_SET_DESTINATION or raises the +% existing singleton*. Starting from the left, property value pairs are +% applied to the GUI before gui_set_destination_OpeningFcn gets called. An +% unrecognized property name or invalid value makes property application +% stop. All inputs are passed to gui_set_destination_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 + +% Edit the above text to modify the response to help gui_set_destination + +% Last Modified by GUIDE v2.5 05-Oct-2018 17:01:10 + +% Begin initialization code - DO NOT EDIT +gui_Singleton = 1; +gui_State = struct('gui_Name', mfilename, ... + 'gui_Singleton', gui_Singleton, ... + 'gui_OpeningFcn', @gui_set_destination_OpeningFcn, ... + 'gui_OutputFcn', @gui_set_destination_OutputFcn, ... + 'gui_LayoutFcn', [] , ... + 'gui_Callback', []); +if nargin && ischar(varargin{1}) + gui_State.gui_Callback = str2func(varargin{1}); +end + +if nargout + [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); +else + gui_mainfcn(gui_State, varargin{:}); +end +% End initialization code - DO NOT EDIT + +% --- Executes just before gui_set_destination is made visible. +function gui_set_destination_OpeningFcn(hObject, eventdata, handles, varargin) +% This function has no output args, see OutputFcn. +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +% varargin command line arguments to gui_set_destination (see VARARGIN) + +% Choose default command line output for gui_set_destination +handles.output = 'Yes'; +handles.destination=varargin{1}; +% set(handles.edit2,'String',handles.destination); +set(handles.text2,'String',handles.destination); + +% Update handles structure +guidata(hObject, handles); + +% Insert custom Title and Text if specified by the user +% Hint: when choosing keywords, be sure they are not easily confused +% with existing figure properties. See the output of set(figure) for +% a list of figure properties. +if(nargin > 3) + for index = 1:2:(nargin-3), + if nargin-3==index, break, end + switch lower(varargin{index}) + case 'title' + set(hObject, 'Name', varargin{index+1}); + case 'string' + set(handles.text1, 'String', varargin{index+1}); + end + end +end + +% Determine the position of the dialog - centered on the callback figure +% if available, else, centered on the screen +FigPos=get(0,'DefaultFigurePosition'); +OldUnits = get(hObject, 'Units'); +set(hObject, 'Units', 'pixels'); +OldPos = get(hObject,'Position'); +FigWidth = OldPos(3); +FigHeight = OldPos(4); +if isempty(gcbf) + ScreenUnits=get(0,'Units'); + set(0,'Units','pixels'); + ScreenSize=get(0,'ScreenSize'); + set(0,'Units',ScreenUnits); + + FigPos(1)=1/2*(ScreenSize(3)-FigWidth); + FigPos(2)=2/3*(ScreenSize(4)-FigHeight); +else + GCBFOldUnits = get(gcbf,'Units'); + set(gcbf,'Units','pixels'); + GCBFPos = get(gcbf,'Position'); + set(gcbf,'Units',GCBFOldUnits); + FigPos(1:2) = [(GCBFPos(1) + GCBFPos(3) / 2) - FigWidth / 2, ... + (GCBFPos(2) + GCBFPos(4) / 2) - FigHeight / 2]; +end +FigPos(3:4)=[FigWidth FigHeight]; +set(hObject, 'Position', FigPos); +set(hObject, 'Units', OldUnits); + +% Show a question icon from dialogicons.mat - variables questIconData +% and questIconMap +load dialogicons.mat + +IconData=questIconData; +questIconMap(256,:) = get(handles.figure1, 'Color'); +IconCMap=questIconMap; + +Img=image(IconData, 'Parent', handles.axes1); +set(handles.figure1, 'Colormap', IconCMap); + +set(handles.axes1, ... + 'Visible', 'off', ... + 'YDir' , 'reverse' , ... + 'XLim' , get(Img,'XData'), ... + 'YLim' , get(Img,'YData') ... + ); + +% Make the GUI modal +set(handles.figure1,'WindowStyle','modal') + +% UIWAIT makes gui_set_destination wait for user response (see UIRESUME) +uiwait(handles.figure1); + +% --- Outputs from this function are returned to the command line. +function varargout = gui_set_destination_OutputFcn(hObject, eventdata, handles) +% varargout cell array for returning output args (see VARARGOUT); +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Get default command line output from handles structure +varargout{1} = handles.output; +try +varargout{1} = handles.output; +varargout{2} = handles.destination; +catch +end + +% The figure can be deleted now +delete(handles.figure1); + +% --- Executes on button press in pushbutton1. +function pushbutton1_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +handles.output = get(hObject,'String'); + +% Update handles structure +guidata(hObject, handles); + +% Use UIRESUME instead of delete because the OutputFcn needs +% to get the updated handles structure. +uiresume(handles.figure1); + +% --- Executes on button press in pushbutton2. +function pushbutton2_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton2 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +handles.output = get(hObject,'String'); + +% Update handles structure +guidata(hObject, handles); + +% Use UIRESUME instead of delete because the OutputFcn needs +% to get the updated handles structure. +uiresume(handles.figure1); + + +% --- Executes when user attempts to close figure1. +function figure1_CloseRequestFcn(hObject, eventdata, handles) +% hObject handle to figure1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +if isequal(get(hObject, 'waitstatus'), 'waiting') + % The GUI is still in UIWAIT, us UIRESUME + uiresume(hObject); +else + % The GUI is no longer waiting, just close it + delete(hObject); +end + + +% --- Executes on key press over figure1 with no controls selected. +function figure1_KeyPressFcn(hObject, eventdata, handles) +% hObject handle to figure1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Check for "enter" or "escape" +if isequal(get(hObject,'CurrentKey'),'escape') + % User said no by hitting escape + handles.output = 'No'; + + % Update handles structure + guidata(hObject, handles); + + uiresume(handles.figure1); +end + +if isequal(get(hObject,'CurrentKey'),'return') + uiresume(handles.figure1); +end + + +% --- Executes on button press in push_SetPath. +function push_SetPath_Callback(hObject, eventdata, handles) +% hObject handle to push_SetPath (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +[pathname] = uigetdir(handles.destination,'Select Destination Folder'); +handles.destination = pathname; +set(handles.text2,'String',handles.destination); +guidata(hObject, handles); + + +% --- Executes during object creation, after setting all properties. +function text2_CreateFcn(hObject, eventdata, handles) +% hObject handle to text2 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called diff --git a/src/dfp/phase_unwrap.m b/src/dfp/phase_unwrap.m new file mode 100644 index 0000000..41baf7f --- /dev/null +++ b/src/dfp/phase_unwrap.m @@ -0,0 +1,13 @@ +function phi = phase_unwrap(psi) + + dx = [zeros([size(psi,1),1]), wrapToPi(diff(psi, 1, 2)), zeros([size(psi,1),1])]; + dy = [zeros([1,size(psi,2)]); wrapToPi(diff(psi, 1, 1)); zeros([1,size(psi,2)])]; + rho = diff(dx, 1, 2) + diff(dy, 1, 1); + + RhoDct = dct2(rho); + [N, M] = size(rho); + [I, J] = meshgrid(0:M-1, 0:N-1); + dctPhi = RhoDct ./ 2 ./ (cos(pi*I/M) + cos(pi*J/N) - 2); + dctPhi(1,1) = 0; + phi = idct2(dctPhi); + \ No newline at end of file diff --git a/src/dfp/processImage1.m b/src/dfp/processImage1.m new file mode 100644 index 0000000..a2937b8 --- /dev/null +++ b/src/dfp/processImage1.m @@ -0,0 +1,91 @@ +function [data_Org,dataSX]= processImage1(I1, I2,wndo,spectra) + + +% % I1= handles.I1; +% % I2= handles.I2 ; + +%==================================== +wbar = waitbar(0.6,'Processing...'); +wbar .CloseRequestFcn = ''; + + mask = ones(size(I1)); + + %==================================== + + ft1 = fftshift(fft2(I1)); + ft0 =ft1; + ft2 = fftshift(fft2(I2)); + lmt1 = round(size(ft1,2)/2)+10; + ft1(:,1:lmt1)=0; + ft2(:,1:lmt1)=0; + + [r, c] = find(abs(ft1) == max(abs(ft1(:)))); + + lmt= round( (size(ft1,2)/2)+(c- (size(ft1,2)/2))/2); + + ft1(:,1:lmt)=0; + ft2(:,1:lmt)=0; + + cdata=ifft2(fftshift(ft2)).*conj(ifft2(fftshift(ft1))); + [N,M]=size(ft2); + + [val,fcx]=max(max(abs(ft2))); + [val,fcy]=max(max(abs(ft2).')); + fcxn=abs((fcx-M/2)/M); fcyn= abs((fcy-N/2)/N); + d=sqrt((N/2-fcy).^2+(M/2-fcx).^2); + + +% ============ Hilbert and freqn domain filtering +% % + [x y ]= meshgrid(1:size(I1,2),1:size(I1,1)); + FIL2d=zeros(size(I1)); + FIL2d(sqrt((x-fcx).^2+(y-fcy).^2)<=d/2)=1; + filter2d=fftshift(FIL2d); + + h1=(ifft2(fft2(I1).*filter2d)); + h2=(ifft2(fft2(I2).*filter2d)); + + Complex_Exp=h2.*conj(h1); + Ph_est=angle(Complex_Exp); + ex=20; + + sigma = 1/wndo; + cdata=cdata.*mask; + waitbar(0.66,wbar); pause(.2) + + + if strcmp(spectra,'All Pass') + g=WFT2(cdata,wndo,0,sigma,1.5*2*pi*fcxn,wndo,0,sigma,1.5*2*pi*fcyn); + elseif strcmp(spectra,'Band Pass') + g=WFT2(Complex_Exp,wndo,0,sigma,1.5*2*pi*fcxn,wndo,0,sigma,1.5*2*pi*fcyn); + end + + + + + Ph_WFT = (g.phase); + Ph_WFT=Ph_WFT(ex:N-ex,ex:M-ex); + sx = g.phase; + + %========================================== + + waitbar(0.8,wbar); + + Ph_FT1 = phase_unwrap(sx(ex:N-ex,ex:M-ex)); + +% Ph_FT1 =unwrapping(sx,1,5); + Ph_FT1=(Ph_FT1-(Ph_FT1(5,5))); + dd = dis_peak(ft0); +% d=86e-3/1700*dd; + [a4a5]=dlmread('SessionConst.txt'); + d=a4a5(2)/a4a5(3)*dd; + theta= a4a5(1); + + Hi = Ph_FT1/(2*pi*(1/d)*tan(theta)); + dataSX = sx(81:end-80,81:end-80)/(2*pi*(1/d)*tan(theta)); + + data_Org=Hi(41:end-40,41:end-40); + + waitbar(1,wbar); pause(0.1) + delete(wbar) + \ No newline at end of file diff --git a/src/dfp/processImage2.m b/src/dfp/processImage2.m new file mode 100644 index 0000000..77f96bc --- /dev/null +++ b/src/dfp/processImage2.m @@ -0,0 +1,95 @@ +function [data_Org,dataSX]= processImage2(I1, I2,wndo,spectra) + + +% % I1= handles.I1; +% % I2= handles.I2 ; + +%==================================== +wbar = waitbar(0.6,'Processing...'); +wbar .CloseRequestFcn = ''; + + mask = ones(size(I1)); + + %==================================== + + ft1 = fftshift(fft2(I1)); + ft0 =ft1; + ft2 = fftshift(fft2(I2)); + lmt1 = round(size(ft1,2)/2)+10; + ft1(:,1:lmt1)=0; + ft2(:,1:lmt1)=0; + + [r, c] = find(abs(ft1) == max(abs(ft1(:)))); + + lmt= round( (size(ft1,2)/2)+(c- (size(ft1,2)/2))/2); + + ft1(:,1:lmt)=0; + ft2(:,1:lmt)=0; + + cdata=ifft2(fftshift(ft2)).*conj(ifft2(fftshift(ft1))); + [N,M]=size(ft2); + + [val,fcx]=max(max(abs(ft2))); + [val,fcy]=max(max(abs(ft2).')); + fcxn=abs((fcx-M/2)/M); fcyn= abs((fcy-N/2)/N); + d=sqrt((N/2-fcy).^2+(M/2-fcx).^2); + + +% ============ Hilbert and freqn domain filtering +% % + [x y ]= meshgrid(1:size(I1,2),1:size(I1,1)); + FIL2d=zeros(size(I1)); + FIL2d(sqrt((x-fcx).^2+(y-fcy).^2)<=d/2)=1; + filter2d=fftshift(FIL2d); + + h1=(ifft2(fft2(I1).*filter2d)); + h2=(ifft2(fft2(I2).*filter2d)); + + Complex_Exp=h2.*conj(h1); + Ph_est=angle(Complex_Exp); + ex=20; + + sigma = 1/wndo; + cdata=cdata.*mask; + waitbar(0.66,wbar); pause(.2) + +% g=wft2f('wfr',cdata,wndo,0,sigma,1.5*2*pi*fcxn,wndo,0,sigma,1.5*2*pi*fcyn,6); +% g=WFT2(cdata,wndo,0,sigma,1.5*2*pi*fcxn,wndo,0,sigma,1.5*2*pi*fcyn); + + if strcmp(spectra,'All Pass') + g=WFT2(cdata,wndo,0,sigma,1.5*2*pi*fcxn,wndo,0,sigma,1.5*2*pi*fcyn); + elseif strcmp(spectra,'Band Pass') + g=WFT2(Complex_Exp,wndo,0,sigma,1.5*2*pi*fcxn,wndo,0,sigma,1.5*2*pi*fcyn); + end + + + + +% % % % Ph_WFT = (g.phase); +% % % % Ph_WFT=Ph_WFT(ex:N-ex,ex:M-ex); + sx = g.phase; + + %========================================== + + waitbar(0.8,wbar); + + % Ph_FT1 = cunwrap(sx); + Ph_FT1 = phase_unwrap(sx(ex:N-ex,ex:M-ex)); + +% Ph_FT1 =unwrapping(sx,1,5); + Ph_FT1=(Ph_FT1-(Ph_FT1(5,5))); + dd = dis_peak(ft0); +% d=86e-3/1700*dd; + [a4a5]=dlmread('SessionConst.txt'); + d=a4a5(2)/a4a5(3)*dd; + theta= a4a5(1); + + + Hi = Ph_FT1/(2*pi*(1/d)*tan(theta)); + dataSX = sx(81:end-80,81:end-80)/(2*pi*(1/d)*tan(theta)); + + data_Org=Hi(41:end-40,41:end-40); + + waitbar(1,wbar); pause(0.1) + delete(wbar) + \ No newline at end of file diff --git a/src/dfp/unwrapping.m b/src/dfp/unwrapping.m new file mode 100644 index 0000000..5ee793d --- /dev/null +++ b/src/dfp/unwrapping.m @@ -0,0 +1,60 @@ +%unwrapped_phase=unwrapping(original_phase,original_x,original_y); +% +%This function is to unwrap the phase for comparison use +%input the original phase and output the unwrapped phase +%original_x,original_y is the starting point, which defaults to the central point of the map + + + +function unwrapped_phase=wrap(original_phase,original_x,original_y); + +error(nargchk(1,3,nargin)); + +[M,N]=size(original_phase); + +if (nargin==1) + original_x=round(M/2); + original_y=round(N/2); +end +if (nargin==2) + original_y=original_x; +end + +unwrapped_phase=original_phase; + +%fixed row +for (j=original_y+1:N) + while (unwrapped_phase(original_x,j)-unwrapped_phase(original_x,j-1)>pi) + unwrapped_phase(original_x,j)=unwrapped_phase(original_x,j)-2*pi; + end + while (unwrapped_phase(original_x,j)-unwrapped_phase(original_x,j-1)<-pi) + unwrapped_phase(original_x,j)=unwrapped_phase(original_x,j)+2*pi; + end +end +for (j=original_y-1:-1:1) + while (unwrapped_phase(original_x,j)-unwrapped_phase(original_x,j+1)>pi) + unwrapped_phase(original_x,j)=unwrapped_phase(original_x,j)-2*pi; + end + while (unwrapped_phase(original_x,j)-unwrapped_phase(original_x,j+1)<-pi) + unwrapped_phase(original_x,j)=unwrapped_phase(original_x,j)+2*pi; + end +end + +for (j=1:N) + for (i=original_x+1:M) + while (unwrapped_phase(i,j)-unwrapped_phase(i-1,j)>pi) + unwrapped_phase(i,j)=unwrapped_phase(i,j)-2*pi; + end + while (unwrapped_phase(i,j)-unwrapped_phase(i-1,j)<-pi) + unwrapped_phase(i,j)=unwrapped_phase(i,j)+2*pi; + end + end + for (i=original_x-1:-1:1) + while (unwrapped_phase(i,j)-unwrapped_phase(i+1,j)>pi) + unwrapped_phase(i,j)=unwrapped_phase(i,j)-2*pi; + end + while (unwrapped_phase(i,j)-unwrapped_phase(i+1,j)<-pi) + unwrapped_phase(i,j)=unwrapped_phase(i,j)+2*pi; + end + end +end diff --git a/src/images/CalibrationIcon.png b/src/images/CalibrationIcon.png new file mode 100644 index 0000000..0901d21 Binary files /dev/null and b/src/images/CalibrationIcon.png differ diff --git a/src/images/Shan_Logo2.png b/src/images/Shan_Logo2.png new file mode 100644 index 0000000..c173b79 Binary files /dev/null and b/src/images/Shan_Logo2.png differ diff --git a/src/images/Shan_Logo3.png b/src/images/Shan_Logo3.png new file mode 100644 index 0000000..a358327 Binary files /dev/null and b/src/images/Shan_Logo3.png differ diff --git a/src/images/Shan_Logo4.png b/src/images/Shan_Logo4.png new file mode 100644 index 0000000..820bbbd Binary files /dev/null and b/src/images/Shan_Logo4.png differ diff --git a/src/images/calib.tif b/src/images/calib.tif new file mode 100644 index 0000000..d4a6e67 Binary files /dev/null and b/src/images/calib.tif differ diff --git a/src/images/height1.png b/src/images/height1.png new file mode 100644 index 0000000..00cb7f2 Binary files /dev/null and b/src/images/height1.png differ diff --git a/src/images/height1.tif b/src/images/height1.tif new file mode 100644 index 0000000..98dcdf7 Binary files /dev/null and b/src/images/height1.tif differ diff --git a/src/images/height11.png b/src/images/height11.png new file mode 100644 index 0000000..79592d7 Binary files /dev/null and b/src/images/height11.png differ diff --git a/src/images/iisc_logo.png b/src/images/iisc_logo.png new file mode 100644 index 0000000..2bdc94c Binary files /dev/null and b/src/images/iisc_logo.png differ diff --git a/src/images/im0.tif b/src/images/im0.tif new file mode 100644 index 0000000..f9c999a Binary files /dev/null and b/src/images/im0.tif differ diff --git a/src/images/im00.tif b/src/images/im00.tif new file mode 100644 index 0000000..c918f27 Binary files /dev/null and b/src/images/im00.tif differ diff --git a/src/images/im1.tif b/src/images/im1.tif new file mode 100644 index 0000000..20330b7 Binary files /dev/null and b/src/images/im1.tif differ diff --git a/src/images/lines.png b/src/images/lines.png new file mode 100644 index 0000000..b5daaad Binary files /dev/null and b/src/images/lines.png differ diff --git a/src/images/p1.png b/src/images/p1.png new file mode 100644 index 0000000..934e492 Binary files /dev/null and b/src/images/p1.png differ diff --git a/src/txt/CaliObject.txt b/src/txt/CaliObject.txt new file mode 100644 index 0000000..183b29f --- /dev/null +++ b/src/txt/CaliObject.txt @@ -0,0 +1 @@ +3e-3 \ No newline at end of file diff --git a/src/txt/Checking.txt b/src/txt/Checking.txt new file mode 100644 index 0000000..ed532d2 --- /dev/null +++ b/src/txt/Checking.txt @@ -0,0 +1 @@ +34.263,0.21,1900.7,0.30162 diff --git a/src/txt/CropCordinate.txt b/src/txt/CropCordinate.txt new file mode 100644 index 0000000..c1259ac --- /dev/null +++ b/src/txt/CropCordinate.txt @@ -0,0 +1 @@ +796,256,1752,1824 diff --git a/src/txt/SessionConst.txt b/src/txt/SessionConst.txt new file mode 100644 index 0000000..d63931b --- /dev/null +++ b/src/txt/SessionConst.txt @@ -0,0 +1 @@ +0.2834,0.17,1944.7 diff --git a/src/txt/calibration.txt b/src/txt/calibration.txt new file mode 100644 index 0000000..a677386 --- /dev/null +++ b/src/txt/calibration.txt @@ -0,0 +1 @@ +13.106,45,0.17,1944.7 diff --git a/src/txt/camset.txt b/src/txt/camset.txt new file mode 100644 index 0000000..564ef9d --- /dev/null +++ b/src/txt/camset.txt @@ -0,0 +1,4 @@ +50 +12 +-4 +5710 \ No newline at end of file diff --git a/src/txt/defaultCamSet.txt b/src/txt/defaultCamSet.txt new file mode 100644 index 0000000..564ef9d --- /dev/null +++ b/src/txt/defaultCamSet.txt @@ -0,0 +1,4 @@ +50 +12 +-4 +5710 \ No newline at end of file diff --git a/src/txt/selectCamera.txt b/src/txt/selectCamera.txt new file mode 100644 index 0000000..99de5bf --- /dev/null +++ b/src/txt/selectCamera.txt @@ -0,0 +1 @@ +3dFrImager diff --git a/src/ui/Calibration_Scanner_3D_v2.fig b/src/ui/Calibration_Scanner_3D_v2.fig new file mode 100644 index 0000000..d47afd9 Binary files /dev/null and b/src/ui/Calibration_Scanner_3D_v2.fig differ diff --git a/src/ui/Interactive_GUI.fig b/src/ui/Interactive_GUI.fig new file mode 100644 index 0000000..fd23656 Binary files /dev/null and b/src/ui/Interactive_GUI.fig differ diff --git a/src/ui/Scanner_3D_v2.fig b/src/ui/Scanner_3D_v2.fig new file mode 100644 index 0000000..0be1e28 Binary files /dev/null and b/src/ui/Scanner_3D_v2.fig differ diff --git a/src/ui/gui_CompleteCalib_Msg.fig b/src/ui/gui_CompleteCalib_Msg.fig new file mode 100644 index 0000000..e9dc1a1 Binary files /dev/null and b/src/ui/gui_CompleteCalib_Msg.fig differ diff --git a/src/ui/gui_StartProfiling.fig b/src/ui/gui_StartProfiling.fig new file mode 100644 index 0000000..83e296f Binary files /dev/null and b/src/ui/gui_StartProfiling.fig differ diff --git a/src/ui/gui_WantCalibration.fig b/src/ui/gui_WantCalibration.fig new file mode 100644 index 0000000..2e4462b Binary files /dev/null and b/src/ui/gui_WantCalibration.fig differ diff --git a/src/ui/gui_ask_cal_KNOWN_Point.fig b/src/ui/gui_ask_cal_KNOWN_Point.fig new file mode 100644 index 0000000..18a1e57 Binary files /dev/null and b/src/ui/gui_ask_cal_KNOWN_Point.fig differ diff --git a/src/ui/gui_calibration_1.fig b/src/ui/gui_calibration_1.fig new file mode 100644 index 0000000..cb743a2 Binary files /dev/null and b/src/ui/gui_calibration_1.fig differ diff --git a/src/ui/gui_confirm_EXIT.fig b/src/ui/gui_confirm_EXIT.fig new file mode 100644 index 0000000..b2634b2 Binary files /dev/null and b/src/ui/gui_confirm_EXIT.fig differ diff --git a/src/ui/gui_set_destination.fig b/src/ui/gui_set_destination.fig new file mode 100644 index 0000000..19f4a0f Binary files /dev/null and b/src/ui/gui_set_destination.fig differ