当前位置: 首页>>代码示例>>Python>>正文


Python FocalPoint.from_square方法代码示例

本文整理汇总了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)
开发者ID:APSL,项目名称:thumbor,代码行数:13,代码来源:cascade_loader_detector_vows.py

示例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
开发者ID:RealGeeks,项目名称:thumbor,代码行数:9,代码来源:distributed_collage.py

示例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)
开发者ID:douglas,项目名称:thumbor,代码行数:10,代码来源:__init__.py

示例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)
开发者ID:5um1th,项目名称:thumbor,代码行数:11,代码来源:local_detector.py

示例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
开发者ID:RealGeeks,项目名称:thumbor,代码行数:14,代码来源:extract_focal.py

示例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)
开发者ID:APSL,项目名称:thumbor,代码行数:14,代码来源:__init__.py

示例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")
                )
开发者ID:5um1th,项目名称:thumbor,代码行数:15,代码来源:focal.py

示例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)
开发者ID:rootart,项目名称:thumbor,代码行数:19,代码来源:__init__.py

示例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)
开发者ID:gi11es,项目名称:thumbor-debian,代码行数:19,代码来源:__init__.py

示例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)
开发者ID:GDxU,项目名称:thumbor,代码行数:7,代码来源:test_point.py

示例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]
开发者ID:caeugusmao,项目名称:thumbor,代码行数:7,代码来源:test_redeye.py

示例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)
开发者ID:douglas,项目名称:thumbor,代码行数:4,代码来源:point_vows.py

示例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)
开发者ID:cicerocomp,项目名称:thumbor,代码行数:4,代码来源:point_vows.py

示例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
开发者ID:expertise-com,项目名称:thumbor,代码行数:7,代码来源:test_focal_points.py

示例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)
开发者ID:5um1th,项目名称:thumbor,代码行数:4,代码来源:point_vows.py


注:本文中的thumbor.point.FocalPoint.from_square方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。