opengl 选择对象,显示3d坐标 pyqt 正投影,透视投影
import copy
import sys
from PyQt5.QtWidgets import QOpenGLWidget, QApplication, QMainWindow
from PyQt5.QtCore import Qt, QPoint
from OpenGL.GL import *
from OpenGL.GLU import *
import cv2
import numpy as np
def point_to_line_distance(points, line_segments):
x0, y0, x1, y1=line_segments[0][0], line_segments[0][1], line_segments[1][0], line_segments[1][1]
px,py=points[0],points[1]
"""计算点到线段的距离"""
line_mag = np.sqrt((x1 - x0) ** 2 + (y1 - y0) ** 2)
if line_mag < 1e-6:
return np.sqrt((px - x0) ** 2 + (py - y0) ** 2)
u = ((px - x0) * (x1 - x0) + (py - y0) * (y1 - y0)) / (line_mag ** 2)
if u < 0.0 or