Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 2088

A bug causes crash when class inherit from cv2.KeyPoint

$
0
0
Look this code: import numpy as np import cv2 class T(cv2.KeyPoint): def __init__(self, pt): super().__init__() self.pt = pt def calculate_corners(A): A_gray = cv2.cvtColor(A, cv2.COLOR_BGR2GRAY) pa = cv2.goodFeaturesToTrack(A_gray, maxCorners=100, qualityLevel=0.01, minDistance=15) pa = np.squeeze(pa) kpa = [] for coor in pa: kpa.append(T(tuple(coor))) return kpa cap = cv2.VideoCapture("E:\\video\\test.mp4") while True: frame = cap.read()[1] if frame is None: break kpa = calculate_corners(frame) frame_corner = cv2.drawKeypoints(frame, kpa, outImage=None, color=(255, 0, 125)) cv2.imshow('frame_corner', frame_corner) cv2.waitKey(1) cv2.destroyAllWindows() cap.release() This code will crash in my system(Windows10, python3.7.3, opencv4.1.0) After test, I'm sure this is caused by class T. I guess that class T dose not inherit release moudle of cv2.KeyPoint, so it cause memory leak. It's just my conjecture. And I didn't know how to fix it. Could anyone give me some advice? Thanks a lot!

Viewing all articles
Browse latest Browse all 2088

Trending Articles