Swift:不pipe我做什么CIDetector总是零
我不明白为什么这个代码不起作用,探测器总是为零,CIDetectorTypeQRCode为常量,一切都与CIDetectorTypeFace一起工作。 我从苹果的API的一个错误。 这是官方文档: 苹果文档
@IBAction func analyseTag(sender: AnyObject) { var detector:CIDetector = CIDetector(ofType: CIDetectorTypeQRCode, context:nil, options:[CIDetectorAccuracy: CIDetectorAccuracyHigh]) var decode = "" var ciImage:CIImage = CIImage(image: ImgChoosed.image) var message:String = ""; let features = detector.featuresInImage(ciImage) for feature in features as [CIQRCodeFeature] { message += feature.messageString } if(message == "") { println("nothing") } else { println("\(message)") } }
你有解决scheme吗? 先谢谢你了
这也发生在我们身上。 iPhone 4s不返回QRCodetypes的CIDetector。 其他types(矩形,脸)虽然工作…
相同的代码在iPhone 6上的预期工作。还没有testing5或5s。
但两个星期前,我相信还是在4s上工作。 我猜,当时还是在iOS 8上。
你提供的代码不能有一个零detector
因为它不是一个可选的,编译器会抱怨代码中的几个地方。
如果function是空的,那么你知道它没有在你的图像中findQR码。 尝试提供更好的图像或closuresCIDetectorAccuracy
。
如果function不是空的,那么你的演员失败。
编辑:你不能在构造函数中传递一个nil
上下文。
- 确保你的ImgChoosed.image不是零。
- 更改另一个input图像进行testing。
- 尝试
for feature in features as! [CIQRCodeFeature]
for feature in features as! [CIQRCodeFeature]
。
我发现在设备上使用解决了这个问题。 模拟器似乎总是返回零。
- 哪个JSON框架与ios SDK?
- 如何closures自动手势以导航控制器返回视图?
- 通用二进制文件是否包含iPhone上App Bundle中的所有重磅ipadgraphics? 该怎么办?
- 无法从Objective-C pod访问快速类
- 如何在UITableView中设置节标题的高度变化?
- xcodebuild:cdtool无法编译:DataModelCompile /path/to/coredatamodel.xcdatamodeld dyld:找不到符号:_OBJC_CLASS _ $ _ OS_object
- 如何截取UIScrollView可见区域的截图?
- “在xCode 5.1中没有select器”validSuits“错误的已知类方法
- “在使用Swift在Xcode 6中导入时,没有这样的模块”LocalAuthentication“