Skip to content

Commit 2679a92

Browse files
committed
last update
1 parent acb88d0 commit 2679a92

File tree

8 files changed

+210
-9
lines changed

8 files changed

+210
-9
lines changed

mainfunc/urls.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@
99
path('main3/', views.main3, name='main3'),
1010
path('main4/', views.main4, name='main4'),
1111
path('tip/', views.tip, name='tip'),
12+
path('tip2/', views.tip2, name='tip2'),
13+
path('tip3/', views.tip3, name='tip3'),
14+
path('tip4/', views.tip4, name='tip4'),
1215
]

mainfunc/views.py

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def main(request):
233233
# 복사한 이미지를 센터x, 센터y 중심으로 넣고 overlay_size 만큼 resize해서
234234
# 원본 이미지에 넣어준다. 크기는 얼굴 크기만큼 resize해주는 것이다.
235235
result = overlay_transparent(
236-
ori, overlay, center_x, center_y-500, overlay_size=(face_size*3, face_size*3))
236+
ori, overlay, center_x, center_y-500, overlay_size=(face_size*4, face_size*4))
237237

238238
# visualize , 직사각형 그리기
239239
img = cv2.rectangle(img, pt1=(face.left(), face.top()),
@@ -417,7 +417,7 @@ def main2(request):
417417
# 복사한 이미지를 센터x, 센터y 중심으로 넣고 overlay_size 만큼 resize해서
418418
# 원본 이미지에 넣어준다. 크기는 얼굴 크기만큼 resize해주는 것이다.
419419
result = overlay_transparent(
420-
ori, overlay, center_x, center_y-500, overlay_size=(face_size*3, face_size*3))
420+
ori, overlay, center_x, center_y-500, overlay_size=(face_size*4, face_size*4))
421421

422422
# visualize , 직사각형 그리기
423423
img = cv2.rectangle(img, pt1=(face.left(), face.top()),
@@ -458,9 +458,37 @@ def main3(request):
458458
scaler = 5.0
459459
# 얼굴 디텍터 모듈 초기화
460460
detector = dlib.get_frontal_face_detector()
461-
# 얼굴 특징점 모듈 초기화 shape_predictor_68_face_landmarks.dat 이 파일이 있어야 실행가능
462-
# shape_predictor_68_face_landmarks.dat 는 머신러닝으로 학습된 모델
463461
predictor = dlib.shape_predictor("shape_predictor_68_face_landmarks.dat")
462+
463+
# # 입력 영상 불러오기
464+
# src = cv2.imread('test.png')
465+
466+
# if src is None:
467+
# print('Image load failed!')
468+
# sys.exit()
469+
470+
# # 사장형 지정을 통한 초기 분할
471+
# rc = cv2.selectROI(src) # 초기 위치 지정하고 모서리 좌표 4개를 튜플값으로 반환
472+
# mask = np.zeros(src.shape[:2], np.uint8) # 마스크는 검정색으로 채워져있고 입력 영상과 동일한 크기
473+
474+
# # 결과를 계속 업데이트 하고 싶으면 bgd, fgd 입력
475+
# cv2.grabCut(src, mask, rc, None, None, 5, cv2.GC_INIT_WITH_RECT)
476+
477+
# # grabCut 자료에서 0,2는 배경, 1,3은 전경입니다.
478+
# # mask == 0 or mask == 2를 만족하면 0으로 설정 아니면 1로 설정합니다
479+
# mask2 = np.where((mask == 0) | (mask == 2), 0, 1).astype('uint8')
480+
481+
# # np.newaxis로 차원 확장
482+
# dst = src * mask2[:, :, np.newaxis]
483+
484+
# cv2.imwrite("test.png", dst)
485+
486+
487+
488+
# image = cv2.imread("test.png",1)
489+
490+
# image2 = remove_grabcut_bg(image)
491+
# cv2.imwrite("test.png", image2)
464492

465493
overlay = cv2.imread('test.png', cv2.IMREAD_UNCHANGED) # 캠으로 찍은 내 사진
466494

@@ -602,7 +630,7 @@ def main4(request):
602630
# 복사한 이미지를 센터x, 센터y 중심으로 넣고 overlay_size 만큼 resize해서
603631
# 원본 이미지에 넣어준다. 크기는 얼굴 크기만큼 resize해주는 것이다.
604632
result = overlay_transparent(
605-
ori, overlay, center_x, center_y-500, overlay_size=(face_size*3, face_size*3))
633+
ori, overlay, center_x, center_y-500, overlay_size=(face_size*4, face_size*4))
606634

