Remove redundant code and use cv2 instead.