rgerum/cameratransform

Sensor height parameter is ignored

agfp opened this issue · 1 comments

agfp commented

Hey, thanks for the awesome work.

I have noticed the sensor height parameter is ignored. I can't achieve the expected results with CameraTransform and I wonder if this might be the reason.

Sample code bellow. No matter if sensor height is 1, 24 or 100, the code bellow will always output True.

import cameratransform as ct
import numpy as np

### Variables

sensor_size      = (35.9, 24.0)
#sensor_size      = (35.9, 1)
#sensor_size      = (35.9, 100)
image_size       = (7952, 5304)
focal_length     = 25.0
camera_latitude  = -36.46268
camera_longitude = 174.701975
camera_altitude  = 360.912796
yaw              = 77.773732 - 90
pitch            = 68.539041

coords = np.array([[174.70690997500003, -36.461052382999980, 35.97441482543945],
                   [174.70771318800007, -36.461040889999936, 35.79658508300781],
                   [174.70772919800004, -36.461770799999954, 35.75333786010742],
                   [174.70692597800007, -36.461782292999940, 35.95493698120117],
                   [174.70690997500003, -36.461052382999980, 35.97441482543945]])

### CameraTransform

projection = ct.RectilinearProjection(focallength_mm=focal_length, sensor=sensor_size, image=image_size)
orientation = ct.SpatialOrientation(heading_deg=yaw, tilt_deg=pitch)
cam = ct.Camera(projection, orientation)
cam.setGPSpos(camera_longitude, camera_latitude, camera_altitude)
imageCoords = cam.imageFromGPS(coords)

### Result

fixedResult = [[3456.16373929, 3115.19355121],
               [3652.4109201 , 2877.87336392],
               [4266.24878201, 2916.81081086],
               [4148.80805633, 3158.17452882],
               [3456.16373929, 3115.19355121]]

# Truncate the imageCoords to 8 decimals to compare with the fixedResult
for i in range(0,len(imageCoords)):
    imageCoords[i][0] = round(imageCoords[i][0], 8)
    imageCoords[i][1] = round(imageCoords[i][1], 8)
    
print(np.array_equal(np.array(imageCoords),np.array(fixedResult)))

Sorry for the quite late reply.
I implemented that the height of the sensor is not not fixed to square camera pixels. But I think it is not the issue with your problem. Maybe the angles are not correct as yaw pitch is a bit differently defined from heading tilt. But it is quite difficult to debug without further information what you are doing and how you calibrated your parameters. You could uses this correspondence to fit your camera.