【问题标题】:VNImageBasedRequest regionOfInterest not within normalized boundsVNImageBasedRequest regionOfInterest 不在标准化范围内
【发布时间】:2018-09-24 07:52:55
【问题描述】:

我正在尝试访问图像的特定部分以对图像的用户定义区域执行 VNCoreMLRequest。我在某些感兴趣的区域遇到错误,而其他区域则很好。每个区域都被归一化。

以下两个方面起作用:

regionOfInterest    CGRect  (origin = (x = 0.49538024164889838, y = 0.31979695431472077), size = (width = 0.26865671641791045, height = 0.24492385786802032))

regionOfInterest    CGRect  (origin = (x = 0.13290689410092396, y = 0.28807106598984761), size = (width = 0.24733475479744135, height = 0.19416243654822332))

但以下两个区域不起作用:

regionOfInterest    CGRect  (origin = (x = 0.15422885572139303, y = 0.87563451776649747), size = (width = 0.29992892679459843, height = 0.32106598984771573))

错误消息:“感兴趣区域 [0.148543, 0.874365, 0.319829, 0.31599] 不在 [0 0 1 1] 的规范化范围内”

regionOfInterest    CGRect  (origin = (x = 0.57640369580668083, y = 0.90862944162436543), size = (width = 0.24307036247334754, height = 0.36928934010152287))

有人能指出我没有看到什么吗?也许我对regionOfInterest有些不理解

【问题讨论】:

  • 根据文档“矩形被标准化为处理后图像的尺寸。它的原点是相对于图像的左下角指定的。”可能您正在相对于左上角(UIKit 起源)而不是左下角进行规范化?

标签: ios coreml apple-vision


【解决方案1】:

这是因为你的 y + height > 1,所以感兴趣的区域比图像大。我正在使用类似的东西

        let x = max((regionOfIntres.origin.x - 0.1), 0)
        let y = max((regionOfIntres.origin.y - 0.1), 0)

        let width = min((regionOfIntres.size.width + 0.2), (1 - x))
        let height = min((regionOfIntres.size.height + 0.2), (1 - y))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-23
    • 1970-01-01
    • 1970-01-01
    • 2016-04-25
    • 1970-01-01
    相关资源
    最近更新 更多