I am trying to extract the location(x,y,z) of the objects from the camera in my scene(highway scene -autobahn).
Note: I have imported the .obj file as my scene (obtained from elsewhere, not created by me) into the Blender and therefore the objects in my highway scene (like a car, tree, etc) do not show any values for location (x,y,z) in the viewport.
problem 1: But I need a sophisticated way to obtain the distance of all the objects of the scene elements from the camera, pixel-wise, to use it as ground truth for further application.
Methods I tried so far :
to create a driver that calculates the distance between two objects but unfortunately, it does not work because the location of the objects does not show as they are imported. it is always (0,0,0). Also, I cannot obtain pixel-wise distance.
use the depth render layer of the cycles render in Blender using the composting nodes and creating a node tree that calculates the distance writing it to the output file. This works! But I do not need a converted value, all I need is the Z-component of the distance to the camera. I followed the solution of using shader in this link How to get Z-distance (not depth) from camera to object for every pixel in the frame?. I am stuck in one place :
problem 2: While using shader nodes, I am unable to see the output of it. How can I extract the pixel-wise output into a file? I can build the node tree as shown in the image below, but I do not know how to proceed further. Please guide me on how to obtain the output into a file. Also, problem 3: I do not quite understand why I am multiplying the view vector with view distance? I followed the solution in the link but unable to understand this point.
This might be a trivial question but as I am a newbie in the computer graphics field, any leads would be extremely useful. Thank you in advance