Get Started         Best Practices         Developer Guide         FAQ        
Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

get bounding box value in pixel

Jeremy Jun 02, 2017

Hi,

I'm trying to match the matchBoundingBox's values to an iPhone screen in pixels. I have to place an UIView over a CraftARItem.

I saw another post to do it in iOS but it is very confusing and lacks some details.

So I multiply the bounding box's value by my screen height/width in pixels. The x seems nearly correct but the y is completely incoherent, even mirrored.

I read that it might be related to the video capture resolution but I don't understand it.

Can somebody help ?

Thanks in advance,




( Agent )
Luis Martinell

Jun 02, 2017

To know exactly the meaning of the bounding box coordinates, check this https://support.catchoom.com/customer/portal/articles/1886553

Note that the coordinates are relative to the query images. The query image is rotated 90 degrees on iOS when the phone is vertical (because of the orientation of the sensor). You should normalize the coordinates using the view size and aspect ratio of the camera frame (HD by default, 16:9). The frame is fit on the screen so that it maintains the aspect (no deformation) and it is cropped on the sides (when the phone is in portrait orientation.

1 rated
Jeremy

Jun 02, 2017

Thanks for your quick response !

I already read this article.

Now it is better but still not at the right place. Here is what I do (my resolution is 568/320 so 16:9 too) :

let wVideoFrame:CGFloat = 1280.0
let hVideoFrame:CGFloat = 720.0

let wRelativePreview = wVideoFrame/CGFloat(568)
let hRelativePreview = hVideoFrame/CGFloat(320)

var topLeft = CGPoint(x: wVideoFrame * CGFloat(boundingBox.topLeftX),y: hVideoFrame * CGFloat(boundingBox.topLeftY))
var topRight = CGPoint(x: wVideoFrame * CGFloat(boundingBox.topRightX) ,y: hVideoFrame * CGFloat(boundingBox.topRightY))
var bottomRight = CGPoint(x: wVideoFrame * CGFloat(boundingBox.bottomRightX),y: hVideoFrame * CGFloat(boundingBox.bottomRightY))
var bottomLeft = CGPoint(x: wVideoFrame * CGFloat(boundingBox.bottomLeftX),y: hVideoFrame * CGFloat(boundingBox.bottomLeftY))

topLeft = CGPoint(x: topLeft.x/wRelativePreview, y: topLeft.y/hRelativePreview)
topRight = CGPoint(x: topRight.x/wRelativePreview, y: topRight.y/hRelativePreview)
bottomRight = CGPoint(x: bottomRight.x/wRelativePreview, y: bottomRight.y/hRelativePreview)
bottomLeft = CGPoint(x: bottomLeft.x/wRelativePreview, y: bottomLeft.y/hRelativePreview)

And I tried to rotate my view.

Can you tell me my mistake ?
0 rated
( Agent )
Luis Martinell

Jun 02, 2017

Can you share images of how it appears?

0 rated
Jeremy

Jun 02, 2017

Here you are : http://hpics.li/1313966
0 rated
( Agent )
Luis Martinell

Jun 06, 2017

What does the red rectangle mean? Isn’t the yellow one upside down? maybe you rotated the 90 degrees in the wrong direction…

-1 rated

Post Your Public Answer

Your name (required)
Your email address (required)
Answer (required)

Couldn't find what you were looking for?

support@catchoom.com
https://cdn.desk.com/
false
catchoom
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete