App Designeで画像を表示しようとしたときにエラーがでてしまう
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
大輝 隅岡
le 6 Fév 2023
Réponse apportée : Kojiro Saito
le 6 Fév 2023
現在,App DesigneでMATLA mobileをインストールしたスマホのカメラで撮影した画像をフォルダに保存し,撮影ごとに,画像を表示していくアプリを作っています.
しかし,撮影した画像がフォルダに保存はされるのですが,下画像のようにエラーがでて表示がされません.
コード,エラー,アプリ画像は以下の通りです.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1285615/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1285620/image.png)
clc
clear
m = mobiledev;
cam = camera(m,'back');
cam.Autofocus = 'on';
for i = 1:100
img = cam.snapshot('manual');
HSV = rgb2hsv(img);
RED = (0.257<= HSV(:,:,1) <= 0.47)
BW2 = imfill(RED,'holes');
fname = [char(datetime('now','Format','yyyy-MM-dd HHmmSS')),'.jpg'];
imwrite(img,['指定したファイル1',fname]);
imwrite(BW2,['指定したファイル2',fname])
imagesc(app.UIAxes,imrotate(BW2,-90));
imagesc(app.UIAxes_2, imrotate(img,-90));
colormap(app.UIAxes,gray);
end
clear
よろしくお願いします.
0 commentaires
Réponse acceptée
Kojiro Saito
le 6 Fév 2023
冒頭のclearが原因のようです。App Designerのアプリは、appというルートオブジェクトにプロパティやコンポーネントがぶら下がります。
ボタン押し下げ時のコールバックでclearをしてしまっているので、このappという変数が消去されてしまい、app.UIAxesのコンポーネントにアクセスできなくなっています。
ButtonPushed関数の2行目と末尾の「clear」を削除してみてください。
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur App Designer を使用したアプリ開発 dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!