Guest User

Untitled

a guest
Jul 18th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. import numpy as np
  2. from plyfile import PlyData
  3. import sys, cv2
  4. from tqdm import tqdm
  5.  
  6. filename1 = sys.argv[1]
  7.  
  8. if '.ply' in filename1:
  9. filename1 = filename1.split('.ply')[0]
  10. if '.png' in filename1:
  11. filename1 = filename1.split('.png')[0]
  12.  
  13. print "Openning " + filename1 +'.ply'
  14. ply1 = PlyData.read(filename1 +'.ply')
  15. print "Openning " + filename1 +'.png'
  16. im1 = cv2.imread(filename1 +'.png')
  17.  
  18. h, w, c = im1.shape
  19. vertex1 = ply1['vertex']
  20.  
  21. for (i, vert) in tqdm(enumerate(vertex1)):
  22. if vert[0] == 0 and vert[1] == 0 and vert[2] == 0:
  23. im1[i/w, i%w] = [0,0,0]
  24.  
  25. def print_KP(event,x,y,flags,param):
  26. if event == cv2.EVENT_LBUTTONDOWN:
  27. if np.sum(im1[y,x]) > 0:
  28. cv2.circle(im1,(x,y),5,(0,0,255),1)
  29. print ('[X,Y]:{},{}'.format(x, y))
  30. else:
  31. print ("Keypoint {} {} do not exist in cloud".format(x, y))
  32.  
  33. cv2.namedWindow("image1")
  34.  
  35. cv2.setMouseCallback("image1", print_KP)
  36. while(1):
  37. cv2.imshow("image1",im1)
  38. if cv2.waitKey(1) & 0xFF == 27:
  39. break
  40. cv2.destroyAllWindows()
Add Comment
Please, Sign In to add comment