Arama butonu
Bu konudaki kullanıcılar: 1 misafir
0
Cevap
206
Tıklama
0
Öne Çıkarma
python kullanarak insan tespiti
A
5 yıl
Er
Konu Sahibi

herkese selam , proje ödevi olarak almıs olduğum(maalesef) insan tespiti algoritması yazmam gerek , bende baslangıc olarak ssd-mobile-net algoritmasını kullanmaya karar verdim . İnsanları resimler üzerinden tespit edip ,etrafına çizdirilen diktortgenin bilgilerini ve doğruluk oranını bastırmam gerek. Aşağıda yazdığım kod ise 0 veriyor . Bilen arkadaşlar yardımcı olursa çok makbule geçer.
Bide main() nin içine print(confidence) veya print(person_box) yazdığımda 0 ve [] veriyor.
import cv2
import numpy as np
import imutils
import warnings
import os
from PIL import Image
warnings.filterwarnings("ignore")

CLASSES = ["background", "aeroplane", "bicycle", "bird", "boat",
"bottle", "bus", "car", "cat", "chair", "cow", "diningtable",
"dog", "horse", "motorbike", "person", "pottedplant", "sheep","sofa", "train", "tvmonitor"]


def load_mobile_net():
protopath = "MobileNetSSD_deploy.prototxt"
modelpath = "MobileNetSSD_deploy.caffemodel"
detector = cv2.dnn.readNetFromCaffe(prototxt=protopath, caffeModel=modelpath)

return detector

def load_image(image_path):
img = cv2.imread(image_path)
#img = cv2.resize(img,fx = 0.4,fy=0.4)
Height,Width= img.shape[:2]

return img,Height,Width

def find_dim(image_path):
img = cv2.imread(image_path)
Heigth,Width= img.shape[:2]

return Height,Width

def detect_object(img,detector):

blob = cv2.dnn.blobFromImage(img, 0.007843, (320,320), 127.5)
detector.setInput(blob)
person_detections = detector.forward()

return blob,person_detections

def get_box_dimensions(person_detections):

for i in np.arange(0, person_detections.shape[2]):
bbox = []
confidence = person_detections[0, 0, i, 2]


if confidence > 0.5:
idx = int(person_detections[0, 0, i, 1])

if CLASSES[idx] != "person":
continue

bbox.append(person_detections[0, 0, i, 3:7] * np.array([800, 400, 800, 400]))
(startX, startY, endX, endY) = person_box.astype("int")

return bbox , confidence

def main():

PATH_TO_TEST_IMAGES_DIR = 'testing'
TEST_IMAGE_PATHS = [ os.path.join(PATH_TO_TEST_IMAGES_DIR, 'image{}.jpg'.format(i)) for i in range(1, 3)]

for image_path in TEST_IMAGE_PATHS:

model = load_mobile_net()
image,H,W = load_image(image_path)
blob,person_detections = detect_object(image,model)
person_box , confidence = get_box_dimensions(person_detections)

main()

DH forumlarında vakit geçirmekten keyif alıyor gibisin ancak giriş yapmadığını görüyoruz.

Üye olduğunda özel mesaj gönderebilir, beğendiğin konuları favorilerine ekleyip takibe alabilir ve daha önce gezdiğin konulara hızlıca erişebilirsin.

Üye Ol Şimdi Değil