Bootstrap

opencv库的基本使用(python)

opencv库的基本使用(python)

1.图片的读取与保存


 
 
  1. # -*- coding: utf-8 -*-
  2. # @Author: Xingmo
  3. import cv2
  4. import numpy as np
  5. # 读取图片: cv2.imread(路径,num) 其中num=0,为灰度图像;num=1为彩图
  6. img = cv2.imread( '002.jpg', 0)
  7. # 创建窗口,cv2.namedWindow(窗口名)
  8. cv2.namedWindow( 'image')
  9. # 保存图片,cv2.imwrite(保存图片名,要保存的图片)
  10. cv2.imwrite( '002.jpg',img)
  11. # 第三个参数针对特定的格式: 对于JPEG,其表示的是图像的质量,用0-100的整数表示(越高越清晰,压缩级别越低),默认为95。 注意,cv2.IMWRITE_JPEG_QUALITY类型为Long,必须转换成int。
  12. cv2.imwrite( '003.jpg',img,[int(cv2.IMWRITE_JPEG_QUALITY), 10])
  13. # 对于PNG,第三个参数表示的是压缩级别。cv2.IMWRITE_PNG_COMPRESSION,从0到9,压缩级别越高,图像尺寸越小。默认级别为3
  14. cv2.imwrite( '004.png', img, [int(cv2.IMWRITE_PNG_COMPRESSION), 5])
  15. # 图片显示,cv2.imshow(窗口名,要显示的图片)
  16. cv2.imshow( 'image1',img)
  17. # 复制img图片
  18. #emptyimage = img.copy()
  19. # 创建空图片
  20. emptyimage = np.zeros(img.shape,np.uint8)
  21. cv2.imshow( 'image2',emptyimage)
  22. # 键盘绑定函数
  23. cv2.waitKey( 0)
  24. # 释放窗口
  25. cv2.destroyAllWindows()


2.像素点的操作,添加椒盐噪声


 
 
  1. # -*- coding: utf-8 -*-
  2. # @Author: Xingmo
  3. import cv2
  4. import numpy as np
  5. # 添加椒盐噪声
  6. def salt(img):
  7. for k in range( 100):
  8. # 建立图片随机坐标点
  9. i = int(np.random.random()*img.shape[ 0])
  10. j = int(np.random.random()*img.shape[ 1])
  11. # 图片为灰度图像,有二维
  12. if img.ndim == 2:
  13. img[i,j] = 255
  14. # 图片为彩色图片,有三维,RGB
  15. elif img.ndim == 3:
  16. img[i,j, 0] = 255
  17. img[i,j, 1] = 255
  18. img[i,j, 2] = 255
  19. return img
  20. if __name__ == '__main__':
  21. # 读取图片
  22. img = cv2.imread( '001.jpg')
  23. # 添加噪声
  24. saltImage = salt(img)
  25. # 图片显示
  26. cv2.imshow( "Salt", saltImage)
  27. # 图片保存
  28. cv2.imwrite( 'salt.jpg',saltImage)
  29. cv2.waitKey( 0)
  30. cv2.destroyAllWindows()

3.彩色图片各通道分离与合并


 
 
  1. # -*- coding: utf-8 -*-
  2. # @Author: Xingmo
  3. import cv2
  4. img = cv2.imread( '001.jpg')
  5. # split 返回BGR三个通道
  6. b,g,r = cv2.split(img)
  7. # merged 通道合并
  8. merge = cv2.merge([b,g,r])
  9. cv2.imshow( 'merge',merge)
  10. #cv2.imshow("Red", r)
  11. #cv2.imshow("Green", g)
  12. #cv2.imshow("Blue", b)
  13. cv2.waitKey( 0)
  14. cv2.destroyAllWindows()



