final code for keypoint detection