×

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

Pillow Python introduction and setup

Introduction Advanced image processing implies handling the picture carefully with the assistance of a PC. Utilizing picture handling we can perform activities like upgrading the picture, obscuring the picture, separating text...

4 minutes read.

Commands in Python

In this tutorial, we will see some of the widely used python commands along with their syntaxes and examples. To make Python more user-friendly, developers have provided these commands to...

12 minutes read.

Difference between Python and CPP

Difference between Python and C++ We all know that both C++ and Python are two of the most popular programming languages. Both C++ and Python shares some basic similarities such as...

6 minutes read.

Copying a file from one folder to Another with Python

In this article, we shall discuss copying a file from one folder to another using python functions. A file is a collection of data or information stored on a computer....

3 minutes read.

Writing to Excel using Python

Python is an Object-Oriented high-level language. Python has an English-like syntax, which is very easy to read and write codes. Python is an interpreted language which means that it uses...

3 minutes read.

Notepad++ For Python

In this article, you are going to learn what notepad++ is and how it is integrated with python to use the python programming language. You can also learn how to...

4 minutes read.

Python RegEx

Python RegEx (python regular expressions) is a concept of writing and finding expressions in a pool of characters easily. A Regular expression (RegEx) is a set of characters that defines search...

10 minutes read.

Uint8 Python

Python: 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 is said...

3 minutes read.

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...

3 minutes read.

__GETITEM__ and __SETITEM__ in Python

These methods are used in assignment operations, unary comparison operations, binary comparison operations and binary operations. These are pre-defined methods that perform many operations on a class instance. Examples like...

3 minutes read.

Data Drop in Python

Introduction You'll understand how to delete a group of rows from a Pandas dataframe in this article.You can read this article on How to Drop Columns in Pandas to find out...

6 minutes read.

Python Redis Example

Introduction: Redis, representing Distant Word reference Server, is a kind of key-esteem NoSQL server. Redis is intended to help circle capacity for determination, holding information after power is stopped, and stores information...

5 minutes read.

os.rename() method in Python

In Python, the os module provides the capacity to interact with the operating system. The operating system comes under the Python module. In this module, Python provides a specific feature...

3 minutes read.

Python Packages

A package is a collection of Python modules that share a similar namespace and are generated by putting all of the modules in a single directory with certain special files...

6 minutes read.

Python Encapsulation

What is meant by Encapsulation? The process of restricting access to the methods and variables so that accidental modification of data can be prevented is known as Encapsulation. The motive of Encapsulation:...

3 minutes read.

Python Set symmetric_difference() method

Python Set symmetric_difference() method The set.symmetric_difference() method returns a new set, which is the symmetric difference of two sets. The returned set contains only the unique items and, hence, deleting the common elements of...

2 minutes read.

Python vs HTML

Python and HTML are not comparable since they are two separate categories of programming languages. Building the structures and layouts of a web page or app requires the usage of HTML,...

8 minutes read.

Python MySQL Database Connection

In this article, you will be able to understand how to connect to a MySQL database through Python. We generally can use many methods or modules to connect to the database...

6 minutes read.

The Calendar Module of Python

The calendar module provides calendar features, including printing functions for a specific month or year. Default is the first day of the week on Monday and the last day on Sunday...

3 minutes read.

Read numpy array in Python

Numpy is a numerical python that deals with multidimensional arrays mostly used in storing multiple values. Python's core scientific computing package is called NumPy. This Python library provides multidimensional array...

9 minutes read.