Ayo*_*oub 6 ios avcapturesession swift cidetector
我正在开发一个检测身份证的应用程序,我正在尝试使用ios内置的CIDetector来检测实时预览中的矩形形状对象.我在这里使用CoreImage Detectors中解释的解决方案
我得到了流动的结果 图像
我的问题:有没有办法提取和裁剪检测到的矩形?
func cropBusinessCardForPoints(image: CIImage, topLeft: CGPoint, topRight: CGPoint, bottomLeft: CGPoint, bottomRight: CGPoint) -> CIImage {
var businessCard: CIImage
businessCard = image.imageByApplyingFilter(
"CIPerspectiveTransformWithExtent",
withInputParameters: [
"inputExtent": CIVector(CGRect: image.extent),
"inputTopLeft": CIVector(CGPoint: topLeft),
"inputTopRight": CIVector(CGPoint: topRight),
"inputBottomLeft": CIVector(CGPoint: bottomLeft),
"inputBottomRight": CIVector(CGPoint: bottomRight)])
businessCard = image.imageByCroppingToRect(businessCard.extent)
return businessCard
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4870 次 |
最近记录: |