zoukankan      html  css  js  c++  java
  • opencv色彩空间

    import cv2 as cv
    import numpy as np
    
    def video_demo():
        capture = cv.VideoCapture("d:/two.mp4")
        low_array = np.array([26, 43, 46])
        up_array = np.array([34, 255, 255])
    
        while(True):
            ret, frame = capture.read()
            if ret == False:
                break
    
            hsv_frame = cv.cvtColor(frame, cv.COLOR_BGR2HSV)
            mask = cv.inRange(hsv_frame, low_array, up_array)
            cv.imshow("video", frame)
            cv.imshow("mask", mask)
            c = cv.waitKey(20)
            if c == 27:
                break
    
    video_demo()

    使用inRange函数实现图像特征提取,其中mask是二值图像。

    import cv2 as cv
    import numpy as np
    
    def video_demo():
        capture = cv.VideoCapture("d:/two.mp4")
        low_array = np.array([26, 43, 46])
        up_array = np.array([34, 255, 255])
    
        while(True):
            ret, frame = capture.read()
            if ret == False:
                break
    
            hsv_frame = cv.cvtColor(frame, cv.COLOR_BGR2HSV)
            mask = cv.inRange(hsv_frame, low_array, up_array)
            cv.imshow("video", frame)
            cv.imshow("mask", mask)
            c = cv.waitKey(20)
            if c == 27:
                break
    
    video_demo()

    使用split将图像划分成三通道,其逆过程是merge函数

  • 相关阅读:
    02Spring注解开发
    01Spring配置文件
    网络编程
    CHIL-SQL-IN 操作符
    CHIL-SQL-通配符
    CHIL-SQL-LIKE 操作符
    CHIL-SQL-TOP 子句
    CHIL-SQL-DELETE 语句
    CHIL-SQL-UPDATE 语句
    CHIL-SQL-INSERT INTO 语句
  • 原文地址:https://www.cnblogs.com/loubin/p/12271703.html
Copyright © 2011-2022 走看看