The function that solve the given problem is the function "performVisualOdometry" in the file "visual_odometry.m".
To test the function use the command: octave-cli test_project.m
All the details are contained in the code comments.
This is an implementation with Least-Squares of a visual odometry pipeline in octave (for an exam in my Master)
MATLAB