Jump to content

Export location, pitch yaw and roll of TRITOP images. ZIESS Inspect


---
 Share

Recommended Posts

---

I'm looking for a way to export the camera location and rotation information for TRITOP image from ZEISS inspect for use in other visualization tools.

I haven't been able ti identify this from the standard menus, only export the images.

Is this possible through python scripting?

Link to comment
Share on other sites

  • 2 weeks later...
---

Hello,

in a project with a nominal measurement series, the positions are defined by a gom.Mat4x4 matrix.

Without e.g. Tritop only, there is the position as a token in the script editor. The rotation could be retrieved by clicking into the image mapping -> R on keyboard for rotation and then by active view in the script editor. It is also possible to construct points on the camera symbols (tick sensor position in the measurement series' properties).

image.thumb.png.659b12d2aca22362adf9656d01cacd8d.png

image.thumb.png.4879c14f83c01f0eb9705272228912fe.png

image.thumb.png.17c9590830515444a1051a23e3d68de7.png

 

 

 

image.png

Link to comment
Share on other sites

  • 3 weeks later...
  • 2 weeks later...
---

Hello again Nanno

I've begun writing the script now.  I've not managed to find the position token for the images you mentioned, but I think extracting them from the view at the same time as the direction will work.

I (think) I am converting from the direction and image_up vectors to yaw pitch and roll, but the whole process seems a little clumsy.

Is there not a more efficient way to directly access this information without going via element-front view?

 

Thanks, again for the help so far, I'll post the resultant script once I've managed to verify it.

Link to comment
Share on other sites

---

Hello again, 

If anyone else is interested this some of the code  used to convert the view_up and view_direction vectors to yaw pitch roll for import into other software (this case photogrammetry software for use of texturing algorithms).

The full script does a few other things too but hope this is of help to someone, or if there are recommendations for better approaches would be very welcome.

Written with the help of others and AI 

 

 
def normalize(v😞
    norm = np.linalg.norm(v)
    return v / norm
 
def calculate_yaw_pitch_roll(forward, up😞
    # refactor gom.vec3 as array for use with numpy
    up_arr = [up.x,up.y,up.z]
    forward_arr = [forward.x,forward.y,forward.z]
   
     # Normalize the forward and up vectors
    forward_arr = normalize(np.array(forward_arr))
    up_arr = normalize(np.array(up_arr))
    # Calculate the right vector
 
    right = np.cross(up_arr, forward_arr)
    right = normalize(right)
 
    # Recalculate the up vector to ensure orthogonality
    up = np.cross(forward_arr, right)
 
    # Create a rotation matrix
    rotation_matrix = np.array([
        right,
        up_arr,
        -forward_arr
    ]).T
 
    # Calculate yaw, pitch, and roll
    yaw = np.arctan2(rotation_matrix[1, 0], rotation_matrix[0, 0])
    pitch = np.arcsin(-rotation_matrix[2, 0])
    roll = np.arctan2(rotation_matrix[2, 1], rotation_matrix[2, 2])
 
    # Convert to degrees
    yaw = np.degrees(yaw)
    pitch = np.degrees(pitch)
    roll = np.degrees(roll)
 
    return yaw, pitch, roll

 

 
# exports a measurement image and reutns its yaw pitch and roll
def process_measurement(current_measurement, series_directory😞
    image_name = current_measurement.name + ".png"
    # export measurement data
    image_file = os.path.join(series_directory, image_name)
 
    # export the current image - requires scanner license
    try:
        gom.script.sys.export_measurement_images (
            elements=[current_measurement],
            file=gom.File (image_file))
    except Exception as e:
        # Handle errors related to license checking
        print(f"Required license for export not available: {e}")
 
    # go to element front view
    gom.script.view.adjust_view_to_element_by_front_view (
        element=current_measurement,
        use_animation=False)
 
    # reset view rotation
    gom.script.view.set_zp (
        up_axis='Y+',
        use_animation=False,
        widget='3d_view')
 
    # get view yaw pitch roll based on scene camera
    # get vector direction of a given image    
    image_direction = gom.app.views.active.view_direction
    image_up = gom.app.views.active.up_direction
    image_position = gom.app.views.active.position
    yaw, pitch, roll = calculate_yaw_pitch_roll(image_direction, image_up)
 
    return image_name, image_position, yaw, pitch, roll
Link to comment
Share on other sites

 Share

×
×
  • Create New...