[英]Pedestrian detection with HOG descriptor and SVM understanding the python code
I am trying to understand the code in python of pedestrian detection with HOG and SVM to accelerate it with an FPGA. 我试图用HOG和SVM理解行人检测python中的代码,以通过FPGA加速它。
Below the code working fine copied from a website 下面的代码可以从网站上正常复制
hog = cv2.HOGDescriptor()
hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())
def detector(image):
rects, weights = hog.detectMultiScale(image, winStride=(4, 4), padding=(8, 8),scale=1.05)
for (x, y, w, h) in rects:
cv2.rectangle(image, (x, y), (x + w, y + h), (0, 0, 255), 2)
cv2.rectangle(image, (x, y), (x + w, y + h), (0, 0, 255), 2)
rects = np.array([[x, y, x + w, y + h] for (x, y, w, h) in rects])
result = non_max_suppression(rects, probs=None, overlapThresh=0.7)
return result
frame = cv2.imread("/.../pedestrian2.jpg")
result = detector(frame.copy())
for (xA, yA, xB, yB) in result: # draw the final bounding boxes after non-maxima supression
cv2.rectangle(frame, (xA, yA), (xB, yB), (0, 255, 0), 2)
img = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
img_out = PIL.Image.fromarray(img)
img_out
Following the tutorial https://www.learnopencv.com/handwritten-digits-classification-an-opencv-c-python-tutorial/ I understand that the main function is hog.compute(im,descriptor)
which compute the HOG features of an image, but where is this function on the first code? 按照教程https://www.learnopencv.com/handwriting-digits-classification-an-opencv-c-python-tutorial/我了解主要功能是
hog.compute(im,descriptor)
,可计算图像,但是此功能在第一个代码中在哪里? Is it inside of one of the functions? 它在功能之一之内吗?
While "explain this code" is a bit too broad for this site, the narrow question of "where is this function on the first code": it's not. 尽管“解释此代码”对于本网站来说有点太宽泛,但“第一个代码中的此功能在哪里”这个狭义问题是:不是。 It is, however, discussed in the tutorial you've linked.
但是,已在您链接的教程中进行了讨论。
At the beginning of the posted code, you instantiate the cv2.HOGDescriptor()
object as hog
. 在发布的代码的开头,您将
cv2.HOGDescriptor()
对象实例化为hog
。 Once created, the object has all of the bound attributes and methods of the cv2.HOGDescriptor()
class, including the .compute()
method, once you invoke it. 创建对象后,一旦调用它,它便具有
cv2.HOGDescriptor()
类的所有绑定属性和方法,包括.compute()
方法。
There's some discussion in this question about the basic usage and here is a link to some of the basic documentation for the HOGDescriptor` class 这个问题中有一些关于基本用法的讨论, 这 是 HOGDescriptor`类的一些基本文档的链接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.