4.直方图的绘画


 
 
  1. # -*- coding: utf-8 -*-
  2. # @Author: Xingmo
  3. ####### 说明 #######
  4. # cv2.calcHist(images, channels, mask, histSize, ranges[, hist[, accumulate ]]) #返回hist
  5. # 第一个参数为读取的图像,必须用方括号括起来。
  6. # 第二个参数是用于计算直方图的通道,这里使用灰度图计算直方图,所以就直接使用第一个通道;
  7. # 第三个参数是Mask,这里没有使用,所以用None。
  8. # 第四个参数是histSize,表示这个直方图分成多少份(即多少个直方柱)。第二个例子将绘出直方图,到时候会清楚一点。
  9. # 第五个参数是表示直方图中各个像素的值,[0.0, 256.0]表示直方图能表示像素值从0.0到256的像素。
  10. # 最后是两个可选参数,由于直方图作为函数结果返回了,所以第六个hist就没有意义了(待确定)
  11. # 最后一个accumulate是一个布尔值,用来表示直方图是否叠加。
  12. #######
  13. # cv.PolyLine(img, polys, is_closed, color, thickness=1, lineType=8, shift=0) # 返回None
  14. # img 读取的图像
  15. # polys 多边形曲线的数组(各个坐标点)
  16. # is_closed 绘制的折线是否关闭的标志,起始点是否有线连接,False为没有
  17. # color 折线的颜色 [b,g,r]
  18. # thickness 折线边缘的厚度
  19. # lineType 线段的类型
  20. # shift 顶点坐标中的小数位数
  21. ######## 说明END #######
  22. import cv2
  23. import numpy as np
  24. # 将直方图(填充)转化为图片
  25. def calcAndDrawHist(image, color):
  26. hist = cv2.calcHist([image], [ 0], None, [ 256], [ 0.0, 255.0])
  27. # cv2.minMaxLoc 最大值maxVal和最小值minVal及它们的位置
  28. minVal, maxVal, minLoc, maxLoc = cv2.minMaxLoc(hist)
  29. # 创建全零图像
  30. histImg = np.zeros([ 256, 256, 3], np.uint8)
  31. hpt = int( 0.95* 256);
  32. for h in range( 256):
  33. # hpt=0.95*256 0.95防止最大值为整张图片的高,每个hist与最大值的比*(256*0.95)即可表示该hist在图片中的高度
  34. intensity = int(hist[h]*hpt/maxVal)
  35. # cv2.line(图像img,第一个点坐标(x1,y1),第二个点坐标(x2,y2),颜色[b,g,r])
  36. cv2.line(histImg,(h, 256), (h, 256-intensity), color)
  37. return histImg
  38. # 将直方图(折线)转化为图片
  39. def DrawHist(img):
  40. # 建立空图片
  41. h = np.zeros(( 256, 256, 3))
  42. # 直方图中各bin的顶点位置
  43. bins = np.arange( 256).reshape( 256, 1)
  44. # BGR三种颜色
  45. color = [ ( 255, 0, 0),( 0, 255, 0),( 0, 0, 255) ]
  46. for ch, col in enumerate(color):
  47. originHist = cv2.calcHist([img],[ch], None,[ 256],[ 0, 256])
  48. # cv2.normalize(图像img,输出图像,归一化后最低值,归一化后最大值,规范化类型 cv2.NORM_MINMAX:仅针对密集阵列)
  49. cv2.normalize(originHist, originHist, 0, 255* 0.9,cv2.NORM_MINMAX)
  50. # np.around(array) 取整数,但数据类型仍为float
  51. hist=np.int32(np.around(originHist))
  52. # np.column_stack 将两个1-D数组作为列堆叠成2维数组
  53. pts = np.column_stack((bins,hist))
  54. # cv2.polylines(图像img,多边形曲线的数组,绘制的折线是否关闭的标志,折线颜色)
  55. cv2.polylines(h,[pts], False,col)
  56. # np.flipud 在上/下方向翻转数组。
  57. h=np.flipud(h)
  58. return h
  59. '''
  60. ####### 灰度图像———直方图(填充) #######
  61. img = cv2.imread('001.jpg',0)
  62. histimg = calcAndDrawHist(img,[255,255,255])
  63. cv2.imshow('hist',histimg)
  64. cv2.waitKey(0)
  65. '''
  66. ####### 彩色图像———直方图(填充) #######
  67. if __name__ == '__main__':
  68. # 读取图片
  69. img = cv2.imread( "001.jpg")
  70. # cv2.spilt 返回BGR三个通道
  71. b, g, r = cv2.split(img)
  72. # calcAndDrawHist(图像img,color填[b,g,r])
  73. histImgB = calcAndDrawHist(b, [ 255, 0, 0])
  74. histImgG = calcAndDrawHist(g, [ 0, 255, 0])
  75. histImgR = calcAndDrawHist(r, [ 0, 0, 255])
  76. cv2.imshow( "histImgB", histImgB)
  77. cv2.imshow( "histImgG", histImgG)
  78. cv2.imshow( "histImgR", histImgR)
  79. cv2.imshow( "Img", img)
  80. ####### 彩色图像———直方图(折线) #######
  81. if __name__ == '__main__':
  82. img = cv2.imread( "001.jpg")
  83. h = DrawHist(img)
  84. cv2.imshow( 'colorhist',h)
  85. cv2.waitKey( 0)
  86. cv2.destroyAllWindows()

结果显示:

彩色图像———直方图(填充)


彩色图像———直方图(折线)


 
 

5.形态学运算:膨胀与腐蚀


 
 
  1. # -*- coding: utf-8 -*-
  2. # @Author: Xingmo
  3. import cv2
  4. import numpy as np
  5. # 读取图像
  6. img = cv2.imread( '004.jpg', 0);
  7. # 构造一个3×3的结构元素
  8. element = cv2.getStructuringElement(cv2.MORPH_RECT,( 3, 3))
  9. # 膨胀图像 cv2.dilate(图像,元素结构)
  10. dilate = cv2.dilate(img, element)
  11. # 腐蚀图像 cv2.erode(图像,元素结构)
  12. erode = cv2.erode(img, element)
  13. # 将两幅图像相减获得边,第一个参数是膨胀后的图像,第二个参数是腐蚀后的图像
  14. result = cv2.absdiff(dilate,erode);
  15. # 上面得到的结果是灰度图,cv2.threshold将其二值化以便更清楚的观察结果
  16. # cv2.threshold(src , thresh, maxval, type[, dst]) 返回retval、dst
  17. # cv2.threshold(图像, 阈值 , 最大值, 阈值类型) 返回值类型、返回处理后图像
  18. # 阈值类型:THRESH_BINARY、THRESH_BINARY_INV、THRESH_TRUNC、THRESH_TOZERO、THRESH_TOZERO_INV
  19. retval, result = cv2.threshold(result, 40, 255, cv2.THRESH_BINARY);
  20. # 反色,即对二值图每个像素取反
  21. result = cv2.bitwise_not(result);
  22. # 显示图像
  23. cv2.imshow( "origin",img); # 原图
  24. cv2.imshow( "result",result); # 边缘检测图
  25. cv2.waitKey( 0)
  26. cv2.destroyAllWindows()
结果显示:


