-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running ARCore in landscape #33
Comments
My changes so far boil down to:
and resizing it as part of
and then with a helper method:
I can do
This works in portrait, and in LandscapeLeft/Right the 3D mask and the video match the right directions, just not the scale. (Here's a link to the full modified example) Example video: |
Update: I was able to hotfix the ARCore
I had played around with the projection matrix, and noticed that when in landscape the factors that x&y are multiplied by were off by about 1.8. When I looked at the matrix in portrait, the value m12 was This works on iPhone X (375x812), iPad 11" (834 x 1194) and iPhone 6S (375 x 667). |
This works for me too. Thanks for sharing your code. But why this let factor: Float = 2.101334 / 1.1820006 ? Shouldn't this calculate internally? Tested on ipad pro 10.5. |
@deshan That is a question for the ARCore developers, I have no why this factor is necessary. The fact that I needed this factor to make the math come out seems to show that there is a bug in the ARCore code when in landscape. |
@Bersaelor is it possible that this factor value (2.101334 / 1.1820006) is only suitable for a particular aspect ratio? I ask because I'm rendering this pipeline to video, and in cases where the video preset is not 9:16 aspect ratio, the projection is scaled wrongly. I could probably just add more magic numbers/calculations and scale again from that ratio to the ratio I'm using, but that's yet another assumption in place - the assumption that 9:16 is what this factor value is based upon. :) Update: I just reversed the two numbers used, and 1.1820006:2.101334 is essentially 9:16! |
Yup, I am quite certain that is the case, I mean var pM = SCNMatrix4.init(
frame.projectionMatrix(
forViewportSize: viewPortSize,
presentationOrientation: orientation, is already accepting the screen size and orientation, one shouldn't have to manually mess with the results anymore as it should be working correctly for each orientation. |
I was wondering whether someone already figured out how to run the ARCore sample in Landscape.
I was roughly trying:
but it's not really working for landscape.
Best I got was the right orientation of scene and video-image, with camera-image and 3D content mis-scaled (in landscape). In portrait the same code is fine.
The text was updated successfully, but these errors were encountered: