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

Ios 如何在swift中创建ciimage中的边框,ios,swift3,edge-detection,ciimage,Ios,Swift3,Edge Detection,Ciimage,我正在编写一个功能,用于更正从ios摄像头扫描的文档的透视图 我想在边缘已确定的文档周围创建边框效果。CiImage具有初始化器属性,我可以使用该属性在检测到的边缘上创建颜色覆盖。我想做的不是创建彩色区域,而是实时创建边界区域。最好的方法是什么 fileprivate func overlayImageForFeatureInImage(_ image: CIImage, feature: CIRectangleFeature) -> CIImage! { var overlay

我正在编写一个功能,用于更正从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)
}