6.初级滤波器


 
 
  1. # -*- coding: utf-8 -*-
  2. # @Author: Xingmo
  3. import cv2
  4. import numpy as np
  5. ######## 线性过滤器 #######
  6. # 低通滤波(平滑图像)
  7. # cv2.blur(图像,滤波器大小(num,num)) #返回dst(处理后图像)
  8. #
  9. # cv2.boxFilter(图像, -1, 滤波器大小(num,num)) #返回dst(处理后图像)
  10. # 第二个参数-1表示与原图相同
  11. #
  12. # 高斯模糊
  13. # cv2.GaussianBlur(图像,滤波器大小(num,num),X方向的高斯内核标准偏差) #返回dst(处理后图像)
  14. ######## 线性过滤器END #######
  15. #
  16. ######## 非线性过滤器 #######
  17. # 中值滤波
  18. # cv2.medianBlur(图像,滤波器大小num)
  19. ####### 非线性过滤器END #######
  20. def salt(img):
  21. for k in range( 100):
  22. # 建立图片随机坐标点
  23. i = int(np.random.random()*img.shape[ 0])
  24. j = int(np.random.random()*img.shape[ 1])
  25. # 图片为灰度图像,有二维
  26. if img.ndim == 2:
  27. img[i,j] = 255
  28. # 图片为彩色图片,有三维,RGB
  29. elif img.ndim == 3:
  30. img[i,j, 0] = 255
  31. img[i,j, 1] = 255
  32. img[i,j, 2] = 255
  33. return img
  34. if __name__ == '__main__':
  35. #
  36. img = cv2.imread( '001.jpg', 0)
  37. salt =salt(img)
  38. # 低通滤波
  39. dst1 = cv2.blur(salt,( 5, 5))
  40. # boxFilter
  41. dst2 = cv2.boxFilter(salt, -1,( 5, 5))
  42. # 高斯模糊
  43. dst3 = cv2.GaussianBlur(salt,( 5, 5), 1.5)
  44. # 中值滤波
  45. dst4 = cv2.medianBlur(salt, 5)
  46. # 图像显示
  47. # 对于椒盐噪声而言,中值滤波效果是最好的,其他效果差不多
  48. cv2.imshow( 'salt',salt)
  49. cv2.imshow( 'blur',dst1)
  50. cv2.imshow( 'boxFilter',dst2)
  51. cv2.imshow( 'GaussianBlur',dst3)
  52. cv2.imshow( 'medianBlur',dst4)
  53. cv2.waitKey( 0)
  54. cv2.destroyAllWindows()
结果显示:



7.sobel


 
 
  1. # -*- coding: utf-8 -*-
  2. # @Author: Xingmo
  3. ####### cv2.sobel说明 #######
  4. # cv2.Sobel(src, ddepth, dx, dy[, dst[, ksize[, scale[, delta[, borderType]]]]]) #返回dst(处理后图像)
  5. # scr 图像
  6. # ddepth 输出图像深度
  7. # S = 符号整型 U = 无符号整型 F = 浮点型
  8. # src.depth()= CV_8U,ddepth= -1 / CV_16S/ CV_32F/CV_64F
  9. # src.depth()= CV_16U/ CV_16S,ddepth= -1 CV_32F//CV_64F
  10. # src.depth()= CV_32F,ddepth= -1 CV_32F/CV_64F
  11. # src.depth()= CV_64F,ddepth= -1 /CV_64F
  12. # 何时ddepth=-1,目的地图像将具有与源相同的深度
  13. # dx
  14. # dy
  15. ####### cv2.sobel说明END #######
  16. import cv2
  17. import numpy as np
  18. img = cv2.imread( '003.jpg', 0)
  19. x = cv2.Sobel(img,cv2.CV_16S, 1, 0)
  20. y = cv2.Sobel(img,cv2.CV_16S, 0, 1)
  21. # cv2.convertScaleAbs 在输入数组的每个元素上,该函数依次执行三个操作:缩放,取绝对值,转换为无符号8位类型
  22. # 转回uint8
  23. absX = cv2.convertScaleAbs(x)
  24. absY = cv2.convertScaleAbs(y)
  25. # cv2.addWeighted(src1 , alpha, src2 , beta , gamma[, dst[, dtype]]) #返回dst(处理后图像)
  26. # cv2.addWeighted(输入1, 分量1, 输入2, 分量2, 标量)
  27. # dst = src1*alpha + src2*beta + gamma
  28. dst = cv2.addWeighted(absX, 0.5,absY, 0.5, 0)
  29. # 图像显示
  30. cv2.imshow( 'origin',img)
  31. cv2.imshow( "absX", absX)
  32. cv2.imshow( "absY", absY)
  33. cv2.imshow( "Result", dst)
  34. cv2.waitKey( 0)
  35. cv2.destroyAllWindows()
结果显示:


此处有sobel算法原理


8.laplacian


 
 
  1. # -*- coding: utf-8 -*-
  2. # @Author: Xingmo
  3. ####### cv2.Laplacian 说明 #######
  4. # cv2.Laplacian(src, ddepth[, dst[, ksize[, scale[, delta[, borderType]]]]]) #返回dst(处理后图像)
  5. # src 图像
  6. # ddepth 输出图像深度
  7. # S = 符号整型 U = 无符号整型 F = 浮点型
  8. # src.depth()= CV_8U,ddepth= -1 / CV_16S/ CV_32F/CV_64F
  9. # src.depth()= CV_16U/ CV_16S,ddepth= -1 CV_32F//CV_64F
  10. # src.depth()= CV_32F,ddepth= -1 CV_32F/CV_64F
  11. # src.depth()= CV_64F,ddepth= -1 /CV_64F
  12. # 何时ddepth=-1,目的地图像将具有与源相同的深度
  13. # dst 输出图像
  14. # ksize 用于计算二阶微分滤波器的孔径大小,其大小必须是正数和奇数
  15. # scale 缩放导数的比例常数,默认情况下没有伸缩系数
  16. # delta 在结果存储之前添加到结果中的可选增量值,默认情况下没有额外的值加到dst中
  17. # borderType 判断图像边界的模式。这个参数默认值为cv2.BORDER_DEFAULT
  18. ####### cv2.Laplacian 说明END #######
  19. import cv2
  20. import numpy as np
  21. # 图像读取
  22. img = cv2.imread( "004.jpg", 0)
  23. gray_lap = cv2.Laplacian(img,cv2.CV_16S,ksize = 3)
  24. # cv2.convertScaleAbs 在输入数组的每个元素上,该函数依次执行三个操作:缩放,取绝对值,转换为无符号8位类型
  25. # 转回uint8
  26. dst = cv2.convertScaleAbs(gray_lap)
  27. # 图像显示
  28. cv2.imshow( 'origin',img)
  29. cv2.imshow( 'laplacian',dst)
  30. cv2.waitKey( 0)
  31. cv2.destroyAllWindows()
