如何高效安装并掌握Python中OpenCV库的全面应用技巧?
- 内容介绍
- 文章标签
- 相关推荐
本文共计227个文字,预计阅读时间需要1分钟。
第一步:安装numpybashpip install numpy
第二步:安装opencv-contrib-pythonbashpip install opencv-contrib-python
第三步:添加灰度滤镜pythonimport cv2
第一步安装numpypipinstallnumpy第二步安装opencv-contrib-pythonpipinstallopencv-contri第一步安装numpy pip install numpy 第二步安装opencv-contrib-python pip install opencv-contrib-python 添加灰色滤镜
import cv2import numpy as npdef show_view():cap cv2.VideoCapture(0)ret cap.set(3, 320) # 设置捕获窗口大小ret cap.set(4, 240)while(cap.isOpened()):ret, frame cap.read()gray cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) # 彩色图像用BGR2RGBcv2.imshow(frame, gray)if cv2.waitKey(1) ord(q):breakcap.release()cv2.destroyAllWindows()if __name__ __main__:show_view()
原图像输出
import cv2import numpy as npdef show_view():cap cv2.VideoCapture(0)ret cap.set(3, 320) # 设置捕获窗口大小ret cap.set(4, 240)while(cap.isOpened()):ret, frame cap.read()# gray cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) # 彩色图像用BGR2RGBcv2.imshow(frame, frame)if cv2.waitKey(1) ord(q):breakcap.release()cv2.destroyAllWindows()if __name__ __main__:show_view()
学习网址docs.opencv.org/master/
本文共计227个文字,预计阅读时间需要1分钟。
第一步:安装numpybashpip install numpy
第二步:安装opencv-contrib-pythonbashpip install opencv-contrib-python
第三步:添加灰度滤镜pythonimport cv2
第一步安装numpypipinstallnumpy第二步安装opencv-contrib-pythonpipinstallopencv-contri第一步安装numpy pip install numpy 第二步安装opencv-contrib-python pip install opencv-contrib-python 添加灰色滤镜
import cv2import numpy as npdef show_view():cap cv2.VideoCapture(0)ret cap.set(3, 320) # 设置捕获窗口大小ret cap.set(4, 240)while(cap.isOpened()):ret, frame cap.read()gray cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) # 彩色图像用BGR2RGBcv2.imshow(frame, gray)if cv2.waitKey(1) ord(q):breakcap.release()cv2.destroyAllWindows()if __name__ __main__:show_view()
原图像输出
import cv2import numpy as npdef show_view():cap cv2.VideoCapture(0)ret cap.set(3, 320) # 设置捕获窗口大小ret cap.set(4, 240)while(cap.isOpened()):ret, frame cap.read()# gray cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) # 彩色图像用BGR2RGBcv2.imshow(frame, frame)if cv2.waitKey(1) ord(q):breakcap.release()cv2.destroyAllWindows()if __name__ __main__:show_view()
学习网址docs.opencv.org/master/

