Giter Club home page Giter Club logo

aruco-android's Introduction

Aruco Android

It is an application to detect Aruco Markers.

screenshot_home

Credits

This application uses:

  • opencv-contrib for computer vision, see LICENSE,
  • aruco, module from opencv-contrib, for aruco markers detection.
  • rajawali, for 3D models renderer.

See more about opencv, and aruco from:

License

As stated above, opencv-contrib uses the BSD license. For details, see LICENSE.

About

Aruco Android is an application to detect Aruco Markers, and try to render a 3D model above it.

Setting

If you have No Implementation Found or library "libopencv_java3.so" not found, instead of master, use feature/all-platforms

git fetch origin
git checkout feature/all-platforms
git pull origin feature/all-platforms

Alternative method: copy all the native opencv libraries into the project, for this:

Using

Camera must be calibrated before detect markers, for that,

  • compile and run camera-calibration projet,
  • present the calibration board to the camera
  • capture between 15 and 20 images, and
  • click on calibrate menu.

Each frame must contain at least 10 markers

screenshot_home

After that, compile app project and enjoy...

screenshot_home

Contributions

You can help turn this application into Augmented Reality, there are some bugs on the positioning of the 3D model above marker.

screenshot_home

Thank you :)

Similar application

You can see in the repository below another marker detection application which uses Vuforia library.

https://github.com/RivoLink/Vuforia-Android

aruco-android's People

Contributors

rivolink avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

aruco-android's Issues

Apk

How do we run this ? Is there a package to install this on Android or a link to the Google store?

java.lang.UnsatisfiedLinkError: No implementation found for long org.opencv.aruco.Aruco.getPredefinedDictionary_0(int)

**Hello,

I'm also trying to use Android to detect A r U co. recently and I found your code and I think it's very good. But in the process of running it, I found this problem. I have searched google but no one seems to have the same problem. Do you have any solution for this, please?**

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.cameracalibration, PID: 14744
java.lang.UnsatisfiedLinkError: No implementation found for long org.opencv.aruco.Aruco.getPredefinedDictionary_0(int) (tried Java_org_opencv_aruco_Aruco_getPredefinedDictionary_10 and Java_org_opencv_aruco_Aruco_getPredefinedDictionary_10__I)
at org.opencv.aruco.Aruco.getPredefinedDictionary_0(Native Method)
at org.opencv.aruco.Aruco.getPredefinedDictionary(Aruco.java:105)
at com.example.cameracalibration.calibration.CameraCalibrator.(CameraCalibrator.java:64)
at com.example.cameracalibration.calibration.CameraCalibrationActivity.onCameraViewStarted(CameraCalibrationActivity.java:174)
at org.opencv.android.CameraBridgeViewBase.processEnterState(CameraBridgeViewBase.java:323)
at org.opencv.android.CameraBridgeViewBase.checkCurrentState(CameraBridgeViewBase.java:313)
at org.opencv.android.CameraBridgeViewBase.surfaceChanged(CameraBridgeViewBase.java:198)
at android.view.SurfaceView.updateSurface(SurfaceView.java:770)
at android.view.SurfaceView$2.onPreDraw(SurfaceView.java:155)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:1088)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2746)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1722)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7605)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1029)
at android.view.Choreographer.doCallbacks(Choreographer.java:852)
at android.view.Choreographer.doFrame(Choreographer.java:787)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1014)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7397)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)

Any help I would greatly appreciate.

No Implementation Found

Hi There

I just got the following error:
No implementation found for long org.opencv.aruco.DetectorParameters.create_0() (tried Java_org_opencv_aruco_DetectorParameters_create_10 and Java_org_opencv_aruco_DetectorParameters_create_10__)

Im static loading the libopencv_java3 successfuly, but when the code calls the DetectorParameters.create() it trows that exception.

Do you have any tips on that?

Receiving info about 2D position

Hi,
is there a method in OpenCV to fetch the 2D points, inside the image, where the markers were detected?
Background of my question is: I want to sort the detected markers, by their position from left to right.

Thank you.

OpenCVLoader.initDebug() failing

java.lang.UnsatisfiedLinkError: dlopen failed: library "libopencv_java3.so" not found

I did my research and found that I am supposed to install OpenCV Manager from play store, which is not there any more :)

Any ideas how to run this project? Would be a great help for my university studies.

Fix for implemetation, Function to pass bitmap or image to see if it has a aruco marker.

Hello,
I went through the app, the mechanism used and tried modifying it to take an image from files as input but the logic for camera integration is too complex.
Can you help me with creating a function that takes a bitmap as input and tell me if it has an Aruco marker and function to mark it?
Plus on a note, The application as a lot of unused class that makes it slow to load.

I have fixed the implementation issue and also added the camera permission on launch, if you want I can share the changes.

Thank you.

3D render

Hi @RivoLink!

Thank you very much for sharing this project.

Did you figure out how to properly make the 3D rendering?

I really appreciate any help you can provide :).

License question

Which license is Aruco using itself? I could not find a license file in the project's root, nor a mention in the Readme. Couldyou please clarify? Thanks!

