CS4610/CS5335: Homework 3

Please turn in this homework to Rob Platt via email on the due date.

HW PA Q1 and Q2 should be submitted in the form of a set of two files

named Q1.m and Q2.m. All this should be zipped up into a single file and

emailed to me.

Have a look at the accompanying zip file. Stub files for Q1.m and Q2.m

are provided to you. You should implement each of these. Once implemented, you should be able to run “hw3(X)” in order to run code for question “X”. hw3.m is given to you and should not need to be modified. The

only thing you need to do is to insert code into the stub functions in Q1.m

and Q2.m.

1

(a) (b)

Figure 1: (a) the sphere localized in Q1. (b) the cylinder localized in Q2.

PA Q1: In this question, you must use RANSAC to localize a sphere given

point cloud data. The point cloud contains a ball that is only partially visible

to the sensor. The position of the center of the ball is unknown. The radius

is unknown, but between 5cm (0.05m) and 11cm (0.11m). Write a function

in Q1.m that calculates these two quantities. You can test your code using

the cropped point cloud (see commented hw3.m). But, you should submit

code that works on the entire point cloud without cropping. Important:

please do NOT use the built-in Matlab function for sphere fitting.

Hint: one way to generate sphere hypotheses is as follows:

1. sample a point from the cloud;

2. sample a radius of the candidate sphere between 5 and 11cm;

3. project a vector from the sampled point in the direction of the associated surface normal for a distance equal to the sampled radius. This

point would be at the center of the candidate sphere.

PA Q2: Same as Q1 except for a cylinder. This question is harder because

you need to calculate the center, the orientation, and the radius (between

0.05m and 0.1m). The orientation should be returned in the form of a unit

2

vector pointing along the axis of the cylinder (either direction is fine). You

only need to solve this problem for the segmented cloud, as implemented in

the code.

Hint: one way to generate cylinder hypotheses is as follows:

1. Sample a radius for the candidate cylinder between 5 and 10 cm.

2. Sample two points from the cloud

3. Set the cylinder axis direction equal to the direction of the cross product between the surface normals associated with the two sampled

points.

4. Pick one of the sampled points from the cloud and use it to estimate

a candidate center, just as you did in Q1.

5. Project the points in the cloud onto the plane orthogonal to the axis

you just calculated. You can do this projection by multiplying the

points in the cloud by this matrix: I − aˆaˆ

T

, where ˆa is equal to the

axis of the cylinder. Also project the candidate center into this plane

in the same way.

6. Evaluate number of inliers in the plane for a circle with the given

projected center and the sampled radius.

3