- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在练习使用一些 swift 2,但在使用 CIDetector 时遇到了一些困难。
我有一个应用程序,里面有一系列图片;三个不同的矩形和三张不同的人物/团体照片。我只是在这些图像上尝试 CIDetector 以查看识别出的内容。我最成功的是人脸——但是它识别的人脸在图像上非常奇怪的地方。
这是我的检测代码:
///does the detecting of features
func detectFeatures() -> [CIFeature]? {
print("detecting")
let detectorOptions: [String: AnyObject] = [CIDetectorAccuracy: CIDetectorAccuracyHigh, CIDetectorImageOrientation: 6]
var detectorType : String
switch currentPhoto.currentType {
case .RECTANGLES:
detectorType = CIDetectorTypeRectangle
case .FACES:
detectorType = CIDetectorTypeFace
default:
print("error in phototype")
return nil
}
let detector = CIDetector(ofType: detectorType, context: nil, options: detectorOptions)
let image = CIImage(image: imageViewer.image!)
guard image != nil else{
print("image not cast to CIImage")
return nil
}
return detector.featuresInImage(image!)
}
添加星星的地方:
for f in features!{
print(f.bounds.origin)
imageViewer.layer.addSublayer(createMarker(f.bounds.size, location: f.bounds.origin))
}
星星的诞生地:
///Creates a star on a layer and puts it over the point passed in
func createMarker(size: CGSize, location: CGPoint) -> CALayer{
print("The marker will be at [\(location.x),\(location.y)]")
//doesn't appear in correct place on the screen
let newLayer = CALayer()
newLayer.bounds = imageViewer.bounds
newLayer.frame = CGRect(origin: location, size: size)
newLayer.contents = UIImage(named: "star")?.CGImage
newLayer.backgroundColor = UIColor(colorLiteralRed: 0.0, green: 0.0, blue: 0.0, alpha: 0.0).CGColor
newLayer.masksToBounds = false
return newLayer
}
有没有人遇到过这样的事情?
最佳答案
很遗憾,我认为您使用的矩形与您使用的图像不兼容。如果您查看 CIDetector Class Reference上面写着:
CIDetectorTypeRectangle A detector that searches for rectangular areasin a still image or video, returning CIRectangleFeature objects thatprovide information about detected regions.
The rectangle detector finds areas that are likely to representrectangular objects that appear in perspective in the image, such aspapers or books seen on a desktop.
结果:
bounds = "(296.752716064453, 74.7079086303711, 181.281158447266,253.205474853516)\n"
我在其他平面矩形上运行了您的代码,但没有找到任何特征。需要有点像“真实世界”的图像。
关于ios - CIDetector 要么没有检测到,要么在奇怪的地方检测到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34244752/
我正在使用 CIDetector 检测 UIImage 中的人脸。我正确地得到了面部矩形,但是当我将图像裁剪为检测到的面部矩形时。它没有显示在我的 ImageView 中。 我已经检查过了。我的形象不
现在我知道坐标系统搞砸了。我试过反转 View 和 imageView,没有。然后我尝试反转特征的坐标,但我仍然遇到同样的问题。我知道它检测到面部、眼睛和嘴巴,但是当我尝试从样本代码中放置覆盖框时,它
我正在查看 CIDetectorTypeQRCode。如何检测其他类型的条码?我可以通过 AVMetadataObjectType 读取其他条形码类型,但是我想用 CIDetector 做同样的事情。
CIDetector 无法检测到最大的矩形。左图为原始图像,右图为矩形检测图像。它没有检测到完整的矩形。我该如何解决? - (CIDetector *)highAccuracyRectangleDet
在尝试使用 CIDetector 检测人脸时减少计算时间时,我尝试按照 Apple 的建议重用单个检测器实例进行多个人脸检测: This class can maintain many state v
我正在练习使用一些 swift 2,但在使用 CIDetector 时遇到了一些困难。 我有一个应用程序,里面有一系列图片;三个不同的矩形和三张不同的人物/团体照片。我只是在这些图像上尝试 CIDet
我正在尝试使用 CIDetector 从 UIImage 中检测 QRCode,以便从中提取 messageString。 我有一个基本上接收 UIImage 作为输入并返回解码的 messageSt
我正在尝试实现内置的 iOS 5 人脸检测 API。我正在使用 UIImagePickerController 的实例来允许用户拍照,然后我尝试使用 CIDetector 来检测面部特征。不幸的是,f
我正在开发一个应用程序,我必须在其中检测左眼、右眼和嘴巴的位置。我的 self.view 上有一个 imageView 并且 imageView 包含一个面部图像,现在我想要同时获取眼睛和嘴巴的坐标。
所以我尝试在 Swift 中使用 CIDetector 制作一个文本检测器。当我将手机指向一段文字时,它没有检测到它。但是,如果我将手机转到一边,它就会工作并检测到文本。我怎样才能改变它,以便它在正确
我多次使用 CIDetector 如下: -(NSArray *)detect:(UIImage *)inimage { UIImage *inputimage = i
我试图让我的应用程序的用户能够从他们的库中获取图像并扫描其中的 QRCode。相关代码如下: 这是从图像选择器返回所选图像的函数。 func imagePickerController(picker:
我正在尝试使用核心检测器获取图像上的文本区域。 - (NSArray *)detectWithImage:(UIImage *)img { // prepare CIImage CII
我正在尝试使用 CIDetector 检测 Rectangle。 我使用的代码来自:https://www.cocoacontrols.com/controls/vnimagescanner 我的问题
我想从实时摄像头和图像中扫描二维码和条形码。我以前使用 ZBar 库来扫描代码。它不扫描特定类型的二维码和条形码。此外,Apple 的 AVFoundation 框架在从实时摄像头扫描代码时似乎更加快
我在我的应用程序中实现了一个 CIDetector 来检测图像上的矩形,但现在我如何使用返回的 CGPoint 来裁剪图像,以便我可以把它显示回来吗? 对于透视,我已经尝试应用 CIPerspecti
我不知道为什么我得到的 CIFaceFeature 总是返回零矩形: import Cocoa import QuartzCore let url = NSURL(string:"http://cs6
我不明白为什么这段代码不起作用,检测器对于 CIDetectorTypeQRCode 常量始终为零,一切都与 CIDetectorTypeFace 一起工作。我怀疑来自 Apple API 的错误。这
我正在尝试用相机拍照,然后检测其中的人脸。但它不起作用... results 数组返回的计数为零。我用一张来自互联网的人的照片测试了这段代码,它返回了 1 张找到的脸。这是我的代码: // MARK:
在为面部或矩形识别设置 CIDetector 时,应该如何使用 CIDetectorMinFeatureSize? description at Apple什么都没告诉我: A key used to
我是一名优秀的程序员,十分优秀!