Can I run ARCore Preview 1 App on Preview 2 release? - unity3d

I've built an app which runs on ARCOre preview 1 package on Unity. I know Google has made major changes in preview 2.
My question is what changes will I have to make in order to run my ARCore preview 1 app run on preview 2?

Take a look at the code in the Preview 2 sample app(s) and update your code accordingly. For example, here is the new code for properly instantiating an object into the AR scene:
if (Session.Raycast(touch.position.x, touch.position.y, raycastFilter, out hit))
{
var andyObject = Instantiate(AndyAndroidPrefab, hit.Pose.position,
hit.Pose.rotation);
// Create an anchor to allow ARCore to track the hitpoint
// as understanding of the physical world evolves.
var anchor = hit.Trackable.CreateAnchor(hit.Pose);
// Andy should look at the camera but still be flush with the plane.
andyObject.transform.LookAt(FirstPersonCamera.transform);
andyObject.transform.rotation = Quaternion.Euler(0.0f,
andyObject.transform.rotation.eulerAngles.y,
andyObject.transform.rotation.z);
// Make Andy model a child of the anchor.
andyObject.transform.parent = anchor.transform;
}

Common
Preview 1 use Tango Core service that can changed Ar-Core service in Preview 2.
Automatic Screen Rotation is Handled.
Some Classes are altered like some reason of following.
For Users:
Introduce AR Stickers
For Developers:
A new C API for use with the Android NDK that complements our existing Java, Unity, and Unreal SDKs;
Functionality that lets AR apps pause and resume AR sessions, for example to let a user return to an AR app after taking a phone call;
Improved accuracy and runtime efficiency across our anchor, plane finding, and point cloud APIs.

I have updated my app from Preview 1 to Preview 2. And it's not a lot. It had minor API changes like the ones for hit flags, Pose.position etc. It would probably be stupid to post the change log here. I suggest that you can file the below steps:
Replace the old sdk with the new one in the Unity Project
Then, check for the error in your default editor, vs or vs code or mono
Just check for the relevant API's in the deveoper docs of AR.
It's not such a cumbersome job, it too me some 5-10 min to upgrade that's it.
Cheers!

Related

How can I adjust microphone input levels in HoloLens?

In our communications app, some people's voices are too quiet. So we want to be able to change the system level of their microphone input.
I searched through all the Windows Universal App samples and Unity documentation and I couldn't find how to change the volume of the Windows microphone (on Windows or HoloLens).
I found that the property to adjust is the AudioDeviceController.VolumePercent property. The following code implements this:
MediaCapture mediaCapture = new MediaCapture();
var captureInitSettings = new MediaCaptureInitializationSettings
{
StreamingCaptureMode = StreamingCaptureMode.Audio
};
await mediaCapture.InitializeAsync(captureInitSettings);
mediaCapture.AudioDeviceController.VolumePercent = volumeLevel;
I confirmed that this code works on Desktop and HoloLens. It changes the system level, so it's automatically persisted, and would affect all apps.

MRTK Not Recognizing Handtracking Input

I am currently using Unity with Microsoft's Mixed Reality Toolkit to create a simple game that places a square that can be moved using hand gesture's (air-tapped and dragged). So far I have attached the ManipulationHandler and NearInterationGrabbable to the square game object such as in the tutorial: Here.
When running the Unity project in the Unity player, the square is able to be manipulated with the GGVPointer. However, when I deploy the Hololens, no gesture input is recognized.
Here is my object hierarchy
and the contents of the cube under inspector
Current Development Evironment:
MRTK 2.2 & 2.3
2019.3.0f6 & .9f1
Deployment on:
Hololens 1
Hololens 1 and 2 emulator
In regards to the solution posted here, after attaching the script in the answer and debugging it in the Hololens emulator I receive the error :
Exception thrown at 0x00007FF80850A839 (KernelBase.dll) in Hololens Test Project.exe: 0x40080202: WinRT transform error (parameters: 0x000000008000000B, 0x0000000080070490, 0x0000000000000014, 0x000000506E7FDA50).
Had the same problem - after you want to change something on the MixedRealityToolkit by copying/cloning the profiles some options like "Input System" gets disabled - so you just have to reactivate it again:

