Is there a way to find the correct object on that pixel from the scene (retrieve the object ID) by scripting via python in blender. Example scene would be:(essentially this but the other way round from 2d to 3d object How to find image coordinates of the rendered vertex?)
This is no complete answer, but I suggest using the 2D to 3D script you linked.
The script and some other simple methods provide the following information:
- Every vertex and its coordinates in 3D (scene) and 2D (rendered image)
- Every face (list of vertices)
- The object to which a vertice belongs
Given a 2D coordinate, we can find the closest vertices by calculating the eulcidean distance.
Now we can find the 3D coordinates of those vertices and get the Objects they belong to.
There might be multiple possible objects so we can either calculate the closest view-intersecting-face or if we have a simple scene just take the vertice that is closest to the camera (3D euclidean distance)