2016-05-15 14 views
0

MATLABでは、画像をロードし、それがどの通貨であるかを検出する画像認識アプリケーションを作成しました。 MATLABでは、GUI表示とMATLAB環境内でうまく動作するすべてのプログラムを何千回も実行しました。MATLAB GUI実行可能ウィンドウアプリケーションは表示されません

しかし、プロジェクトをMATLABを介して実行可能ファイルに変換すると、GUIは表示されませんが、バックグラウンドで実行されるため、プログラムを手動で閉じるためにタスクマネージャに移動する必要があります。私は自分のPC用にMATLAB Runtimeをインストールしました。

私はテストを行い、ただ1つのボタンで簡単なGUIを作成し、それを実行可能ファイルに変換し、GUIの内容をうまく表示しました。だから私は、MATLABには何も問題はないことを知っています。

私はコマンドウィンドウで実行可能なイメージ認識を実行し、このエラーが発生しました。

java.lang.IllegalStateException: ActionData AbstractNamedUniqueID object with unique ID 'close-genome-desktop' and user-visible name 'Exit NGS Browser'. is already registered. 
    at com.mathworks.mwswing.binding.KeyBindingManager.throwError(KeyBindingManager.java:623) 
    at com.mathworks.mwswing.binding.KeyBindingManager.addAction(KeyBindingManager.java:201) 
    at com.mathworks.mwswing.binding.KeyBindingManager.parseAndRegisterActions(KeyBindingManager.java:71) 
    at com.mathworks.services.binding.MatlabKeyBindings.addActionFile(MatlabKeyBindings.java:666) 
    at com.mathworks.services.binding.MatlabKeyBindings.readActionAndContextFilesFromOSGi(MatlabKeyBindings.java:639) 
    at com.mathworks.services.binding.MatlabKeyBindings.<clinit>(MatlabKeyBindings.java:592) 
    at com.mathworks.widgets.action.BaseAbstractAction.<init>(BaseAbstractAction.java:24) 
    at com.mathworks.widgets.action.AbstractNewAction.<init>(AbstractNewAction.java:24) 
    at com.mathworks.hg.peer.FiguresGroup$NewFigureAction.<init>(FiguresGroup.java:78) 
    at com.mathworks.hg.peer.FiguresGroup.createToolBar(FiguresGroup.java:68) 
    at com.mathworks.hg.peer.FiguresGroup.<init>(FiguresGroup.java:43) 
    at com.mathworks.hg.peer.FiguresGroup.getInstance(FiguresGroup.java:52) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    at com.mathworks.widgets.desk.DTGroup.createPropertyProvider(DTGroup.java:253) 
    at com.mathworks.widgets.desk.DTGroup.getPropertyProvider(DTGroup.java:190) 
    at com.mathworks.widgets.desk.DTOccupant.getProperty(DTOccupant.java:748) 
    at com.mathworks.widgets.desk.DTOccupant.getToolstripTabs(DTOccupant.java:520) 
    at com.mathworks.widgets.desk.DTGroup.add(DTGroup.java:345) 
    at com.mathworks.widgets.desk.Desktop.addClient(Desktop.java:6569) 
    at com.mathworks.widgets.desk.Desktop.addClient(Desktop.java:6536) 
    at com.mathworks.widgets.desk.Desktop.addSingletons(Desktop.java:5603) 
    at com.mathworks.mde.desk.MLDesktop.<init>(MLDesktop.java:554) 
    at com.mathworks.mde.desk.MLDesktop.getInstance(MLDesktop.java:615) 
    at com.mathworks.mde.desk.MLDesktopRegistrar.getDesktop(MLDesktopRegistrar.java:11) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    at com.mathworks.mlservices.MLServices.getRegisteredService(MLServices.java:29) 
    at com.mathworks.mlservices.MatlabDesktopServices.<clinit>(MatlabDesktopServices.java:14) 
    at com.mathworks.hg.peer.FigureClientProxy.getMatlabDesktop(FigureClientProxy.java:504) 
    at com.mathworks.hg.peer.FigureClientProxy.<init>(FigureClientProxy.java:92) 
    at com.mathworks.hg.peer.HG2FigureClientProxy.<init>(HG2FigureClientProxy.java:20) 
    at com.mathworks.hg.peer.FigureHG2Mediator.<init>(FigureHG2Mediator.java:43) 
    at com.mathworks.hg.peer.HG2FigurePeer.createFigureClient(HG2FigurePeer.java:74) 
    at com.mathworks.hg.peer.FigurePeer.doInitializePeer(FigurePeer.java:454) 
    at com.mathworks.hg.peer.FigurePeer$2.run(FigurePeer.java:419) 
    at com.mathworks.jmi.AWTUtilities$Invoker$5$1.run(AWTUtilities.java:591) 
    at com.mathworks.mvm.context.ThreadContext$1.call(ThreadContext.java:76) 
    at com.mathworks.mvm.context.ThreadContext.callWithContext(ThreadContext.java:105) 
    at com.mathworks.mvm.context.ThreadContext.runWithContext(ThreadContext.java:73) 
    at com.mathworks.mvm.context.MvmContext.runWithContext(MvmContext.java:107) 
    at com.mathworks.jmi.AWTUtilities$Invoker$5.runWithOutput(AWTUtilities.java:588) 
    at com.mathworks.jmi.AWTUtilities$Invoker$2.watchedRun(AWTUtilities.java:475) 
    at com.mathworks.jmi.AWTUtilities$WatchedRunnable.run(AWTUtilities.java:436) 
    at java.awt.event.InvocationEvent.dispatch(Unknown Source) 
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source) 
    at java.awt.EventQueue.access$200(Unknown Source) 
    at java.awt.EventQueue$3.run(Unknown Source) 
    at java.awt.EventQueue$3.run(Unknown Source) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) 
    at java.awt.EventQueue.dispatchEvent(Unknown Source) 
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
    at java.awt.EventDispatchThread.run(Unknown Source) 
