系統分析與設計HW3

2021-08-18 19:04:10 字數 2476 閱讀 6345

cap=cv2.videocapture(0)

if key == ord('q'):

break

import os

import numpy as np

from pil import image

import tensorflow as tf

import math

from tkinter import *

from tkinter import filedialog

from pil import image, imagetk

import time

import dlib

from skimage import io

import cv2

import glob

if __name__ == "__main__":

predictor_path = "shape_predictor_68_face_landmarks.dat"

predictor = dlib.shape_predictor(predictor_path)

detector = dlib.get_frontal_face_detector()

window = tk() #makes main window

window.wm_title("digital microscope")

window.config(background="#ffffff")

#graphics window

imageframe = frame(window, width=640, height=480)

imageframe.grid(row=0, column=0, padx=10, pady=2)

defshow_real

(): _, frame = cap1.read()

frame = cv2.flip(frame, 1)

if frame is

notnone:

frame = cv2.cvtcolor(frame, cv2.color_bgr2rgba)

img = cv2.cvtcolor(frame, cv2.color_bgr2gray)

dets = detector(img,0)

#print("number of faces detected: {}".format(len(dets)))

for i,d in enumerate(dets):#人臉識別

#print("detection {}: left: {} top: {} right: {} bottom: {}".format(

# i, d.left(), d.top(), d.right(), d.bottom()))

shape = predictor(img, d)

for p in shape.parts():

cv2.circle(frame,(p.x,p.y),2,(0,0,0),-1)#將捕捉到的landmark點用opencv畫上去

img = image.fromarray(frame)

imgtk = imagetk.photoimage(image=img)

lmain.imgtk = imgtk

lmain.configure(image=imgtk)

lmain.after(10,show_real) #不斷更新實現實時的效果

defrealtime_start

():global lmain

lmain = label(imageframe)

lmain.grid(row=0, column=0)

global cap1#設定捕捉攝像頭

cap1 = cv2.videocapture(0)

show_real()

print("start")

defrealtime_stop

():global cap1

cap1.release()

cv2.destroyallwindows()

print("stop")

#button控制項使用

e = button(window,text='realtime_start',command=realtime_start)

e.grid(row =1,column=0)

f = button(window,text='realtime_stop',command=realtime_stop)

f.grid(row =2,column=0)

window.mainloop()

最後實現用button控制項來控制識別開始和結束啦

系統分析與設計HW3

優點 需求是明確的,在短期內可獲取每個階段是無差錯的 有利於大型軟體開發過程中人員的組織 管理,有利於軟體開發方法和工具的研究,從而提高了大型軟體專案開發的質量和效率。缺點 資源調配問題 優點 缺點 優點 缺點統一過程是乙個物件導向且基於網路的程式開發方 統一過程中的軟體生命週期在時間上被分解為四個...

系統分析與設計hw3

從專案特點 風險特徵 人力資源利用角度思考 瀑布模型 優點 有利於大型軟體開發過程中人員的組織 管理,有利於軟體開發方法和工具的研究,從而提高了大型軟體專案開發的質量和效率。缺點 1 開發過程一般不能逆轉,否則代價太大 2 實際的專案開發很難嚴格按該模型進行 3 客戶往往很難清楚地給出所有的需求,而...

系統分析與設計 HW3

優點 1 瀑布模型的流程符合客觀的開發方式 2 有利於軟體開發方法和工具的研究,從而提高了大型軟體專案開發的質量和效率 3 理論上當前一階段的工作完成,人們只需要關注後續的部分。缺點 1 瀑布模型的各個環節前後相連,開發過程不能逆轉,出現調整時代價過大 2 模型要求需求明確,但是往往客戶無法給出精確...