code: def event_cv2_drawRectangles(event, x, y, flags, param):
      global global_image
      global global_bboxes
      global global_leftButtonDownPoint
  
      # draw all previous bounding boxes, and the most recent box in a different color
      imgCopy = global_image.copy()
      drawRectangles(imgCopy, global_bboxes)
      if len(global_bboxes) > 0:
          drawRectangles(
              imgCopy, [global_bboxes[-1]], color=(255, 0, 0)
          )
  
      # handle mouse events
      if event == cv2.EVENT_LBUTTONDOWN:
          global_leftButtonDownPoint = (x, y)
  
      elif event == cv2.EVENT_LBUTTONUP:
          pt1 = global_leftButtonDownPoint
          pt2 = (x, y)
          minPt = (min(pt1[0], pt2[0]), min(pt1[1], pt2[1]))
          maxPt = (max(pt1[0], pt2[0]), max(pt1[1], pt2[1]))
          imgWidth, imgHeight = imArrayWidthHeight(global_image)
          minPt = ptClip(minPt, imgWidth, imgHeight)
          maxPt = ptClip(maxPt, imgWidth, imgHeight)
          global_bboxes.append(minPt + maxPt)
  
      elif (
          flags == cv2.EVENT_FLAG_LBUTTON
      ):  # if left mouse button is held down
          cv2.rectangle(
              imgCopy,
              global_leftButtonDownPoint,
              (x, y),
              (255, 255, 0),
              1,
          )
  
      else:
          drawCrossbar(imgCopy, (x, y))
      cv2.imshow("AnnotationWindow", imgCopy)
  
imports: from __future__ import print_function
  from builtins import chr
  import os, sys, importlib, shutil
  from cntk_helpers import *
label_desc: Use image node_id 1 for calling a global function with example usage: event_cv2_drawRectangles(event, x, y, flags, param) without return types