计算机视觉(三)

左手的ㄟ右手 2022-06-03 10:38 419阅读 0赞

1、滤波器

傅里叶变换主要作用反应图像各区域像素变化的幅度。

滤波器(核)矩阵:一组权重集合(内部所有值加和为0),作用在源图像的一个区域(滑动),并由此生成目标图像的一个元素。

高通滤波器(HPF):检测图像的某个区域,然后根据像素与周围像素的亮度差值提升该像素的滤波器。如果亮度变化很大,中央像素的亮度会增加(反之则不会)。

(即某个像素比它周围的像素更突出,就会提升它的亮度)

  1. def convolve(input, weights, output=None, mode='reflect', cval=0.0,
  2. origin=0):
  3. return _correlate_or_convolve(input, weights, output, mode, cval,
  4. origin, True)
  5. input : array_like Input array to filter. weights : array_like Array of weights, same number of dimensions as input output : ndarray, optional The `output` parameter passes an array in which to store the filter output. Output array should have different name as compared to input array to avoid aliasing errors. mode : {'reflect','constant','nearest','mirror', 'wrap'}, optional the `mode` parameter determines how the array borders are handled. For 'constant' mode, values beyond borders are set to be `cval`. Default is 'reflect'. cval : scalar, optional Value to fill past edges of input if `mode` is 'constant'. Default is 0.0 origin : array_like, optional The `origin` parameter controls the placement of the filter, relative to the centre of the current element of the input. Default of 0 is equivalent to ``(0,)*input.ndim``.
  6. def GaussianBlur(src, ksize, sigmaX, dst=None, sigmaY=None, borderType=None): # real signature unknown; restored from __doc__ """ GaussianBlur(src, ksize, sigmaX[, dst[, sigmaY[, borderType]]]) -> dst """ pass

参数1:源图像

参数2:高斯矩阵尺寸

参数3:标准差

高斯矩阵的尺寸越大,标准差越大,处理过的图像模糊程度越大。

自定义卷积核。

  1. from cv2 import *
  2. import numpy as np
  3. from scipy import ndimage
  4. kernel_3x3=np.array([[-1,-1,-1],
  5. [-1,8,-1],
  6. [-1,-1,-1]])
  7. kernel_5x5=np.array([[-1,-1,-1,-1,-1],
  8. [-1,1,2,1,-1],
  9. [-1,2,4,2,-1],
  10. [-1,1,2,1,-1],
  11. [-1,-1,-1,-1,-1]])
  12. img=imread("D:/temp/1.jpg",0)
  13. img1=ndimage.convolve(img,kernel_3x3)# 注:使用ndimage.convolve()时,滤波核的维度应与原始图像的维度相同,故此采用灰度图
  14. img2=ndimage.convolve(img,kernel_5x5)
  15. blurred=GaussianBlur(img,(11,11),0)
  16. g_hpf=img-blurred
  17. imshow('Pic',img)
  18. imshow('3x3',img1)
  19. imshow('5x5',img2)
  20. imshow('g_hpf',g_hpf)
  21. waitKey()
  22. destroyAllWindows()

低通滤波器(LPF):在像素与周围的亮度差值小于一个特定值时,平滑该像素的亮度,用于去噪和模糊化。如上面的高斯模糊(平滑滤波器)。

