kandi background
Explore Kits

arcore-android-sdk | ARCore SDK for Android Studio | Android library

 by   google-ar C Version: v1.35.0 License: Non-SPDX

 by   google-ar C Version: v1.35.0 License: Non-SPDX

kandi X-RAY | arcore-android-sdk Summary

arcore-android-sdk is a C library typically used in Mobile, Android applications. arcore-android-sdk has no bugs, it has no vulnerabilities and it has medium support. However arcore-android-sdk has a Non-SPDX License. You can download it from GitHub.
This SDK provides APIs for all of the essential AR features like motion tracking, environmental understanding, and light estimation. With these capabilities you can build entirely new AR experiences or enhance existing apps with AR features.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • arcore-android-sdk has a medium active ecosystem.
  • It has 4642 star(s) with 1161 fork(s). There are 253 watchers for this library.
  • There were 3 major release(s) in the last 6 months.
  • There are 306 open issues and 1064 have been closed. On average issues are closed in 80 days. There are 4 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of arcore-android-sdk is v1.35.0
arcore-android-sdk Support
Best in #Android
Average in #Android
arcore-android-sdk Support
Best in #Android
Average in #Android

quality kandi Quality

  • arcore-android-sdk has no bugs reported.
arcore-android-sdk Quality
Best in #Android
Average in #Android
arcore-android-sdk Quality
Best in #Android
Average in #Android

securitySecurity

  • arcore-android-sdk has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
arcore-android-sdk Security
Best in #Android
Average in #Android
arcore-android-sdk Security
Best in #Android
Average in #Android

license License

  • arcore-android-sdk has a Non-SPDX License.
  • Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.
arcore-android-sdk License
Best in #Android
Average in #Android
arcore-android-sdk License
Best in #Android
Average in #Android

buildReuse

  • arcore-android-sdk releases are available to install and integrate.
  • Installation instructions are available. Examples and code snippets are not available.
arcore-android-sdk Reuse
Best in #Android
Average in #Android
arcore-android-sdk Reuse
Best in #Android
Average in #Android
Top functions reviewed by kandi - BETA

kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample Here

Get all kandi verified functions for this library.

Get all kandi verified functions for this library.

arcore-android-sdk Key Features

ARCore SDK for Android Studio

arcore-android-sdk Examples and Code Snippets

Community Discussions

Trending Discussions on arcore-android-sdk
  • How to draw a line between anchors on the plane with ARcore without arFragment
  • How can I load my glTF file on SceneViewer with ARCore Android SDK
  • ARCore: it takes very long to start tracking
Trending Discussions on arcore-android-sdk

QUESTION

How to draw a line between anchors on the plane with ARcore without arFragment

Asked 2020-Sep-30 at 12:29

I'm building my app around this Agora ARcore Demo based on Google's hello_ar_java Sample APP.

This application, capture user's taps and check if any planes in the scene were found. If so, create an anchor at that point.

I would like to draw a line between the various anchors.

Everything I find on the web uses sceneForm and arFragment.

At the moment I have managed to implement sceneForm without arFragment but the line is not showing, probably because of of this method that I don't know how to replace without arFragment: nodeToAdd.setParent(arFragment.getArSceneView().getScene());

To implement sceneform in my project I'm taking a cue from this project LineView Are there any other methods without using sceneform?

This is how I am proceeding:

