Giter VIP home page Giter VIP logo

augmented-reality's Introduction

augmented-reality

Augmented reality card based application with Python, numpy and OpenCV

Usage

  • Place the image of the surface to be tracked inside the reference folder.
  • On line 36 of src/ar_main.py replace 'model.jpg' with the name of the image you just copied inside the reference folder.
  • On line 40 of src/ar_main.py replace 'fox.obj' with the name of the model you want to render. To change the size of the rendered model change the scale parameter (number 3) in line 103 of src/ar_main.py by a suitable number. This might require some trial and error.
  • Open a terminal session inside the project folder and run python src/ar_main.py

Command line arguments

  • --rectangle, -r: Draws the projection of the reference surface on the video frame as a blue rectangle.
  • --matches, -m: Draws matches between reference surface and video frame.

Troubleshooting

If you get the message:

Unable to capture video

printed to your terminal, the most likely cause is that your OpenCV installation has been compiled without FFMPEG support. Pre-built OpenCV packages such as the ones downloaded via pip are not compiled with FFMPEG support, which means that you have to build it manually.

If you get the error:

Traceback (most recent call last):
File "src/ar_main.py", line 174, in
main()
File "src/ar_main.py", line 40, in main
obj = OBJ(os.path.join(dir_name, 'models/fox.obj'), swapyz=True)
File "[...]/augmented-reality/src/objloader_simple.py", line 16, in init
v = v[0], v[2], v[1]
TypeError: 'map' object is not subscriptable

The most likely cause is that you are trying to execute the code with Python 3 and the code is written in Python 2. The map function in Python 3 returns an iterable object of type map, and not a subscriptible list. To fix it, change the calls to map() by list(map()) on lines 14, 19 and 24 of src/objloader_simple.py.

Update: This should no longer be an issue after this commit

Explanation

See this blog entries for an in-depth explanation of the logic behind the code:

Results

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.