我正在尝试访问图像的特定部分以对图像的用户定义区域执行 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
最佳答案
这是因为你的 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))
关于ios - VNImageBasedRequest regionOfInterest 不在规范化范围内,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49825719/