Warning: Unable to create com.mathworks.hg.peer.FiguresGroup, for details see 
C:\Users\ELECTR~1\AppData\Local\Temp\MATLABDesktopCreateError.log 

そして、これはすべて私の関数を呼び出し、GUIイベントのアクションを持っている私のメインのファイルである - 私はこれに追加されたコードの唯一の部分は(私はそれをコメントしたImage.m

function varargout = Image(varargin) 
% IMAGE MATLAB code for Image.fig 
%  IMAGE, by itself, creates a new IMAGE or raises the existing 
%  singleton*. 
% 
%  H = IMAGE returns the handle to a new IMAGE or the handle to 
%  the existing singleton*. 
% 
%  IMAGE('CALLBACK',hObject,eventData,handles,...) calls the local 
%  function named CALLBACK in IMAGE.M with the given input arguments. 
% 
%  IMAGE('Property','Value',...) creates a new IMAGE or raises the 
%  existing singleton*. Starting from the left, property value pairs are 
%  applied to the GUI before Image_OpeningFcn gets called. An 
%  unrecognized property name or invalid value makes property application 
%  stop. All inputs are passed to Image_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 Image 

% Last Modified by GUIDE v2.5 14-May-2016 19:14:58 

% Begin initialization code - DO NOT EDIT 
gui_Singleton = 1; 
gui_State = struct('gui_Name',  mfilename, ... 
        'gui_Singleton', gui_Singleton, ... 
        'gui_OpeningFcn', @Image_OpeningFcn, ... 
        'gui_OutputFcn', @Image_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 Image is made visible. 
function Image_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 Image (see VARARGIN) 

% Choose default command line output for Image 
handles.output = hObject; 

% Update handles structure 
guidata(hObject, handles); 

% UIWAIT makes Image wait for user response (see UIRESUME) 
% uiwait(handles.figure1); 


% --- Outputs from this function are returned to the command line. 
function varargout = Image_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 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) 
global im im2 
[path,user_cance]=imgetfile(); 
if user_cance 
    msgbox(sprintf('Error'),'Error','Error'); 
    return 
end 
im=imread(path); 
im=im2double(im); %converts to double 
im2=im; %for backup process :) 
axes(handles.axes1); 
imshow(im); 
currency = ClassImages(path) 
set(handles.edit1,'String',currency) 

% --- 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) 


% --- Executes on button press in pushbutton3. 
function pushbutton3_Callback(hObject, eventdata, handles) 
% hObject handle to pushbutton3 (see GCBO) 
% 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 pushbutton4. 
function pushbutton4_Callback(hObject, eventdata, handles) 
% hObject handle to pushbutton4 (see GCBO) 
% eventdata reserved - to be defined in a future version of MATLAB 
% handles structure with handles and user data (see GUIDATA) 


% --- Executes on slider movement. 
function slider1_Callback(hObject, eventdata, handles) 
% hObject handle to slider1 (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 


% --- Executes during object creation, after setting all properties. 
function slider1_CreateFcn(hObject, eventdata, handles) 
% hObject handle to slider1 (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 



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 


% --- 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 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) 
global im im2 %Hold two images im-Main-Image im2-Second-Image 
[path,user_cance]=imgetfile(); % Push button and store the path of the image in path 
if user_cance 
    msgbox(sprintf('Error'),'Error','Error'); % If Image is not found display error 
    return 
end 
im=imread(path); %Read image and store in im 
im=im2double(im); %converts to double 
im2=im; %for backup process :) 
axes(handles.axes1); % Display the image on the axes 
imshow(im); %Show Image 
currency = ClassImages(path) % Stores the currency of the image in currency 
set(handles.edit1,'String',currency) %Sets edit box in the GUI to the value of the currency 

私はいただきました!間違っ見当がつかない、それはMATLABでそれを実行するときに正常に動作しますが、それは実行可能なアプリケーションになったときにクラッシュします。

答えて

0

はい私はそれを解決できました。最初はMATLAB R2016aを使用していました。そして、MATLABが次のMATLABアプリケーションのセットで段階的に廃止されるという古い関数を使用していました。古い関数を削除し、それを実行可能ファイルに再コンパイルすると、それは機能しました。したがって、当初、MATLAB Runtime for R2016aはライブラリ内にその機能を持っていませんでした。しかし、私のアプリケーションが機能するためには、その機能が必要でした。だから私はMATLAB R2015aにダウングレードし、私の実行ファイルは古い関数を含んでいました。

関連する問題