資源簡(jiǎn)介
運(yùn)用opencv數(shù)據(jù)庫(kù)底下的haar-like特征分類(lèi)器,在jetson nano上配合csi攝像頭(usb和ip攝像頭不行)實(shí)現(xiàn)人臉識(shí)別。
代碼片段和文件信息
#?MIT?License
#?Copyright?(c)?2019?JetsonHacks
#?See?LICENSE?for?OpenCV?license?and?additional?information
#?https://docs.opencv.org/3.3.1/d7/d8b/tutorial_py_face_detection.html
#?On?the?Jetson?Nano?OpenCV?comes?preinstalled
#?Data?files?are?in?/usr/sharc/OpenCV
import?numpy?as?np
import?cv2
#?gstreamer_pipeline?returns?a?GStreamer?pipeline?for?capturing?from?the?CSI?camera
#?Defaults?to?1280x720?@?30fps
#?Flip?the?image?by?setting?the?flip_method?(most?common?values:?0?and?2)
#?display_width?and?display_height?determine?the?size?of?the?window?on?the?screen
def?gstreamer_pipeline(
????capture_width=3280
????capture_height=2464
????display_width=820
????display_height=616
????framerate=21
????flip_method=0
):
????return?(
????????“nvarguscamerasrc?!?“
????????“video/x-raw(memory:NVMM)?“
????????“width=(int)%d?height=(int)%d?“
????????“format=(string)NV12?framerate=(fraction)%d/1?!?“
????????“nvvidconv?flip-method=%d?!?“
????????“video/x-raw?width=(int)%d?height=(int)%d?format=(string)BGRx?!?“
????????“videoconvert?!?“
????????“video/x-raw?format=(string)BGR?!?appsink“
????????%?(
????????????capture_width
????????????capture_height
????????????framerate
????????????flip_method
????????????display_width
????????????display_height
????????)
????)
def?face_detect():
????face_cascade?=?cv2.CascadeClassifier(
????????“./haar/haarcascade_frontalface_default.xml“
????)
????eye_cascade?=?cv2.CascadeClassifier(
????????“
評(píng)論
共有 條評(píng)論