Jump to content

accessing reference points and pixels


---
 Share

Recommended Posts

I'd like to have a Python script that imports a .ginspect-file (Atos Q) and extracts both the 2D measurement images creates an overlay with the reference points in matplotlib. Have been searching the forum and scratching my head to no avail as how to access those reference points. Could you please hint me in the right direction.

-------------------

# -*- coding: utf-8 -*-

import gom
import numpy as np
from matplotlib import pyplot as plt

DIRNAME = 'c:/temp/'
  
#Start by closing all current projects
gom.script.sys.close_project()

#Load the data file
gom.script.sys.load_project(file= DIRNAME + 'myproject.ginspect')

#Show it to me
gom.script.view.toggle_image_mapping(enable=True, use_animation=False)

#Show both the left and the right camera image
lImage = np.array(gom.app.project.measurement_series['Scan 1'].measurements['M1'].images['left camera'].data.rgb[0])
rImage = np.array(gom.app.project.measurement_series['Scan 1'].measurements['M1'].images['right camera'].data.rgb[0])
 
fig, (axl, axr) = plt.subplots(1, 2)
axl.imshow(lImage, cmap='gray')
axr.imshow(rImage, cmap='gray')
plt.show()
 
### 

#pick the measurement
measurement = [gom.app.project.measurement_series['Scan 1'].measurements['M1']]

#pick the last frame from the series of frames
stage = gom.app.project.stages[-1]

#pick the first reference point and lookup points for left and right camera
left = gom.api.project.get_image_acquisition (measurement, 'left camera', [stage.index])[0]
right = gom.api.project.get_image_acquisition (measurement, 'right camera', [stage.index])[0]

point = gom.app.project.actual_elements['Point 1'].coordinate

p = gom.api.imaging.compute_pixels_from_point ([(point, left), (point, right)])

print (p)  

#then to matplotlib again.........

Link to comment
Share on other sites

 Share

×
×
  • Create New...