Coder Social home page Coder Social logo

juancc / puzzleapp Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 28.6 MB

Android application using c++ library and Opencv for the guidance of the assembly of a puzzle the development is proposed using JNI for both PC and mobile development

Java 6.82% Makefile 79.90% C++ 13.28%

puzzleapp's Introduction

Puzzle

Research project from 2014 of a mobile (Android) Augmented Reality application for the guidance of the assembly of a puzzle. In Learning mode it automatically learn the parts and position of a given puzzle from images as shown on img folder. In the Guidance mode, show visual cues for assembly the puzzle.

The projects includes "directly" C++ code on Android app. The C++ development is on JNI folder and works for both desktop and mobile. For more information look at NKD Guides.

The desktop client main.cpp learn the puzzle (parts and locations) from the path given in the first argument (if given), it opens a test image:

Test puzzle image

Then it learn from the geometry of the parts and run a loop while the user needs guidance of the parts. The application don't track when the user puts the partg on the correct location, it only shows hitns of the parts position and the user has to manually click for the next hint.

The mobile client src/com/example/puzzle learn the parts from a path defined on ar.cpp. Then the runtime of the application is defined on PuzzleActivity.java and the methods used from C code are declared on Augmentation.java:

Notes

Disclosure

The intention of this proyect was to integrate Computer Vision C++ code from 2014 into a mobile device (In this case Android because it was easy to adquire) thus no further usability was intended. This proyect is discontinuated, is unknown if still works on new Android versions. See why this is a naive implementation.

A puzzle is used for simulates the assembly of manufacturing projects and the use of IAR (Industrial Augmented Reality).

Code Structure

Main code location

PuzzleApp
│── jni: Main code lives here
│   │── scr: Source code of vision modules are located under 
│   │── bin: Compiled desktop app 
│   │── main.cpp: Client scripts for desktop 
│   └── ar.cpp: Interface for export C++ classes for Android
│── src/com/example/puzzle: Native Android classes
│   │── Augmentation.java: Interface class that define the AR methods and loads from compiled C++
│   └── PuzzleActivity.java: Android activity of application
│── bin: Compiled Android app and OpenCV v3
└── img: Images of the Puzzle used for training 

Vision Modes

The application have two main moments, in the first one, it learn the geometry of the parts and on the second one display hints for guide the assembly. This two modes are integrated on the same function ArMoments::calcMoment

Learning Mode

The learning mode is excecuted at the beginning of the runtime. It uses the images located on a folder with a specific structure as shown here and contains:

  • parts: each part defined as a folder that is numerated starting from 1 inside images of the part

Part Example

Example training image part 2

  • assembly: for each folder how does each step of the assembly looks

Part Example

Example assembly step 3

The learning mode uses a 7 dimension vector with the Hu moments as descriptor of each part (known as their features). The Hu moments are commonly used in classic vision problems due to their invariability to Translation, Rotation and Scale (TRS) transformations meaning the position, rotation and distance of the camera will not affect (very small changes) the value of the descriptor vector of each part.

Then a simplified K-nearest neighbors algorithm (KNN) located on KNN.cpp is "trained". As the descriptors are invariant to TRS the training is just and addition of each vector to a matrix where each row is the index of the part and the columns the moments.

The Puzzle

The puzzle is commontly used on research to study de assembly of products in a controlled way. The proposed puzzle has the characteristics that each part and all mid the assembly steps have a completly different geometry. Additionally all the configurations looks different to be able to identify

Guidance Mode

After the learning phase is performed each new image is passed to the function ArMoments::calcMoment where some kind of segmentation is performed to find the contours on the image. For each contour found a vector with the Hu moments is calculated and calculated its near neighbour on the matrix builded on training.

Why is this naive?

This is part of a research project thus its purpose is only to be able to use a mobile device. Some of the reasons this could not be used in any other real-life application:

  • Segmentation is poorly done, only works on clear background with black parts (It is a research project)
  • Using Hu moments as features: they are not the most robust regarding affine transformations. Also small or similar parts will fail. If you are doing something similar use deep learning
  • AR guidance is poor
  • Only works on flat parts
  • Is highly influenced by lightng as shadows can get taken as geometry of the parts

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.