结果显示:


由于laplacian对噪声敏感,对图片先去躁可得到更好的效果


 
 
  1. blur = cv2.medianBlur(img,3)
  2. blur = cv2.blur(img,(3,3))
此处有laplacain算法原理

9.canny


 
 
  1. # -*- coding: utf-8 -*-
  2. # @Author: Xingmo
  3. ####### cv2.Canny 说明 #######
  4. # cv2.Canny(image, threshold1, threshold2[, edges[, apertureSize[, L2gradient]]]) 返回edges(边缘图)
  5. # image 原图像,该图像必须为单通道的灰度图
  6. # threshold1 第一个阈值
  7. # threshold2 第二个阈值
  8. # apertureSize Sobel算子的孔径大小,其有默认值3
  9. # L2gradient 是否使用L2范数,一个计算图像梯度幅值的标识,默认值false
  10. ####### cv2.Canny 说明END #######
  11. import cv2
  12. import numpy as np
  13. # 读取图片
  14. img = cv2.imread( '004.jpg', 0)
  15. # 高斯模糊
  16. blur = cv2.GaussianBlur(img,( 3, 3), 0)
  17. canny = cv2.Canny(blur, 50, 200)
  18. # 图像显示
  19. cv2.imshow( 'origin',img)
  20. cv2.imshow( 'Canny', canny)
  21. cv2.waitKey( 0)
  22. cv2.destroyAllWindows()
结果显示:


canny的基本步骤




        <div class="hide-article-box hide-article-pos text-center">
        <a class="btn-readmore" data-report-click="{&quot;mod&quot;:&quot;popu_376&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/Lxingmo/article/details/73825081&quot;,&quot;strategy&quot;:&quot;readmore&quot;}">
            展开阅读全文
            <svg class="icon chevrondown" aria-hidden="true">
                <use xlink:href="#csdnc-chevrondown"></use>
            </svg>
        </a>
    </div>
        <div class="recommend-box"><div class="recommend-item-box type_blog clearfix" data-report-click="{&quot;mod&quot;:&quot;popu_614&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/luanpeng825485697/article/details/79509870&quot;,&quot;strategy&quot;:&quot;BlogCommendFromMachineLearnPai2&quot;,&quot;index&quot;:&quot;0&quot;}">
<div class="content" style="width: 712px;">
	<a href="https://blog.csdn.net/luanpeng825485697/article/details/79509870" target="_blank" rel="noopener" title="python深度学习库系列教程——python调用opencv库教程">
	<h4 class="text-truncate oneline" style="width: 552px;">
			<em>python</em>深度学习库系列教程——<em>python</em>调用<em>opencv</em>库教程		</h4>
	<div class="info-box d-flex align-content-center">
		<p class="date-and-readNum oneline">
			<span class="date hover-show">03-17</span>
			<span class="read-num hover-hide">
				阅读数 
				1万+</span>
			</p>
		</div>
	</a>
	<p class="content" style="width: 712px;">
		<a href="https://blog.csdn.net/luanpeng825485697/article/details/79509870" target="_blank" rel="noopener" title="python深度学习库系列教程——python调用opencv库教程">
			<span class="desc oneline">全栈工程师开发手册(作者:栾鹏)python教程全解OpenCV安装pipinstall--upgradesetuptoolspipinstallnumpyMatplotlibpipinstallop...</span>
		</a>
		<span class="blog_title_box oneline ">
								<span class="type-show type-show-blog type-show-after">博文</span>
										<a target="_blank" rel="noopener" href="https://blog.csdn.net/luanpeng825485697">来自:	<span class="blog_title"> 全栈工程师开发手册(原创)</span></a>
											</span>
	</p>
</div>
</div>
<div class="comment-edit-box d-flex">
	<a id="commentsedit"></a>
	<div class="user-img">
		<a href="//me.csdn.net/liuxiaohuidegushi" target="_blank" rel="noopener">
			<img class="" src="https://avatar.csdn.net/9/0/F/3_liuxiaohuidegushi.jpg">
		</a>
	</div>
	<form id="commentform">
		<input type="hidden" id="comment_replyId">
		<textarea class="comment-content" name="comment_content" id="comment_content" placeholder="想对作者说点什么"></textarea>
		<div class="opt-box"> <!-- d-flex -->
			<div id="ubbtools" class="add_code">
				<a href="#insertcode" code="code" target="_self"><i class="icon iconfont icon-daima"></i></a>
			</div>
			<input type="hidden" id="comment_replyId" name="comment_replyId">
			<input type="hidden" id="article_id" name="article_id" value="73825081">
			<input type="hidden" id="comment_userId" name="comment_userId" value="">
			<input type="hidden" id="commentId" name="commentId" value="">
			<div style="display: none;" class="csdn-tracking-statistics tracking-click" data-report-click="{&quot;mod&quot;:&quot;popu_384&quot;,&quot;dest&quot;:&quot;&quot;}"><a href="#" target="_blank" class="comment_area_btn" rel="noopener">发表评论</a></div>
			<div class="dropdown" id="myDrap">
				<a class="dropdown-face d-flex align-items-center" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
				<div class="txt-selected text-truncate">添加代码片</div>
				<svg class="icon d-block" aria-hidden="true">
					<use xlink:href="#csdnc-triangledown"></use>
				</svg>
				</a>
				<ul class="dropdown-menu" id="commentCode" aria-labelledby="drop4">
					<li><a data-code="html">HTML/XML</a></li>
					<li><a data-code="objc">objective-c</a></li>
					<li><a data-code="ruby">Ruby</a></li>
					<li><a data-code="php">PHP</a></li>
					<li><a data-code="csharp">C</a></li>
					<li><a data-code="cpp">C++</a></li>
					<li><a data-code="javascript">JavaScript</a></li>
					<li><a data-code="python">Python</a></li>
					<li><a data-code="java">Java</a></li>
					<li><a data-code="css">CSS</a></li>
					<li><a data-code="sql">SQL</a></li>
					<li><a data-code="plain">其它</a></li>
				</ul>
			</div>  
			<div class="right-box">
				<span id="tip_comment" class="tip">还能输入<em>1000</em>个字符</span>
				<input type="button" class="btn btn-sm btn-cancel d-none" value="取消回复">
				<input type="submit" class="btn btn-sm btn-red btn-comment" value="发表评论">
			</div>
		</div>
	</form>
