What are compile-time constant?

11 ビュー (過去 30 日間)
JAI PRAKASH
JAI PRAKASH 2019 年 3 月 8 日
コメント済み: Walter Roberson 2019 年 3 月 8 日
Hi I want to generate a MEX file for following function
function RGB = test(I)
RGB = insertShape(I,'circle',[150 280 35],'LineWidth',5,'Color', 'green');
I am using following cmds to generate .mex file
I = imread('peppers.png');
codegen('test.m','-args',{I})
Error: '??? COLOR must be numeric for code generation'
In insertshape doc it is mentioned that. 'Color' and 'SmoothEdges' must be compile-time constants.
I dont understand this instruction.

採用された回答

Walter Roberson
Walter Roberson 2019 年 3 月 8 日
use [0 1 0] for the color instead of 'green'
  2 件のコメント
JAI PRAKASH
JAI PRAKASH 2019 年 3 月 8 日
[0 1 0] is for black I see.
Anyways what are the codes for other colors?
Thanks
Walter Roberson
Walter Roberson 2019 年 3 月 8 日
Ah. There are two competing conventions for indicating RGB color values. One uses values in the range 0 to 1; the other one uses values in the range 0 to 255. So green would be [0 255 0]
There is a partial table at https://xkcd.com/color/rgb/ . The representation there is given in hex. For example 'pig pink', #e78ea5 would correspond to [hex2dec('e7'), hex2dec('8e'), hex2dec('a5')] or [231 142 165]

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Coder についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by