小编Nut*_*ula的帖子

如何在swift中创建ciimage中的边框

我正在编写一个功能,用于修正从ios相机扫描的文档的透视图.

我想在已确定边缘的文档周围创建边框效果.CiImage具有初始化属性,我可以使用该属性在检测到的边缘上创建颜色叠加.我想要做的不是创建彩色区域,而是想要创建边界区域,但实时.最好的方法是什么?

fileprivate func overlayImageForFeatureInImage(_ image: CIImage, feature: CIRectangleFeature) -> CIImage! {

    var overlay = CIImage(color: CIColor(color: self.borderDetectionFrameColor))

    overlay = overlay.cropping(to: image.extent)
    print("the extent of image is \(image.extent)")

    overlay = overlay.applyingFilter("CIPerspectiveTransformWithExtent", withInputParameters: ["inputExtent":     CIVector(cgRect: image.extent),
                                                                                               "inputTopLeft":    CIVector(cgPoint: feature.topLeft),
                                                                                               "inputTopRight":   CIVector(cgPoint: feature.topRight),
                                                                                               "inputBottomLeft": CIVector(cgPoint: feature.bottomLeft),
                                                                                               "inputBottomRight": CIVector(cgPoint: feature.bottomRight)])

    return overlay.compositingOverImage(image)
}
Run Code Online (Sandbox Code Playgroud)

edge-detection ios ciimage swift3

5
推荐指数
0
解决办法
412
查看次数

标签 统计

ciimage ×1

edge-detection ×1

ios ×1

swift3 ×1