607635
# visualize , 직사각형 그리기
608636
img = cv2.rectangle(img, pt1=(face.left(), face.top()),
@@ -639,4 +667,13 @@ def main4(request):
639667
return render(request, 'mainfunc/main.html')
640668

641669
def tip(request):
642-
return render(request, 'mainfunc/tip.html')
670+
return render(request, 'mainfunc/tip.html')
671+
672+
def tip2(request):
673+
return render(request, 'mainfunc/tip2.html')
674+
675+
def tip3(request):
676+
return render(request, 'mainfunc/tip3.html')
677+
678+
def tip4(request):
679+
return render(request, 'mainfunc/tip4.html')

static/img/boy3.png

-5.96 KB
Loading

templates/mainfunc/main.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
</a>
5151
<br/><br>
5252
"사진을 클릭하면 설명교구로 이동합니다"
53+
<br/>
54+
"q를 눌러 사진을 찍은 다음 얼굴만큼 드래그한 뒤에 space를 눌러주세요"
5355
{%else%}
5456
로그인 후 이용해주세요
5557
<br/><br/><br/>

templates/mainfunc/tip.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@
3535
<img src="{%static 'img/boy.png' %}" style="border: 3px solid ;border-radius: 50%;"; width="120%">
3636
</a>
3737

38-
<a type="button" href="{% url 'mainfunc:tip' %}" style="WIDTH: 70pt; HEIGHT: 120pt; margin-right: 80px">
38+
<a type="button" href="{% url 'mainfunc:tip2' %}" style="WIDTH: 70pt; HEIGHT: 120pt; margin-right: 80px">
3939
<img src="{%static 'img/boy2.png' %} " style="border: 3px solid ;border-radius: 50%;"width="120%">
4040
</a>
4141

42-
<a type="button" href="{% url 'mainfunc:tip' %}" style="WIDTH: 70pt; HEIGHT: 120pt; margin-right: 80px">
42+
<a type="button" href="{% url 'mainfunc:tip3' %}" style="WIDTH: 70pt; HEIGHT: 120pt; margin-right: 80px">
4343
<img src="{%static 'img/boy3.png' %} " style="border: 3px solid ;border-radius: 50%;" width="120%">
4444
</a>
4545

46-
<a type="button" href="{% url 'mainfunc:tip' %}" style="WIDTH: 70pt; HEIGHT: 120pt; margin-right: 80px">
46+
<a type="button" href="{% url 'mainfunc:tip4' %}" style="WIDTH: 70pt; HEIGHT: 120pt; margin-right: 80px">
4747
<img src="{%static 'img/boy4.png' %} " style="border: 3px solid ;border-radius: 50%;" width="120%">
4848
</a>
4949
{% endif %}

templates/mainfunc/tip2.html

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{% load static %}
2+
<!DOCTYPE html>
3+
<html lang="en">
4+
<head>
5+
<meta charset="utf-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
7+
<meta name="description" content="" />
8+
<meta name="author" content="" />
9+
<title>해피톡 웹사이트</title>
10+
<!-- Favicon-->
11+
<link rel="icon" type="image/x-icon" href="{% static 'assets/favicon.ico' %}" />
12+
<!-- Font Awesome icons (free version)-->
13+
<script src="https://use.fontawesome.com/releases/v5.15.4/js/all.js" crossorigin="anonymous"></script>
14+
<!-- Google fonts-->
15+
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css" />
16+
<link href="https://fonts.googleapis.com/css?family=Roboto+Slab:400,100,300,700" rel="stylesheet" type="text/css" />
17+
<!-- Core theme CSS (includes Bootstrap)-->
18+
<link href="{% static 'css/styles.css' %}" rel="stylesheet" />
19+
</head>
20+
<!-- Navigation-->
21+
{% include "navbar.html"%}
22+
<header class="masthead">
23+
24+
<!-- Masthead-->
25+
<div class="container">
26+
<div style="margin-bottom: 100%">
27+
<!-- 메인기능 -->
28+
{% if user.is_authenticated %}
29+
<p>
30+
<img src="{%static 'img/boy2.png' %}" style="border: 3px solid ;border-radius: 10%; margin-right: 50px; width :450px; height :720px;"/>
31+
<img src="{%static 'img/boy2_text.png' %}" style="border: 3px solid ;border-radius: 10%;" width="40%;"/>
32+
</p>
33+
<br>
34+
<a type="button" href="{% url 'mainfunc:tip' %}" style="WIDTH: 70pt; HEIGHT: 120pt; margin-right: 80px">
35+
<img src="{%static 'img/boy.png' %}" style="border: 3px solid ;border-radius: 50%;"; width="120%">
36+
</a>
37+
38+
<a type="button" href="{% url 'mainfunc:tip2' %}" style="WIDTH: 70pt; HEIGHT: 120pt; margin-right: 80px">
39+
<img src="{%static 'img/boy2.png' %} " style="border: 3px solid ;border-radius: 50%;"width="120%">
40+
</a>
41+
42+
<a type="button" href="{% url 'mainfunc:tip3' %}" style="WIDTH: 70pt; HEIGHT: 120pt; margin-right: 80px">
43+
<img src="{%static 'img/boy3.png' %} " style="border: 3px solid ;border-radius: 50%;" width="120%">
44+
</a>
45+
46+
<a type="button" href="{% url 'mainfunc:tip4' %}" style="WIDTH: 70pt; HEIGHT: 120pt; margin-right: 80px">
47+
<img src="{%static 'img/boy4.png' %} " style="border: 3px solid ;border-radius: 50%;" width="120%">
48+
</a>
49+
{% endif %}
50+
</div>
51+
</div>
52+
</header>
53+
</html>

templates/mainfunc/tip3.html

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{% load static %}
2+
<!DOCTYPE html>
3+
<html lang="en">
4+
<head>
5+
<meta charset="utf-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
7+
<meta name="description" content="" />
8+
<meta name="author" content="" />
9+
<title>해피톡 웹사이트</title>
10+
<!-- Favicon-->
11+
<link rel="icon" type="image/x-icon" href="{% static 'assets/favicon.ico' %}" />
12+
<!-- Font Awesome icons (free version)-->
13+
<script src="https://use.fontawesome.com/releases/v5.15.4/js/all.js" crossorigin="anonymous"></script>
14+
<!-- Google fonts-->
15+
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css" />
16+
<link href="https://fonts.googleapis.com/css?family=Roboto+Slab:400,100,300,700" rel="stylesheet" type="text/css" />
17+
<!-- Core theme CSS (includes Bootstrap)-->
18+
<link href="{% static 'css/styles.css' %}" rel="stylesheet" />
19+
</head>
20+
<!-- Navigation-->
21+
{% include "navbar.html"%}
22+
<header class="masthead">
23+
24+
<!-- Masthead-->
25+
<div class="container">
26+
<div style="margin-bottom: 100%">
27+
<!-- 메인기능 -->
28+
{% if user.is_authenticated %}
29+
<p>
30+
<img src="{%static 'img/boy3.png' %}" style="border: 3px solid ;border-radius: 10%; margin-right: 50px; width :450px; height :720px;"/>
31+
<img src="{%static 'img/boy3_text.png' %}" style="border: 3px solid ;border-radius: 10%;" width="40%;"/>
32+
</p>
33+
<br>
34+
<a type="button" href="{% url 'mainfunc:tip' %}" style="WIDTH: 70pt; HEIGHT: 120pt; margin-right: 80px">
35+
<img src="{%static 'img/boy.png' %}" style="border: 3px solid ;border-radius: 50%;"; width="120%">
36+
</a>
37+
38+
<a type="button" href="{% url 'mainfunc:tip2' %}" style="WIDTH: 70pt; HEIGHT: 120pt; margin-right: 80px">
39+
<img src="{%static 'img/boy2.png' %} " style="border: 3px solid ;border-radius: 50%;"width="120%">
40+
</a>
41+
42+
<a type="button" href="{% url 'mainfunc:tip3' %}" style="WIDTH: 70pt; HEIGHT: 120pt; margin-right: 80px">
43+
<img src="{%static 'img/boy3.png' %} " style="border: 3px solid ;border-radius: 50%;" width="120%">
44+
</a>
45+
46+
<a type="button" href="{% url 'mainfunc:tip4' %}" style="WIDTH: 70pt; HEIGHT: 120pt; margin-right: 80px">
47+
<img src="{%static 'img/boy4.png' %} " style="border: 3px solid ;border-radius: 50%;" width="120%">
48+
</a>
49+
{% endif %}
50+
</div>
51+
</div>
52+
</header>
53+
</html>

templates/mainfunc/tip4.html

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{% load static %}
2+
<!DOCTYPE html>
3+
<html lang="en">
4+
<head>
5+
<meta charset="utf-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
7+
<meta name="description" content="" />
8+
<meta name="author" content="" />
9+
<title>해피톡 웹사이트</title>
10+
<!-- Favicon-->
11+
<link rel="icon" type="image/x-icon" href="{% static 'assets/favicon.ico' %}" />
12+
<!-- Font Awesome icons (free version)-->
13+
<script src="https://use.fontawesome.com/releases/v5.15.4/js/all.js" crossorigin="anonymous"></script>
14+
<!-- Google fonts-->
15+
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css" />
16+
<link href="https://fonts.googleapis.com/css?family=Roboto+Slab:400,100,300,700" rel="stylesheet" type="text/css" />
17+
<!-- Core theme CSS (includes Bootstrap)-->
18+
<link href="{% static 'css/styles.css' %}" rel="stylesheet" />
19+
</head>
20+
<!-- Navigation-->
21+
{% include "navbar.html"%}
22+
<header class="masthead">
23+
24+
<!-- Masthead-->
25+
<div class="container">
26+
<div style="margin-bottom: 100%">
27+
<!-- 메인기능 -->
28+
{% if user.is_authenticated %}
29+
<p>
30+
<img src="{%static 'img/boy4.png' %}" style="border: 3px solid ;border-radius: 10%; margin-right: 50px; width :450px; height :720px;"/>
31+
<img src="{%static 'img/boy4_text.png' %}" style="border: 3px solid ;border-radius: 10%;" width="40%;"/>
32+
</p>
33+
<br>
34+
<a type="button" href="{% url 'mainfunc:tip' %}" style="WIDTH: 70pt; HEIGHT: 120pt; margin-right: 80px">
35+
<img src="{%static 'img/boy.png' %}" style="border: 3px solid ;border-radius: 50%;"; width="120%">
36+
</a>
37+
38+
<a type="button" href="{% url 'mainfunc:tip2' %}" style="WIDTH: 70pt; HEIGHT: 120pt; margin-right: 80px">
39+
<img src="{%static 'img/boy2.png' %} " style="border: 3px solid ;border-radius: 50%;"width="120%">
40+
</a>
41+
42+
<a type="button" href="{% url 'mainfunc:tip3' %}" style="WIDTH: 70pt; HEIGHT: 120pt; margin-right: 80px">
43+
<img src="{%static 'img/boy3.png' %} " style="border: 3px solid ;border-radius: 50%;" width="120%">
44+
</a>
45+
46+
<a type="button" href="{% url 'mainfunc:tip4' %}" style="WIDTH: 70pt; HEIGHT: 120pt; margin-right: 80px">
47+
<img src="{%static 'img/boy4.png' %} " style="border: 3px solid ;border-radius: 50%;" width="120%">
48+
</a>
49+
{% endif %}
50+
</div>
51+
</div>
52+
</header>
53+
</html>

0 commit comments

Comments
 (0)