DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Stop Writing Database Migration Scripts: Declarative Schema Sync for Java
  • Searching Kafka Without an Index: Lessons From Building Message Search for Kafdrop
  • ScyllaDB in Enterprise Java: High-Performance NoSQL With Eclipse JNoSQL
  • Member Spotlight: Shai Almong

Trending

  • Build a Voice Assistant With Gemini Live API
  • AI Agents Need an Identity Plane: Rethinking Enterprise Authorization for Autonomous Software
  • How to Migrate From LangChainGo to Genkit Go
  • Why AI Agents Need a Shared Enterprise Ontology

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Data Engineering
  3. AI/ML
  4. AR and Java By Hand (Part 1): Introduction

AR and Java By Hand (Part 1): Introduction

Learn more about beginning your own AR project with Java.

By 
Radek Hecl
·
Aug. 27, 19 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
14.0K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

Chances are, you have already at least heard the term "augmented reality." The very generic definition says that augmented reality is real-world-enhanced, computer-generated information. This mini-series will be about enhancing the captured image or video by adding a 3D model into it. Like in this video.

If you want to know how this works, then keep reading. I will walk you through all the steps. The following image is the rough summarization of the steps.

Processing steps

Now, in simple terms, the final goal is to display a cube on top of the white A4 paper. The process to do that starts by thresholding the pixels to find the white ones. This produces several blobs — assuming the A4 paper is the biggest of them. Others are suppressed. The next step is to identify contour, edge lines, and corners of the paper. Then, the planar transformation is computed. Planar transformation is used to compute a projection matrix, which allows drawing 3D objects to the original image. Finally, the projection matrix is transformed into the OpenGL compatible form. Then, you can do anything with that.

Sounds trivial, right? Maybe. Still, it takes some effort to go through the details; therefore, I have prepared the following sections.

  1. Introduction (you are reading it now)
  2. Plane detection and tracking
  3. Homography
  4. Camera pose
  5. Video & OpenGL

In addition, there is an example project accompanying this series, which you can find under the "Download the Project" button.

Code is written in Java (+ few OpenGL shaders) and build by Maven. As soon as you understand these, you should be able to build the project and run the test applications. Test applications are executable classes within test sources. Additionally, our main classes are CameraPoseVideoTestApp  and CameraPoseJoglTestApp.

Regarding the expected level of knowledge, it will be very helpful if you have some knowledge about linear algebra, homogenous coordinates, RGB image representation, pinhole camera model, and perspective projection. Although I will try to keep the required level to the minimum, it is too much to explain every little thing in detail.

Now, let me make a note about the quality of the result. There are two main factors which affect quality – implementation and environment. I will cover one type of implementation, and I will let you judge how good it is. Please leave me comments, especially if you have a concrete idea to improve. The second factor which matters is the environment. This includes everything from camera quality, noise, distractions in the scene, lighting, occlusion, until the time you can spend on the processing each frame. Even today’s state of the art algorithms will fail under the crappy environment. Please keep this in mind when you do your own experiments.

Some extra reading? I used these resources (valid as of August 2019).

  • https://bitesofcode.wordpress.com/2017/09/12/augmented-reality-with-python-and-opencv-part-1/
  • http://ksimek.github.io/2012/08/13/introduction/
  • http://www.uco.es/investiga/grupos/ava/node/26
  • http://www.cse.psu.edu/~rtc12/CSE486/lecture16.pdf
  • https://en.wikipedia.org/wiki/Camera_resectioning
  • https://docs.opencv.org/3.4.3/dc/dbb/tutorial_py_calibration.html
  • Gordon, V. Scott. Computer Graphics Programming in OpenGL with JAVA Second Edition
  • Solem, Jan Erik. Programming Computer Vision with Python

Summary

This article gave you an overall idea of the project. Stay tuned for the next chapter where we tell you how to track the plane.

augmented reality Java (programming language)

Published at DZone with permission of Radek Hecl. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Stop Writing Database Migration Scripts: Declarative Schema Sync for Java
  • Searching Kafka Without an Index: Lessons From Building Message Search for Kafdrop
  • ScyllaDB in Enterprise Java: High-Performance NoSQL With Eclipse JNoSQL
  • Member Spotlight: Shai Almong

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook