daily pastebin goal
28%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import numpy as np
  2. import cv2
  3.  
  4. surf = cv2.xfeatures2d.SURF_create()
  5. trainer = cv2.BOWKMeansTrainer(300)
  6.  
  7.  
  8. for i in range(0, 300):
  9.     image = np.random.randint(255, size=(400, 400), dtype=np.uint8)
  10.     _, desc = surf.detectAndCompute(image, None)
  11.     trainer.add(desc)
  12.     print(str(i) + " " + str(len(desc)))
  13.  
  14. dict_ = trainer.cluster()
  15.  
  16. fs_write = cv2.FileStorage('dict.json', cv2.FILE_STORAGE_WRITE)
  17. fs_write.write("dict", dict_)
  18. fs_write.release()
  19. print(dict_.shape)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top