1、二维码识别检测
使用OpenCV相关API实现
主要代码
import cv2 as cv
import numpy as np
src = cv.imread("D:/pythonwork/11.jpg")
cv.imshow("image", src)
gray = cv.cvtColor(src, cv.COLOR_BGR2GRAY)
qrcoder = cv.QRCodeDetector()
codeinfo, points, straight_qrcode = qrcoder.detectAndDecode(gray)
print(points)
print(points[0][0])
result = np.copy(src)
#cv.putText(result,'%s'%codeinfo,tuple(points[2][0]),cv.FONT_HERSHEY_SIMPLEX, 0.8,(0, 0, 255))
cv.drawContours(result, [np.int32(points)], 0, (0, 0, 255), 2)
print("qrcode : %s"% codeinfo)
cv.imshow("result", result)
code_roi = np.uint8(straight_qrcode)
cv.imshow("qrcode roi", code_roi)
cv.waitKey(0)
cv.destroyAllWindows()
实验效果
2、高斯模糊
实现高斯模糊图像和高斯滤波性能测试
代码实现
import cv2 as cv
import numpy as np
#均值模糊 使图片模糊
def get_mean_burry(image):
cv.imshow('iamge',image)
dst=cv.blur(image,(5,5))
cv.imshow('burry',dst)
src=cv.imread('D:/pythonwork/33.png')
get_mean_burry(src)
cv.waitKey(0)
cv.destroyAllWindows()
实验效果
3、线性回归
实现简单示例函数
通过代码实现返回一个5*5的对角矩阵
import numpy as np
a = np.eye(5)
a
实验结果
实现数据集显示的函数
对数据集使用散点图进行可视化
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import os
%matplotlib inline
# 数据存储路径
path = 'ex1data1.txt'
# 读入相应的数据文件
data = pd.read_csv(path, header=None,names=['Population','Profit']