Yesterday I searched the problem on Google and found nothing useful (according to my skill level, I might overlooked something that could be hints), so I decided to ask in the G+ Python community .
Based on Brett Ponsler's helpful suggestion, I tried to rewrite my test code and also went to download the Grabcut sample code again (this version is fine). This time, the sample code was running successfully.
Then I noticed a magic word ``0xFF'' in the new downloaded sample code. Using the hint, I finally found the bug report about cv2.waitKey() and came up with a tiny test code:
import cv2 import numpy as np cv2.namedWindow('test') while True: #key = cv2.waitKey(33) #this won't work #key = 0xFF & cv2.waitKey(33) #this is ok key = np.int16(cv2.waitKey(33)) #this is ok  if key == 27: break else: print key, hex(key), key % 256 cv2.destroyAllWindows()---
 The question I posted in the Python community: https://plus.google.com/117911423781149907976/posts/CdvQ3vWVV19