我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用dlib.rectangles()。
def getAllFaceBoundingBoxes(self, rgbImg): """ Find all face bounding boxes in an image. :param rgbImg: RGB image to process. Shape: (height, width, 3) :type rgbImg: numpy.ndarray :return: All face bounding boxes in an image. :rtype: dlib.rectangles """ assert rgbImg is not None try: return self.detector(rgbImg, 1) except Exception as e: #pylint: disable=broad-except print("Warning: {}".format(e)) # In rare cases, exceptions are thrown. return []
def OPENCV_getAllFaceBoundingBoxes(self, rgbImg): """ Find all face bounding boxes in an image. :param rgbImg: RGB image to process. Shape: (height, width, 3) :type rgbImg: numpy.ndarray :return: All face bounding boxes in an image. :rtype: opencv.rectangles """ assert rgbImg is not None lit=[] try: faces = self.OPENCV_Detector.detectMultiScale(rgbImg) for (x, y, w, h) in faces: lit.append(dlib.rectangle(int(x),int(y),int(x+w),int(y+h))) return lit except Exception as e: print("Warning: {}".format(e)) # In rare cases, exceptions are thrown. return []
def HOG_getAllFaceBoundingBoxes(self, rgbImg): """ Find all face bounding boxes in an image. :param rgbImg: RGB image to process. Shape: (height, width, 3) :type rgbImg: numpy.ndarray :return: All face bounding boxes in an image. :rtype: dlib.rectangles """ assert rgbImg is not None try: return self.HOG_Detector(rgbImg, 1) except Exception as e: print("Warning: {}".format(e)) # In rare cases, exceptions are thrown. return []