Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applying the example code gom.api.imaging.compute_point_from_pixels() results in an error #82

Closed
resident12 opened this issue Mar 6, 2024 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@resident12
Copy link

resident12 commented Mar 6, 2024

Applying the example code of gom.api.imaging.compute_point_from_pixels() to lookup the 3D coordinates of a 2D point alas results in an error. Would appreciate to be able to utilize the described functionality as stated in the documentation. Or should the data be pre-processed somehow to make it work? Please advise me.

#see https://zeissiqs.github.io/zeiss-inspect-addon-api/2023/python_api/python_api.html#gom-api-imaging-compute-point-from-pixels

import gom

DIRNAME = 'c:/data/'
MEASUREMENT_SERIES = 'Scan 1'
MEASUREMENT = 'M1'

gom.script.sys.close_project() #Start by closing all current projects
gom.script.sys.load_project(file= DIRNAME + 'ATOSQ12_1.ginspect')
gom.script.view.toggle_image_mapping(enable=True, use_animation=False) #Show it to me in the UI

measurement = gom.app.project.measurement_series[MEASUREMENT_SERIES].measurements[MEASUREMENT]

left = gom.api.project.get_image_acquisition(measurement, 'left camera', [0])[0]

p = gom.api.imaging.compute_point_from_pixels([[(gom.Vec2d (10, 10), left)]], False)

print(p)

Error in line 18

GomApiError: Computation of 2D points is not allowed in 3D projects.

Stacktrace:

Line 18 in 'gom-api-imaging-compute-point-from-pixels.py' ()

@mprinkezs
Copy link
Contributor

Please try it with two (i.e. left and right) camera images as described in https://zeissiqs.github.io/zeiss-inspect-addon-api/2023/python_examples/point_pixel_transformations.html.
There are cases where a single image is sufficient, I am currently investigating the background.

@mprinkezs mprinkezs self-assigned this Mar 14, 2024
@mprinkezs mprinkezs added the bug Something isn't working label Mar 14, 2024
@resident12
Copy link
Author

Thank you for the reply. Yes, I can confirm it does work with two images. But, then the relation between left and right image-pixels must be known. We need the single image solution. A big thank you in advance. Your help is very much appreciated.

@mprinkezs
Copy link
Contributor

The topic is not sorted out completely yet. What I learned now, is that a single image works only with 2D projects in ZEISS INSPECT Correlate. In this case, the measuring object must have a flat surface and the camera axis must be orthogonal to this surface.

@mprinkezs
Copy link
Contributor

Unfortunately, a preceding step is required in this case. You use the function gom.api.imaging.compute_epipolar_line as a helper. You supply a set of tuples (pixel, image) and an additional image and get an epipolar line for the second image for each tuple. The wanted pixel-match is located on this epipolar line. (see https://en.wikipedia.org/wiki/Epipolar_geometry)
As the final step, you have to search for the wanted pixel on the epipolar line. This is typically done by gray value comparison of the surrounding pixels. As a prerequisite, the pixels must be located at distinct position, i.e. not on a uniformly colored surface. In the best case, the surface has been prepared with a speckle pattern.

@resident12
Copy link
Author

Thank you. Please hold on. I'm still chewing on this one :-). Yes, the Epipolar-line is an option, but then the pixel matching must be redone.

Perhaps it can be done easier. For, in the Zeiss Inspect GUI I can switch on/off the visual overlay of the 2D-image, 3D-mesh and Reference-Points of a saved project => the sensor calibration matrix is stored with the data and is reread with the data from disk. I could apply that calibration matrix to solve the issue. But somehow I can't use the export via File->Export->Sensor Calibration. To be used under specific conditions only?

@mprinkezs
Copy link
Contributor

May I ask you to refer to the ZEISS Quality Forum? This way, more people would be able to see and hopefully answer your question.

@mprinkezs
Copy link
Contributor

Closing due lack of activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants