From 4b489bf3626f3d57e510076edc91e5ca10df57d4 Mon Sep 17 00:00:00 2001 From: Siryuanshao Date: Sun, 6 Jan 2019 15:51:31 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BA=BA=E8=84=B8=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 人脸识别/getface.py | 65 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 人脸识别/getface.py diff --git a/人脸识别/getface.py b/人脸识别/getface.py new file mode 100644 index 0000000..8db6b29 --- /dev/null +++ b/人脸识别/getface.py @@ -0,0 +1,65 @@ +# coding = utf-8 +# 圈出图片中所有的人脸 +import numpy as np +import math +import cv2 +import dlib + +path = '/Users/yanshao/Desktop/img/timg.jpeg' +Model = '/Users/yanshao/dlib/shape_predictor_5_face_landmarks.dat' + +# 首先把图片转化为方形 + +detector = dlib.get_frontal_face_detector() +predictor = dlib.shape_predictor(Model) + + +def preprocess(): + image = cv2.imread(path) + height, width, chl = image.shape[0], image.shape[1], image.shape[2] + rec = int(max(height, width) * 1.5) + pic = np.zeros((rec, rec, chl), np.uint8) + baseh, basew = (rec - height) // 2, (rec - width) // 2 + pic[baseh:height + baseh, basew:width + basew] = image + return pic, rec + + +# 为了检测出图片中的所有人脸,我们每次把图片翻转45度 +def get_dist(point1, point2): + return math.sqrt((point1[0]-point2[0])*(point1[0]-point2[0]) + + (point1[1]-point2[1])*(point1[1]-point2[1])) + + +def get_pos(point, M): + return np.linalg.solve([[M[0][0], M[0][1]], + [M[1][0], M[1][1]]], + [point[0]-M[0][2], point[1]-M[1][2]]).astype(np.int32) + + +pic, rec = preprocess() +center = (rec//2,rec//2) +list = [] +for ang in range(0, 8): + M = cv2.getRotationMatrix2D(center, 45*ang, 1) + pic2 = cv2.warpAffine(pic, M, (rec, rec)) + dets = detector(pic2, 1) + print(len(dets)) + for face in dets: + left, right, top, bot = face.left(), face.right(), face.top(), face.bottom() + LT, RB = get_pos((left, top), M), get_pos((right, bot), M) + list.append(((LT[0]+RB[0])//2, (LT[1]+RB[1])//2, (right-left)//2)) + + cv2.destroyAllWindows() + +length = len(list) +for i in range(0, length): + flag = False + for j in range(0, i): + if get_dist(list[i], list[j]) < list[i][2]+list[j][2]: + flag = True + if not flag: + cv2.circle(pic, (list[i][0], list[i][1]), list[i][2], (0, 255, 0)) + +cv2.imshow("img", pic) +cv2.waitKey(0) +cv2.destroyAllWindows() From 0b945a686d407e1d59e12324601cd446497023d7 Mon Sep 17 00:00:00 2001 From: Siryuanshao Date: Sun, 6 Jan 2019 23:53:38 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E5=85=B3?= =?UTF-8?q?=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 数据库设计表 | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 数据库设计表 diff --git a/数据库设计表 b/数据库设计表 new file mode 100644 index 0000000..bd86ca0 --- /dev/null +++ b/数据库设计表 @@ -0,0 +1,41 @@ +User表: +UsedID(主键) +UserName +总金额 +用户头像 + +寄送信息:(单个用户可以对应到多个地址) +MessageId(主键) +UserId(主键) +Address +tel-phone + +封面展示:(每一本书对应一张需要展示的图片) +bookId(主键) +Image + +Book表: +BookId(主键) +BookName +价格 +Author +引言 +大分类 + +简介表:(反正简介不会超过太多张对吧) +bookId(主键) +引言(这样我们经过排序之后就可以展示书本简介) +简介图片 + + +购物车: +UserId(主键) +BookId(主键) +数量 + + +订单表:(我们甚至可以由这个计算出每本书销售数量) +UserId(主键) +MessageId(主键) +BookId(主键) +Statue:待付款,待发货,待收货,待评价,订单已经完成,退货中