Autonomous robot, line following and Aruco detection. Android Java

asked 2019-05-13 07:35:10 -0600

Agus gravatar image

updated 2019-05-13 10:35:40 -0600

Hi guys, firstly let me thank you for this fantastic library that I´m using on my final mechanical degree project. Basically I´m using a Lego EV3 Mindstorm robot to simulate a warehouse environment, he follows a black line, calculating the center of the line all the time and detecting Aruco markers on the floor. I´m working on a small Android app using Android Studio, I use my mobile phone camera as the robot "eyes", using OpenCV library to process every frame the camera takes, so if the camera doesn´t detect any Aruco marker the robot follows the black line, but if he detects a marker on the floor he turns right/left or goes ahead until next marker. I´ve implemented all of this java code inside onCameraFrame() method, and I´m trying to know if there is a way to detect lines and markers at the same time, using parallel threads, Asynctask... I´m not a programmer so I need some tips or guide through where the onCameraFrame method works detecting the center of the line and also detecting Aruco Markers and the same time. Right now the robot does this steps correlatively: 1) Search for Aruco marker on the floor 1.1) If an Aruco marker is detected: draw the marker, call SystemClock.sleep() (this freeze the camera), approach to the marker slowly and turns left or right depending on the ID of the marker 1.2) If there is no Aruco detected the robot follows the center of the black line

The problem that I have is that the method drawDetectedMarkers() doesn´t makes its job, because Aruco marker is not drawed until the mRgba is returned at the end of the camera frame, so it will never be draw on the frame until onCameraFrame finish, the code works like this:

public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {

        final Mat mRgba = inputFrame.rgba();

        detectAndDrawMarkers();

        if (corners.size() > 0) {         //if the corners array is bigger than 0 then an Aruco marker has been detected
            drawDetectedMarker(mRgba);    
            turnID(arucoIDs);            //inside this method there is a SystemClock.sleep(), freezing the screen and  waiting until the robot finish the movement
        } else {

            followLine(mRgba);
        }
        return mRgba;
    }

So I need help with:

1) Some way to detect the black line and detect Aruco marker at the same time. 2) Draw the Aruco marker before the frame freeze.

Here is a screenshoot of the frame, there are 2 roi, the green detects the black line center, and the blue one detects the aruco. image description

Thanks so much and best regards.

edit retag flag offensive close merge delete

Comments

I need some help, thanks in advance :)

Agus gravatar imageAgus ( 2019-05-16 03:38:43 -0600 )edit

@Agus -- however, please do not post answers here, if you have a question or a comment, thank you.

berak gravatar imageberak ( 2019-05-16 04:02:51 -0600 )edit