</div>

	<div class="comment-list-container">
	<a id="comments"></a>
	<div class="comment-list-box" style="max-height: none;"><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="10401348" data-replyname="weixin_45536318">        <a target="_blank" href="https://me.csdn.net/weixin_45536318"><img src="https://avatar.csdn.net/1/2/6/3_weixin_45536318.jpg" alt="weixin_45536318" class="avatar"></a>          <div class="right-box ">            <div class="info-box">              <a target="_blank" href="https://me.csdn.net/weixin_45536318"><span class="name ">weixin_45536318:</span></a>              <span class="comment">学习学习</span><span class="date" title="2019-08-17 07:50:01">(4周前</span><span class="floor-num">#2楼)</span><span class="opt-box"><a class="btn btn-link-blue btn-report" data-type="report">举报</a><a class="btn btn-link-blue btn-reply" data-type="reply">回复</a></span></div><div class="comment-like " data-commentid="10401348"><svg class="icon "><use xlink:href="#csdnc-thumbsup"></use></svg><span></span></div></div></li></ul><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="8751681" data-replyname="qq_35531398">        <a target="_blank" href="https://me.csdn.net/qq_35531398"><img src="https://avatar.csdn.net/0/F/2/3_qq_35531398.jpg" alt="qq_35531398" class="avatar"></a>          <div class="right-box ">            <div class="info-box">              <a target="_blank" href="https://me.csdn.net/qq_35531398"><span class="name ">hhhhh_bird:</span></a>              <span class="comment">学习</span><span class="date" title="2018-11-23 12:15:39">(9个月前</span><span class="floor-num">#1楼)</span><span class="opt-box"><a class="btn btn-link-blue btn-report" data-type="report">举报</a><a class="btn btn-link-blue btn-reply" data-type="reply">回复</a></span></div><div class="comment-like " data-commentid="8751681"><svg class="icon "><use xlink:href="#csdnc-thumbsup"></use></svg><span></span></div></div></li></ul></div>
	<div id="commentPage" class="pagination-box d-none" style="display: block;"><div id="Paging_0753284719763891" class="ui-paging-container"><ul><li class="js-page-first js-page-action ui-pager ui-pager-disabled"></li><li class="js-page-prev js-page-action ui-pager ui-pager-disabled">上一页</li><li data-page="1" class="ui-pager focus">1</li><li class="js-page-next js-page-action ui-pager ui-pager-disabled">下一页</li><li class="js-page-last js-page-action ui-pager ui-pager-disabled"></li></ul></div></div>
	
</div>
<div class="recommend-item-box recommend-recommend-box"><div id="kp_box_59" data-pid="59" data-report-click="{&quot;mod&quot;:&quot;kp_popu_59-78&quot;,&quot;keyword&quot;:&quot;&quot;}"><script type="text/javascript">
(function() {
    var s = "_" + Math.random().toString(36).slice(2);
    document.write('<div style="" id="' + s + '"></div>');
    (window.slotbydup = window.slotbydup || []).push({
        id: "u3491668",
        container:  s
    });
})();

<div class="recommend-item-box recommend-box-ident recommend-download-box clearfix" data-report-view="{&quot;mod&quot;:&quot;popu_614&quot;,&quot;dest&quot;:&quot;https://download.csdn.net/download/amanfromearth/10395218&quot;,&quot;strategy&quot;:&quot;BlogCommendFromBaidu2&quot;,&quot;index&quot;:&quot;7&quot;}" data-report-click="{&quot;mod&quot;:&quot;popu_614&quot;,&quot;dest&quot;:&quot;https://download.csdn.net/download/amanfromearth/10395218&quot;,&quot;strategy&quot;:&quot;BlogCommendFromBaidu2&quot;,&quot;index&quot;:&quot;7&quot;}">
	<a href="https://download.csdn.net/download/amanfromearth/10395218" rel="noopener" target="_blank">
		<div class="content clearfix">
			<div class="">
				<h4 class="text-truncate oneline clearfix">
					<em>python</em>2环境的<em>opencv</em>库					</h4>
				<span class="data float-right">05-06</span>
			</div>
			<div class="desc oneline">
					Anaconda2下的opencv库,下载之后直接放置在Anaconda2\Lib\site-packages文件夹中即可				</div>
			<span class="type-show type-show-download">下载</span>
		</div>
	</a>
</div>
Pythonopencv基本操作不详细解释 - 梅花14的博客 - CSDN博客

4-22

Python opencv库教程 - 当你努力到把自己都感动的时候,..._CSDN博客

11-13

<div class="recommend-item-box recommend-recommend-box"><div id="kp_box_60" data-pid="60" data-report-view="{&quot;mod&quot;:&quot;kp_popu_60-43&quot;,&quot;keyword&quot;:&quot;&quot;}" data-report-click="{&quot;mod&quot;:&quot;kp_popu_60-43&quot;,&quot;keyword&quot;:&quot;&quot;}"><div id="three_ad8" class="mediav_ad"></div>
python opencv 基本操作 - quanwei的博客 - CSDN博客

12-2

Python OpenCV 基本操作 - jie310600的博客 - CSDN博客

12-11

		<div class="recommend-item-box blog-expert-recommend-box" style="display: block;">
		<div class="d-flex">
			<div class="blog-expert-recommend">
				<div class="blog-expert">
					<div class="blog-expert-flexbox" data-report-view="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/Lxingmo/article/details/73825081&quot;}"><div class="blog-expert-item"><div class="blog-expert-info-box"><div class="blog-expert-img-box" data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/Lxingmo/article/details/73825081&quot;}"><a href="https://blog.csdn.net/luanpeng825485697" target="_blank"><img src="https://avatar.csdn.net/2/A/7/3_luanpeng825485697.jpg" alt="数据架构师" title="数据架构师"></a><span data-report-click="{&quot;mod&quot;:&quot;popu_710&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/Lxingmo/article/details/73825081&quot;}"><span class="blog-expert-button-follow btn-red-follow" data-name="luanpeng825485697" data-nick="数据架构师">关注</span></span></div><div class="info"><span data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/Lxingmo/article/details/73825081&quot;}"><a href="https://blog.csdn.net/luanpeng825485697" target="_blank"><h5 class="oneline" title="数据架构师">数据架构师</h5></a></span>  <p></p><p class="article-num" title="721篇文章"> 721篇文章</p><p class="article-num" title="排名:177"> 排名:177</p><p></p></div></div></div><div class="blog-expert-item"><div class="blog-expert-info-box"><div class="blog-expert-img-box" data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/Lxingmo/article/details/73825081&quot;}"><a href="https://blog.csdn.net/nature_XD" target="_blank"><img src="https://avatar.csdn.net/B/5/E/3_nature_xd.jpg" alt="Q-沐风听雨-" title="Q-沐风听雨-"></a><span data-report-click="{&quot;mod&quot;:&quot;popu_710&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/Lxingmo/article/details/73825081&quot;}"><span class="blog-expert-button-follow btn-red-follow" data-name="nature_XD" data-nick="Q-沐风听雨-">关注</span></span></div><div class="info"><span data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/Lxingmo/article/details/73825081&quot;}"><a href="https://blog.csdn.net/nature_XD" target="_blank"><h5 class="oneline" title="Q-沐风听雨-">Q-沐风听雨-</h5></a></span>  <p></p><p class="article-num" title="59篇文章"> 59篇文章</p><p class="article-num" title="排名:千里之外"> 排名:千里之外</p><p></p></div></div></div><div class="blog-expert-item"><div class="blog-expert-info-box"><div class="blog-expert-img-box" data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/Lxingmo/article/details/73825081&quot;}"><a href="https://blog.csdn.net/shaoduo" target="_blank"><img src="https://avatar.csdn.net/2/C/7/3_shaoduo.jpg" alt="shaoduo" title="shaoduo"></a><span data-report-click="{&quot;mod&quot;:&quot;popu_710&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/Lxingmo/article/details/73825081&quot;}"><span class="blog-expert-button-follow btn-red-follow" data-name="shaoduo" data-nick="shaoduo">关注</span></span></div><div class="info"><span data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/Lxingmo/article/details/73825081&quot;}"><a href="https://blog.csdn.net/shaoduo" target="_blank"><h5 class="oneline" title="shaoduo">shaoduo</h5></a></span>  <p></p><p class="article-num" title="84篇文章"> 84篇文章</p><p class="article-num" title="排名:千里之外"> 排名:千里之外</p><p></p></div></div></div><div class="blog-expert-item"><div class="blog-expert-info-box"><div class="blog-expert-img-box" data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/Lxingmo/article/details/73825081&quot;}"><a href="https://blog.csdn.net/qq_40179738" target="_blank"><img src="https://avatar.csdn.net/B/D/8/3_qq_40179738.jpg" alt="Tony_Tree" title="Tony_Tree"></a><span data-report-click="{&quot;mod&quot;:&quot;popu_710&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/Lxingmo/article/details/73825081&quot;}"><span class="blog-expert-button-follow btn-red-follow" data-name="qq_40179738" data-nick="Tony_Tree">关注</span></span></div><div class="info"><span data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/Lxingmo/article/details/73825081&quot;}"><a href="https://blog.csdn.net/qq_40179738" target="_blank"><h5 class="oneline" title="Tony_Tree">Tony_Tree</h5></a></span>  <p></p><p class="article-num" title="13篇文章"> 13篇文章</p><p class="article-num" title="排名:千里之外"> 排名:千里之外</p><p></p></div></div></div></div>
				</div>
			</div>
		</div>
	</div><div class="recommend-item-box baiduSearch recommend-box-ident" data-report-view="{&quot;mod&quot;:&quot;popu_614&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/qq_40179738/article/details/81074914&quot;,&quot;strategy&quot;:&quot;searchFromBaidu1&quot;,&quot;index&quot;:&quot;5&quot;}" data-report-click="{&quot;mod&quot;:&quot;popu_614&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/qq_40179738/article/details/81074914&quot;,&quot;strategy&quot;:&quot;searchFromBaidu1&quot;,&quot;index&quot;:&quot;5&quot;}" data-track-view="{&quot;mod&quot;:&quot;popu_614&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/qq_40179738/article/details/81074914&quot;,&quot;strategy&quot;:&quot;searchFromBaidu1&quot;,&quot;index&quot;:4,&quot;extend1&quot;:&quot;_&quot;}" data-track-click="{&quot;mod&quot;:&quot;popu_614&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/qq_40179738/article/details/81074914&quot;,&quot;strategy&quot;:&quot;searchFromBaidu1&quot;,&quot;index&quot;:4,&quot;extend1&quot;:&quot;_&quot;}" data-flg="true">                <a href="https://blog.csdn.net/qq_40179738/article/details/81074914" target="_blank">              		<h4 class="text-truncate oneline" style="width: 641px;"><em>OpenCV</em>-<em>Python</em>教程 - Tony的博客 - CSDN博客</h4>                  <div class="info-box d-flex align-content-center">                    <p>                      <span class="date">7-7</span>                    </p>                  </div>                </a>            	</div><div class="recommend-item-box baiduSearch recommend-box-ident" data-report-view="{&quot;mod&quot;:&quot;popu_614&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/u010837794/article/details/54019810&quot;,&quot;strategy&quot;:&quot;searchFromBaidu1&quot;,&quot;index&quot;:&quot;6&quot;}" data-report-click="{&quot;mod&quot;:&quot;popu_614&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/u010837794/article/details/54019810&quot;,&quot;strategy&quot;:&quot;searchFromBaidu1&quot;,&quot;index&quot;:&quot;6&quot;}" data-track-view="{&quot;mod&quot;:&quot;popu_614&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/u010837794/article/details/54019810&quot;,&quot;strategy&quot;:&quot;searchFromBaidu1&quot;,&quot;index&quot;:5,&quot;extend1&quot;:&quot;_&quot;}" data-track-click="{&quot;mod&quot;:&quot;popu_614&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/u010837794/article/details/54019810&quot;,&quot;strategy&quot;:&quot;searchFromBaidu1&quot;,&quot;index&quot;:5,&quot;extend1&quot;:&quot;_&quot;}" data-flg="true">                <a href="https://blog.csdn.net/u010837794/article/details/54019810" target="_blank">              		<h4 class="text-truncate oneline" style="width: 633px;"><em>Python</em>中<em>使用</em><em>OpenCV</em>最<em>基本</em>的程序 - 把你挖出来的博客 - CSDN博客</h4>                  <div class="info-box d-flex align-content-center">                    <p>                      <span class="date">11-2</span>                    </p>                  </div>                </a>            	</div>
