How to optimize viewrenderable in arcore? - android

I created an application that use viewrenderable to show Gif in ARCore, but after 90-100 or more the app will crash. How to reuse viewrenderable in ARCore?
ViewRenderable.builder()
.setView(fragment.context, gifObject)
.build()
.thenAccept { viewRenderable ->
viewRenderable.view
... //create anchor and node
}
Please help me, I'm using ARCore Android SDK

Maybe you create too many anchors,It's very resource intensive,you could create an anchor,an anchorNode as global,then every frame,you detach last anchor,then create a new anchor,and use anchorNode.setAnchor(anchor). have a try,maybe it works.

Incase you haven't found a solution yet, I recommend debugging and find out any rendering related issues using Graphics API Debugger (GAPID). It comes with an interface that lets you view and inspect frame by frame

Related

Loading glb model in react native three using expo-three component not working on android device. The model appears on the web version though

I'm trying to create a react-native apps with three js using expo-gl, expo-three frameworks.
Following is the list of imports..
import { ExpoWebGLRenderingContext, GLView } from 'expo-gl';
import ExpoTHREE, { Renderer, TextureLoader } from 'expo-three';
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';
import * as React from 'react';
import {
AmbientLight,
HemisphereLight,
BoxBufferGeometry,
Fog,
GridHelper,
Mesh,
MeshStandardMaterial,
PerspectiveCamera,
PointLight,
Scene,
SpotLight,
Camera,
InstancedMesh,
} from 'three';
import OrbitControlsView from 'expo-three-orbit-controls';
Apart from the basic scene, camera and light setup I'm trying to load a glb model using the ExpoTHREE.loadAsync method as below...
const loadGlb = async ()=>{
const obj = await ExpoTHREE.loadAsync(
[require('./assets/suzanne.glb')],
null,
null}).
then((e)=>{
scene.add(e.scene);
e.scene.traverse((f)=>{if(f.isMesh){f.material = new THREE.MeshNormalMaterial();}});
})
.catch((err)=>{console.log(err)});
}
loadGlb();
Using the ref: https://www.npmjs.com/package/expo-three
The model loads when I run the code on the desktop browser but not on my android phone using expo app. Please let me know what am I doing wrong.
You can access the app here https://expo.io/#praful124/expo3
I had the same problem and ended up running into the fact that it does not support textures inside the glb file. But if you find a solution, I will be very happy if you share them.

How to change material a sfa file?

I have a single model and I want to change image of it.
with below codes I can render my model (sfb file):
ModelRenderable.builder()
.setSource(this, sfb_source])
.build()
.thenAccept(renderable -> this.renderable = renderable)
.exceptionally(
throwable -> {
Toast toast =
Toast.makeText(this, "Unable to load andy renderable", Toast.LENGTH_LONG);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
return null;
});
Now, my model is unique. but I have multi images(with same sizes).
I should create multi sfb files or is there any ways to load them and change it in real time?
Firstly it is worth mentioning that Scene form is deprecated, or more accurately 'open sourced and archived', in case you are building on it which I think you might be from your code - see note here: https://developers.google.com/sceneform/develop.
You can still work with the older versions or open version of Sceneform - this may be ok for your use case.
Either way, for your requirements it sounds like you have two options:
use a model which support animation - Sceneform based instructions here: https://developers.google.com/sceneform/develop/animation
delete and replace the model when you want to change it - this is not as slow as it sounds and can, in my experience, look fairly seamless when changing model colours etc (at least in Sceneform based apps - not tried with OpenGL and ARCore).

Android Fotoapparat library

