Merge branch 'yuanshao'

master
Siryuanshao 6 years ago
commit 234345d44c

@ -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()

@ -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待付款,待发货,待收货,待评价,订单已经完成,退货中
Loading…
Cancel
Save