×

Augmented reality in python

In this article, we shall learn about augmented reality in python.

Augmented reality is a technology that captures the world around you and adds virtual content or objects on top of it, such that it looks as if those virtual objects are present in the real world. The word ‘augment‘ itself means to add something. So, we add computer-generated 2-D or 3-D content or object in the real world.

In order to view these computer-generated graphics, we require a hand-held device like a smartphone, headgear (like a hollow lens – it is a Microsoft product which puts the augmented reality object in front of you) etc.

The famous game ‘Pokemon Go‘ is based on augmented reality. In this game, the user first needs to move to a location where a particular pokemon is located, and once he/she reaches there, they can then see a pokemon image on your smartphone. The game extends in chasing the instructions following the pokemon.

In order to use augmented reality on your mobile phone, your mobile phone should contain a camera, an accelerometer, a compass and a GPS sensor. Along with these, it should also have a good memory and processing power.

Applications of Augmented Reality

The majority of people think that AR (Augmented Reality) is essentially an entertainment technology. But that’s not totally true. Many larger brands have already identified various applications of this advanced technology, and hence, they are using it for certain user-friendly mobile applications.

These days, it is used by companies to create demos for their products like apparel or jewellery etc. We also have some other applications of augmented reality, like providing some real-time information, creating virtual sticking notes, as well as for some interactive advertising. Augmented reality is helpful in business as it is proved that people are more likely to buy a product if they can interact with it.

Augmented reality is also being used these days in health care, education, aerospace and defence and also in the e-commerce sector. Due to demand in these as well as other sectors, the global AR market (Augmented reality market) is expected to reach 85 billion dollars by 2025, indeed resulting in demand for developers expertized in this advanced technology of augmented reality-based applications.

Opportunities:

In terms of job prospects, several sources highlight that the starting average salary for augmented reality developers in the US is in the range of 95,000 dollars to 110,000 dollars, and the top end is around 200,000 dollars. And according to the sources, in India, a good augmented reality developer with an experience in the range of 3 to 5 years can easily get an average salary in the range of 5 lakh per annum to 8 lakh per annum.

Python program example for augmented reality:

test.py

import cv2 as cv
import numpy as np


img = cv.imread( " ima.jpg " ) # mention the image address in the peranthesis
print( img.shape )
cv.putText(
    img = img,
    text = f" opencv version : { cv.__version } ",
    org = ( 30, 40 ),
    fontFace = ( cv.FONT_HERSHEY_PLAIN ),
    fontScale = 1.5,
    color = ( 0, 255, 0 ),
    thickness = 2,
    lineType = cv.LINE_AA,
)
cv.imshow( " img ", img )
cv.waitKey( 0 )
cv.destroyAllWindows()

Generate_markers.py

import cv2 as cv
from cv2 import aruco
marker_dict = aruco.Dictionary_get( aruco.DICT_4*4_50 )
MARKER_SIZE = 400  # pixels
for id in range( 20 ):
    marker_image = aruco.drawMarker( marker_image, id, MARKER_SIZE)
    # cv.imshow( " img ", marker_image )
    cv.imwrite( f " markers / markder_{ id }.png ", marker_image )
    # cv.waitKey( 0 )
    # break


Detect_markers.py

import cv2 as cv
from cv2 import aruco
marker_dict = aruco.Dictionary_get( aruco.DICT_4*4_50 )
param_markers = aruco.DetectorParameters_create( )
cap = cv.VideoCapture( 0 )
while True:
    ret, frame = cap.read( )
    if not ret:
        break
    gray_frame = cv.cvtColor( frame, cv.COLOR_BGR2GRAY )
    marker_corners, marker_IDs, reject = aruco.detectMarkers(
        gray_frame, marker_dict, parameters = param_markers
    )
    for ids, corners in zip( marker_IDs, marker_corners ):
        cv.polylines( frame, [ corners.astype( np.int32 ) ], True, ( 0, 255, 255 ) )
        corners = corners.reshape( 4, 2 )
        corners = corners.astype( int )
        top_right = corners[ 0 ].ravel( )
        cv.putText(
            frame,
            f" id : {ids[ 0 ] } ",
            top_right,
            cv.FONT_HERSHEY_PLAIN,
            1.3,
            ( 200, 100,0 ),
            2,
            cv.LINE_AA,
        )
        # print( ids, " ", corners )
    cv.imshow( " frame ", frame )
    key = cv.waitKey( 1 )
    if key == ord( " q "):
        break
    cap.release( )
    cv.destroyAllWindows( )