Wrong Detection? How to properly calibrate?

Hi @RivoLink

First of all thanks a lot for providing this application, it helped me a lot to start building a prototype based on ArUco - I needed to adapt your implementation slightly so that it works under Android 11 (e.g. cannot use mode world readable for preferences), but it eventually ran.

Now I am facing another challenge: the calibration seems to be working, as it effectively stores values in preferences which seem okay, however when I run the detection part of the application, the axis look all messed up - worse, when I am filming the full board the application hangs. Any idea what I am doing wrong, how do you properly calibrate the board? I assume 15-20 frames shall be captured from different viewpoints, right?

Many thanks in advance for your help!

Aruco center

Hi,
how can I compute Aruco center on the image?
Thank you,

Gabriele

No implementation found for long org.opencv.aruco.Aruco.getPredefinedDictionary

hello i am trying to detect the aruco marker but i am getting error No implementation found for long org.opencv.aruco.Aruco.getPredefinedDictionary based on my code

package com.example.opencv_aruco;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.Toast;

import org.opencv.android.BaseLoaderCallback;
import org.opencv.android.CameraBridgeViewBase;
import org.opencv.android.LoaderCallbackInterface;
import org.opencv.android.OpenCVLoader;
import org.opencv.aruco.Aruco;
import org.opencv.aruco.Dictionary;
import org.opencv.core.Mat;
import org.opencv.core.MatOfInt;
import org.opencv.core.Scalar;
import org.opencv.imgproc.Imgproc;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends Activity implements CameraBridgeViewBase.CvCameraViewListener2 {

private static final String TAG = "MainActivity";
private CameraBridgeViewBase mOpenCvCameraView;
private Dictionary mDictionary;
private MatOfInt mIds;
private List<Mat> mCorners;
private boolean isDetecting = false;
private Button btnDetectMarker;

private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
    @Override
    public void onManagerConnected(int status) {
        switch (status) {
            case LoaderCallbackInterface.SUCCESS:
                Log.i(TAG, "OpenCV loaded successfully");
                mOpenCvCameraView.enableView();
                break;
            default:
                super.onManagerConnected(status);
                break;
        }
    }
};

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.activity_main);

    mOpenCvCameraView = findViewById(R.id.camera_view);
    mOpenCvCameraView.setVisibility(CameraBridgeViewBase.VISIBLE);
    mOpenCvCameraView.setCvCameraViewListener(this);

    btnDetectMarker = findViewById(R.id.btn_detect_marker);
    btnDetectMarker.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            isDetecting = true;
        }
    });

    mDictionary = Aruco.getPredefinedDictionary(Aruco.DICT_5X5_50);
    mIds = new MatOfInt();
    mCorners = new ArrayList<>();
}

@Override
protected void onResume() {
    super.onResume();
    if (OpenCVLoader.initDebug()) {
        Log.d(TAG, "OpenCV initialization succeeded");
        mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
    } else {
        Log.d(TAG, "OpenCV initialization failed");
        Toast.makeText(this, "OpenCV initialization failed", Toast.LENGTH_LONG).show();
    }
}

@Override
protected void onPause() {
    super.onPause();
    if (mOpenCvCameraView != null)
        mOpenCvCameraView.disableView();
}

@Override
protected void onDestroy() {
    super.onDestroy();
    if (mOpenCvCameraView != null)
        mOpenCvCameraView.disableView();
}

@Override
public void onCameraViewStarted(int width, int height) {
}

@Override
public void onCameraViewStopped() {
}

@Override
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
    Mat frame = inputFrame.rgba();

    if (isDetecting) {
        Mat gray = inputFrame.gray();
        mIds = new MatOfInt();
        mCorners.clear();

        // Detect markers
        Aruco.detectMarkers(gray, mDictionary, mCorners, mIds);

        // Draw markers and measure width and height
        if (mIds.total() > 0) {
            Aruco.drawDetectedMarkers(frame, mCorners, mIds, new Scalar(255, 0, 0));
            for (Mat corners : mCorners) {
                if (corners.rows() == 1 && corners.cols() == 4) {
                    for (int i = 0; i < 4; i++) {
                        Imgproc.line(frame,
                                new org.opencv.core.Point(corners.get(0, i)),
                                new org.opencv.core.Point(corners.get(0, (i + 1) % 4)),
                                new Scalar(0, 255, 0), 2);
                    }
                    double width = Math.sqrt(Math.pow(corners.get(0, 0)[0] - corners.get(0, 1)[0], 2) +
                            Math.pow(corners.get(0, 0)[1] - corners.get(0, 1)[1], 2));
                    double height = Math.sqrt(Math.pow(corners.get(0, 1)[0] - corners.get(0, 2)[0], 2) +
                            Math.pow(corners.get(0, 1)[1] - corners.get(0, 2)[1], 2));
                    Log.d(TAG, "Width: " + width + ", Height: " + height);
                }
            }
        }

        // Reset the flag
        isDetecting = false;
    }

    return frame;
}

}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.