text: import cv2
  
  def detectFaceOpenCVHaar(faceCascade, frame, inHeight=300, inWidth=0):
      frameOpenCVHaar = frame.copy()
      frameHeight = frameOpenCVHaar.shape[0]
      frameWidth = frameOpenCVHaar.shape[1]
      if not inWidth:
          inWidth = int((frameWidth / frameHeight) * inHeight)
  
      scaleHeight = frameHeight / inHeight
      scaleWidth = frameWidth / inWidth
  
      frameOpenCVHaarSmall = cv2.resize(frameOpenCVHaar, (inWidth, inHeight))
      frameGray = cv2.cvtColor(frameOpenCVHaarSmall, cv2.COLOR_BGR2GRAY)
  
      faces = faceCascade.detectMultiScale(frameGray)
      bboxes = []
      for (x, y, w, h) in faces:
          x1 = x
          y1 = y
          x2 = x + w
          y2 = y + h
          cvRect = [int(x1 * scaleWidth), int(y1 * scaleHeight),
                    int(x2 * scaleWidth), int(y2 * scaleHeight)]
          bboxes.append(cvRect)
          cv2.rectangle(frameOpenCVHaar, (cvRect[0], cvRect[1]), (cvRect[2], cvRect[3]), (0, 255, 0),
                        int(round(frameHeight / 150)), 4)
      return frameOpenCVHaar, bboxes
  
  
  def detectFaceOpenCVDnn(net, frame, conf_threshold):
      frameOpencvDnn = frame.copy()
      frameHeight = frameOpencvDnn.shape[0]
      frameWidth = frameOpencvDnn.shape[1]
      blob = cv2.dnn.blobFromImage(frameOpencvDnn, 1.0, (300, 300), [104, 117, 123], False, False)
  
      net.setInput(blob)
      detections = net.forward()
      bboxes = []
      for i in range(detections.shape[2]):
          confidence = detections[0, 0, i, 2]
          if confidence > conf_threshold:
              x1 = int(detections[0, 0, i, 3] * frameWidth)
              y1 = int(detections[0, 0, i, 4] * frameHeight)
              x2 = int(detections[0, 0, i, 5] * frameWidth)
              y2 = int(detections[0, 0, i, 6] * frameHeight)
              bboxes.append([x1, y1, x2, y2])
              cv2.rectangle(frameOpencvDnn, (x1, y1), (x2, y2), (0, 255, 0), int(round(frameHeight/150)), 8)
      return frameOpencvDnn, bboxes
  
  
  def detectFaceDlibHog(detector, frame, inHeight=300, inWidth=0):
  
      frameDlibHog = frame.copy()
      frameHeight = frameDlibHog.shape[0]
      frameWidth = frameDlibHog.shape[1]
      if not inWidth:
          inWidth = int((frameWidth / frameHeight)*inHeight)
  
      scaleHeight = frameHeight / inHeight
      scaleWidth = frameWidth / inWidth
  
      frameDlibHogSmall = cv2.resize(frameDlibHog, (inWidth, inHeight))
  
      frameDlibHogSmall = cv2.cvtColor(frameDlibHogSmall, cv2.COLOR_BGR2RGB)
      faceRects = detector(frameDlibHogSmall, 0)
      #print(frameWidth, frameHeight, inWidth, inHeight)
      bboxes = []
      for faceRect in faceRects:
  
          cvRect = [int(faceRect.left()*scaleWidth), int(faceRect.top()*scaleHeight),
                    int(faceRect.right()*scaleWidth), int(faceRect.bottom()*scaleHeight) ]
          bboxes.append(cvRect)
          cv2.rectangle(frameDlibHog, (cvRect[0], cvRect[1]), (cvRect[2], cvRect[3]), (0, 255, 0), int(round(frameHeight/150)), 4)
      return frameDlibHog, bboxes
  