VNCoreMLRequest regionOfInterest error

I implemented a feature that allows the user to indicate areas within an image to perform image recognition. Currently, the areas are cropped into new images and each image is identified by the MLModel. This was a quick and easy build, so now I'm trying to only use the one image for inspection by the MLModel by indicating the specific region of interest for each request. This is where I'm running into issues that I don't understand.

The following CGRect works fine:

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


however, the next CGRect results in an error when the VNImageRequestHandler attempts to perform it:

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

here is the resulting error message:

"The region of interest [0.154228, 0.875634, 0.299928, 0.321065] is not within the normalized bounds of [0 0 1 1]"


What am I missing? I can't tell what I am doing wrong.

Replies

Donka,

This seems because

0.87563451776649747+0.32106598984771573>1


Your first CGRect doesn't have that problem