[Ro...] Posted Tuesday at 12:45 PM Share Posted Tuesday at 12:45 PM I try to make use of the coordinates of the marker locations. As a verification I plot the 2D-XY-coordinates over left and right grayscale image. That works well for every 1st measurement in any .ginspect-sequence, but locations misalign for any next measurement in the file. See examples: M1.png shows correct locations. M2.png is wrong. Utilizing GOMInpsect 2023. Please help me out. What am I missing? --- import gom import numpy as np import os from matplotlib import pyplot as plt PROJECT_PATH = 'C:/Users/user/Documents/Deviation Study' #Let op: Slash needs to be changed to forward when inserting paths from Windows Explorer EXPORT_PATH = '//omnas.labs.tno.nl/Projects/Duurzame Luchtvaart/GOM L+R Images/Set1' #Let op: Slash needs to be changed to forward when inserting paths from Windows Explorer fileList = [] MEASUREMENT_SERIES = 'Scan 1' MEASUREMENT = 'M' DISPLAY = True #close any project gom.script.sys.close_project () for file in os.listdir(PROJECT_PATH): if file.endswith(".ginspect"): fileList.append(file) #Get file path filePath = os.path.join(PROJECT_PATH, file) print ("Now processing:", filePath) #open project gom.script.sys.load_project ( file=filePath, load_working_copy=True) #refXML refXML_path = os.path.join(EXPORT_PATH, 'default.refxml') gom.script.sys.export_reference_points_xml ( elements=[gom.app.project.measurement_series[MEASUREMENT_SERIES].results['points']], file=refXML_path, only_selected_points=False) reference_points = np.array(gom.app.project.measurement_series[MEASUREMENT_SERIES].results['points'].data.coordinate) print("shape of reference points", reference_points.shape) print(reference_points) results = [] #loop over the measurements for i in range(1,9): #loop over 8 measurements measurestage = MEASUREMENT + str(i) print("measurestage:", measurestage) measurement = gom.app.project.measurement_series[MEASUREMENT_SERIES].measurements[measurestage] lImage = np.array(measurement.images['left camera'].data.rgb[0]) rImage = np.array(measurement.images['right camera'].data.rgb[0]) if DISPLAY: print("display") fig, (axl, axr) = plt.subplots(1,2) fig.canvas.manager.set_window_title("measurestage "+measurestage) axl.imshow(lImage, cmap = 'gray') axr.imshow(rImage, cmap = 'gray') #loop over the markerIds for index, id in enumerate(measurement.reference_point_id): print("marker id",id) if id is not None: reference_point = measurement.reference_point_coordinate[index] #print(f'Reference point in {MEASUREMENT_SERIES} - {measurestage}: ID = {id}, P = {reference_point})') left = gom.api.project.get_image_acquisition(measurement, 'left camera', [0])[0] right = gom.api.project.get_image_acquisition(measurement, 'right camera', [0])[0] try: image_coordinates = gom.api.imaging.compute_pixels_from_point([(reference_point, left), (reference_point, right)]) print('Image coordinates of reference point (left, right):', image_coordinates) results.append([measurestage, id, image_coordinates]) #plot the marker locations over the L+R 2D images if DISPLAY: lmarker = [image_coordinates[0].x, image_coordinates[0].y] axl.plot(lmarker[0], lmarker[1], '*r') rmarker = [image_coordinates[1].x, image_coordinates[1].y] axr.plot(rmarker[0], rmarker[1], '*r') except: print(f'Error on measurement {measurestage}, with marker {id}') if DISPLAY: plt.show() print(results) print('Processing Complete!') gom.script.sys.close_project () Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in