5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

#BoundingBoxがうまく表示されないときは座標をチェック

Visionの物体検出の結果(VNRecognizedObjectObservation)は、0~1の数字に正規化されています。
これを画像上の座標に直すにはVNImageRectForNormalizedRectメソッドを使います。

rectInImage = VNImageRectForNormalizedRect(observation.boundingBox, Int(image.size.width), Int(image.size.height))

また、boundingboxのy座標は、CGRectのyと上下逆(一番下が0)なので、BoundingBoxをViewで表示するときは、上下を逆にする必要があります。

yInImage = image.size.height - rectInImage.minY - rectInImage.height
5
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?