个人学习(九) - 导入opencv-python库 - 林俊宇的博客 - CSDN博客

9-8

python opencv常用方法的使用例程 - jsy2236的博客 - CSDN博客

11-6

<div class="recommend-item-box recommend-recommend-box"><div id="kp_box_61" data-pid="61"><iframe src="https://adaccount.csdn.net/#/preview/261?m=LcAJQQHncnDinyHiLJicAQnnmiUiLSpHnXtJnScHbtDtXbJcHAnAStQWDLQAnXEftAAoJnJLJnptLcQvASbpHitiAJcipAApQpJQ&amp;k=" frameborder="0" width="100%" height="75px" scrolling="no"></iframe><img class="pre-img-lasy" data-src="https://kunyu.csdn.net/1.png?d=2&amp;k=&amp;m=LcAJQQHncnDinyHiLJicAQnnmiUiLSpHnXtJnScHbtDtXbJcHAnAStQWDLQAnXEftAAoJnJLJnptLcQvASbpHitiAJcipAApQpJQ"></div></div><div class="recommend-item-box baiduSearch recommend-box-ident" data-report-view="{&quot;mod&quot;:&quot;popu_614&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/CDQ928/article/details/75137350/&quot;,&quot;strategy&quot;:&quot;searchFromBaidu1&quot;,&quot;index&quot;:&quot;9&quot;}" data-report-click="{&quot;mod&quot;:&quot;popu_614&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/CDQ928/article/details/75137350/&quot;,&quot;strategy&quot;:&quot;searchFromBaidu1&quot;,&quot;index&quot;:&quot;9&quot;}" data-track-view="{&quot;mod&quot;:&quot;popu_614&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/CDQ928/article/details/75137350/&quot;,&quot;strategy&quot;:&quot;searchFromBaidu1&quot;,&quot;index&quot;:8,&quot;extend1&quot;:&quot;_&quot;}" data-track-click="{&quot;mod&quot;:&quot;popu_614&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/CDQ928/article/details/75137350/&quot;,&quot;strategy&quot;:&quot;searchFromBaidu1&quot;,&quot;index&quot;:8,&quot;extend1&quot;:&quot;_&quot;}" data-flg="true">                <a href="https://blog.csdn.net/CDQ928/article/details/75137350/" target="_blank">              		<h4 class="text-truncate oneline" style="width: 633px;"><em>Python</em>-<em>OpenCV</em><em>基本</em>操作 - 吃狼的1只羊 - CSDN博客</h4>                  <div class="info-box d-flex align-content-center">                    <p>                      <span class="date">5-21</span>                    </p>                  </div>                </a>            	</div>
<div class="recommend-item-box recommend-recommend-box"><div id="kp_box_62" data-pid="62"><iframe src="https://adaccount.csdn.net/#/preview/264?m=LcppQQtbLAHtALtcbDnSyHJpbcJEJtEnLSbQmttXbHbnXbnbiDHniJDXipAfpHQSJLWJLJcSnQimLLJpofSSiLtfiUXHcbQttLiQ&amp;k=" frameborder="0" width="100%" height="75px" scrolling="no"></iframe><img class="pre-img-lasy" data-src="https://kunyu.csdn.net/1.png?d=2&amp;k=&amp;m=LcppQQtbLAHtALtcbDnSyHJpbcJEJtEnLSbQmttXbHbnXbnbiDHniJDXipAfpHQSJLWJLJcSnQimLLJpofSSiLtfiUXHcbQttLiQ"></div></div>
opencv_python安装成功 导入 cv2失败
08-11

