• OpenCV Series : Slope + Radian + Degree


    if True:
    	# Addition
    	add = lambda x, y : (x + y)
    	# Multiplication
    	mcl = lambda x, y : (x * y)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    ------   -----------  -----------
    IMG           903px       1212px
    ------   -----------  -----------
    A4            210mm        297mm
    ------   -----------  -----------
    Ratio      4.3px/mm     4.1px/mm
              0.23mm/px    0.24mm/px
    ------   -----------  -----------
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    在这里插入图片描述
    在这里插入图片描述

    if True:
        zero = np.zeros(frame.shape[:2], np.uint8)
        b, g, r = cv2.split(frame)
        frame = cv2.merge([zero, zero, r]).astype(np.uint8)
    
    • 1
    • 2
    • 3
    • 4
    if True:
        single = cv2.cvtColor(normal, cv2.COLOR_BGR2YCR_CB)
        (y, cr, cb) = cv2.split(single)
        cr = cv2.GaussianBlur(cr, (5, 5), 0)
        _, skin = cv2.threshold(cr, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
        res = cv2.bitwise_and(normal, normal, mask = skin)
        cv2.imshow('Cr', res)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    if True:
        sobelx = cv2.Sobel(gray, cv2.CV_64F, 1, 0, ksize=9)
        sobely = cv2.Sobel(gray, cv2.CV_64F, 0, 1, ksize=9)
        sobel = cv2.addWeighted(sobelx, 0.5, sobely, 0.5, 0)
        cv2.imshow('Sobel', sobel)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

    RealSence ToF

    https://github.com/IntelRealSense/librealsense/tree/development/wrappers/python
    https://github.com/IntelRealSense/librealsense/tree/development/wrappers/python/examples
    
    • 1
    • 2
    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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    Librealsense frames support the buffer protocol

    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()
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
  • 相关阅读:
    CanvasScaler计算方法
    【观察】智能产业加速,为何AI算力要先行?
    掌握 BERT:自然语言处理 (NLP) 从初级到高级的综合指南(1)
    绘制花朵-第13届蓝桥杯Scratch选拔赛真题精选
    Python基础入门篇【36】-python初识异常及常见的异常类型
    高级架构师_Docker_第2章_ Docker核心原理_ 第7节IDEA集成Docker
    【图论】最小生成树(python和cpp)
    【Python黑科技】制作一个定时小闹钟,自动发送系统通知提示(保姆级图文+实现代码)
    2022/7/ 20 训练记录
    AI时代下普通小程序员的想法
  • 原文地址:https://blog.csdn.net/unix2linux/article/details/133031106