Python使用Opencv画一个哆啦A梦(动态),并制作成可执行文件.exe

直接上代码

import cv2
import numpy as np

img=np.zeros([640,640,3]).astype(np.uint8)
img=img.ravel()
for i,j in enumerate(img):
    if j==0:
        img[i]=255
img=np.reshape(img,[640,640,3])

##头
for i in range(250):
    cv2.circle(img,[320,320],i,color=[255,0,0],thickness=4,lineType=16)
cv2.imshow('frams',img)
cv2.waitKey(500)

##眼部旁边两条线
for i in range(130):
    cv2.ellipse(img,[320,320],[250,i],180,180,0,[255,255,255],4,16)
cv2.ellipse(img,[320,320],[250,130],180,180,0,[0,0,0],4,16)
cv2.imshow('frams',img)
cv2.waitKey(500)

##去除蓝色
for i in range(320):
    cv2.ellipse(img,[320,320],[i,i],0,180,0,[255,255,255],4,16)
cv2.circle(img,[320,320],250,color=[0,0,0],thickness=4,lineType=16)
cv2.imshow('frams',img)
cv2.waitKey(500)

##左眼
for i in range(50):
    cv2.ellipse(img,[270,190],[110,i],90,0,360,[255,255,255],4,16)
cv2.ellipse(img,[270,190],[110,50],90,0,360,[0,0,0],4,16)
cv2.imshow('frams',img)
cv2.waitKey(500)

##左眼中间黑点
for i in range(25):
    cv2.ellipse(img,[270,190],[55,i],90,0,360,[0,0,0],4,16)
cv2.imshow('frams',img)
cv2.waitKey(500)

##左眼眼中反光
for i in range(20):
    cv2.circle(img,[290,170],i,color=[255,255,255],thickness=4,lineType=16)
cv2.imshow('frams',img)
cv2.waitKey(500)

##右眼
for i in range(50):
    cv2.ellipse(img, [370, 190], [110, i], 90, 0, 360, [255, 255, 255], 4, 16)
cv2.ellipse(img,[370,190],[110,50],90,0,360,[0,0,0],4,16)
cv2.imshow('frams',img)
cv2.waitKey(500)

##鼻子
for i in range(25):
    cv2.circle(img,[320,300],i,color=[0,0,255],thickness=4,lineType=16)
cv2.circle(img,[320,300],i,color=[0,0,0],thickness=4,lineType=16)
cv2.imshow('frams',img)
cv2.waitKey(500)

##右眼里面
cv2.line(img,[320,200],[390,150],[0,0,0],4,16)
cv2.imshow('frams',img)
cv2.waitKey(500)
cv2.line(img,[320,200],[390,250],[0,0,0],4,16)
cv2.imshow('frams',img)
cv2.waitKey(500)

##鼻子到嘴巴
cv2.line(img,[320,325],[320,460],[0,0,0],4,16)
cv2.imshow('frams',img)
cv2.waitKey(500)
cv2.ellipse(img,[320,350],[130,110],0,180,0,[0,0,0],4,16)
cv2.imshow('frams',img)
cv2.waitKey(500)

#左边胡子
cv2.line(img,[230,300],[110,250],[0,0,0],4,16)
cv2.imshow('frams',img)
cv2.waitKey(500)
cv2.line(img,[240,320],[100,330],[0,0,0],4,16)
cv2.imshow('frams',img)
cv2.waitKey(500)
cv2.line(img,[220,340],[110,360],[0,0,0],4,16)
cv2.imshow('frams',img)
cv2.waitKey(500)

#右边胡子
cv2.line(img,[430,300],[570,270],[0,0,0],4,16)
cv2.imshow('frams',img)
cv2.waitKey(500)
cv2.line(img,[420,320],[560,330],[0,0,0],4,16)
cv2.imshow('frams',img)
cv2.waitKey(500)
cv2.line(img,[410,340],[550,370],[0,0,0],4,16)
np.set_printoptions(threshold=np.inf)
cv2.imshow('frams',img)

# cv2.imshow('frams',img)
cv2.waitKey(0)
cv2.destroyAllWindows()

没找到opencv的填充,就直接用for循环进行颜色填充。
for循环进行颜色填充,其他的都是描线。

效果图如下(实际上是动态图
Python使用Opencv画一个哆啦A梦(动态),并制作成可执行文件.exe_第1张图片
最后使用pyinstaller转化成exe文件可以看我之前的文章
这里

你可能感兴趣的:(opencv,python,计算机视觉)