我想建网站,做网站相册,招聘网站开发的流程,做网站只买一个程序目录 模版匹配原理实现 霍夫变换霍夫线检测 模版匹配
原理 实现
rescv.matchTemplate(img,template,method)import numpy as np
import cv2 as cv
import matplotlib.pyplot as pltimgcv.imread(./汪学长的随堂资料/6/模板匹配/lena.jpg)
templatecv.imread(./汪学长的随堂资… 目录 模版匹配原理实现 霍夫变换霍夫线检测 模版匹配
原理 实现
rescv.matchTemplate(img,template,method)import numpy as np
import cv2 as cv
import matplotlib.pyplot as pltimgcv.imread(./汪学长的随堂资料/6/模板匹配/lena.jpg)
templatecv.imread(./汪学长的随堂资料/6/模板匹配/face.jpg)
rescv.matchTemplate(img,template,cv.TM_CCORR)
min_val,max_val,min_loc,max_loccv.minMaxLoc(res)
top_leftmax_loc
h,wtemplate.shape[:2]
bottom_right(top_left[0]w,top_left[1]h)
cv.rectangle(img,top_left,bottom_right,[0,255,0],2)
plt.imshow(img[:,:,::-1])注
霍夫变换 霍夫线检测
cv.HoughLines(img,rho,theta,threshold)imgcv.imread(./image/rili,jpg,0)
edgescv.Canny(img,50,150)
linescv.HoughLines(edges,0.8,np.pi/180,150)
for line in lines:rho,thetaline[0]anp.cos(theta)bnp.sin(theta)x0rho*ay0rho*bx1int(x01000*(-b))y1int(y01000*a)x2int(x0-1000*(-b))y2int(y0-1000*a)cv.line(img,(x1,y1),(x2,y2),(0,255,0))
plt.imshow(img[:,:,::-1])