フィルターのクリア

Operator '+' is not supported for operands of type 'matlab.gr​aphics.pri​mitive.Ima​ge'

17 ビュー (過去 30 日間)
Md Shahidul Islam
Md Shahidul Islam 2021 年 8 月 14 日
コメント済み: Md Shahidul Islam 2021 年 8 月 14 日
I try to append image from tvec_json to 'tvec' array but I face this problem. Please anyone help. Here is my code below:
input_name = "output_wp2camera.json";
raw = fileread(input_name);
input_params = jsondecode(raw);
camera_matrix = input_params.camera_matrix;
dist = input_params.dist_coefs;
tvec_json = input_params.translational_vectors;
rvec_json = input_params.rotational_vectors;
tvec = [];
rvec = [];
len = length(tvec_json);
for i = 1:len
tvec.append(array(tvec_json(image + string(i))))
rvec.append(array(rvec_json(image + string(i))))
end

回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 8 月 14 日
You did not assign a value to a variable named image, so image is being found as a function. Your line
tvec.append(array(tvec_json(image + string(i))))
is equivalent to
tvec.append(array(tvec_json(image() + string(i))))
We recommend that you avoid using image as the name of a variable to prevent running into this kind of problem.
  4 件のコメント
Walter Roberson
Walter Roberson 2021 年 8 月 14 日
It appears that image is intended to be a constant there, rather than a variable name.
tvec.append(array(tvec_json("image" + string(i))))
Md Shahidul Islam
Md Shahidul Islam 2021 年 8 月 14 日
Thank you so much for your support and suggestion

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

カテゴリ

Help Center および File ExchangeJSON Format についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by