Code Monkey home page Code Monkey logo

Comments (3)

lilanxiao avatar lilanxiao commented on May 30, 2024

The formula is called "shoelace formula". This formula requires that all vertices must be sorted in clockwise or counter-clockwise order.

For the intersection of boxes, there are two types of vertices. "intersections of edges" and "corners in boxes", as the green ones and red ones in this Picture show. The basic idea of my code is:

  1. find these two types of vertices, respectively
  2. sort them in clockwise/counter-clockwise order
  3. use the shoelace formula to get the area.

My implementation needs this sort() because it finds the two types of vertices separately, which is intuitive and naive. The other implementations use a more elegant "sequential cutting" algorithm to find all vertices at once. To be honest, I'm not an expert in geometry. But this algorithm seems to provide sorted vertices directly so that there is no need to sort them afterward.

I think the "sequential cutting" is probably faster than my implementation but the result should be the same.

from rotated_iou.

JonathanCMitchell avatar JonathanCMitchell commented on May 30, 2024

ok that makes sense. My only concern is how that sort will affect the backwards pass when differentiating.

from rotated_iou.

lilanxiao avatar lilanxiao commented on May 30, 2024

The back-propagation is explained in issue #7. The trick is to use torch.gather() and the sorting itself doesn't need a backward pass.

from rotated_iou.

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.