我训练了我自己的模型来识别一个模式,我把它作为一个.svm,并且在没有好的轨迹时通过跟踪运动来支持这一点。这是很好的工作,但我的问题是,有时我得到假阳性,有时覆盖最近开始的运动轨迹。在
我尝试用dir()
记录检测器,但是找不到任何置信域,也没有检查引用,但是我无法找到如何让这个跟踪器输出其置信级别。在
我想做的是基本上有一个系统愿意使用的轨迹质量的阈值,随着时间的推移,这个阈值逐渐降低。也就是说,如果它丢失了我的模式轨迹,并立即从图像中随机选取一个低置信度轨迹,它不会覆盖我最近的(因此也是高质量的)运动轨迹。然而,如果运动轨迹已经运行了很长时间,它更有可能滑落,我更倾向于相信低质量的轨道。在
TL;DR;如何获得此探测器的置信水平?非常感谢您能给我的任何帮助。
我在下面附上了我的代码以显示上下文
import os
import sys
import glob
import dlib
import cv2
detector_path = sys.argv[1] #first point towards the detector to use
video_path = sys.argv[2] #then point it towards a folder filled with images. Doesn't need to be drawn from video
win = dlib.image_window()
files_to_test = os.listdir(video_path)
detector = dlib.simple_object_detector(detector_path)
tracker = None
tracker_age = 0
for file in files_to_test:
img = dlib.load_rgb_image(video_path + "/" + file)
dets = detector(img)
print("Number of faces detected: {}".format(len(dets)))
for k, d in enumerate(dets):
print("Detection {}: Left: {} Top: {} Right: {} Bottom: {}".format(
k, d.left(), d.top(), d.right(), d.bottom()))
if len(dets) > 0:
tracker = dlib.correlation_tracker()
d = dets[0]
print(dir(d))
x = d.left()
y = d.top()
x2 = d.right()
y2 = d.bottom()
rect = dlib.rectangle(x,y,x2,y2)
tracker.start_track(img,rect)
tracker_age = 0
win.clear_overlay()
win.add_overlay(dets)
else:
print("relying on motion track for the past {} frames".format(tracker_age))
if not tracker == None:
tracker.update(img)
pos = tracker.get_position()
startX = int(pos.left())
startY = int(pos.top())
endX = int(pos.right())
endY = int(pos.bottom())
# draw the bounding box from the correlation object tracker
cv2.rectangle(img, (startX, startY), (endX, endY),
(0, 255, 0), 2)
win.set_image(img)
dlib.hit_enter_to_continue()
使用
dlib.simple_object_detector
您将无法获得所需的内容,请尝试以下函数:[boxes, confidences, detector_idxs] = dlib.fhog_object_detector.run_multiple(detectors, image, upsample_num_times=1, adjust_threshold=0.0)
有关详细信息,请参见http://dlib.net/train_object_detector.py.html
相关问题 更多 >
编程相关推荐