ENGO 333: COMPUTING FOR GEOMATICS ENGINEERS LAB #9: PLANE EXTRACTION FROM 3D POINT CLOUDS OBJECTIVES: To implement a C++ object-oriented program to solve a Geomatics/Mechatronics Engineering problem, namely 3D plane extraction from point clouds using a simple RANSAC algorithm for reconstructing the 3D shape of a room. DATE DUE: Friday, November 18 by the end of the day, please. Lab 9 may be completed individually or in pairs. If working in pairs, you must arrange to do the work together. Both members of the group should share the work equally and will receive the same grade. Please only submit one copy of the labs to one of the respective dropboxes. Make sure to indicate the names of both partners on the report so that we can assign a grade to the other partner. You may work with a partner from any lab section. Warning: Of all the ENGO 333 labs, this one has the most steps and requires you to write the most code from scratch. It is not difficult, but make sure to follow the instructions carefully, you will be putting together a lot of your skills in this lab. In the prelab you got ready by defining a class with some member functions. During the lab you will add one more function and then test you class on real data. If you haven’t completed the prelab, do it before starting the lab. Task 4 (numbering continued from prelab): Write the prototype and definition of a function that implements Algorithm 2 (next page). Before writing the function, read the pseudocode and figure out what the function is doing and what it will do to the Plane object when it runs. You can use TestAlgorithm2.txt to test Algorithm 2. The file contains 7 inliers and 2 outliers. Points labelled 6 and 9 are the outliers. If your code is working correctly, it should find the parameters of the plane as follows (same as in the prelab): 𝑛𝑥 = −6.47376 × 10−6 , 𝑛𝑦 = −0.000226619, 𝑛𝑧 = 1, 𝑑 = −99.9954 And the Boolean vector should indicate: [1 1 1 1 1 0 1 1 0] When you are testing your function for Algorithm 2, you may notice that your results vary slightly every time you run the code. This is because RANSAC tries to fine at least 3 correct points and fits a plane to them. If this plane fits well to at least half the points, then it will stop. If your code is correct, then if you change the while loop condition from c < m/2 to c < 7 you should get the exact answer (this will force the algorithm to only stop if the plane fits to 7 points (ie. all the 7 correct points). Only try this for testing, not with the real data. 2022 1 of 3 ENGO 333: COMPUTING FOR GEOMATICS ENGINEERS Task 6: You are almost there: In main(): a. Read the data in file PointCloudData.txt into a matrix (using the ReadDataToMatrix() function). You should get an 𝑛 × 4 matrix, where 𝑛 is the number of points in the file. b. Create an empty vector of Plane objects. c. Create a matrix 𝐼 of size 𝑛 × 1 and fill it with zeros d. Looping from 1 to 6 a. Read the Seeds[n].txt file. Hint: You can use something like: "Seeds"+to_string(i)+".txt" to make the file name inside a loop where i is an 2022 2 of 3 ENGO 333: COMPUTING FOR GEOMATICS ENGINEERS int. Given the IDs of the points in each file, find their 3D coordinates in the original matrix point coordinates (that you read in 5a) b. Use the function from Task 4 and calculate the correct plane parameter for the plane corresponding to the set of points in Seeds[n].txt. c. Insert the plane object into the vector of Plane (created in task 5b) d. For each point in the original matrix of point coordinates i. Calculate the distance of the point from the plane ii. If the distance is smaller than 0.01, set the corresponding element of 𝐼 equal to the plane number (the number between 1 and 6, depending on which iteration you are in) e. Create a new matrix and concatenate the matrix of original points and the matrix 𝐼 to make a matrix that contains a list of points and the plane number of each point. f. Write this 𝑛 × 5 matrix to a file called OutputPointCloud.txt g. Convert the vector of Plane into an Eigen matrix so that the first column is the plane number and the following columns are the plane parameters and write this Matrix to a file called OutputPlanes.txt Task 7: Making pretty figure to show off you results Create a new MATLAB m-file to load OutputPointCloud.txt and plot the points in six different colours (one for each plane) in a single 3-D plot. What to Submit: 1. A report that describes what you did for all the tasks from the prelab and lab. Do not just copy and paste the task list, instead describe how you worked through the tasks and what you did to test each step. The report should include a figure showing the plot3() for Task 7 and a table listing the contents of OutputPlanes.txt. In this and all future reports you write as an engineer, all figures and tables must have captions and be referred to in the text. Table captions to on top of the table (while figure captions go below). 2. Your main.cpp file, plane class (.h and .cpp) and your .m file. 2022 3 of 3