Code Monkey home page Code Monkey logo

Comments (14)

nitindf avatar nitindf commented on June 9, 2024 2

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.

The coordinates are in the corners parameter in Aruco.detectMarkers(gray, dictionary, corners, ids, parameters) which is a List of Mat objects . There is an item in this list for every detected marker id. So, you can try accessing them like this,

Mat coordinates = corners.get(i); //get item in List
List<Point> corners_xy = new ArrayList<>(4);
for (int r = 0; r < coordinates.rows(); r++) {
    for (int c = 0; c < coordinates.cols(); c++) {
        corners_xy.add(new Point((int)coordinates.get(r,c)[0], (int)coordinates.get(r,c)[1])); // x,y point   
    }
}  
//Access the coordinates of 4 corners
Point top_left = corners_xy.get(0);
Point top_right = corners_xy.get(1);
Point bottom_right = corners_xy.get(2);
Point bottom_left = corners_xy.get(3);

And insert the above code here,

Aruco.detectMarkers(gray, dictionary, corners, ids, parameters);
if(corners.size()>0){
    Aruco.drawDetectedMarkers(rgb, corners, ids);
    for(int i = 0;i<ids.toArray().length;i++) {
        //insert code here

from aruco-android.

Meett98 avatar Meett98 commented on June 9, 2024 1

It will helpful to us.

Thank You. @RivoLink

from aruco-android.

RivoLink avatar RivoLink commented on June 9, 2024

Hi,

In this file ImageActivity.java, at the line 174, you have the 4 corners 3D positions of each marker, your can use them if you want to sort the detected markers.

Tell me if that doesn't help you.

from aruco-android.

Meett98 avatar Meett98 commented on June 9, 2024

how to display xyz cordinates of the detected markers on screen and when we change the position of marker then it will get updated.

from aruco-android.

RivoLink avatar RivoLink commented on June 9, 2024

With @nitindf codes

You can do :

Point top_left = corners_xy.get(0);

int x = (int)top_left.x;
int y = (int)top_left.y;

String text = String.format("(x: %d, y: %d)", x, y);

Point text_position = new Point(
	rgb.cols()/2,
	rgb.rows()/2
);

int font_face = Core.FONT_HERSHEY_SIMPLEX;
double font_scale = 1.0;
Scalar font_color = new Scalar(255, 255, 0);

Imgproc.putText(rgb, text, text_position, font_face, font_scale, font_color);

from aruco-android.

Meett98 avatar Meett98 commented on June 9, 2024

How to get Z coordinate ??

from aruco-android.

RivoLink avatar RivoLink commented on June 9, 2024

For a marker, we have 2 positions :

  • The position in the real world which has 3d coordinates (x,y,z), and
  • The position in the screen which only has 2d coordinates (x, y)

For the 2d coordinates you can have it with above code

For the 3d coordinates, they are stored in tvec=[x,y,z], for more information you can refer here :
Get the distance from camera to an OpenCV ArUco Marker

from aruco-android.

Meett98 avatar Meett98 commented on June 9, 2024

Can you explain the whole project through a video??

from aruco-android.

Helidhimmar avatar Helidhimmar commented on June 9, 2024

Can you explain the whole project through a video??

+1 yes please ,it will useful to us.

from aruco-android.

RivoLink avatar RivoLink commented on June 9, 2024

Hello

I don't know how to make videos, but I will write an article to explain the project and I will share the link with you.

Thank you for your interest in this project.

from aruco-android.

Meett98 avatar Meett98 commented on June 9, 2024

@RivoLink I want to display x,y,z cordinates of tvec on the graph, So how it can be done?

from aruco-android.

RivoLink avatar RivoLink commented on June 9, 2024

Hi @meet98, sorry for delay.

I created a new branch feature/tvec-coords for your request.

Here's a gist: RivoLink/ImageActivity.java

Open an image containing a marker with the Aruco Android app to view tvec coordinates

May it help you,
You can create a new issue if you have more questions.

from aruco-android.

Meett98 avatar Meett98 commented on June 9, 2024

Hey @RivoLink Thanks for your efforts.
The thing is app is working correctly but sometimes device gets hang or app crashes and i also added another activity in project in which i plot the graph of tvec , so the problem is sometimes app works perfectly but sometimes it gets crash, so is there any specific reason for this issue? and if you have any solution then tell me so that it will helpful for me.

from aruco-android.

RivoLink avatar RivoLink commented on June 9, 2024

Hi @Meett98
Can you create a new issue for this and and I will happy to help you.

from aruco-android.

Related Issues (15)

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.