How to apply AR into live video stream?

What are the possible methods to create an AR solution like this?
https://www.youtube.com/watch?v=9zD_YQBaZEY
You need AR devices and AR SDK and 3D engine, for example, iPhone + ARKit + Unity(Unreal).
But the content shown in your youtube link is unlikely AR content, it made by some kind of after effect software.
OK I make a simple search, here:tracking-3d-camera-movement, this is what you want I think.

Adjust camera focus in ARKit

I want to adjust the device's physical camera focus while in augmented reality. (I'm not talking about the SCNCamera object.)
In an Apple Dev forum post, I've read that autofocus would interfere with ARKit's object detection, which makes sense to me.
Now, I'm working on an app where the users will be close to the object they're looking at. The focus the camera has by default makes everything look very blurry when closer to an object than around 10cm.
Can I adjust the camera's focus before initializing the scene, or preferably while in the scene?
20.01.2018
Apparently, there's still no solution to this problem. You can read more about this at this reddit post and this developer forum post for private API workarounds and other (non-helping) info.
25.01.2018
#AlexanderVasenin provided a useful update pointing to Apple's documentation. It shows that ARKit will be able to support not just focusing, but also autofocusing as of iOS 11.3.
See my usage sample below.
As stated by Alexander, iOS 11.3 brings autofocus to ARKit.
The corresponding documentation site shows how it is declared:
var isAutoFocusEnabled: Bool { get set }
You can access it this way:
var configuration = ARWorldTrackingConfiguration()
configuration.isAutoFocusEnabled = true // or false
However, as it is true by default, you should not even have to set it manually, unless you chose to opt out.
UPDATE: Starting from iOS 11.3 ARKit supports autofocusing, and it's enabled by default (more info). Manual focusing still aren't available.
Prior to iOS 11.3 ARKit did not supported neither manual focus adjust nor autofocusing.
Here is Apple's reply on the subject (Oct 2017):
ARKit does not run with autofocus enabled as it may adversely affect plane detection. There is an existing feature request to support autofocus and no need to file additional requests. Any other focus discrepancies should be filed as bug reports. Be sure to include the device model and OS version. (source)
There is another thread on Apple forums where a developer claims he was able to adjust autofocus by calling AVCaptureDevice.setFocusModeLocked(lensPosition:completionHandler:) method on private AVCaptureDevice used by ARKit and it appears it's not affecting tracking. Though the method itself is public, the ARKit's AVCaptureDevice is not, so using this hack in production would most likely result in App Store rejection.
if #available(iOS 16.0, *) {
// This property is nil on devices that aren’t equiped with an ultra-wide camera.
if let device = ARWorldTrackingConfiguration.configurableCaptureDeviceForPrimaryCamera {
do {
try device.lockForConfiguration ()
// configuration your focus mode
// you need to change ARWorldTrackingConfiguration().isAutoFocusEnabled at the same time
device.unlockForConfiguration ()
} catch {
}
}
} else {
// Fallback on earlier versions
}
Use configurableCaptureDeviceForPrimaryCamera method, and this is only available after iOS 16 or later.
Documentation
/
ARKit
/
Configuration Objects
/
ARConfiguration
/
configurableCaptureDeviceForPrimaryCamera

Unity3d EasyAR Target loads at the start of the camera before find the trarget

I am tring to build an AR android app with unity3d last version and EASYAR SDK.
I have create the target and i am able to load my image or video at it's chile object but the child objct (cube or plane) load imediately when th camera opens.
i am looking some help on how i can apear the image or start the video when the camera find the target and not when the app starts.
thnns a lot in advanced guys for the help!!!
You can simply disable them in the beginning and modify the OnTargetFound event of the ImageTargetBehaviour script to enable them. Something like this:
public GameObject myARObject;
void OnTargetFound(TargetAbstractBehaviour behaviour)
{
Debug.Log("Found: " + Target.Id);
myARObject.SetActive (true);
}
Hope this helps.