opencv-Trackbar调色板

来源:互联网 发布:淘宝店铺转让流程图 编辑:程序博客网 时间:2024/06/06 04:02

参考:

1、http://docs.opencv.org/3.3.0/  官方文档api

2、http://docs.opencv.org/3.3.0/d6/d00/tutorial_py_root.html 官方英文教程

3、https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_tutorials.html

4、https://github.com/makelove/OpenCV-Python-Tutorial# 进阶教程

5、https://docs.opencv.org/3.3.0/index.html  官方英文教程

6、https://github.com/abidrahmank/OpenCV2-Python-Tutorials

7、https://www.learnopencv.com/

8、http://answers.opencv.org/questions/ OpenCV论坛


注:安装的版本 opencv_python-3.3.0-cp36-cp36m-win_amd64.whl



参考:https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_tutorials.html




Trackbar调色板

目标

  • Learn to bind trackbar to OpenCV windows
  • You will learn these functions : cv2.getTrackbarPos(), cv2.createTrackbar() etc.

代码演示

import cv2import numpy as npdef nothing(x):    pass# Create a black image, a windowimg = np.zeros((300,512,3), np.uint8)cv2.namedWindow('image')# create trackbars for color changecv2.createTrackbar('R','image',0,255,nothing) # 取值范围 0~255cv2.createTrackbar('G','image',0,255,nothing)cv2.createTrackbar('B','image',0,255,nothing)# create switch for ON/OFF functionalityswitch = '0 : OFF \n1 : ON'cv2.createTrackbar(switch, 'image',0,1,nothing) # 0~1 范围while(1):    cv2.imshow('image',img)    k = cv2.waitKey(1) & 0xFF    if k == 27:        break    # get current positions of four trackbars    r = cv2.getTrackbarPos('R','image')    g = cv2.getTrackbarPos('G','image')    b = cv2.getTrackbarPos('B','image')    s = cv2.getTrackbarPos(switch,'image')    if s == 0:        img[:] = 0    else:        img[:] = [b,g,r]cv2.destroyAllWindows()




原创粉丝点击