public void onDrawFrame(GL10 gl) {
    // Clear screen to notify driver it should not load any pixels from previous frame.
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);

    if (mSession == null) {
        return;
    }
    // Notify ARCore session that the view size changed so that the perspective matrix and
    // the video background can be properly adjusted.
    mDisplayRotationHelper.updateSessionIfNeeded(mSession);

    try {
        // Obtain the current frame from ARSession. When the configuration is set to
        // UpdateMode.BLOCKING (it is by default), this will throttle the rendering to the
        // camera framerate.
        Frame frame = mSession.update();
        Camera camera = frame.getCamera();

        // Handle taps. Handling only one tap per frame, as taps are usually low frequency
        // compared to frame rate.
        MotionEvent tap = queuedSingleTaps.poll();
        if (tap != null && camera.getTrackingState() == TrackingState.TRACKING) {
            for (HitResult hit : frame.hitTest(tap)) {
                // Check if any plane was hit, and if it was hit inside the plane polygon
                Trackable trackable = hit.getTrackable();
                // Creates an anchor if a plane or an oriented point was hit.
                if ((trackable instanceof Plane && ((Plane) trackable).isPoseInPolygon(hit.getHitPose()))
                        || (trackable instanceof Point
                        && ((Point) trackable).getOrientationMode()
                        == Point.OrientationMode.ESTIMATED_SURFACE_NORMAL)) {
                    // Hits are sorted by depth. Consider only closest hit on a plane or oriented point.
                    // Cap the number of objects created. This avoids overloading both the
                    // rendering system and ARCore.
                    if (anchors.size() >= 250) {
                        anchors.get(0).detach();
                        anchors.remove(0);
                    }
                    // Adding an Anchor tells ARCore that it should track this position in
                    // space. This anchor is created on the Plane to place the 3D model
                    // in the correct position relative both to the world and to the plane.
                    anchors.add(hit.createAnchor());
                    break;
                }
            }
        }

        // Draw background.
        mBackgroundRenderer.draw(frame);

        // If not tracking, don't draw 3d objects.
        if (camera.getTrackingState() == TrackingState.PAUSED) {
            return;
        }

        // Get projection matrix.
        float[] projmtx = new float[16];
        camera.getProjectionMatrix(projmtx, 0, 0.1f, 100.0f);

        // Get camera matrix and draw.
        float[] viewmtx = new float[16];
        camera.getViewMatrix(viewmtx, 0);

        // Compute lighting from average intensity of the image.
        final float lightIntensity = frame.getLightEstimate().getPixelIntensity();

        if (isShowPointCloud()) {
            // Visualize tracked points.
            PointCloud pointCloud = frame.acquirePointCloud();
            mPointCloud.update(pointCloud);
            mPointCloud.draw(viewmtx, projmtx);

            // Application is responsible for releasing the point cloud resources after
            // using it.
            pointCloud.release();
        }

        // Check if we detected at least one plane. If so, hide the loading message.
        if (mMessageSnackbar != null) {
            for (Plane plane : mSession.getAllTrackables(Plane.class)) {
                if (plane.getType() == Plane.Type.HORIZONTAL_UPWARD_FACING
                        && plane.getTrackingState() == TrackingState.TRACKING) {
                    hideLoadingMessage();
                    break;
                }
            }
        }

        if (isShowPlane()) {
            // Visualize planes.
            mPlaneRenderer.drawPlanes(
                    mSession.getAllTrackables(Plane.class), camera.getDisplayOrientedPose(), projmtx);
        }

        // Visualize anchors created by touch.
        float scaleFactor = 1.0f;

        for (Anchor anchor : anchors) {
            if (anchor.getTrackingState() != TrackingState.TRACKING) {
                continue;
            }
            // Get the current pose of an Anchor in world space. The Anchor pose is updated
            // during calls to session.update() as ARCore refines its estimate of the world.
            anchor.getPose().toMatrix(mAnchorMatrix, 0);


            // Update and draw the model and its shadow.
            mVirtualObject.updateModelMatrix(mAnchorMatrix, mScaleFactor);
            mVirtualObjectShadow.updateModelMatrix(mAnchorMatrix, scaleFactor);
            mVirtualObject.draw(viewmtx, projmtx, lightIntensity);
            mVirtualObjectShadow.draw(viewmtx, projmtx, lightIntensity);
        }

        sendARViewMessage();
    } catch (Throwable t) {
        // Avoid crashing the application due to unhandled exceptions.
        Log.e(TAG, "Exception on the OpenGL thread", t);
    }
}

Then:

 public void drawLineButton(View view) {
    AnchorNode nodeToAdd;
    for (Anchor anchor : anchors) {
        anchorNode = new AnchorNode(anchor);
        anchorNodeList.add(anchorNode);
        //this is the problem imho
        //nodeToAdd.setParent(arFragment.getArSceneView().getScene());
        numberOfAnchors++;

    }

    if (numberOfAnchors == 2 ) {
        drawLine(anchorNodeList.get(0), anchorNodeList.get(1));
    }
}

