Unity3d ARKit not reset - unity3d

I am using vuforia & ARKit sdk in my application.
I have two buttons ( Vuforia & ARKit buttons)
My app work flow:
Open the app
Clicked on “vuforia AR” button (1st time)
If marker found Vuforia AR works.
i am switch to “ARKit” 1st time, it will be working fine.
If we press back button, it will redirect to MainScreen
Again Click on “vuforia AR” button (2nd time)
Vuforia working good.
If we switch to “ARKit” , ARKit Camera is not resetting .
Here arkit camera is freezing.
Note: both SDK are using single scene and I tried two different scenes also. My issue is not resolved.

Don't know if you solved your problem.
If not, did you tried to reset your ARKit scene ?
Here's a sample code I founded in another post. Working fine for me to reset my ARKit Session.
public void ResetScene()
{
ARKitWorldTrackingSessionConfiguration sessionConfig = new ARKitWorldTrackingSessionConfiguration(UnityARAlignment.UnityARAlignmentGravity, UnityARPlaneDetection.Horizontal);
UnityARSessionNativeInterface.GetARSessionNativeInterface().RunWithConfigAndOptions(sessionConfig, UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking);
}
Don't forget to change sessionConfig parameters with yours ! ;)

Related

Camera X - Accessing both Front and Back Cameras simultaneously using Camera X API

Trying to preview both cameras (front and back) concurrently using Android X API -
Camera camera = cameraProvider.bindToLifecycle((LifecycleOwner)this, cameraSelector, preview); //Back-Camera
Camera camera2 = cameraProvider.bindToLifecycle((LifecycleOwner)this, cameraSelector2, preview2); //Front-Camera
With the above code-snippet, only front camera comes up. If I change the order above, back camera shows up as expected.
Tried acquiring the instances of Camera feature (cameraProvider = ProcessCameraProvider.getInstance(this)) twice, however I found strange observation by mapping one camera per one provider. Upon home press and launching app again, either one of the preview (Back or Front) shows up and there is no pattern found.
Can anyone throw more lights on this? Is it anything to do with the target device i.e. device incompatibility? The target device I am using is OnePlus 5.
CameraX doesn't support opening more than 1 camera at a time, which is why when you attempt to open 2 cameras by calling ProcessCameraProvider.bindToLifecycle() twice, only the second camera is opened.
ProcessCameraProvider provides access to the cameras on the device, and as its name suggests, it has the scope of the process/application, i.e it's a Singleton, once it's initialized, you'll get the same instance with each consequent call to ProcessCameraProvider.getInstance().

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.

Cannot Change to a specific scene in Unity after building it to mobile device

Currently I'm using Application.load() to change scenes and it works perfectly in Unity. When I built it to a mobile platform and tested it, only in that one scene I can't change to a specific scene.
For example, gameplayScene, levelSelectionScene, mainMenu. I'm able to change scene from mainMenu to levelSelectionScene and then to gameplayScene. For unknown reason, I'm unable to go back to levelSelectionScene from gameplayScene while I can change scene to mainMenu from gameplayScene.
Below is the sample code from button that goes to levelSelectionScene from gameplayScene
private void OnClick ()
{
Debug.Log ("clicked");
if (PlayerPrefs.GetInt("SanguineDifficultyAchieved") == 1)
{
Debug.Log("Entering Difficulty");
m_Owner.SetActive ();
}
else
{
Debug.Log("Exiting");
State.Current = State.NotInGame;
Application.LoadLevel(scene.name);
}
m_Owner.close ();
I don't understand why it works on Unity debugger but then it doesn't work on mobile platforms.
Update 1
I tried to use numbers instead of strings it worked well. But I still don't understand the reason why.
Finally got an answer. It seems that the scenes collided with each other because I use scenes from Asset Bundle and the added scenes from build settings. That is why the when i use Application.Load(int number) works because i only access the scene from build settings.

PBJVision switch to front facing camera

Hi I am trying to switch between the rear and front facing cameras if i start he session with the front facing camera it works but with the other way way round the AVCapturepreview layer is not visible and just presents a blank screen.
First stop the preview session.
When stopped (use the delegate for this) set the camera device you want and restart the preview session.
In code:
[[PBJVision sharedInstance] stopPreview];
//implement the following deluge ate
- (void)visionSessionDidStopPreview:(PBJVision *)vision{
vision.cameraDevice = PBJCameraDeviceFront;
[vision startPreview];
}

barcodereader sample application

I am using the barcodereader sample application provided in the cascades samples to embed a QRCode scanner into my application.
As it stands the sample is great, but I want the scanner to open as soon as the user navigates to my screen and I want to get rid of the opening slider images that are in the sample.
Firstly, I have tried removing the images and their animations and adding the action:
onCreationCompleted: {
camera.open()
}
to the Page. This opens the camera perfectly as expected, but for some reason, the bacrode just doesn't scan.
So, I wound back a step, and this time I just put the code in exactly as is and just changed the code to read:
onCreationCompleted: {
startupAnimation.play()
}
As expected, the screen open, plays the annimation, but still it fails to read barcodes, however, if I invoke the animation again (by tapping the screen), the animation plays again and the scanner reads the barcode without any issues at all.
All I can think of is that this is a timing issue and that I need some sort of delay after the screen has been created before the camera can be started as a barcode reader?
Anyone able to help?
Thanks,
Douglas
To get scanning right away at application launch, you need to make sure the camera is actually set up and initialized.
Basically, in onCreationComplete, open the camera. In onCameraOpened, start the viewfinder. In onViewfinderStarted, set the barcode detector camera to be the camera.