Why am I getting an error running the Monocular Visual Simultaneous Localization and Mapping tutorial?

6 views (last 30 days)
Hello,
I am trying to run the Monocular Visual Simultaneous Localization and Mapping tutorial in R2020b and am getting the following error messages:
Error using worldToImage
Expected worldPoints to be nonempty.
validateattributes(worldPoints, {'double', 'single'}, ...
projectedPoints = worldToImage(intrinsics, R, t, localMapPoints);
I did not make any change to the code, except one in the Download and Explore the Input Image Sequence section, in order to create a datastore with the images I have been using in my test.
The error messages are thrown after the function helperTrackLocalMap is called on the main loop of the Tracking section:
[refKeyFrameId, localKeyFrameIds, currPose, mapPointsIdx, featureIdx] = helperTrackLocalMap(mapPointSet, directionAndDepth, vSetKeyFrames, mapPointsIdx, ...
featureIdx, currPose, currFeatures, currPoints, intrinsics, scaleFactor, numLevels);
Any help to troubleshoot this issue would be greatly appreciated.
Thanks.

Answers (1)

Saurabh
Saurabh on 25 Feb 2025
I understand that you are trying to run the ‘Monocular Visual Simultaneously Localization and mapping’ tutorial in R2020b and encountering an error as mentioned.
To minimize errors when working with a custom dataset, consider implementing the following strategies:
  1. Adjust the number of feature points: because input images are larger than the example images, more points can be collected from them. In the helper function 'helperDetectAndExtractFeatures' of the main example file, change ‘numPoints’ from 1000 to 2000.
  2. Decrease the frames skipped between the key frames: in ‘helperIsKeyFrame’ of the main example file, change 20 to a smaller value, say 15 or 10. A smaller value will create more key frames and ensure the tracking is not lost.
Additionally, make sure that the input image files are in the correct order. They should be in order when sorted alphabetically, so if numbers are included in the filenames, they should have leading zeros, ex:
  • 0000.png
  • 0001.png
  • 0002.png
Otherwise, the photos will not be processed in the correct sequence.
I hope this helps in resolving your query.

Categories

Find more on Computer Vision Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!