Python基础之opencv框架
Python中的opencv框架
程序举例演示:
[python] view plain copy
- import cv2
- img=cv2.imread('1.jpg')
- cv2.imshow('image',img)
- cv2.waitKey(0)
- #转为灰度图
- img=cv2.cvtColor(img,cv2.COLOR_RGB2GRAY)
- cv2.imshow('image',img)
- cv2.waitKey(0)
- cv2.destroyAllWindows()
执行程序:
灰度图:
在图片上划线:
[python] view plain copy
- import cv2
- img=cv2.imread('1.jpg')
- #在图片上划线
- green=(0,255,0)
- cv2.line(img,(0,0),(900,900),green,9)
- cv2.imshow('img',img)
- cv2.waitKey(0)
- cv2.destroyAllWindows()
执行程序结果:
在图片上画圆:
[python] view plain copy
- import cv2
- img=cv2.imread('1.jpg')
- #在图片上画圆
- green=(0,255,0)
- cv2.circle(img,(300,300),100,green,20)
- cv2.imshow('img',img)
- cv2.waitKey(0)
- cv2.destroyAllWindows()
程序执行效果:
在图片上画矩形:
[python] view plain copy
- import cv2
- img=cv2.imread('1.jpg')
- #在图片上画矩形,四元组组成,左上角坐标点和右下角坐标点
- green=(0,255,0)
- cv2.rectangle(img,(200,100),(300,200),green,3)
- cv2.imshow('img',img)
- cv2.waitKey(0)
- cv2.destroyAllWindows()
执行程序:
相关推荐
huang00 2020-08-21
wangdaren 2020-02-19
learningCV 2020-11-10
learningCV 2020-08-25
wangdaren 2020-08-15
BeanJoy 2020-07-28
csdmeb 2020-06-25
wangdaren 2020-06-14
pythonxuexi 2020-06-13
woniulx0 2020-06-13
greent00 2020-06-10
liangzuojiayi 2020-06-09
greent00 2020-06-09
csdmeb 2020-06-08
BeanJoy 2020-06-06
lihuifei 2020-06-05
wangdaren 2020-06-03
wangdaren 2020-05-31