我想知道为什么默认情况下不继承包装方法/函数的元数据(例如__name__
, )。相反,提供该功能。__doc__
partial
functools
update_wrapper
为什么默认情况下不这样做并没有在任何地方提到(据我所知),例如这里和许多functools.partial
关于如何“解决问题”的教程__name__
。
是否有继承此信息会导致问题/混乱的示例?
我在 python 中使用哈里斯角检测的 opencv 实现。我的问题是关于下面 gif 中显示的行为 - 当图像旋转时,角停止被检测到(在各种旋转时)。完整代码:
import cv2
image_path = 'image1.jpg'
original_image = cv2.imread(image_path)
def play(video, name='video', wait=60, key='q'):
for f in video:
cv2.imshow(name, f)
if cv2.waitKey(wait) == ord(key):
return
def rotate(image, theta, point=(0,0)):
M = cv2.getRotationMatrix2D((point[1], point[0]), theta, 1)
return cv2.warpAffine(image, M, (image.shape[1], image.shape[0]))
def rotate_detect(image):
for theta in range(0, 360):
img = rotate(image, theta, (original_image.shape[0] / 2, original_image.shape[1] / 2))
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
dst = cv2.cornerHarris(gray,9,13,0.04)
#result is dilated for marking the corners, not …
Run Code Online (Sandbox Code Playgroud)