Git Product home page Git Product logo

Comments (7)

zhengthomastang avatar zhengthomastang commented on August 16, 2024

The code should not depend on the input image size. Can you add the error message here?

from cal_pnp.

shirleyzz avatar shirleyzz commented on August 16, 2024

Hello I have solved the previous problem.Now I get my calibration photo and re-projection error as 11.6.
Meanwhile, I used Python and a another way to solve the H matrix (I guess it uses the same logic as OpenCV) listed as below. And the error of the used 18 points in GPS is about 66 meters.
Have you ever measured the error this way? Thanks for your time.

from_pt = [[ 426.5,  640],
       [ 719 ,  503.5],
       [ 873.5,  513],
       [1194.5,  561.5],
       [1469.5,  589 ],
       [1404.5,  614],
       [1519 ,  751.5],
       [1660 , 1014 ],
       [ 460.5,  614.5]]
to_pt = [[28.605053, -81.196441],
      [28.605271, -81.196252],
      [28.605189, -81.196192],
      [28.605038, -81.196111],
      [28.604943, -81.196044],
      [28.604938, -81.196108],
      [28.604849, -81.196214],
      [28.604783, -81.196325],
      [28.605071, -81.196426]]
#Fill the matrices
A_data = []
for pt in from_pt:
    A_data.append( [-pt[1], pt[0], 1, 0] )
    A_data.append( [ pt[0], pt[1], 0, 1] )
b_data = []
for pt in to_pt:
    b_data.append(pt[0])
    b_data.append(pt[1])
A = np.matrix( A_data )
b = np.matrix( b_data ).T
c = np.linalg.lstsq(A, b)[0].T
c = np.array(c)[0]
print("Solved coefficients:")
print(c)
print("Translated 'from_pt':")
#These will be identical to 'to_pt' since
#ur example transformation is exact
for pt in from_pt:
    print ("%f, %f" % (
    c[1]*pt[0] - c[0]*pt[1] + c[2],
    c[1]*pt[1] + c[0]*pt[0] + c[3] ))
#calculate error
from math import radians, degrees, sin, cos, asin, acos, sqrt
def great_circle(lon1, lat1, lon2, lat2):
    lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])    
    return 6371 * (acos(sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) * cos(lon1 - lon2)))
total_dis = 0
for i in range(9):
    print(i)
    pt = from_pt[i]
    lon1,lat1 = (
    c[1]*pt[0] - c[0]*pt[1] + c[2],
    c[1]*pt[1] + c[0]*pt[0] + c[3] )  
    print(lat1,lon1)
    lon2,lat2 = to_pt[i]
    print(lat2,lon2)
    distance = great_circle(lon1,lat1,lon2,lat2)
    total_dis += distance
total_dis
#Reference
https://elonen.iki.fi/code/misc-notes/2d-rigid-fit/index.html

from cal_pnp.

zhengthomastang avatar zhengthomastang commented on August 16, 2024

Thank you for sharing your code. It looks like the method is similar, but I didn't measure the error like this - I only measured the reprojection error. How did you define the 6371 weight?

from cal_pnp.

shirleyzz avatar shirleyzz commented on August 16, 2024

Well as I am converting GPS to meter/kilometer, the radius of the Earth is 6371km. :)

from cal_pnp.

zhengthomastang avatar zhengthomastang commented on August 16, 2024

Thanks for the reminder. Now I remember. We have done the experiments already. In our scenario, the largest span (for the area covered by all cameras) is about 3 km. If we assume the plane is not flat, the corresponding arc length is 3.01044482025 km. We believe the difference is negligible in our case.

from cal_pnp.

shirleyzz avatar shirleyzz commented on August 16, 2024

Hello Thomas, I think I get your point. Also I want to mention that I want to measure distance and speed
(of traffic scene) from the images/videos. Do you think this calibration procedure is adequate or it's simply calibrating lens distortion? Thanks ahead.

from cal_pnp.

zhengthomastang avatar zhengthomastang commented on August 16, 2024

As long as the tracking is reliable, you should be able to measure the travel distance and speed using homographies generated by our algorithm. You can refer to one of the papers at the AI City Challenge Workshop this year: http://openaccess.thecvf.com/content_CVPRW_2019/papers/AI%20City/Spanhel_Vehicle_Re-Identifiation_and_Multi-Camera_Tracking_in_Challenging_City-Scale_Environment_CVPRW_2019_paper.pdf

from cal_pnp.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.