2、边缘检测

  1. OpenCV提供了许多边缘检测滤波函数,包括Laplacian()、Sobel()以及Scharr()。这些滤波函数都会将**非边缘区域转为黑色**,将**边缘区域转为白色或其他饱和的颜色**。但是,这些函数都很容易将噪声错误地识别为边缘。缓解这个问题的方法是在**找到边缘之前对图像进行模糊处理**。OpenCV也提供了许多模糊滤波函数,包括blur()(简单的算术平均)、medianBlur()以及GaussianBlur()。边缘检测滤波函数和模糊滤波函数的参数有很多,但总会有一个ksize参数,它是一个奇数,表示滤波器的宽和高(以像素为单位)。

  这里使用medianBlur()作为模糊函数,它对去除数字化的视频噪声非常有效,特别是去除彩色图像的噪声;使用Laplacian()作为边缘检测函数,它会产生明显的边缘线条,灰度图像更是如此。在使用medianBlur()函数之后,将要使用Laplacian()函数之前,需要将图像从BGR色彩空间转为灰度色彩空间。

  在得到Laplacian()函数的结果之后,需要将其转换成黑色边缘和白色背景的图像。然后将其归一化(使它的像素值在0到1之间),并乘以源图像以便能将边缘变黑。

  1. #coding:utf-8
  2. from cv2 import *
  3. import numpy
  4. import distutils
  5. def strokeEdges(src,dst,blurksize=7,edgeksize=5):
  6. if blurksize>=3:
  7. blurredsrc=medianBlur(src,blurksize)
  8. graysrc=cvtColor(blurredsrc,COLOR_BGR2GRAY)
  9. else:
  10. graysrc=cvtColor(src,COLOR_BGR2GRAY) #灰度图
  11. Laplacian(graysrc,CV_8U,graysrc,ksize=edgeksize)
  12. #归一化
  13. normalizedInverseAlpha=(1.0/255)*(255-graysrc)
  14. channels=split(src) #分离通道
  15. for channel in channels:
  16. channel[:]=channel*normalizedInverseAlpha
  17. merge(channels,dst)
  18. return dst
  19. img0=imread("D:/temp/1.jpg",1)
  20. dst=img0
  21. dst=filters.strokeEdges(img0,dst,blurksize=7,edgeksize=5)
  22. imshow('dst',dst) #合并通道
  23. 注意,核的大小可由strokeEdges()函数的参数来指定。blurKsize参数会 作为medianBlur()含糊的ksize参数,edgeKsize参数会作为Laplacian()函数的ksize参数。对于作者的摄像头,将blurKsize值设为7,将edgeKsize值设为5会得到最好的效果。但对于较大的ksize(比如7),使用medianBlur()的代价很高。如果在使用strokeEdges()函数时遇到性能问题,可试着减小blurKsize的值。要关闭模糊效果,可以将blurKsize的值设为3以下

Distutils包是标准Python库的一部分;主要特点有两个:
(1)是让用户觉得安装新模块、包和工具的过程是简单、一致又轻松的;
(2)是让开发者觉得创建这些新模块、包和工具的分发包是简单、一致又轻松的;

3、Canny边缘检测

Canny边缘检测算法有5个步骤:使用高斯滤波器对图像进行去噪、计算梯度、在边缘上使用非最大抑制(NMS)、在检测到的边缘上使用双阈值去除假阳性(false positive),最后还会分析所有的边缘及其之间的连接,以保留真正的边缘并消除不明显的边缘。

参考:http://blog.csdn.net/m0\_37264397/article/details/70314025

  1. def Canny(image, threshold1, threshold2, edges=None, apertureSize=None, L2gradient=None): # real signature unknown; restored from __doc__ """ Canny(image, threshold1, threshold2[, edges[, apertureSize[, L2gradient]]]) -> edges """ pass
  2. from cv2 import *
  3. import numpy as np
  4. img=imread("D:/temp/1.jpg",0)
  5. imwrite('canny.jpg',Canny(img,200,300))
  6. imshow('canny',imread('canny.jpg'))
  7. waitKey()
  8. destroyAllWindows()

4、轮廓检测