Example input:

Augmented reality in python

Output:

Augmented reality in python

Related Topics

Crash Course on Python by Google

There is a new, free Python programming course offered by Google on Coursera. No programming experience is necessary. There are numerous Python courses available, but when you learn that Google is...

5 minutes read.

Io stringio Python

Python programming language: Python is an interactive and more accessible language than any other programming language. The python programming language uses a variety of libraries to perform the operations in a...

7 minutes read.

Python Prime factorization

Python Prime factorization In this tutorial, we will design a program where we will find all the prime factors of a number. Then, we will print all these prime factors of...

3 minutes read.

Cross Entropy in Python

Introduction Cross-entropy loss is frequently combined with the softmax function. Determine the total entropy among the distributions or the cross-entropy, which is the difference between two probability distributions. For the purpose...

5 minutes read.

Introducing modern python computing in simple packages

Python is the language for newly evolving technologies and has become one of the most popular computer languages in the world. Python is used in everything right from a simple...

3 minutes read.

Amazon rekognition using python

Amazon recognition service is an AI service which is an image labelling API (Application programming interface). In this article, we shall learn to use the AWS python boto3 module to...

3 minutes read.

SKLearn Model Selection

The model selections of SK learn has many functions with which we can work on.It has functions to cross-validate the model and, it also provides validation and learning curves.It is...

3 minutes read.

PyPi TensorFlow

It is a free open-source library for high-performative numerical computations. The architecture of TensorFlow allows us for easy deployment and computing across a varied number of platforms and from desktops...

3 minutes read.

Sort Dictionary in Python

Dictionaries In Python, a dictionary is an unordered collection or set of data types that enable of store data in an unordered key-value/pair. The key is stored alongside with value. Dictionary contains key:...

4 minutes read.

Python Sys Stdout

Python Programming Language: Python programming language is one of the most used programming languages, as it is used widely in the field of software and data analysis, web development, etc. It...

3 minutes read.

Python random.seed() function

The random module in Python produces a random number or pseudo-random data, that is, deterministic. The seed function records the state of a random function to provide the same random...

6 minutes read.

Python String zfill() method

Python String zfill() method The string.zfill() method in Python returns a copy of the string while adding the zeros (0) at the beginning of the string, until it reaches the specified...

1 minute read.

Is Python Case-sensitive when Dealing with Identifiers

Yes, Python is a case-sensitive language while dealing with identifiers. Python is one of the top trending, widely-used programming languages. Python is a general-purpose programming language. It is a case-sensitive...

6 minutes read.

Python Dictionary update() method

Python Dictionary update() method The dictionary.update() method in Python inserts the specified items to the dictionary. Syntax dictionary.update(iterable) Parameter iterable- This parameter represents a dictionary or an iterable object with key value pairs, that will...

1 minute read.

Python Program to Print Sum of all Elements in an Array

Python program to print sum of all elements in an array A set of objects stored in contiguous memory locations is referred to as an array. The concept is to keep...

2 minutes read.

Binary Search Visualization using Pygame in Python

A calculation like Binary Search is seen effectively by picturing. Here in this tutorial, a function that pictures the Binary Search Algorithm is carried out. The Graphical User’s Interface (GUI)...

15 minutes read.

Simple GUI calculator using PyQt5 in Python

GUI: The user is provided with information using manipulable visual widgets that don't require command-line input. These interface components respond to the user's interactions per the pre-programmed script, assisting each user's...

4 minutes read.

Attributes in python

In this article, we shall learn about attributes in python. Classes are a mix of data and functions, which in reality mean attributes and methods respectively. Typically, the body of a...

3 minutes read.

Python String rfind() method

The string. rfind() method in Python returns the highest index in the string if the substring sub is found else it returns -1 if the substring is not found. Syntax string.rfind(sub [,start [,end]]) Parameter sub: This parameter...

2 minutes read.

Python Time Module

Python contains many files that can be imported into a python code and used whenever we want. One of that modules is the time module. It is a good practice...

6 minutes read.