I am facing two issues when using codegen on my code. I have attached images of my code for reference.
1) The error report recognises cameraPoses as a struct even though it is a 2x2 table when I run the code. When I take the values in cameraPoses and make camPoses (as shown in the image), that is recognised as a table.
2) Once I use camPoses in Bundle Adjustment, I get a codegen error that says 'This function does not support one-dimensional indexing. I am not sure what that means because my variable dimensions match the documentation. I have also attached images of my variables and their dimensions.

 채택된 답변

Matt
Matt 2026년 7월 16일
편집: Matt 2026년 7월 16일

1 개 추천

The issue is not your runtime dimensions. Instead, tt is a codegen representation/type issue.
In MATLAB R2026a, the codegen implementation of imageviewset/poses returns a struct:
struct('ViewId', viewsId, 'AbsolutePose', absPoses)
So the report calling "cameraPoses" a struct is expected, even though normal MATLAB execution shows a 2x2 table.
cameraPoses = poses(vSetKeyFrames);
viewIds = uint32(cameraPoses.ViewId(:));
numViews = numel(viewIds);
absolutePose = cell(numViews, 1);
for k = 1:numViews
absolutePose{k} = cameraPoses.AbsolutePose(k);
end
camPoses = table(viewIds, absolutePose, ...
'VariableNames', {'ViewId', 'AbsolutePose'});
[refinedPoints, refinedAbsPoses] = bundleAdjustment( ...
xyzWorldPoints, tracks, camPoses, intrinsics, ...
'FixedViewIDs', uint32(1), BAParams.full{:});
Additionally, I recommend avoiding "1:height(cameraPoses)" for codegen here. If "cameraPoses" is the codegen struct, "height(cameraPoses)" is not the number of poses. Use "numel(cameraPoses.ViewId)" and preserve the actual ViewId values so they still match "tracks.ViewIds".
“One-dimensional indexing” means codegen is seeing an object array that only supports linear indexing like "pose(k)", but something in the generated validation path is trying table/row-style indexing. Making "AbsolutePose" a cell column avoids that path failing.
Hope this resolves the issue.
Regards,
Matt.

댓글 수: 1

Sankar
Sankar 2026년 7월 18일
That solved the issue! Thank you so much.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기

제품

릴리스

R2026a

질문:

2026년 7월 10일

댓글:

2026년 7월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by