Tags

, , , , , , , , , , , , ,

SaltwashAR is a Python Augmented Reality application, which lets us render and interact with 3D robots on 2D markers.

Let’s go through the steps to install SaltwashAR, as well as a brief overview of the application.

Installation

I will install SaltwashAR as a Visual Studio Python Application project on my Windows 7 64-bit PC.

Note: SaltwashAR is a Python application that can be installed on alternative operating systems, using whichever IDE or terminal you wish.

Python Tools for Visual Studio

First, we will install Microsoft’s Python Tools for Visual Studio 2.2.2 – a free, open source plugin that turns Visual Studio into a Python IDE.

Note: if you don’t already have a compatible version of Visual Studio, download and install Visual Studio 2015 Community for free.

We’ll also need to install a Python interpreter. There are a number of options and I’m plumping for the Anaconda (Python 2.7 Windows 64-bit) Python distribution, which I have previously used with PTVS 2.1 for SaltwashAR.

Select “Add Anaconda to my PATH environment variable” and “Register Anaconda as my default Python 2.7” during the Anaconda2 2.4.1 installation.

Note: if you want to check the environment variables settings on Windows 7 then go to

Start menu->right-click Computer->Properties->Advanced system settings->Advanced->Environment Variables->System variables

Finally, let’s launch Visual Studio and create a new Python Application project for SaltwashAR:

File->New->Project->Python Application (name the project “SaltwashAR”)

SaltwashInstallationAndOverview_NewProject

Once the project is created, the default SaltwashAR.py script can be deleted.

We will now confirm the Python Environment for Anaconda:

View->Other Windows->Python Environments->Python 64-bit 2.7->”This is the default environment for new projects”

SaltwashInstallationAndOverview_PythonEnvironments

Also, ensure that the Completion DB for Anaconda is refreshed in the Python Environments window.

Great, we now have Python Tools for Visual Studio installed and a Visual Studio Python Application project created!

Note: check out the PTVS Wiki for further details on installation, features and tutorials.

SaltwashAR

Okay, so we have Python Tools for Visual Studio. Next, let’s download SaltwashAR from GitHub and integrate it into our new Visual Studio Python Application project.

On GitHub, select “Download Zip” and copy the contents of the zip folder into the Visual Studio Python Application project folder (Visual Studio 2015\Projects\SaltwashAR\SaltwashAR).

saltwashinstallationandoverview_projectfolder

Back in our Visual Studio Python Application project, right-click the SaltwashAR project file in the Solution Explorer window and Add->Existing Folder for each SaltwashAR application folder: calibration, images, markers, scripts. Also, add the appsettings.ini file by right-clicking the SaltwashAR project file in the Solution Explorer and Add->Existing Item->All Files (*.*).

Open the scripts folder in the Solution Explorer, right-click main.py and “Set as Startup File”.

saltwashinstallationandoverview_solutionexplorer

Dependencies

So far, we have installed Python Tools for Visual Studio and integrated SaltwashAR into our Visual Studio Python Application project. However, we still need to install some core dependencies before we start our SaltwashAR application.

PyOpenGLPyOpenGL is a Python binding for OpenGL graphics library. For my Windows 7 64-bit PC I downloaded PyOpenGL-3.1.1b1-cp27-none-win_amd64.whl and PyOpenGL_accelerate-3.1.1a1-cp27-none-win_amd64.whl from http://www.lfd.uci.edu/~gohlke/pythonlibs/ and copied the OpenGL and OpenGL_accelerate folders into the Anaconda Lib\site-packages folder.

OpenCVOpenCV is a computer vision library. For my Windows 7 64-bit PC I downloaded OpenCV for Windows (Version 2.4.9) and copied the build\python\2.7\x64\cv2.pyd file into the Anaconda Lib\site-packages folder.

All our core dependencies are now in place, and SaltwashAR can be started.

Note: there are optional dependencies to install, as you enable features via the SaltwashAR appsettings.ini file. Currently, the optional dependencies are:

  • BeautifulSoup 4.4.1
  • SpeechRecognition 3.1.3
  • pyttsx 1.1
  • PyBrain 0.3.3

Overview

Out of the box

We have integrated SaltwashAR into our Visual Studio Python Application project and installed the core dependencies. Let’s start SaltwashAR and experience some out of the box Augmented Reality!

First, open the SaltwashAR markers folder (Visual Studio 2015\Projects\SaltwashAR\SaltwashAR\markers) and print the two marker images onto paper (the images can be resized to fit the paper, so long as the width/height ratio remains fixed). You now have 2D markers on which to render the 3D robots.

Next, attach your webcam to the PC. Ideally, you will calibrate your camera as per the calibration instructions on the SaltwashAR Wiki – but for now simply use the calibration settings provided with the application.

Finally, start the Visual Studio Python Application project for SaltwashAR by pressing F5 (or selecting Debug menu->Start Debugging). Hold the 2D markers in front of the webcam. Hopefully, you will see the robots appear.

saltwashinstallationandoverview_outofthebox

You can rotate the 2D markers so that the robots are facing you.

Features

The out of the box SaltwashAR application lets us render 3D robots on 2D markers. But it is features that let us interact with the robots.

You can switch a feature on via the SaltwashAR appsettings.ini file – simply change a value from False to True before starting the application:

[Features]
Browser=False
HandGesture=True
PlayYourCardsRight=False

For example, once the value of HandGesture is changed from False to True and the application is started, the robot responds to my hand gestures:

saltwashinstallationandoverview_handgesture

Note: be sure to install the feature dependencies, as stated on the SaltwashAR Wiki. For example, for the hand gesture feature I installed the Text To Speech dependency ‘pyttsx 1.1’.

Please let me know if you have any issues getting SaltwashAR installed and started on your computer, and I will try to assist.

If you want to help develop features for SaltwashAR, please check out the SaltwashAR Wiki.

Ciao!

Advertisements