Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
RivoLink committed May 1, 2020
1 parent 785021c commit 610c57a
Show file tree
Hide file tree
Showing 13 changed files with 195 additions and 1,890 deletions.
58 changes: 57 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,57 @@
Aruco Android
# Aruco Android

> It is an application to detect Aruco Markers.
<center>
<img width="75%" src="screenshots/marker_drawing_axis.png" alt="screenshot_home" />
</center>

## Credits

This application uses:

- **opencv-contrib** for computer vision, see [LICENSE](opencv344-contrib/LICENSE),
- **aruco**, module from opencv-contrib, for ***aruco markers*** detection.
- **rajawali**, for 3D models renderer.

See more about ***opencv***, and ***aruco*** from:

- [opencv](https://opencv.org)
- [opencv-contrib](https://github.com/opencv/opencv_contrib)
- [aruco](http://www.uco.es/investiga/grupos/ava/node/26)
- [rajawali](https://github.com/Rajawali/Rajawali)

## About

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

## 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***

<center>
<img width="75%" src="screenshots/board_detecting_markers.png" alt="screenshot_home" />
</center>

After that, compile ***app*** project and enjoy...

<center>
<img width="75%" src="screenshots/board_drawing_axis.png" alt="screenshot_home" />
</center>

## Contributions

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

<center>
<img width="75%" src="screenshots/marker_drawing_model.png" alt="screenshot_home" />
</center>

Thank you :)
19 changes: 18 additions & 1 deletion app/src/main/java/mg/rivolink/app/aruco/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame){

Aruco.estimatePoseSingleMarkers(corners,0.04f,cameraMatrix,distCoeffs,rvecs,tvecs);
for(int i=0;i<ids.toArray().length;i++){
transformModel(tvecs.row(0),rvecs.row(0));
Aruco.drawAxis(rgb,cameraMatrix,distCoeffs,rvecs.row(i),tvecs.row(i),0.02f);
}

Expand All @@ -161,7 +162,23 @@ public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame){
public void onCameraViewStopped(){
rgb.release();
}


private void transformModel(final Mat tvec,final Mat rvec){
runOnUiThread(new Runnable(){
@Override
public void run(){
renderer.transform(
tvec.get(0,0)[0]*50,
-tvec.get(0,0)[1]*50,
-tvec.get(0,0)[2]*50,

rvec.get(0,0)[2],//yaw
rvec.get(0,0)[1],//pitch
rvec.get(0,0)[0] //roll
);
}
});
}
}


25 changes: 20 additions & 5 deletions app/src/main/java/mg/rivolink/app/aruco/renderer/Renderer3D.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.rajawali3d.renderer.Renderer;

import mg.rivolink.app.aruco.R;
import org.rajawali3d.math.*;

public class Renderer3D extends Renderer{

Expand All @@ -22,30 +23,44 @@ public Renderer3D(Context context){
setFrameRate(60);
}

@Override
protected void initScene() {
light=new PointLight();
light.setPosition(0,0,4);
light.setPower(3);

try {
LoaderOBJ objParser=new LoaderOBJ(mContext.getResources(),mTextureManager,R.raw.camaro_obj);
LoaderOBJ objParser=new LoaderOBJ(mContext.getResources(),mTextureManager,R.raw.box_obj);
objParser.parse();
model=objParser.getParsedObject();
model.setPosition(0,0,-5);
model.setRotation(90,90,0);
model.setPosition(0,0,-10);
model.setVisible(false);
getCurrentScene().addLight(light);
getCurrentScene().addChild(model);


} catch(ParsingException e) {
e.printStackTrace();
}
}

public void transform(double tx,double ty,double tz,double yaw,double pitch,double roll){
/* Some bugs here
if(!model.isVisible())
model.setVisible(true);
model.setPosition(tx,ty,tz);
model.setOrientation(new Quaternion().fromEuler(
Math.toDegrees(yaw),
Math.toDegrees(pitch),
Math.toDegrees(roll)
));
*/
}

@Override
protected void render(long ellapsedRealtime,double deltaTime){
super.render(ellapsedRealtime,deltaTime);
model.rotate(Vector3.Axis.Y,0.5);
//model.rotate(Vector3.Axis.Y,0.5);
}

@Override
Expand Down
Binary file added app/src/main/res/drawable-nodpi/brick.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/drawable-nodpi/camaro.jpg
Binary file not shown.
16 changes: 16 additions & 0 deletions app/src/main/res/raw/box_mtl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Wavefront .mtl file - created by SpaceDraw

# File created: 20-03-24, 21:04

newmtl standard
Ns 20.0
d 1.0
Tr 0.0
illum 2
Ka 0.50189996 0.50189996 0.50189996
Kd 0.50189996 0.50189996 0.50189996
Ks 0.50189996 0.50189996 0.50189996
Ke 0.0 0.0 0.0
map_Ka brick.jpg
map_Kd brick.jpg

84 changes: 84 additions & 0 deletions app/src/main/res/raw/box_obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Wavefront .obj file - created by SpaceDraw

# File created: 20-03-24, 21:04

mtllib box.mtl

#
# object cube1
#

v -1.504095 -1.498365 -1.502577
v 1.491942 -1.498365 -1.502577
v -1.504095 1.497673 -1.502577
v 1.491942 1.497673 -1.502577
v -1.504095 -1.498365 1.493461
v 1.491942 -1.498365 1.493461
v -1.504095 1.497673 1.493461
v 1.491942 1.497673 1.493461
# 8 vertices

vn 0.0 -1.0 0.0
vn 0.0 -1.0 0.0
vn 0.0 -1.0 0.0
vn 0.0 -1.0 0.0
vn 0.0 1.0 0.0
vn 0.0 1.0 0.0
vn 0.0 1.0 0.0
vn 0.0 1.0 0.0
vn -1.0 0.0 0.0
vn -1.0 0.0 0.0
vn -1.0 0.0 0.0
vn -1.0 0.0 0.0
vn 1.0 0.0 0.0
vn 1.0 0.0 0.0
vn 1.0 0.0 0.0
vn 1.0 0.0 0.0
vn 0.0 0.0 -1.0
vn 0.0 0.0 -1.0
vn 0.0 0.0 -1.0
vn 0.0 0.0 -1.0
vn 0.0 0.0 1.0
vn 0.0 0.0 1.0
vn 0.0 0.0 1.0
vn 0.0 0.0 1.0
# 24 vertex normals

vt 0.0 0.0 -0.5
vt 1.0 -1.0 -0.5
vt 0.0 -1.0 -0.5
vt 1.0 0.0 -0.5
vt 1.0 0.0 0.5
vt 0.0 0.0 0.5
vt 0.0 -1.0 0.5
vt 1.0 -1.0 0.5
vt 0.0 0.0 -0.499999
vt 1.0 -1.0 -0.499999
vt 0.0 -1.0 -0.499999
vt 1.0 0.0 -0.499999
vt 0.0 0.0 0.5
vt 1.0 0.0 0.5
vt 1.0 -1.0 0.5
vt 0.0 -1.0 0.5
vt 0.0 -1.0 -0.5
vt 0.0 0.0 -0.5
vt 1.0 0.0 -0.5
vt 1.0 -1.0 -0.5
vt 0.0 -1.0 0.5
vt 1.0 0.0 0.5
vt 0.0 0.0 0.5
vt 1.0 -1.0 0.5
# 24 texture coords

g cube1

usemtl standard
s off
f 1/3/3 2/2/2 6/4/4 5/1/1
f 7/8/8 8/7/7 4/6/6 3/5/5
f 5/10/10 7/12/12 3/9/9 1/11/11
f 2/15/15 4/14/14 8/13/13 6/16/16
f 1/20/20 3/19/19 4/18/18 2/17/17
f 6/24/24 8/22/22 7/23/23 5/21/21
# 6 polygons

12 changes: 0 additions & 12 deletions app/src/main/res/raw/camaro_mtl

This file was deleted.

Loading

0 comments on commit 610c57a

Please sign in to comment.