Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • DSA
  • Practice Problems
  • Python
  • C
  • C++
  • Java
  • Courses
  • Machine Learning
  • DevOps
  • Web Development
  • System Design
  • Aptitude
  • Projects
Open In App
Next Article:
Project Idea (Augmented Reality - ARuco Code Detection and Estimation)
Next article icon

Project Idea (Augmented Reality – QR Code Scanner)

Last Updated : 17 May, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

Project Idea : A project based on scanning and detecting qr codes and with inclusion of pose estimation for optimization in detection of qr code and displaying a pyramid over it virtually and storing the read data from qr code. 

QR Code – Quick Response code -A QR code uses four standardized encoding modes (numeric, alphanumeric and byte/binary) to efficiently store data; extensions may also be used. 

How to install ->Install python (2.7 or 3.0 or higher) ->Install OpenCV Library for Ubuntu ->Install zbar, numpy, PIL Libraries for ubuntu ->Copy and paste the code in the editor and save it as qrcode.py 

Running the code : ->Open terminal and run the following command ->python qrcode.py 

Python




import zbar
from PIL import Image,ImageColor
import cv2
import numpy as np
 
cv2.namedWindow("Python Qr-Code Detection")
cap = cv2.VideoCapture(0)
 
scanner = zbar.ImageScanner()
scanner.parse_config('enable')
 
while True:
        ret, im = cap.read()
        if not ret:
          continue
    # Read Image
    #im = cv2.imread("sahilkhosla.jpg");
    size = im.shape
    gray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY, dstCn=0)
        pil = Image.fromarray(gray)
        width, height = pil.size
        raw = pil.tobytes()
        image = zbar.Image(width, height, 'Y800', raw)
        scanner.scan(image)
 
    for symbol in image:
            print 'decoded', symbol.type, 'symbol', '"%s"' % symbol.data
        topLeftCorners, bottomLeftCorners, bottomRightCorners, topRightCorners = [item for item in symbol.location]
            cv2.line(im, topLeftCorners, topRightCorners, (255,0,0),2)
                cv2.line(im, topLeftCorners, bottomLeftCorners, (255,0,0),2)
            cv2.line(im, topRightCorners, bottomRightCorners, (255,0,0),2)
            cv2.line(im, bottomLeftCorners, bottomRightCorners, (255,0,0),2)
 
        #2D image points. If you change the image, you need to change vector
                 
        image_points = np.array([
                            (int((topLeftCorners[0]+topRightCorners[0])/2), int((topLeftCorners[1]+bottomLeftCorners[1])/2)),     # Nose
                            topLeftCorners,     # Left eye left corner
                            topRightCorners,     # Right eye right corner
                            bottomLeftCorners,     # Left Mouth corner
                            bottomRightCorners      # Right mouth corner
                        ], dtype="double")
          
        # 3D model points.
        model_points = np.array([
                            (0.0, 0.0, 0.0),             # Nose
                            (-225.0, 170.0, -135.0),     # Left eye left corner
                            (225.0, 170.0, -135.0),      # Right eye right corner
                            (-150.0, -150.0, -125.0),    # Left Mouth corner
                            (150.0, -150.0, -125.0)      # Right mouth corner
                          
                        ])
          
          
        # Camera internals
          
        focal_length = size[1]
        center = (size[1]/2, size[0]/2)
        camera_matrix = np.array(
                         [[focal_length, 0, center[0]],
                         [0, focal_length, center[1]],
                         [0, 0, 1]], dtype = "double"
                         )
          
        print "Camera Matrix :\n {0}".format(camera_matrix)
          
        dist_coeffs = np.zeros((4,1)) # Assuming no lens distortion
        (success, rotation_vector, translation_vector) = cv2.solvePnP(model_points, image_points, camera_matrix, dist_coeffs, flags=cv2.CV_ITERATIVE)
          
        print "Rotation Vector:\n {0}".format(rotation_vector)
        print "Translation Vector:\n {0}".format(translation_vector)
          
          
        # Project a 3D point (0, 0, 1000.0) onto the image plane.
        # We use this to draw a line sticking out of the nose
          
          
        (nose_end_point2D, jacobian) = cv2.projectPoints(np.array([(0.0, 0.0, 100.0)]), rotation_vector, translation_vector, camera_matrix, dist_coeffs)
          
        for p in image_points:
            cv2.circle(im, (int(p[0]), int(p[1])), 3, (0,0,255), -1)
          
          
        p1 = ( int(image_points[0][0]), int(image_points[0][1]))
        p2 = ( int(nose_end_point2D[0][0][0]), int(nose_end_point2D[0][0][1]))
         
                #pillars
        cv2.line(im, bottomLeftCorners, p2, (255,0,0), 2)
        cv2.line(im, topLeftCorners, p2, (255,0,0), 2)
        cv2.line(im, bottomRightCorners, p2, (255,0,0), 2)
        cv2.line(im, topRightCorners, p2, (255,0,0), 2)
          
        # Display image
    cv2.imshow("Output", im)
     
    # Wait for the magic key
        keypress = cv2.waitKey(1) & 0xFF
        if keypress == ord('q'):
        break
 