- 问答

<div class="recommend-item-box recommend-recommend-box"><div id="kp_box_63" data-pid="63" data-report-view="{&quot;mod&quot;:&quot;kp_popu_63-624&quot;,&quot;keyword&quot;:&quot;&quot;}" data-report-click="{&quot;mod&quot;:&quot;kp_popu_63-624&quot;,&quot;keyword&quot;:&quot;&quot;}"><script type="text/javascript">
    (function() {
        var s = "_" + Math.random().toString(36).slice(2);
        document.write('<div style="" id="' + s + '"></div>');
        (window.slotbydup = window.slotbydup || []).push({
            id: "u4221910",
            container: s
        });
    })();

python中的opencv模块,怎么用gpu加速
11-18

我现在用python跟着做了图片搜索的一个项目,之前安装了theano,编译了cuda,但不知道怎么才算运用到opencv模块中 论坛

<div class="recommend-item-box recommend-recommend-box"><div id="kp_box_64" data-pid="64" data-report-view="{&quot;mod&quot;:&quot;kp_popu_64-626&quot;,&quot;keyword&quot;:&quot;&quot;}" data-report-click="{&quot;mod&quot;:&quot;kp_popu_64-626&quot;,&quot;keyword&quot;:&quot;&quot;}"><script type="text/javascript">
(function() {
    var s = "_" + Math.random().toString(36).slice(2);
    document.write('<div style="" id="' + s + '"></div>');
    (window.slotbydup = window.slotbydup || []).push({
        id: "u3600856",
        container:  s
    });
})();