I'm new to Android-Developement and I would like to make a Camera-app. I found this library (this is the Github page).
But I don't know how to implement a library. I followed these steps (method 2) but I'm getting an error in a popup window called 'IDE Fatal Errors'. It says: 'To investigate / fix the problem IDE wants to attach following files to the bug report. We recommend to include all the files providing maximum information. Note: all the data you send will be kept private.' Then I can select a 'diagnostic.txt'. There is a section 'file content' where 'rootsChanged' is written. I can report the whole window to Google.
The following step is to configure the 'Fotoapparat' instance. What is an instance? When I search on Google I only find articles talking about making a library.
I'm sorry if these are stupid question but I am a beginner and I would like to learn more about Android-Development. Thanks in advance for your time and help.
Add this line in your build.gradle(Module: app) file ->
dependecies {
//Your other dependencies...
implementation 'io.fotoapparat:fotoapparat:2.3.3'
}
And start using your code. Library is working fine.
EDIT - >
You need to learn basics of java.
To setup instance of the object you need to create a variable.
Hence in your case:
Fotoapparat yourVariableName = new FotoapparatFotoapparat
.with(context)
.into(cameraView) // view which will draw the camera preview
.previewScaleType(ScaleType.CenterCrop) // we want the preview to fill the view
.photoResolution(ResolutionSelectorsKt.highestResolution()) // we want to have the biggest photo possible
.lensPosition(LensPositionSelectorsKt.back()) // we want back camera
.focusMode(SelectorsKt.firstAvailable( // (optional) use the first focus mode which is supported by device
FocusModeSelectorsKt. continuousFocusPicture(),
FocusModeSelectorsKt.autoFocus(), // in case if continuous focus is not available on device, auto focus will be used
FocusModeSelectorsKt.fixed() // if even auto focus is not available - fixed focus mode will be used
))
.flash(SelectorsKt.firstAvailable( // (optional) similar to how it is done for focus mode, this time for flash
FlashSelectorsKt.autoRedEye(),
FlashSelectorsKt.autoFlash(),
FlashSelectorsKt.torch()
))
.frameProcessor(myFrameProcessor) // (optional) receives each frame from preview stream
.logger(LoggersKt.loggers( // (optional) we want to log camera events in 2 places at once
LoggersKt.logcat(), // ... in logcat
LoggersKt.fileLogger(this) // ... and to file
))
.build();
And start using yourVariableName.

OpenTok: PublisherView on top of SubscriberView

The basic sample project of OpenTok shows how to make a VideoCall, showing the subscribers videostream in a small frame above the publishers stream.
I'm trying to achieve the same, only vice versa.
Problems:
Simply changing the two container views in the layout xml doesnt work. What happens is, that the publisher stream (the one that should now be on top of the other stream) is not showing up (is invisble)
This issue describes the exact problem, hinting me towards using setZOrderMediaOverlay(true); setZOrderOnTop(true); The problem with this approach is that now the publisher stream is on top of everything, even the android gui which is not tolerable for my use case.
Using only setZOrderMediaOverlay(true); does not work. The publisher view still is invisble.
Any idea on how to achieve this?
Try using TextureViews instead of GLSurfaceView, which is what OpenTok sdk uses by default.
To enable TextureViews, build your session in this way:
Session session = new Session.Builder(this, "apiKey", "sessionId")
.sessionOptions(new Session.SessionOptions() {
#Override
public boolean useTextureViews() {
return true;
}
}).build();
That will make the Publisher and Subscriber objects use TextureViews for its rendering.
Oficial doc is here

Taking Screenshots Using Qt C++ on Android

thanks for checking my question out!
I'm currently working on a project using Qt C++, which is designed to be multi-platform. I'm a bit of a newcoming to it, so I've been asked to set up the ability to take screenshots from within the menu structure, and I'm having issues with the Android version of the companion app.
As a quick overview, it's a bit of software that send the content of a host PC's screen to our app, and I've been able to take screenshots on the Windows version just fine, using QScreen and QPixmap, like so:
overlaywindow.cpp
{
QPixmap screenSnapData = screenGrab->currentBackground();
}
screenGrabber.cpp
{
QScreen *screen = QGuiApplication::primaryScreen();
return screen->grabWindow( QApplication::desktop()->winId() );
}
Unfortunately, Android seems to reject QScreen, and with most suggestions from past Google searches suggesting the now-deprecated QPixmap::grab(), I've gotten a little stuck.
What luck I have had is within the code for the menu itself, and QWidget, but that isn't without issue, of course!
QFile doubleCheckFile("/storage/emulated/0/Pictures/Testing/checking.png");
doubleCheckFile.open(QIODevice::ReadWrite);
QPixmap checkingPixmap = QWidget::grab();
checkingPixmap.save(&doubleCheckFile);
doubleCheckFile.close();
This code does take a screenshot, but only of the button strip currently implemented, and not for the whole screen. I've also taken a 'screenshot' of just a white box with the screen's dimensions by using:
QDesktopWidget dw;
QWidget *screen=dw.screen();
QPixmap checkingPixmap = screen->grab();
Would anyone know of whether there was an alternative to using QScreen to take a screenshot in Android, or whether there's a specific way to get it working as compared to Windows? Or would QWidget be the right track? Any help's greatly appreciated!
as i can read in Qt doc : In your screenGrabber.cpp :
QScreen *screen = QGuiApplication::primaryScreen();
return screen->grabWindow( QApplication::desktop()->winId() );
replace with :
QScreen *screen = QGuiApplication::primaryScreen();
return screen->grabWindow( 0 ); // as 0 is the id of main screen
If you want to take a screenshot of your own widget, you can use the method QWidget::render (Qt Doc):
QPixmap pixmap(widget->size());
widget->render(&pixmap);
If you want to take a screenshot of another app/widget than your app, you should use the Android API...

Categories

Resources