OpenCV Series : Slope + Radian + Degree

复制代码
------   -----------  -----------
IMG           903px       1212px
------   -----------  -----------
A4            210mm        297mm
------   -----------  -----------
Ratio      4.3px/mm     4.1px/mm
          0.23mm/px    0.24mm/px
------   -----------  -----------


c 复制代码
def lineSlope(p1, p2):
    slope = (p2[1] - p1[1]) / (p2[0] - p1[0])
    return slope

def slopeAngle(p1, p2):
    slope  = lineSlope(p1, p2)
    radian = np.arctan(slope)
    return radian

def angleDegree(radian):
    theta = int(radian * 180 / np.pi) % 360
    return theta

RealSence ToF

复制代码
https://github.com/IntelRealSense/librealsense/tree/development/wrappers/python
https://github.com/IntelRealSense/librealsense/tree/development/wrappers/python/examples
c 复制代码
pip install pyrealsense2

Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting pyrealsense2
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/80/53/7c90f162661b4ad0dd4d2d4dc2e8330c52943cbd968c44770464d6d658b8/pyrealsense2-2.54.1.5217-cp39-cp39-win_amd64.whl (5.7 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.7/5.7 MB 10.8 MB/s eta 0:00:00
Installing collected packages: pyrealsense2
Successfully installed pyrealsense2-2.54.1.5217

Librealsense frames support the buffer protocol

c 复制代码
import numpy as np
import pyrealsense2 as rs

pipeline = rs.pipeline()
pipeline.start()

try:
    while True:
        frames = pipeline.wait_for_frames()
        depth = frames.get_depth_frame()
        if not depth: continue

        depth_data = depth.as_frame().get_data()
		np_image = np.asanyarray(depth_data)
finally:
    pipeline.stop()
相关推荐
@forever@32 分钟前
【JAVA】LinkedList与链表
java·python·链表
程序员爱钓鱼1 小时前
Python编程实战:面向对象与进阶语法——类型注解与代码规范(PEP 8)
后端·python·ipython
程序员爱钓鱼1 小时前
Python实战:用高德地图API批量获取地址所属街道并写回Excel
后端·python·ipython
reasonsummer2 小时前
【教学类-97-06】20251105“葡萄”橡皮泥黏贴(小班主题《苹果与橘子》)
python
卖个几把萌3 小时前
【16】Selenium+Python 接管已打开谷歌浏览器
python·selenium·测试工具
像风一样的男人@3 小时前
python --两个文件夹文件名比对(yolo 图和label标注比对检查)
windows·python·yolo
lllsure3 小时前
【Python】Dict(字典)
开发语言·python
tianyuanwo4 小时前
Rust开发完全指南:从入门到与Python高效融合
开发语言·python·rust
如何原谅奋力过但无声5 小时前
TensorFlow 2.x常用函数总结(持续更新)
人工智能·python·tensorflow
程序员-小李5 小时前
基于 Python + OpenCV 的人脸识别系统开发实战
开发语言·python·opencv