Git Product home page Git Product logo

Comments (1)

JakubSochor avatar JakubSochor commented on July 17, 2024

You are on the correct path; however, there are other steps necessary to compute the IMAGE coordinates of VP3. See the functions bellow.

def getFocal(vp1, vp2, pp):
    return math.sqrt(- np.dot(vp1[0:2]-pp[0:2], vp2[0:2]-pp[0:2]))


def homogenizeAndNormalize(p):
    p = np.array(p)
    p = p.flatten()
    assert len(p) == 2 or len(p) == 3
    if len(p) == 2:
        return np.concatenate((p, [1]))
    else:
        return p/p[2]

"""
Compute camera calibration from two van points and principal point
"""
def computeCameraCalibration(_vp1, _vp2, _pp):
    vp1 = homogenizeAndNormalize(_vp1)
    vp2 = homogenizeAndNormalize(_vp2)
    pp = homogenizeAndNormalize(_pp)
    focal = getFocal(vp1, vp2, pp)
    vp1W = np.concatenate((vp1[0:2], [focal]))    
    vp2W = np.concatenate((vp2[0:2], [focal]))    
    ppW = np.concatenate((pp[0:2], [0])) 
    vp3W = np.cross(vp1W-ppW, vp2W-ppW)
    vp3 = np.concatenate((vp3W[0:2]/vp3W[2]*focal + ppW[0:2], [1]))
    vp3Direction = np.concatenate((vp3[0:2], [focal]))-ppW
    roadPlane = np.concatenate((vp3Direction/np.linalg.norm(vp3Direction), [10]))
    return vp1, vp2, vp3, pp, roadPlane, focal

from boxcars.

Related Issues (20)

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.