cv2.waitKey(0)
 
 

For more Projects visit this link



Next Article
Project Idea (Augmented Reality - ARuco Code Detection and Estimation)
author
sahilkhoslaa
Improve
Article Tags :
  • Project

Similar Reads

  • Project Idea | Augmented Reality Search
    Project Title: AR Search Introduction and Conceptual framework: AR Search is an Android app based on the latest technologies. The technologies we used in the project to develop Augmented Reality are Unity, Vuforia Ground Plane Support, Vuforia Plane Finder, IBM Watson, Google Custom Search JSON API.
    2 min read
  • Project Idea (Augmented Reality - ARuco Code Detection and Estimation)
    Project Idea : A project based on scanning and detecting Aruco codes. Implementing Homography for estimation of intrinsic and extrinsic camera calibration parameters and inclusion of Pose Estimation for the implementation of augmented Reality projects in further future projects. For Qr Code Detectio
    4 min read
  • Project Idea | Road Accident Safety System
    Project Title: Road Accident Safety System Introduction: In India there are many deaths approximately more than 150000 deaths due to road accidents and this rate keeps increasing year by year and the main reason behind this is lack of accident-prone area caution boards. So, basically the idea of "Ro
    5 min read
  • Project Idea | Airport Security Using Beacon
    Project Title : Airport Security Using Beacon Introduction: Airport security refers to the techniques and methods used in an attempt to protect passengers, staff, and planes which use the airports from accidental/malicious harm, crime, and other threats. Aviation security is a combination of human a
    5 min read
  • Project Idea | Attendance System Using Smart Card
    1. Project Title: Smart Attendance System 2. Introduction: The current attendance system in most of the educational institutions is paper based, wherein the students are expected to sign an attendance sheet. This system has several disadvantages like: (a) The students can mark attendance of their fe
    4 min read
  • Project Idea | (Games using Hand Gestures)
    Idea To design games using hand gestures. Simple games like pacman or you can build it yourself using some cool libraries available like in python it is PYGAME. Tool This project is based on Computer Vision. Implementation Can be implemented in any programming language but for simplicity take python
    1 min read
  • Project Idea - Object Detection and Tracking
    Project title: Object Detection and Tracking Introduction: A lot of people go to supermarkets and retail stores and shops to idle around and window-shop instead of purchasing any products. The thought of analyzing this kind of behavior was intriguing. How does this kind of behavior affect product sa
    5 min read
  • Project Idea | (Smart Restaurants)
    Introduction: This project idea is dedicated to improve scenario in restaurants and hotels for better customer experience. The concept is simple to implement and very useful for every kind of food place whether it is a small restaurant or a big hotel. The system provides managed food delivery right
    2 min read
  • Project Idea | ( Character Recognition from Image )
    Aim : The aim of this project is to develop such a tool which takes an Image as input and extract characters (alphabets, digits, symbols) from it. The Image can be of handwritten document or Printed document. It can be used as a form of data entry from printed records. Tool : This project is based o
    2 min read
  • Project Idea | Get Me Through
    PROJECT TITLE : Get Me Through Why this name? The name of the project is just an exclamation to steer through the monotonous work, in today's world of spreading automation technologies. OVERVIEW: A Free, Offline, Real-Time, Open-source(MIT Licensed) web-app to assist organisers of any event in allow
    7 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences