python+opencv
小满丫
贵有恒,何必三更起五更眠。最无益,只怕一日曝十日寒。
展开
-
图像预处理 ————灰度化
分量法、最大值法、加权平均法# -*- coding: UTF-8 -*-import cv2 as cvimport numpy as npimport matplotlib.pyplot as plt# def zh_ch(string):# return string.encode("gbk").decode(errors="ignore")img = cv.imr...原创 2020-02-19 17:03:16 · 1215 阅读 · 0 评论 -
视频换色
# created by Huang Lu# 28/08/2016 14:46:31 # Department of EE, Tsinghua Univ.import cv2import numpy as npcap = cv2.VideoCapture(0)# set blue threshlower_blue=np.array([78,43,46])upper_blue=...原创 2019-06-20 12:42:05 · 146 阅读 · 0 评论 -
换色+边缘检测
# -*- coding:utf-8 -*-import cv2import numpy as npimg = cv2.imread('01.jpg')cv2.namedWindow("original", 0)cv2.imshow("original", img)rows, cols, channels = img.shapeBGR = np.array([246, 217,...原创 2019-06-20 11:40:16 · 234 阅读 · 0 评论 -
基于RGB的水体提取
# -*- coding:utf-8 -*-import cv2import numpyimage = cv2.imread("01.jpg")cv2.namedWindow("original", 0)# cv2.resizeWindow("original", 400, 400)cv2.imshow("original", image)# BGR = numpy.array...原创 2019-06-20 09:53:18 · 2300 阅读 · 0 评论 -
用python测量实际的物体大小————拟合椭圆计算面积
**1.pycharm中需要附加的库:imutils**imutils 这里贴出Github地址 自行补充:https://github.com/jrosebr1/imutils或者下载我打包好的https://download.csdn.net/download/weixin_42512266/11146956下面贴出全部代码 + 部分注释# -*- coding:utf-8 -*-...原创 2019-04-28 11:13:34 · 4239 阅读 · 1 评论 -
python+opencv人脸检测摄像头
# -*- coding:utf-8 -*-import cv2 as cvimport numpy as npimport sys# src = cv.imread('test1.jpg')path = r'D:\face'def face_detect_demo(image): gray = cv.cvtColor(image,cv.COLOR_BGR2GRAY)...原创 2019-04-23 11:11:02 · 387 阅读 · 0 评论 -
python3人脸识别的两种方法
第一种:import cv2import numpy as npfilename = 'test1.jpg'path = r'D:\face'def detect(filename): face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml') face_cascade.lo...原创 2019-04-23 10:37:23 · 1473 阅读 · 0 评论 -
opencv边界矩形、最小外接圆、椭圆拟合
import cv2import numpy as npim = cv2.imread('2.jpg')imgray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)ret, thresh = cv2.threshold(imgray, 180, 255, cv2.THRESH_BINARY)image, contours, hierarchy = cv2....原创 2019-04-27 15:41:27 · 762 阅读 · 0 评论 -
opencv-py 计算物体的外接矩阵
# -*- coding:utf-8 -*-# import the necessary packagesfrom scipy.spatial import distance as distfrom imutils import perspectivefrom imutils import contoursimport numpy as npimport imutilsimport ...原创 2019-04-26 19:24:37 · 556 阅读 · 1 评论