在计算机视觉中,轮廓检测不仅用来检测图像或者视频帧中物体的轮廓,而且还有其他操作与轮廓检测有关。如:计算多边形边界、形状逼近和计算感兴趣区域。这是与图像数据交互时的简单操作,因为NumPy中的矩形区域可以使用数组切片(slice)来定义。在物体检测(包括人脸)和物体跟踪时会大量使用。

  1. def threshold(src, thresh, maxval, type, dst=None): # real signature unknown; restored from __doc__ """ threshold(src, thresh, maxval, type[, dst]) -> retval, dst """ pass
  2. threshold()简单阈值
  3.   这个函数有四个参数,第一个原图像,第二个进行分类的阈值,第三个是高于(低于)阈值时赋予的新值,第四个是一个方法选择参数,常用的有:
  4.     cv2.THRESH_BINARY(黑白二值)
  5.     cv2.THRESH_BINARY_INV(黑白二值反转)
  6.     cv2.THRESH_TRUNC (得到的图像为多像素值)
  7.     cv2.THRESH_TOZERO
  8.     cv2.THRESH_TOZERO_INV
  9. 该函数有两个返回值,第一个retVal(得到的阈值(在后面一个方法中会用到)),第二个就是阈值化后的图像。
  10. def findContours(image, mode, method, contours=None, hierarchy=None, offset=None): # real signature unknown; restored from __doc__ """ findContours(image, mode, method[, contours[, hierarchy[, offset]]]) -> image, contours, hierarchy """ pass
  11. findContours()函数有三个参数:输入图像、层次类型和轮廓逼近方法。
  12.   这个函数会修改输入图像,因此建议使用原始图像的一份拷贝(如:通过img.copy()来作为输入图像)。
  13.   由函数返回的层次树相当重要:cv2.RETR_TREE参数会得到图像中轮廓的整体层次结构,以此来建立轮廓之间的“关系”。如果只想得到最外面的轮廓,可使用cv2.RETR_EXTERNAL。这对消除包含在其他轮廓中的轮廓很有用(如在大多数情形下,不需要检测一个目标包含在另一个与之相同的目标里面)
  14.   findContours()函数有三个返回值:修改后的图像、图像的轮廓以及它们的层次。使用轮廓来画出图像的彩色版本(即把轮廓画成绿色),并显示出来。
  15. 画出轮廓:
  16. def drawContours(image, contours, contourIdx, color, thickness=None, lineType=None, hierarchy=None, maxLevel=None, offset=None): # real signature unknown; restored from __doc__ """ drawContours(image, contours, contourIdx, color[, thickness[, lineType[, hierarchy[, maxLevel[, offset]]]]]) -> image """ pass
  17. from cv2 import *
  18. import numpy as np
  19. img=np.zeros((200,200),dtype=np.uint8)# 创建一个200x200大小的黑色空白图像
  20. img[50:150,50:150]=255 # 在图像的中央放置一个白色方块
  21. ret,thresh=threshold(img,127,255,0) #对图像进行二值化操作
  22. image,contours,hieraracy=findContours(thresh,RETR_TREE,CHAIN_APPROX_SIMPLE)# 寻找轮廓
  23. color=cvtColor(img,COLOR_GRAY2BGR)# 颜色空间转换
  24. img=drawContours(color,contours,-1,(0,0,255),2)# 画出轮廓,-1,表示所有轮廓,画笔颜色为(0, 0, 255),即Red,粗细为3
  25. imshow('contours',color)
  26. waitKey()
  27. destroyAllWindows()

