91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 7.38MB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2023-09-29
  • 語言: Python
  • 標(biāo)簽: python??opencv??行人檢測??

資源簡介

基于python語言的opencv行人檢測,通過OpenCV自帶的HOG+SVM行人檢測器圖片中的行人,并根據(jù)界面提示按鈕,選擇相應(yīng)的操作。

資源截圖

代碼片段和文件信息

?#?import?the?necessary?packages
from?__future__?import?print_function??#確保代碼同時在Python2.7和Python3上兼容
from?imutils.object_detection?import?non_max_suppression
from?imutils?import?paths
import?numpy?as?np
import?argparse
import?imutils???#安裝庫pip?install?imutils?;pip?install?--upgrade?imutils更新版本大于v0.3.1
import?cv2

#?construct?the?argument?parse?and?parse?the?arguments
ap?=?argparse.ArgumentParser()
ap.add_argument(“-i“?“--images“required=True?help=“path?to?images?directory“)
#?args?=?vars(ap.parse_args())

#?初始化我們的行人檢測器
hog?=?cv2.HOGDescriptor()???#初始化方向梯度直方圖描述子
hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())??#設(shè)置支持向量機(jī)(Support?Vector?Machine)使得它成為一個預(yù)先訓(xùn)練好了的行人檢測器
#到這里,我們的OpenCV行人檢測器已經(jīng)完全載入了,我們只需要把它應(yīng)用到一些圖像上
#---------------------------------------------------------------------------------------------------------
image_Path=“./images“;
#?loop?over?the?image?paths
for?imagePath?in?paths.list_images(image_Path):?#args[“images“]
????#?load?the?image?and?resize?it?to?(1)?reduce?detection?time
????#?and?(2)?improve?detection?accuracy
????image?=?cv2.imread(imagePath)
????image?=?imutils.resize(image?width=min(400?image.shape[1]))
????orig?=?image.copy()
????‘‘‘
????構(gòu)造了一個尺度scale=1.05的圖像金字塔,以及一個分別在x方向和y方向步長為(44)像素大小的滑窗
????scale的尺度設(shè)置得越大,在圖像金字塔中層的數(shù)目就越少,相應(yīng)的檢測速度就越快,但是尺度太大會導(dǎo)致行人出現(xiàn)漏檢;
????同樣的,如果scale設(shè)置得太小,將會急劇的增加圖像金字塔的層數(shù),這樣不僅耗費計算資源,而且還會急劇地增加檢測過程
????中出現(xiàn)的假陽數(shù)目(也就是不是行人的被檢測成行人)。這表明,scale是在行人檢測過程中它是一個重要的參數(shù),
????需要對scale進(jìn)行調(diào)參。我會在后面的文章中對detectMultiScale中的每個參數(shù)做些調(diào)研。
????‘‘‘
#?detect?people?in?the?image:
????(rects?weights)?=?hog.detectMultiScale(image?winStride=(4?4)
????????padding=(8?8)?scale=1.05)

????#?draw?the?original?bounding?boxes
????for?(x?y?w?h)?in?rects:
????????cv2.rectangle(orig?(x?y)?(x?+?w?y?+?h)?(0?0?255)?2)

????????#?apply?non-maxima?suppression?to?the?bounding?boxes?using?a
????????#?fairly?large?overlap?threshold?to?try?to?maintain?overlapping
????????#?boxes?that?are?still?people
????#應(yīng)用非極大抑制方法,通過設(shè)置一個閾值來抑制那些重疊的邊框
????rects?=?np.array([[x?y?x?+?w?y?+?h]?for?(x?y?w?h)?in?rects])
????pick?=?non_max_suppression(rects?probs=None?overlapThresh=0.65)

????#?draw?the?final?bounding?boxes
????for?(xA?yA?xB?yB)?in?pick:
????????cv2.rectangle(image?(xA?yA)?(xB?yB)?(0?255?0)?2)

????#?show?some?information?on?the?number?of?bounding?boxes
????filename?=?imagePath[imagePath.rfind(“/“)?+?1:]
????print(“[INFO]?{}:?{}?original?boxes?{}?after?suppression“.format(
????????filename?len(rects)?len(pick)))

????#?show?the?output?images
????cv2.imshow(“Before?NMS“?orig)
????cv2.imshow(“After?NMS“?image)
????cv2.waitKey(0)

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-03-01?17:56??PedestrianDetection\
?????目錄???????????0??2019-03-01?17:56??PedestrianDetection\.idea\
?????文件?????????183??2018-01-21?14:41??PedestrianDetection\.idea\misc.xml
?????文件?????????290??2018-01-21?14:40??PedestrianDetection\.idea\modules.xml
?????文件?????????455??2018-01-21?14:41??PedestrianDetection\.idea\PedestrianDetection.iml
?????文件???????10650??2018-01-22?09:32??PedestrianDetection\.idea\workspace.xml
?????文件??????????39??2018-12-18?18:04??PedestrianDetection\1.txt
?????文件????????3361??2018-12-10?19:27??PedestrianDetection\detect.py
?????目錄???????????0??2018-12-18?18:07??PedestrianDetection\image\
?????目錄???????????0??2019-03-01?17:56??PedestrianDetection\images\
?????文件???????98918??2018-12-18?17:41??PedestrianDetection\images\person_1.jpg
?????文件???????23582??2018-12-18?17:40??PedestrianDetection\images\person_10.jpg
?????文件??????150943??2018-12-18?17:56??PedestrianDetection\images\person_11.jpg
?????文件??????921654??2003-05-20?13:43??PedestrianDetection\images\person_12.bmp
?????文件??????921654??2003-05-20?13:43??PedestrianDetection\images\person_13.bmp
?????文件??????204593??2018-12-18?17:58??PedestrianDetection\images\person_14.jpeg
?????文件??????103383??2018-12-18?18:00??PedestrianDetection\images\person_15.jpeg
?????文件??????921654??2003-05-20?13:43??PedestrianDetection\images\person_16.bmp
?????文件??????921654??2003-05-20?13:43??PedestrianDetection\images\person_2.bmp
?????文件???????22728??2018-12-18?17:53??PedestrianDetection\images\person_220.jpg
?????文件??????921654??2003-05-20?13:37??PedestrianDetection\images\person_221.bmp
?????文件??????921654??2003-05-20?13:43??PedestrianDetection\images\person_3.bmp
?????文件??????921654??2003-05-20?13:43??PedestrianDetection\images\person_302.bmp
?????文件??????921654??2003-05-20?13:44??PedestrianDetection\images\person_390.bmp
?????文件??????945906??2018-12-18?17:47??PedestrianDetection\images\person_4.JPG
?????文件???????37042??2018-12-18?17:46??PedestrianDetection\images\person_5.jpg
?????文件???????71234??2018-12-18?17:47??PedestrianDetection\images\person_6.jpg
?????文件???????83034??2018-12-18?17:36??PedestrianDetection\images\person_7.jpg
?????文件???????30150??2018-12-18?17:50??PedestrianDetection\images\person_8.jpg
?????文件??????921654??2003-05-20?13:43??PedestrianDetection\images\person_9.bmp
?????文件????????3511??2018-12-18?18:06??PedestrianDetection\untitled1.py
............此處省略0個文件信息

評論

共有 條評論