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');

 Akzeptierte Antwort

Steven Lord
Steven Lord am 11 Mai 2022
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 Kommentar

Thank you so much for pointing out Steven! Totally overlooked that part

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by