Advertisement
lamiastella

grabcut.py

Feb 3rd, 2017
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. $ python grabcut.py mts.jpg
  2.  
  3. ===============================================================================
  4. Interactive Image Segmentation using GrabCut algorithm.
  5.  
  6. This sample shows interactive image segmentation using grabcut algorithm.
  7.  
  8. USAGE :
  9. python grabcut.py <filename>
  10.  
  11. README FIRST:
  12. Two windows will show up, one for input and one for output.
  13.  
  14. At first, in input window, draw a rectangle around the object using
  15. mouse right button. Then press 'n' to segment the object (once or a few times)
  16. For any finer touch-ups, you can press any of the keys below and draw lines on
  17. the areas you want. Then again press 'n' for updating the output.
  18.  
  19. Key '0' - To select areas of sure background
  20. Key '1' - To select areas of sure foreground
  21. Key '2' - To select areas of probable background
  22. Key '3' - To select areas of probable foreground
  23.  
  24. Key 'n' - To update the segmentation
  25. Key 'r' - To reset the setup
  26. Key 's' - To save the results
  27. ===============================================================================
  28.  
  29.  
  30. ** (output:18169): WARNING **: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-PnQnjuUEoF: Connection refused
  31. Instructions :
  32.  
  33. Draw a rectangle around the object using right mouse button
  34.  
  35. Now press the key 'n' a few times until no further change
  36.  
  37. For finer touchups, mark foreground and background after pressing keys 0-3
  38. and again press 'n'
  39.  
  40. For finer touchups, mark foreground and background after pressing keys 0-3
  41. and again press 'n'
  42.  
  43. mark background regions with left mouse button
  44.  
  45. mark background regions with left mouse button
  46.  
  47. mark foreground regions with left mouse button
  48.  
  49. mark background regions with left mouse button
  50.  
  51. mark background regions with left mouse button
  52.  
  53. Now press the key 'n' a few times until no further change
  54.  
  55. Now press the key 'n' a few times until no further change
  56.  
  57. For finer touchups, mark foreground and background after pressing keys 0-3
  58. and again press 'n'
  59.  
  60. For finer touchups, mark foreground and background after pressing keys 0-3
  61. and again press 'n'
  62.  
  63. OpenCV Error: Assertion failed (!bgdSamples.empty() && !fgdSamples.empty()) in initGMMs, file /home/mona/computer_vision/opencv-3.2.0/modules/imgproc/src/grabcut.cpp, line 379
  64. Traceback (most recent call last):
  65. File "grabcut.py", line 169, in <module>
  66. cv2.grabCut(img2,mask,rect,bgdmodel,fgdmodel,1,cv2.GC_INIT_WITH_MASK)
  67. cv2.error: /home/mona/computer_vision/opencv-3.2.0/modules/imgproc/src/grabcut.cpp:379: error: (-215) !bgdSamples.empty() && !fgdSamples.empty() in function initGMMs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement