本文整理汇总了Python中thumbor.point.FocalPoint.from_square方法的典型用法代码示例。如果您正苦于以下问题:Python FocalPoint.from_square方法的具体用法?Python FocalPoint.from_square怎么用?Python FocalPoint.from_square使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类thumbor.point.FocalPoint
的用法示例。
在下文中一共展示了FocalPoint.from_square方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: should_append_the_returned_focal_points_to_context_request
# 需要导入模块: from thumbor.point import FocalPoint [as 别名]
# 或者: from thumbor.point.FocalPoint import from_square [as 别名]
def should_append_the_returned_focal_points_to_context_request(self, topic):
focal_point1_repr = FocalPoint.from_square(1, 2, 3, 4).to_dict()
focal_point2_repr = FocalPoint.from_square(5, 6, 7, 8).to_dict()
calls = topic.context.request.focal_points.append.call_args_list
first_call_arg_repr = calls[0][0][0].to_dict()
secon_call_arg_repr = calls[1][0][0].to_dict()
expect(first_call_arg_repr).to_equal(focal_point1_repr)
expect(secon_call_arg_repr).to_equal(focal_point2_repr)
示例2: features_to_focal_points
# 需要导入模块: from thumbor.point import FocalPoint [as 别名]
# 或者: from thumbor.point.FocalPoint import from_square [as 别名]
def features_to_focal_points(cls, features):
focal_points = []
for (left, top, width, height), neighbors in features:
top = cls.add_hair_offset(top, height)
focal_points.append(
FocalPoint.from_square(left, top, width, height, origin="Face Detection"))
return focal_points
示例3: detect
# 需要导入模块: from thumbor.point import FocalPoint [as 别名]
# 或者: from thumbor.point.FocalPoint import from_square [as 别名]
def detect(self, context):
features = self.get_features(context)
if features:
for (left, top, width, height), neighbors in features:
context['focal_points'].append(FocalPoint.from_square(left, top, width, height))
else:
self.next(context)
示例4: detect
# 需要导入模块: from thumbor.point import FocalPoint [as 别名]
# 或者: from thumbor.point.FocalPoint import from_square [as 别名]
def detect(self, callback):
features = self.get_features()
if features:
for square, neighbors in features:
self.context.request.focal_points.append(FocalPoint.from_square(*square))
callback()
else:
self.next(callback)
示例5: extract_focal
# 需要导入模块: from thumbor.point import FocalPoint [as 别名]
# 或者: from thumbor.point.FocalPoint import from_square [as 别名]
def extract_focal(self):
parts = self.parse_url(self.context.request.image_url)
if parts:
image, top, right, left, bottom = parts
top, right, left, bottom = int(top), int(right), int(left), int(bottom)
width = right - left
height = bottom - top
self.context.request.focal_points.append(
FocalPoint.from_square(left, top, width, height, origin="Original Extraction")
)
self.context.request.image_url = image
示例6: detect
# 需要导入模块: from thumbor.point import FocalPoint [as 别名]
# 或者: from thumbor.point.FocalPoint import from_square [as 别名]
def detect(self, callback):
features = self.get_features()
if features:
for (left, top, width, height), neighbors in features:
top = self.__add_hair_offset(top, height)
self.context.request.focal_points.append(
FocalPoint.from_square(left, top, width, height, origin="Face Detection")
)
callback()
else:
self.next(callback)
示例7: focal
# 需要导入模块: from thumbor.point import FocalPoint [as 别名]
# 或者: from thumbor.point.FocalPoint import from_square [as 别名]
def focal(self, focal_string):
parsed = self.focal_regex.match(focal_string)
if parsed:
left, top, right, bottom = parsed.groups()
left, top, right, bottom = int(left), int(top), int(right), int(bottom)
width = right - left
height = bottom - top
if width and height:
self.context.request.focal_points.append(
FocalPoint.from_square(left, top, width, height, origin="Explicit")
)
示例8: detect
# 需要导入模块: from thumbor.point import FocalPoint [as 别名]
# 或者: from thumbor.point.FocalPoint import from_square [as 别名]
def detect(self, context):
size = context['engine'].size
image_header = cv.CreateImageHeader(size, cv.IPL_DEPTH_8U, 3)
cv.SetData(image_header, Image.open(StringIO(context['buffer'])).tostring())
grayscale = cv.CreateImage(size, 8, 1)
cv.CvtColor(image_header, grayscale, cv.CV_BGR2GRAY)
cv.EqualizeHist(grayscale, grayscale)
faces = cv.HaarDetectObjects(grayscale, Detector.cascade, cv.CreateMemStorage(), 1.1, 3, cv.CV_HAAR_DO_CANNY_PRUNING, (30, 30))
if faces:
for face in faces:
left, top, width, height = face[0]
top = self.__add_hair_offset(top, height)
context['focal_points'].append(FocalPoint.from_square(left, top, width, height))
else:
self.next(context)
示例9: detect
# 需要导入模块: from thumbor.point import FocalPoint [as 别名]
# 或者: from thumbor.point.FocalPoint import from_square [as 别名]
def detect(self, callback):
try:
features = self.get_features()
except Exception:
logger.warn('Error during face detection; skipping to next detector')
self.next(callback)
return
if features:
for (left, top, width, height), neighbors in features:
top = self.__add_hair_offset(top, height)
self.context.request.focal_points.append(
FocalPoint.from_square(left, top, width, height, origin="Face Detection")
)
callback()
else:
self.next(callback)
示例10: test_new_point_square_point
# 需要导入模块: from thumbor.point import FocalPoint [as 别名]
# 或者: from thumbor.point.FocalPoint import from_square [as 别名]
def test_new_point_square_point(self):
point = FocalPoint.from_square(x=350, y=50, width=110, height=110)
expect(point.x).to_equal(405)
expect(point.y).to_equal(105)
expect(point.weight).to_equal(12100)
示例11: config_context
# 需要导入模块: from thumbor.point import FocalPoint [as 别名]
# 或者: from thumbor.point.FocalPoint import from_square [as 别名]
def config_context(context):
image_w, image_h = expected.size[0], expected.size[1]
point = FocalPoint.from_square(50, 50, image_w - 100, image_h - 100, origin='Face Detection')
context.request.focal_points = [point]
示例12: topic
# 需要导入模块: from thumbor.point import FocalPoint [as 别名]
# 或者: from thumbor.point.FocalPoint import from_square [as 别名]
def topic(self):
return FocalPoint.from_square(0, 300, 300, 300)
示例13: topic
# 需要导入模块: from thumbor.point import FocalPoint [as 别名]
# 或者: from thumbor.point.FocalPoint import from_square [as 别名]
def topic(self):
return FocalPoint.from_square(350, 50, 110, 110)
示例14: test_from_square
# 需要导入模块: from thumbor.point import FocalPoint [as 别名]
# 或者: from thumbor.point.FocalPoint import from_square [as 别名]
def test_from_square():
point = FocalPoint.from_square(x=10.0, y=20.0, width=100, height=200)
assert point.x == 55.0
assert point.y == 110.0
assert point.weight == 20000.0
示例15: topic
# 需要导入模块: from thumbor.point import FocalPoint [as 别名]
# 或者: from thumbor.point.FocalPoint import from_square [as 别名]
def topic(self):
return FocalPoint.from_square(x=350, y=50, width=110, height=110)