Coder Social home page Coder Social logo

Comments (3)

pqpo avatar pqpo commented on May 19, 2024 1

很不错的方案,但是给的四个点并不知道哪两个是对角线顶点,可能是AB,AC 或者 AD,需要遍历一下。由于哪个是左上并没有明确的定义,所以可以简单的以离原点最近的点作为 左上,之后再连线判断另外两个点是否在线的两侧来判断对角线,具体实现可以看:

vector<Point> Scanner::sortPointClockwise(vector<Point> points) {

from smartcropper.

titanseason avatar titanseason commented on May 19, 2024

OK, 明白了,谢谢

from smartcropper.

honeyhhhh avatar honeyhhhh commented on May 19, 2024
'''
    判断四个点 左上左下,右上右下
    左上的点为 最靠近左边的两个点中最靠近上面的点
    如果能判断哪个点是左上,那么可以连接对角线,通过交点与四个点的大小关系判断位置,距离原点最近的不一定是左上
'''
if len(points) != 4:
    print('wrong point num')
    exit(0)
point_sort_left = sorted(points , key=lambda k: [k[0], k[1]])  
lt, ld = sorted([point_sort_left[0], point_sort_left[1]], key=lambda k:[k[1], k[0]])
rt, rd = sorted([point_sort_left[2], point_sort_left[3]], key=lambda k:[k[1], k[0]])
display(lt, rt, rd, ld)

from smartcropper.

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.