5. 边界框、最小矩形区域和最小闭圆的轮廓

  可用OpenCV的cv2.findContours函数找到不规则的、歪斜的以及旋转的形状。现实的应用会对目标的边界框、最小矩形面积、最小闭圆特别感兴趣。

  1. 高斯金字塔用来向下采样 def pyrDown(src, dst=None, dstsize=None, borderType=None): # real signature unknown; restored from __doc__ """ pyrDown(src[, dst[, dstsize[, borderType]]]) -> dst """ pass 从一个高分辨率图像变成低分辨率图 3个参数:
  2. tmp: 当前图像,初始化为原图像 src
  3. dst: 目的图像( 显示图像,为输入图像的一半)
  4. Size( tmp.cols/2, tmp.rows/2 ) :目的图像大小, 既然我们是向下采样
  5. def pyrUp(src, dst=None, dstsize=None, borderType=None): # real signature unknown; restored from __doc__ """ pyrUp(src[, dst[, dstsize[, borderType]]]) -> dst """ pass
  6. http://blog.csdn.net/m0_37264397/article/details/70303128
  7. def rectangle(img, pt1, pt2, color, thickness=None, lineType=None, shift=None): # real signature unknown; restored from __doc__ """ rectangle(img, pt1, pt2, color[, thickness[, lineType[, shift]]]) -> img """ pass
  8. def boundingRect(points): # real signature unknown; restored from __doc__ """ boundingRect(points) -> retval """ pass
  9. points:输入点集。
  10. 返回最小正矩形。
  11. 最小矩形区域
  12. def minAreaRect(points): # real signature unknown; restored from __doc__ """ minAreaRect(points) -> retval """ pass
  • points:输入点集。
  • 返回最小斜矩形。

    1. def boxPoints(box, points=None): # real signature unknown; restored from __doc__ """ boxPoints(box[, points]) -> points """ pass

    寻找盒子的顶点

  1. def minEnclosingCircle(points): # real signature unknown; restored from __doc__ """ minEnclosingCircle(points) -> center, radius """ pass
  2. * points:输入点集。
  3. * center:圆心。
  4. * radius:半径。
  5. * 对给定的 2D 点集,寻找最小面积的包围圆形
  6. 如下,在摄像(动态图像)中寻找轮廓(动态)。
  7. from cv2 import *
  8. import numpy as np
  9. videocapture=VideoCapture(0)
  10. success,franme=videocapture.read()
  11. while success:
  12. # image=pyrDown(franme)#下采样降维
  13. image=pyrUp(franme)#上采样升维
  14. ret,thresh=threshold(cvtColor(image.copy(),COLOR_BGR2GRAY),127,255,THRESH_BINARY)
  15. #findContours()函数有三个返回值:修改后的图像、图像的轮廓以及它们的层次。
  16. img,contiours,hier=findContours(thresh,RETR_EXTERNAL,CHAIN_APPROX_SIMPLE)
  17. #遍历轮廓中的像素点
  18. for c in contiours:
  19. # 现计算出一个简单的边界框
  20. x,y,w,h=boundingRect(c)
  21. rectangle(image,(x,y),(x+w,y+h),(0,255,0),2)# 将轮廓信息转换成(x, y)坐标,并加上矩形的高度和宽度
  22. rect=minAreaRect(c) # 画出矩形
  23. box=boxPoints(rect)# 计算包围目标的最小矩形区域
  24. # 注:OpenCV没有函数能直接从轮廓信息中计算出最小矩形顶点的坐标。所以需要计算出最小矩形区域,
  25. # 然后计算这个矩形的顶点。由于计算出来的顶点坐标是浮点型,但是所得像素的坐标值是整数(不能获取像素的一部分)
  26. box=np.int0(box)
  27. # 所以需要做一个转换
  28. drawContours(image,[box],0,(0,0,255),3)# 画出该矩形
  29. #圈出目标
  30. (x,y),radius=minEnclosingCircle(c)
  31. center=(int(x),int(y)) # 会返回一个二元组,第一个元素为圆心的坐标组成的元组,第二个元素为圆的半径值。
  32. radius=int(radius)
  33. image=circle(image,center,radius,(0,0,255),2)
  34. drawContours(image, contiours, -1, (255, 0, 0), 1)
  35. imshow('contious', image)
  36. waitKey(10)
  37. success, franme = videocapture.read()
  38. **6、凸轮廓与Douglas-Peucker算法**
  39.   大多数处理轮廓的时候,物体的形状(包括凸形状)都是变化多样的。凸形状内部的任意两点之间的连线都在该形状里面。
  40.   cv2.approxPloyDP是一个OpenCV函数,它用来计算近似的多边形框。该函数有三个参数:
  41.   第一个参数为“轮廓”;
  42.   第二个参数为“ε值”,它表示源轮廓与近似多边形的最大差值(这个值越小,近似多边形与源轮廓越接近);
  43.   第三个参数为“布尔标记”,它表示这个多边形是否闭合。
  44.   ε值对获取有用的轮廓非常重要。是为所得到的近似多边形周长与源轮廓周长之间的最大差值,这个差值越小,近似多边形与源轮廓就越相似。
  45.   可通过OpenCVcv2.arcLength函数来得到轮廓的周长信息。
  46. ### ArcLength ###
  47. 计算轮廓周长或曲线长度
  48. double cvArcLength( const void* curve, CvSlice slice=CV_WHOLE_SEQ, int is_closed=-1 );
  49. curve
  50. 曲线点集序列或数组
  51. slice
  52. 曲线的起始点,缺省是计算整个曲线的长度
  53. is\_closed
  54. 表示曲线是否闭合,有三种情况:
  55. * is\_closed=0 - 假设曲线不闭合
  56. * is\_closed>0 - 假设曲线闭合
  57. * is\_closed<0 - 若曲线是序列,检查 ((CvSeq\*)curve)->flags 中的标识 CV\_SEQ\_FLAG\_CLOSED 来确定曲线是否闭合。否则 (曲线由点集的数组 (CvMat\*) 表示) 假设曲线不闭合。
  58. 函数 cvArcLength通过依次计算序列点之间的线段长度,并求和来得到曲线的长度。
  59. def approxPolyDP(curve, epsilon, closed, approxCurve=None): # real signature unknown; restored from __doc__ """ approxPolyDP(curve, epsilon, closed[, approxCurve]) -> approxCurve """ pass
  60. http://blog.csdn.net/qq_18343569/article/details/47999257
  61. opencv提供了convexHull()函数来查找图像中物体的凸包,起函数定义如下: void cv::convexHull ( InputArray points,
  62. OutputArray hull,
  63. bool clockwise = false,
  64. bool returnPoints = true
  65. )
  66. 1
  67. 2
  68. 3
  69. 4
  70. 5
  71. def convexHull(points, hull=None, clockwise=None, returnPoints=None): # real signature unknown; restored from __doc__ """ convexHull(points[, hull[, clockwise[, returnPoints]]]) -> hull """ pass 参数解释
  72. points:输入的二维点集,Mat类型数据即可
  73. hull:输出参数,用于输出函数调用后找到的凸包
  74. clockwise:操作方向,当标识符为真时,输出凸包为顺时针方向,否则为逆时针方向。
  75. returnPoints:操作标识符,默认值为true,此时返回各凸包的各个点,否则返回凸包各点的指数,当输出数组时std::vector时,此标识被忽略。
  76. C++ code:http://blog.csdn.net/keith\_bb/article/details/70194073
  77. from cv2 import *
  78. import numpy as np
  79. videocapture=VideoCapture(0)
  80. success,franme=videocapture.read()
  81. while success:
  82. # image=pyrDown(franme)#下采样降维
  83. # image=pyrUp(franme)#上采样升维
  84. image=franme
  85. #对图像进行二值化
  86. ret,thresh=threshold(cvtColor(image.copy(),COLOR_BGR2GRAY),100,255,THRESH_BINARY)
  87. #findContours()函数有三个返回值:修改后的图像、图像的轮廓以及它们的层次。
  88. img,contiours,hier=findContours(thresh,RETR_EXTERNAL,CHAIN_APPROX_NONE)
  89. #遍历轮廓中的像素点
  90. for c in contiours:
  91. epsilon=0.01*arcLength(c,True)
  92. approx=approxPolyDP(c,epsilon,True)
  93. #寻找凸包
  94. hull=convexHull(c)
  95. drawContours(image,approx, -1, (0,0,255), 3)
  96. drawContours(image, hull, -1, (0, 0, 255), 3)
  97. imshow('contious', image)
  98. waitKey(10)
  99. success, franme = videocapture.read()
  100. destroyAllWindows()
  101. **7 直线和圆检测**
  102.   Hough变换是直线和形状检测背后的理论基础。
  103. **绘制直线 ** 
  104.   函数为:cv2.lineimg,Point pt1,Point pt2,color,thickness=1,line\_type=8 shift=0
  105.   有值的代表有默认值,不用给也行。可以看到这个函数主要接受参数为两个点的坐标,线的颜色(彩色图像的话颜色就是一个1\*3的数组)
  106. 直线检测     直线检测可通过HoughLinesHoughLinesP函数来完成,它们仅有的差别是:第一个函数使用标准的Hough变换,第二个函数使用概率Hough变换。 HoughLinesP函数之所以成为概率版本的Hough变换是因为它只通过分析点的子集并估计这些点都属于一条直线的概率,这是标准Hough变换的优化版本,该函数的计算代价会少一些,执行会变得更快。
  107. def HoughLinesP(image, rho, theta, threshold, lines=None, minLineLength=None, maxLineGap=None): # real signature unknown; restored from __doc__ """ HoughLinesP(image, rho, theta, threshold[, lines[, minLineLength[, maxLineGap]]]) -> lines """ pass
  108. 第一个参数:输入灰度图像
  109. 第二个参数:输出检测的线条
  110. 第三个参数:极径
  111. 第四个参数:极角
  112. 第五个参数:累加平面阈值
  113. 第六个参数:最低线段长度
  114. 第七个参数:点点之间的最大距离
  115. 参考:http://blog.csdn.net/m0\_37264397/article/details/72729423
  116. def line(img, pt1, pt2, color, thickness=None, lineType=None, shift=None): # real signature unknown; restored from __doc__ """ line(img, pt1, pt2, color[, thickness[, lineType[, shift]]]) -> img """ pass
  117. Demo
  118. from cv2 import *
  119. import numpy as np
  120. image=imread("D:/temp/1.jpg")
  121. gray=cvtColor(image,COLOR_BGR2GRAY)
  122. edge=Canny(gray,50,120)
  123. minLineLength=20
  124. maxLineGap=5
  125. lines=HoughLinesP(edge,1,np.pi/180,100,minLineLength,maxLineGap)
  126. for x1,y1,x2,y2 in lines[0]:
  127. line(image,(x1,y1),(x2,y2),(0,255,0),2)
  128. imshow('edge',edge)
  129. imshow('line',image)
  130. waitKey()
  131. destroyAllWindows()
  132. HoughLines函数会接收一个由Canny边缘检测滤波器处理过的单通道二值图像,不一定需要Canny滤波器,但是一个经过去噪并只有边缘的图像当作Hough变换的输入会很不错。
  133. HoughLinesP的参数:
  134.     需要处理的参数;
  135.     线段的几何表示rhotheta,一般分别取1np.pi/180
  136.     阈值,低于该阈值的直线会被忽略,Hough变换可以理解为投票箱和投票数之间的关系,每一个投票箱代表一个直线,投票数达到阈值的直线会被保留,其他的会被删除。
  137.     minLineLengthmaxLineGap 
  138. 问题:
  139. https://stackoverflow.com/questions/16144015/python-typeerror-nonetype-object-has-no-attribute-getitem#comment23064755_16144015
  140. from cv2 import *
  141. import numpy as np
  142. videocapture=VideoCapture(0)
  143. ret,image=videocapture.read()
  144. while ret:
  145. img=image
  146. gray=cvtColor(image,COLOR_BGR2GRAY)
  147. edge=Canny(gray,50,120)
  148. minLineLength=20
  149. maxLineGap=5
  150. lines = (edge, 1, np.pi/180, 20, np.array([]), 10)[0]
  151. for l in lines:
  152. line(image, (l[0],l[1]), (l[2],l[3]), (0, 255, 0), 2)
  153. imshow('line', image)
  154. imshow('edge',edge)
  155. imshow('image',img)
  156. waitKey(10)
  157. ret, image = videocapture.read()
  158. destroyAllWindows()
  159. ** **
  160. **圆检测**
  161.     OpenCVHoughCircles函数可用来检测圆,它与使用HoughLines函数类似。像用来决定删除或保留直线的两个参数minLineLengthmaxLineGap一样,HoughCircles有一个圆心间的最小距离和圆的最小及最大半径。
  162. def medianBlur(src, ksize, dst=None): # real signature unknown; restored from __doc__ """ medianBlur(src, ksize[, dst]) -> dst """ pass
  163. def HoughCircles(image, method, dp, minDist, circles=None, param1=None, param2=None, minRadius=None, maxRadius=None): # real signature unknown; restored from __doc__ """ HoughCircles(image, method, dp, minDist[, circles[, param1[, param2[, minRadius[, maxRadius]]]]]) -> circles """ pass
  164. http://blog.csdn.net/m0\_37264397/article/details/72729423
  165. Demo1
  166. from cv2 import *
  167. import numpy as np
  168. image=imread("D:/temp/a2.jpg")
  169. gray=cvtColor(image,COLOR_BGR2GRAY)
  170. img=medianBlur(gray,5)
  171. # cimg=cvtColor(img,COLOR_BGR2GRAY)
  172. circles=HoughCircles(img,HOUGH_GRADIENT,1,120,param1=100,param2=30,minRadius=0,maxRadius=0)
  173. circles=np.uint16(np.around(circles))
  174. for i in circles[0,:]:
  175. circle(image,(i[0],i[1]),i[2],(0,255,0),2)
  176. circle(image,(i[0],i[1]),2,(0,0,255),3)
  177. imshow('image',image)
  178. waitKey()
  179. destroyAllWindows()
  180. Demo2
  181. from cv2 import *
  182. import numpy as np
  183. videocapture=VideoCapture(0)
  184. ret,image=videocapture.read()
  185. while ret:
  186. gray=cvtColor(image,COLOR_BGR2GRAY)
  187. img=medianBlur(gray,5)
  188. cimg=cvtColor(img,COLOR_GRAY2BGR)
  189. circles = HoughCircles(img, HOUGH_GRADIENT, 1, 120, param1=100, param2 = 30, minRadius = 0, maxRadius = 0)
  190. circles = np.uint16(np.around(circles))
  191. for i in circles[0, :]:
  192. circle(image, (i[0], i[1]), i[2], (0, 255, 0), 2)
  193. circle(image, (i[0], i[1]), 2, (0, 0, 255), 3)
  194. imshow('image',image)
  195. waitKey(10)
  196. ret, image = videocapture.read()
  197. destroyAllWindows()
  198. 运行出现:AttributeError: 'NoneType' object has no attribute 'rint',暂未解决。

发表评论

表情:
评论列表 (有 0 条评论,419人围观)

还没有评论,来说两句吧...

相关阅读

    相关 计算机视觉

    1、滤波器 傅里叶变换主要作用反应图像各区域像素变化的幅度。 滤波器(核)矩阵:一组权重集合(内部所有值加和为0),作用在源图像的一个区域(滑动),并由此生成目标图像的一个

    相关 计算机视觉(二)

    1、捕获摄像头的帧   VideoCapture类可以获得摄像头的帧流。但对摄像头而言,通常不是用视频的文件名来构造VideoCapture类,而是需要传递摄像头的设备索引(

    相关 计算机视觉大顶级国际会议

    与所有其它学术领域都不同,计算机科学使用会议而不是期刊作为发表研究成果的主要方式。目前国外计算机界评价学术水平主要看在顶级学术会议上发表的论文。特别是在机器学习、计算机视觉和人