swift - VNRectangle Bounding Box 在 AVFoundation Frame 中的 x 轴上偏移不正确
问题描述
这是问题的剪辑这是我如何生成边界框,对坐标应用必要的变换以适应框架。不知道为什么 X 轴如此偏离(除非在中心)。也许它被翻转了?提前致谢!
func drawVisionRequestResults(_ results: [VNRecognizedTextObservation]) {
//bounding box transformations
let transform = CGAffineTransform(scaleX: 1, y: -1).translatedBy(x: 0, y: -self.previewView.frame.height)
let translate = CGAffineTransform.identity.scaledBy(x: self.previewView.frame.width
, y: self.previewView.frame.height)
//highlight search term in frame
for word in results {
if word.topCandidates(1).first?.string.lowercased().contains(searchTerm.lowercased()) == true {
self.counter = 0
searchingText.text = "Found"
let rectangleBounds = word.boundingBox.applying(translate).applying(transform)
previousRectCoordinate = rectangleBounds.origin
previewView.drawLayer(in: rectangleBounds)
}
解决方案
推荐阅读
- php - PHP登录表单未插入用户数据
- sql - Teradata, transactional data where columns have individual update dates
- python - 将索引附加到 for 循环以进行分页
- php - 在 laravel 5.3 中计数
- cordova - 离子与纯科尔多瓦
- python - 用 NA 替换文本文件中特定位置的空格
- gun - GUN 是大数据的好选择吗?
- sql-server - SQL Server 初学者问题
- r - `difftime` 中可能存在的错误 - 在 R 中计算日期时间的差异
- android - 底部应用栏不显示菜单项