Closed davesargrad closed 2 years ago
@rgerum Hi Richard.
Silly question for you.. In my call to gpsFromImage I am seeing only 2 points of precision in the returned latitude/longitude. I dont think this is just a printing issue, since I see the same in the debugger (within the numpy array).
What do I need to do to extract the full floating point precision of the latitude/longitude?
geo_pts = c.gpsFromImage(cam_pts, Z=0.0)
print(f"**************************my geo thingy {geo_pts}")
A view in the debugger:
Well normally you should just get the value with the float precision:
import cameratransform as ct
camera = ct.Camera(ct.RectilinearProjection(focallength_px=3863.64, image=[2592, 4608]))
camera.elevation_m = 20
camera.tilt_deg = 80
camera.heading_deg = 100
camera.setGPSpos(49, 8, 10)
print(camera.gpsFromImage([1000, 2000]))
yields: [48.9999084 8.00142067 0. ]
So maybe it just depends on your coordinate inputs.
You could try "print(c)" to print the parameters of your camera. And print the pixel point you want to transform. Maybe there are some string things with your parameters. Maybe some are accidentally for some reason stored as integers.
@Richard - @davesargrad and I I have been playing with the Lat / Lon precision related to the question @davesargrad asked today. We have two code snippets that are doing the same gpsFromImage call with the same camera initialization data and we are getting two different structures resulting from the gpsFromImage call. The screenshot below shows the code we are developing (left hand side) and the test code I had developed earlier (right hand). The results of the call to gspFromImage results in an ndarray of 1, 3 on the right hand side (red highlight circle), while the code on the left hand side results in an ndarray of 3, (null) (blue circle). One key thing to point out is that code being developed is using the 1.1 code from github tag, while the test code used some of the enhancements you made during our discussions (i.e. trunk). Is it possible that you fixed a bug in the 1.1 code that is in the trunk?
Also, below is new test code replicated the camera calls from our developed code. This works with the trunk version - that is, it returns a ndarray of 1, 3.
`import numpy as np
import cameratransform.cameratransform as ct
c = {"focal_length": 6, "latitude": 53.631495, "longitude": 10.005011, "altitude": 39.01} vso = {"elevation": 2.0, "tilt_deg": 0.0, "roll_deg": 0.0, "heading_deg": 0} vss = {"width": 4, "height": 4} vis = {"width": 1280, "height": 710}
spatial_orientation = ct.SpatialOrientation(elevation_m=vso["elevation"], tilt_deg=vso["tilt_deg"], roll_deg=vso["roll_deg"], heading_deg=vso["heading_deg"])
rectilinear_projection = ct.RectilinearProjection(focallength_mm=c['focal_length'], sensor=(vss['width'], vss['height']), image_width_px=vis['width'], image_height_px=vis['height'])
lens_distortion = ct.NoDistortion() if "lens_distortion" in c and "name" in c["lens_distortion"]: if "BROWN" == c["lens_distortion"]["name"] and "BROWN" in c["lens_distortion"]: k1 = c["lens_distortion"]["BROWN"].get("k1", None) k2 = c["lens_distortion"]["BROWN"].get("k2", None) k3 = c["lens_distortion"]["BROWN"].get("k3", None)
lens_distortion = ct.BrownLensDistortion(k1, k2, k3)
cam = ct.Camera(rectilinear_projection, orientation=spatial_orientation, lens=lens_distortion) cam.setGPSpos(c['latitude'], c['longitude'], c['altitude'])
cam_pts = np.array([[476.31516456604004, 166.61448150873184]]) geo_pts = cam.gpsFromImage(cam_pts, Z=0) `
hmm sounds strange. But to investigate it more, I would need to also have a minimal example of the code that does not work. Both cameratransform versions should give the same result.
The only thing to consider, if you input just one point, e.g. a (2) array, the output should be a (3) array. If you input a (1,2) array, the output should be a (1,3) array. But in your case it seems that the result is an array of type object. It might also have something to do with the numpy version.
@rgerum - I just tried our working test code (code from above) with the 1.1 distribution and we reproduced the same problem we were setting. Specifically, the geo_pts is a ndarray (3,):
The code using the "enhanced" functionality produces:
This would seem to indicate that something changed between the 1.1 and trunk version. If you would like, we can write a separate issue to handle this apparent bug. Please let me know if there is more information you would like. Outside of the cameratransform version, the environment is the same in both situations.
ok if it is gone in the trunk version, I should maybe just make a new release to fix this issue.
@rgerum and @ralphflat Thanks both for helping to resolve this. It does seem that there is a bug in the 1.1 version .. assuming that you did not expect the output of gpsFromImage to change form (from 1.1 to trunk)..
As soon as you tag a new release.. we will try it out.
I think this relates to the lat/lon precision issue.. but really i think it will fix a bigger bug. Part of what Ralph and I saw was that the numpy array coming from gpsFromImage had some odd values (for example the dtype was an object that we didnt expect)
@rgerum - thanks for the 1.2 release. This works consistently for the two bits of code we have.
I just upgraded in this fashion:
pip install cameratransform==1.2
I'll do some testing today.
Yay.. 1.2 up and working.. and I'm getting more sensible numbers.
Hi. This project seems to have great documentation. I see that it is tagged with a 1.1 release. However I don't see many issues or activity on the project.
Is the software mature? Is it something that I should pick up and experiment with, or is it better for me to look elsewhere for a library to take me from camera into geodetic coordinates?
If the author (@rgerum) still supports this, then I am very excited to use this. I simply love the effort that I see here.
Thanks, Dave