title: Opencv draw a rectangle in a picture were never shown
body: <p>Hey everybody i have some trouble using opencv 3.x and python 3.x.
  What i want to do is to draw a basic rectangle in a picture but the rectangle will never be drawn. 
  I read this similar thread but it doesn't helped me with my fault.
  <a href="https://stackoverflow.com/questions/28823243/python-opencv-mouse-callback-for-drawing-rectangle">Python OpenCV: mouse callback for drawing rectangle</a></p>
  
  <p>It would be nice if someone could give me a hint.</p>
  
  <pre><code>#!/usr/bin/env python3
  import cv2
  import numpy as np
  Path = 'picture.jpg'
  image_float_size = 400.0
  image_int_size = int(image_float_size)
  color = [0,255,0]
  rectangle = False
  
  def on_event(event,x,y,flags,param):
      global startpointx,startpointy,rectangle
      if event == cv2.EVENT_LBUTTONDOWN:
          rectangle = True
          startpointx = x
          startpointy = y
          print('Down',x,y) #debugging
          cv2.rectangle(resized,(x,y),(x,y),(0,255,0),-1)
  
      elif event == cv2.EVENT_LBUTTONUP:
          rectangle = False
          print('Up',x,y)
          cv2.rectangle(resized,(startpointx,startpointy),(x,y),(0,255,0),-1)
  
      elif event == cv2.EVENT_MOUSEMOVE:
          if rectangle:
              print('Move',startpointx,startpointy,x,y)#debugging
              cv2.rectangle(resized,(startpointx,startpointy),(x,y),(0,255,0),-1)
  
  # Read the image and convert it into gray
  image = cv2.imread(Path)
  gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
  
  # resize the image
  ration = image_float_size / gray_image.shape[1]
  dim = (image_int_size,int(gray_image.shape[0]*ration))
  resized = cv2.resize(gray_image, dim, interpolation = cv2.INTER_AREA)
  
  # set window for the image
  cv2.namedWindow('window')
  
  # mouse callback
  cv2.setMouseCallback('window',on_event)
  
  # wait forever for user to press any key, after key pressed close all windows
  while True:
      cv2.imshow('window',resized)
      if cv2.waitKey(0):
          break
          cv2.destroyAllWindows()
  </code></pre>