代码拉取完成,页面将自动刷新
import numpy as np # Arrays
import cv2 # OpenCV
############ SPECIFIC FUNCTIONS ###############
class GradientClass(object):
def __init__(self):
pass
def get_sobel(self, img, dirx, diry):
# Return thresholded sobel in specified direction
sobel = cv2.Sobel(img, cv2.CV_64F, dirx, diry, ksize=self.Vars['sobel_ksize'])
sobel = np.absolute(sobel)
sobel = sobel - sobel.min() # Rescale to 0-255 values
thresh = np.zeros(sobel.shape, np.uint8)
thresh[sobel > self.Vars['sobel_thresh']] = 255
sobel = thresh.copy()
sobel = self.morphology(sobel)
return sobel
def binarization(self, frame_gray, *args):
# Treat image and return binary
sobelx = self.get_sobel(frame_gray, self.Vars['sobel_order'], 0)
sobely = self.get_sobel(frame_gray, 0, self.Vars['sobel_order'])
sobelBoth = cv2.bitwise_or(sobelx, sobely)
return sobelBoth
if __name__ == '__main__':
import detection_main
detection_main.start_program(trackMethod='auto', mode='gradient', GUI=False)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。