![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
opencv
jialan75
这个作者很懒,什么都没留下…
展开
-
opencv 仿射变换 (平移旋转变换)
import cv2 as cvimport numpy as npdog = cv.imread('imgs/dog.png')h,w,ch = dog.shapeM = np.float32([[1,0,100],[0,1,100]])new = cv.warpAffine(dog,M,(w,h))cv.imshow("dog",dog)cv.imshow("new",new)cv.waitKey(0)import cv2 as cvimport numpy as npd原创 2022-02-27 15:44:58 · 965 阅读 · 0 评论 -
opencv 水平翻转 上下翻转 旋转
import cv2 as cvimport numpy as npdog = cv.imread('imgs/dog.jpeg')# 缩小指定大小new = cv.resize(dog,(600,400))# 缩小一半new = cv.resize(dog,None,fx=0.5,fy=0.5,interpolation=cv.INTER_AREA)# 上下翻转new2 = cv.flip(new,0)# 水平翻转new2 = cv.flip(new,1)# 上下翻原创 2022-02-27 15:28:27 · 3290 阅读 · 0 评论 -
opencv 综合案例 在画板上 画圆画矩形画线条
# 基本功能# 可以用过鼠标进行基本图形的绘制# 1. 可以画线,当用户l键,即选择画线,此时,滑动鼠标既可画线# 2. 可以矩形,当用户r键,即选择画矩形,此时,滑动鼠标既可画矩形# 3. 可以画圆,当用户c键,即选择画圆,此时,滑动鼠标既可画圆# 4. 当用户q键 退出程序# curshape 0-drawline,1-drawrect,2-circleimport cv2 as cvimport numpy as npcurshape = 0startpos = (0, 0.原创 2022-02-27 13:45:11 · 227 阅读 · 0 评论 -
opencv 添加 线条 矩形 椭圆 圆 多边形
import cv2 as cvimport numpy as npimg = np.zeros((480,640,3),np.uint8)b,g,r = cv.split(img)b[:] = 250g[:] = 250r[:] = 250img2 = cv.merge((b,g,r))# 绘制线条cv.line(img2,(0,0),(300,300),(0,255,0),5,4)cv.line(img2,(40,0),(340,300),(0,0,255),5,16)# 绘.原创 2022-02-27 13:17:49 · 662 阅读 · 0 评论 -
opencv 通道分离与合并
import cv2 as cvimport numpy as npimg = np.zeros((480,640,3),np.uint8)b,g,r = cv.split(img)b[10:100,10:100] = 255g[10:100,10:100] = 255r[10:100] = 255img2 = cv.merge((b,g,r))cv.imshow("img",img)cv.imshow('b',b)cv.imshow('g',g)cv.imshow('img.原创 2022-02-27 11:59:23 · 680 阅读 · 0 评论 -
opencv 修改颜色模式 cvtColor
import cv2def callback(index): cvt_img = cv2.cvtColor(img, css[index]) cv2.imshow('color', cvt_img)cv2.namedWindow('color', cv2.WINDOW_NORMAL)img = cv2.imread('imgs/RMB.jpeg')css = [ cv2.COLOR_BGR2RGBA, cv2.COLOR_BGR2BGRA, cv2.原创 2022-02-27 11:31:24 · 1260 阅读 · 0 评论 -
opencv 画矩形
import cv2import numpy as npclass App: startX = 0 startY = 0 flag_rect = False def onmouse(self, event, x, y, flags, param): if event == cv2.EVENT_LBUTTONDOWN: self.flag_rect = True self.startX = x .原创 2022-02-27 09:12:54 · 2761 阅读 · 2 评论 -
opencv 二值 开运算 去除噪点 膨胀
import cv2import numpy as np获取背景1.通过二值法得到黑白图片2.通过形态学获取北京img = cv2.imread(‘imgs/yb.png’)cv2.imshow(‘img’,img)img = cv2.imread(‘images/yn.png’)gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)cv2.imshow(‘gray’,gray)ret,thresh = cv2.threshold(gray,0,255,.原创 2022-02-27 08:07:44 · 2055 阅读 · 0 评论 -
opencv 读取 显示 保存 图片
<dependencies> <dependency> <groupId>org.bytedeco</groupId> <artifactId>javacv-platform</artifactId> <version>1.5.5</version> </dependency> &l...原创 2022-02-26 18:54:16 · 933 阅读 · 1 评论