Why is the function 'oldInlierLocation' undefined?

I am trying out the object detection and tracking for augmented reality Mathworks example. https://www.mathworks.com/videos/object-recognition-and-tracking-for-augmented-reality-90546.html
I have tried running the code but I am getting an error saying 'Unrecognized function or variable 'oldInlierLocation'. I have included a snippet of it below.
How do I define it? I am new to Matlab and I could not find any resources or answers on this.
if(nnz(isValid>=2))
[trackingGTransform,oldInlierLocation,newInlierLocation]= ...
estimationGeometricTransform(...
oldValidLocation,newValidLocation,'similarity');
end
figure(1)
showMatchedFeatures(prevCameraFrame,cameraFrame,...
oldInlierLocation,newInlierLocation,'Montage');

 採用された回答

Steven Lord
Steven Lord 2022 年 5 月 11 日

1 投票

You made at least one mistake copying the code from around 4:10 in that video. Your code:
if(nnz(isValid>=2))
The video's code:
if (nnz(isValid) >= 2)
The placement of that first right parenthesis is important. In your code, the if condition is never satisfied and so the code inside the if statement is not executed. Therefore the variable oldInlierLocations never gets defined. In the video code, the if condition is satisfied and so the code inside executes and defines oldInlierLocations.

1 件のコメント

Bavaani Shri Gopalsamy
Bavaani Shri Gopalsamy 2022 年 5 月 12 日
Thank you so much for pointing out Steven! Totally overlooked that part

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by