![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/196085/image.jpeg)
SimulinkへのfasterRCNNObjectDetectorクラスの読み込み方法について
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Shuto Higashi
il 19 Set 2018
Commentato: Shuto Higashi
il 20 Set 2018
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/196189/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/196190/image.png)
上記のようなSimulinkブロックを作成し、matファイルに保存している学習済みのFaster R-CNN(fasterRCNNObjectDetectorクラス)をloadしようとしたのですが、以下のようなエラーが出ます。
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/196191/image.png)
そのほかFrom WorkspaceブロックやFrom Fileブロックを用いてロードしようとしても同様にサポートされていないとエラーが表示されます。
こちらのwebセミナーではSimulink上でFaster R-CNNが扱えるといった旨の解説がなされているのですが、具体的な読み込み方法についてご存知の方がいらしたらお教えください。
0 Commenti
Risposta accettata
Tohru Kikawada
il 20 Set 2018
MATLAB Functionブロックの中ではコード生成可能な関数のみ記述ができます。
fasterRCNNObjectDetector はコード生成に対応していないため、MATLAB Functionブロックの中に直接記述することはできません。 coder.extrinsic を使って外部関数としてMATLAB側で実行するように宣言する必要があります。
具体的には下記のような記述になります。 coder.extrinsic 宣言した関数はコード生成はできませんのでご注意ください。
MATLAB Functionブロックの記述例:
function Iout = myFasterRCNNDetecter(I)
coder.extrinsic('detectFasterRCNN');
Iout = zeros(128,194,3,'uint8');
Iout = detectFasterRCNN(I);
end
MATLAB Functionブロックから呼び出す detectFasterRCNN.m の記述例:
function I = detectFasterRCNN(I)
persistent detector
if isempty(detector)
data = load('fasterRCNNVehicleTrainingData.mat');
detector = data.detector;
end
[bboxes,scores] = detect(detector,I);
if ~isempty(scores)
I = insertObjectAnnotation(I,'rectangle',bboxes,scores);
end
end
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/196085/image.jpeg)
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!