Python opencv
03-17

terminating async callback 用基于Python语言的opencv想打开摄像头,出现这个错误,该怎么弄 论坛

pythonopencv怎么拼接两张图片?
11-26

- 问答

python3.6+opencv3.4,中为什么cv和cv2不能同时import
09-18

- 问答

<div class="recommend-item-box recommend-recommend-box"><div id="kp_box_65" data-pid="65" data-report-view="{&quot;mod&quot;:&quot;kp_popu_65-1378&quot;,&quot;keyword&quot;:&quot;&quot;}" data-report-click="{&quot;mod&quot;:&quot;kp_popu_65-1378&quot;,&quot;keyword&quot;:&quot;&quot;}"><script type="text/javascript">
    (function() {
        var s = "_" + Math.random().toString(36).slice(2);
        document.write('<div style="" id="' + s + '"></div>');
        (window.slotbydup = window.slotbydup || []).push({
            id: "u4221803",
            container: s
        });
    })();

cv2.error: OpenCV(4.0.0)
01-24

- 问答

<div class="recommend-item-box recommend-recommend-box"><div id="kp_box_66" data-pid="66" data-report-view="{&quot;mod&quot;:&quot;kp_popu_66-87&quot;,&quot;keyword&quot;:&quot;&quot;}" data-report-click="{&quot;mod&quot;:&quot;kp_popu_66-87&quot;,&quot;keyword&quot;:&quot;&quot;}"><div id="three_ad38" class="mediav_ad"></div>
            <div class="recommend-item-box type_hot_word">
                            <div class="content clearfix" style="width: 712px;">
                <div class="float-left">
                                    <span>
                    <a href="https://www.csdn.net/gather_1d/NtjaAg3sLWRvd25sb2Fk.html" target="_blank">
                    c# 键值对 键可以重复</a>
                </span>
                                    <span>
                    <a href="https://www.csdn.net/gather_19/NtjaAg4sLWRvd25sb2Fk.html" target="_blank">
                    c#把负数转整形</a>
                </span>
                                    <span>
                    <a href="https://www.csdn.net/gather_1d/NtjaAg5sLWRvd25sb2Fk.html" target="_blank">
                    c# 鼠标移上去提示</a>
                </span>
                                    <span>
                    <a href="https://www.csdn.net/gather_10/NtjaEgwsLWRvd25sb2Fk.html" target="_blank">
                    c#结构体定义</a>
                </span>
                                    <span>
                    <a href="https://www.csdn.net/gather_18/NtjaEgxsLWRvd25sb2Fk.html" target="_blank">
                    使用c#编写一个透明窗体</a>
                </span>
                                    <span>
                    <a href="https://www.csdn.net/gather_1f/NtjaEgysLWRvd25sb2Fk.html" target="_blank">
                    api 饿了么c#</a>
                </span>
                                    <span>
                    <a href="https://www.csdn.net/gather_1f/NtjaEgzsLWRvd25sb2Fk.html" target="_blank">
                    c# 根据网络定位</a>
                </span>
                                    <span>
                    <a href="https://www.csdn.net/gather_18/NtjaEg0sLWRvd25sb2Fk.html" target="_blank">
                    c# 清除html标签</a>
                </span>
                                    <span>
                    <a href="https://www.csdn.net/gather_15/NtjaEg1sLWRvd25sb2Fk.html" target="_blank">
                    c# uwp最小化</a>
                </span>
                                    <span>
                    <a href="https://www.csdn.net/gather_17/NtjaEg2sLWRvd25sb2Fk.html" target="_blank">
                    c# 离线 翻译类</a>
                </span>
                                    </div>
            </div>
                            </div>
                        <div class="recommend-loading-box">
            <img src="https://csdnimg.cn/release/phoenix/images/feedLoading.gif">
        </div>
        <div class="recommend-end-box" style="display: block;">
            <p class="text-center">没有更多推荐了,<a href="https://blog.csdn.net/" class="c-blue c-blue-hover c-blue-focus">返回首页</a></p>
        </div>
    </div>
</main>
;