Here the Nodes exist and are real. I don't find any errors, and the lines don't show:

private void drawLine(AnchorNode node1, AnchorNode node2) {
    //Here the knots exist and are real. I don't find any errors, and the lines don't show
    runOnUiThread(new Runnable() {

        @Override
        public void run() {

            Vector3 point1, point2;
            point1 = node1.getWorldPosition();
            point2 = node2.getWorldPosition();

            //First, find the vector extending between the two points and define a look rotation
            //in terms of this Vector.
            final Vector3 difference = Vector3.subtract(point1, point2);
            final Vector3 directionFromTopToBottom = difference.normalized();
            final Quaternion rotationFromAToB =
                    Quaternion.lookRotation(directionFromTopToBottom, Vector3.up());
            MaterialFactory.makeOpaqueWithColor(getApplicationContext(), new Color(0, 255, 244))
                    .thenAccept(
                            material -> {
                        /* Then, create a rectangular prism, using ShapeFactory.makeCube() and use the difference vector
                               to extend to the necessary length.  */
                                Log.d(TAG,"drawLine insie .thenAccept");
                                ModelRenderable model = ShapeFactory.makeCube(
                                        new Vector3(.01f, .01f, difference.length()),
                                        Vector3.zero(), material);
                        /* Last, set the world rotation of the node to the rotation calculated earlier and set the world position to
                               the midpoint between the given points . */
                                Anchor lineAnchor = node2.getAnchor();
                                nodeForLine = new Node();
                                nodeForLine.setParent(node1);
                                nodeForLine.setRenderable(model);
                                nodeForLine.setWorldPosition(Vector3.add(point1, point2).scaled(.5f));
                                nodeForLine.setWorldRotation(rotationFromAToB);
                            }
                    );



        }
    });


}

this is the example of my point1,poin2 and directionFromTopToBottom in the drawLine() function:

point1: [x=0.060496617, y=-0.39098215, z=-0.21526277]
point2: [x=0.05695567, y=-0.39132282, z=-0.33304527]
directionFromTopToBottom: [x=0.030049745, y=0.0028910497, z=0.9995442]

ANSWER

Answered 2020-Sep-30 at 12:09

You code is not calling your drawLineButton() function, is it? Anyway, it looks like you're trying to use some things from Sceneform (MaterialFactory, ModelRenderable, etc) while doing some pure OpenGL rendering as done in the hello_ar_java.

Mixing those will result in nothing good since Sceneform uses filament as rendering engine which could use OpenGL or Vulkan. So either go fully with Sceneform or fully with OpenGL (and understand how OpenGL and Android work).

Now, if you want to continue with hello_ar_java sample, follow an OpenGL tutorial in order to be able to generate a vertex for each anchor and draw them with GL_LINES with the line size you like. Here's a good OpenGL tutorial: https://learnopengl.com/ I recommend going through all the Getting Started section, but just keep in mind that it is OpenGL and Android uses OpenGL ES, there are some differences but the computer graphics principles are the same.

Source https://stackoverflow.com/questions/64046101

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install arcore-android-sdk

See the [Quickstart for Android Java](//developers.google.com/ar/develop/java/quickstart) or [Quickstart for Android NDK](//developers.google.com/ar/develop/c/quickstart) developer guide.

Support

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

Find more information at:

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 650 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases
Explore Kits

Save this library and start creating your kit

Clone
  • https://github.com/google-ar/arcore-android-sdk.git

  • gh repo clone google-ar/arcore-android-sdk

  • git@github.com:google-ar/arcore-android-sdk.git

Share this Page

share link

See Similar Libraries in

Reuse Pre-built Kits with arcore-android-sdk
Consider Popular Android Libraries
Try Top Libraries by google-ar
Compare Android Libraries with Highest Support
Compare Android Libraries with Highest Quality
Compare Android Libraries with Highest Security
Compare Android Libraries with Permissive License
Compare Android Libraries with Highest Reuse
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 650 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases
Explore Kits

Save this library and start creating your kit