4

MATLAB コードを C コードに変換するための MathWorks ガイドに従っています。最初のステップは入力することです

%#codegen

Cコードに変換したいすべての関数の後、しかしそうすると、以下のコードで次のプロンプトが表示されます。

function lanes=find_lanes(B,h, stats)
% Find the regions that look like lanes
%#codegen

lanes = {};
l=0;
    for k = 1:length(B)
    metric = stats(k).MajorAxisLength/stats(k).MinorAxisLength;
    %testlane(k);
    %end
    %function testlane(k)
        coder.inline('never');
        if metric > 5 & all(B{k}(:,1)>100)
            l=l+1;
            lanes(l,:)=B(k);
        else
            delete(h(k))
        end
    end
end

中括弧の周り:

コード生成は、"varargin" および "varargout" のセル操作のみをサポートします

別のプロンプトは言う

コード生成は、インデックス作成による可変の「レーン」サイズの増加をサポートしていません

レーンが2回目に言及された場所。

関数の入力引数は次のとおりです。

B - Is the output of the bwboundaries Image Processing toolbox function. It is a P-by-1 cell array, where P is the number of objects and holes. Each cell in the cell array contains a Q-by-2 matrix. Each row in the matrix contains the row and column coordinates of a boundary pixel. Q is the number of boundary pixels for the corresponding region.

h - plots the boundaries of the objects with a green outline while being a matrix of size 1 X length(B), holding the values of the boundaries like so like so:

h(K)=plot(boundary(:,2), boundary(:,1), 'g', 'LineWidth', 2);//boundary(:,1) - Y coordinate, boundary(:,2) - X coordinate.

stats - 19x1 struct array acquired using the regionprops function from the Image Processing toolbox with fields: MajorAxisLength and MinorAxisLength (of the object)

このエラーを解決するために、ご意見をお寄せいただければ幸いです。前もって感謝します!

4

2 に答える 2

5

コード生成に関するいくつかのポイント -

  1. MATLAB および Image Processing Toolbox の関数のサブセットのみがコード生成をサポートします - Image Processing Toolbox はコード生成をサポートします

  2. セル配列はまだコード生成をサポートしていません -セル配列のサポート

  3. あなたのコードでは、変数が大きくなっているようです。つまり、配列の初期サイズがワークフローをサポートできていません。可変サイズの入力のコード生成に従う必要があります。

于 2013-12-09T19:32:33.960 に答える