You can calculate the inertia tensor for some primitive geometries of a linkage using known formula. Most of these are listed here. If you do not have a regular shape for which you can find the inertia tensor by a simple formula, you need to obtain this through integration (using the generalised formula). As this is not practicable by hand, most CAD programs ...
To expand on my comment, the last line of your DH table gives the transform between END_EFFECTOR-1 and END_EFFECTOR frames, right? I'm saying instead of <θ2, 0, 0, 0> to have <180+θ2, 180, 0, 0>.
There's no movement between your end effector and the object you're attaching to the end effector, so there's no point in keeping the end effector frame....
You do not neceserily create an explicit C-Space representation which you sample.
You have to choose, if you want to create your path in axis space or operational space (Cartesian space). This is a design choice and has some influence on the final shape of the trajectory. I am going to assume, that you plan in operational space (Cartesian-like).
You sample ...
The best (and cheapest) method would be to use AprilTags. I have added the python bindings for it here.
For a great starting point, refer to this blog that explains the setup in C++.
It can not only tell you the distance but also the orientation of the object
I hope it helps.