How do I calculate the camera's perpendicular to the object's Z-axis?

I need to get the ratio of how much the viewport camera looks at the object perpendicular to the Z axis?
For example, there is a cube and the user rotates the camera. when you align it with the Z axis, the cube will change its transparency. How do I calculate how much the camera is perpendicular to the cube on the Z axis?

We have camera and object matrices:
camera = context.region_data.view_matrix
obj = context.active_object

if I understand you correctly, you can assume that the distance between camera Z and object Z will be at a minimum when the distance is measured as a perpendicular. Therefore if you take the location as vectors for the camera and object and set the Z value to 0 - you should copy these vectors, or you will move the objects… you can then use Vector Maths to get the distance between these vectors, something like:

cam_loc = camera_object.location.copy()
obj_loc = other_object.location.copy()
cam_loc.z = 0
obj_loc.z = 0
separation = (obj_loc - cam_loc).length

Cheers, Clock.

unfortunately this does not fit, I need to bind to the local orientation of the object. I need something like how it works on a 3D manipulator.

each axis changes its transparency depending on the camera’s perpendicularity