本文整理汇总了Python中cv2.HOGDescriptor方法的典型用法代码示例。如果您正苦于以下问题:Python cv2.HOGDescriptor方法的具体用法?Python cv2.HOGDescriptor怎么用?Python cv2.HOGDescriptor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cv2
的用法示例。
在下文中一共展示了cv2.HOGDescriptor方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_hog
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import HOGDescriptor [as 别名]
def get_hog() :
winSize = (20,20)
blockSize = (10,10)
blockStride = (5,5)
cellSize = (10,10)
nbins = 9
derivAperture = 1
winSigma = -1.
histogramNormType = 0
L2HysThreshold = 0.2
gammaCorrection = 1
nlevels = 64
signedGradient = True
hog = cv2.HOGDescriptor(winSize,blockSize,blockStride,cellSize,nbins,derivAperture,winSigma,histogramNormType,L2HysThreshold,gammaCorrection,nlevels, signedGradient)
return hog
affine_flags = cv2.WARP_INVERSE_MAP|cv2.INTER_LINEAR
示例2: get_hog
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import HOGDescriptor [as 别名]
def get_hog():
""" Get hog descriptor """
# cv2.HOGDescriptor(winSize, blockSize, blockStride, cellSize, nbins, derivAperture, winSigma, histogramNormType,
# L2HysThreshold, gammaCorrection, nlevels, signedGradient)
hog = cv2.HOGDescriptor((SIZE_IMAGE, SIZE_IMAGE), (8, 8), (4, 4), (8, 8), 9, 1, -1, 0, 0.2, 1, 64, True)
print("hog descriptor size: '{}'".format(hog.getDescriptorSize()))
return hog
开发者ID:PacktPublishing,项目名称:Mastering-OpenCV-4-with-Python,代码行数:10,代码来源:knn_handwritten_digits_recognition_k_training_testing_preprocessing_hog.py
示例3: turn_hog_desc
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import HOGDescriptor [as 别名]
def turn_hog_desc(old: np.ndarray) -> np.ndarray:
fd, _ = hog(
old,
orientations=8,
pixels_per_cell=(16, 16),
cells_per_block=(1, 1),
block_norm="L2-Hys",
visualize=True,
)
# also available with opencv-python
# hog = cv2.HOGDescriptor()
# return hog.compute(old)
return fd
示例4: __init__
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import HOGDescriptor [as 别名]
def __init__(self, flip = True):
self.vs = PiVideoStream(resolution=(800, 608)).start()
self.flip = flip
time.sleep(2.0)
self.hog = cv2.HOGDescriptor()
self.hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())
示例5: BB_init
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import HOGDescriptor [as 别名]
def BB_init(self):
# use HOG method to initialize bounding box
self.hog = cv2.HOGDescriptor()
self.hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())
self._box_init_window_name = 'Bounding Box Initialization'
cv2.namedWindow(self._box_init_window_name)
cv2.setMouseCallback(self._box_init_window_name, self._on_mouse)
示例6: __init__
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import HOGDescriptor [as 别名]
def __init__(self):
print('Initializing HOGBox...')
self.hog = cv2.HOGDescriptor()
self.hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())
self._box_init_window_name = 'Click mouse to initialize bounding box'
cv2.namedWindow(self._box_init_window_name)
cv2.setMouseCallback(self._box_init_window_name, self.on_mouse)
print('HOGBox initialized.')
示例7: __init__
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import HOGDescriptor [as 别名]
def __init__(self):
self.cap = scorer.VideoCapture(0)
self.hog = cv2.HOGDescriptor()
self.hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())
示例8: get_hog
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import HOGDescriptor [as 别名]
def get_hog():
""" Get hog descriptor """
# cv2.HOGDescriptor(winSize, blockSize, blockStride, cellSize, nbins, derivAperture, winSigma, histogramNormType,
# L2HysThreshold, gammaCorrection, nlevels, signedGradient)
hog = cv2.HOGDescriptor((SIZE_IMAGE, SIZE_IMAGE), (8, 8), (4, 4), (8, 8), 9, 1, -1, 0, 0.2, 1, 64, True)
print("get descriptor size: {}".format(hog.getDescriptorSize()))
return hog
开发者ID:PacktPublishing,项目名称:Mastering-OpenCV-4-with-Python,代码行数:12,代码来源:svm_handwritten_digits_recognition_preprocessing_hog_c_gamma.py
示例9: get_hog
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import HOGDescriptor [as 别名]
def get_hog():
"""Get hog descriptor"""
# cv2.HOGDescriptor(winSize, blockSize, blockStride, cellSize, nbins, derivAperture, winSigma, histogramNormType,
# L2HysThreshold, gammaCorrection, nlevels, signedGradient)
hog = cv2.HOGDescriptor((SIZE_IMAGE, SIZE_IMAGE), (8, 8), (4, 4), (8, 8), 9, 1, -1, 0, 0.2, 1, 64, True)
print("get descriptor size: {}".format(hog.getDescriptorSize()))
return hog
开发者ID:PacktPublishing,项目名称:Mastering-OpenCV-4-with-Python,代码行数:12,代码来源:svm_handwritten_digits_recognition_preprocessing_hog.py
示例10: __init__
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import HOGDescriptor [as 别名]
def __init__(self, storage):
super(HOG, self).__init__(storage)
self.STORAGE_SUB_NAME = 'hog_normalized'
self.sub_folder = self.storage.get_sub_folder(
self.STORAGE_SUPER_NAME, self.STORAGE_SUB_NAME)
self.storage.ensure_dir(self.sub_folder)
self.hog = cv2.HOGDescriptor()
self.base_size = 256
示例11: __init__
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import HOGDescriptor [as 别名]
def __init__(self):
self.hog = cv2.HOGDescriptor()
self.hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())
self.winStride = g.config['stride']
self.padding = g.config['padding']
self.scale = float(g.config['scale'])
self.meanShift = True if int(g.config['mean_shift']) > 0 else False
g.logger.debug('Initializing HOG')
示例12: func
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import HOGDescriptor [as 别名]
def func(path):
frame = cv2.imread(path)
frame = cv2.resize(frame,(128,128))
converted2 = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
converted = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) # Convert from RGB to HSV
#cv2.imshow("original",converted2)
lowerBoundary = np.array([0,40,30],dtype="uint8")
upperBoundary = np.array([43,255,254],dtype="uint8")
skinMask = cv2.inRange(converted, lowerBoundary, upperBoundary)
skinMask = cv2.addWeighted(skinMask,0.5,skinMask,0.5,0.0)
#cv2.imshow("masked",skinMask)
skinMask = cv2.medianBlur(skinMask, 5)
skin = cv2.bitwise_and(converted2, converted2, mask = skinMask)
#frame = cv2.addWeighted(frame,1.5,skin,-0.5,0)
#skin = cv2.bitwise_and(frame, frame, mask = skinMask)
#skinGray=cv2.cvtColor(skin, cv2.COLOR_BGR2GRAY)
#cv2.imshow("masked2",skin)
img2 = cv2.Canny(skin,60,60)
#cv2.imshow("edge detection",img2)
'''
hog = cv2.HOGDescriptor()
h = hog.compute(img2)
print(len(h))
'''
surf = cv2.xfeatures2d.SURF_create()
#surf.extended=True
img2 = cv2.resize(img2,(256,256))
kp, des = surf.detectAndCompute(img2,None)
#print(len(des))
img2 = cv2.drawKeypoints(img2,kp,None,(0,0,255),4)
#plt.imshow(img2),plt.show()
cv2.waitKey(0)
cv2.destroyAllWindows()
print(len(des))
return des