×
1 Choose EITC/EITCA Certificates
2 Learn and take online exams
3 Get your IT skills certified

Confirm your IT skills and competencies under the European IT Certification framework from anywhere in the world fully online.

EITCA Academy

Digital skills attestation standard by the European IT Certification Institute aiming to support Digital Society development

LOG IN TO YOUR ACCOUNT

CREATE AN ACCOUNT FORGOT YOUR PASSWORD?

FORGOT YOUR PASSWORD?

AAH, WAIT, I REMEMBER NOW!

CREATE AN ACCOUNT

ALREADY HAVE AN ACCOUNT?
EUROPEAN INFORMATION TECHNOLOGIES CERTIFICATION ACADEMY - ATTESTING YOUR PROFESSIONAL DIGITAL SKILLS
  • SIGN UP
  • LOGIN
  • INFO

EITCA Academy

EITCA Academy

The European Information Technologies Certification Institute - EITCI ASBL

Certification Provider

EITCI Institute ASBL

Brussels, European Union

Governing European IT Certification (EITC) framework in support of the IT professionalism and Digital Society

  • CERTIFICATES
    • EITCA ACADEMIES
      • EITCA ACADEMIES CATALOGUE<
      • EITCA/CG COMPUTER GRAPHICS
      • EITCA/IS INFORMATION SECURITY
      • EITCA/BI BUSINESS INFORMATION
      • EITCA/KC KEY COMPETENCIES
      • EITCA/EG E-GOVERNMENT
      • EITCA/WD WEB DEVELOPMENT
      • EITCA/AI ARTIFICIAL INTELLIGENCE
    • EITC CERTIFICATES
      • EITC CERTIFICATES CATALOGUE<
      • COMPUTER GRAPHICS CERTIFICATES
      • WEB DESIGN CERTIFICATES
      • 3D DESIGN CERTIFICATES
      • OFFICE IT CERTIFICATES
      • BITCOIN BLOCKCHAIN CERTIFICATE
      • WORDPRESS CERTIFICATE
      • CLOUD PLATFORM CERTIFICATENEW
    • EITC CERTIFICATES
      • INTERNET CERTIFICATES
      • CRYPTOGRAPHY CERTIFICATES
      • BUSINESS IT CERTIFICATES
      • TELEWORK CERTIFICATES
      • PROGRAMMING CERTIFICATES
      • DIGITAL PORTRAIT CERTIFICATE
      • WEB DEVELOPMENT CERTIFICATES
      • DEEP LEARNING CERTIFICATESNEW
    • CERTIFICATES FOR
      • EU PUBLIC ADMINISTRATION
      • TEACHERS AND EDUCATORS
      • IT SECURITY PROFESSIONALS
      • GRAPHICS DESIGNERS & ARTISTS
      • BUSINESSMEN AND MANAGERS
      • BLOCKCHAIN DEVELOPERS
      • WEB DEVELOPERS
      • CLOUD AI EXPERTSNEW
  • FEATURED
  • SUBSIDY
  • HOW IT WORKS
  •   IT ID
  • ABOUT
  • CONTACT
  • MY ORDER
    Your current order is empty.
EITCIINSTITUTE
CERTIFIED

How can the display text be added to the image when drawing object borders using the "draw_vertices" function?

by EITCA Academy / Saturday, 30 December 2023 / Published in Artificial Intelligence, EITC/AI/GVAPI Google Vision API, Understanding shapes and objects, Drawing object borders using pillow python library, Examination review

To add display text to the image when drawing object borders using the "draw_vertices" function in the Pillow Python library, we can follow a step-by-step process. This process involves retrieving the vertices of the detected objects from the Google Vision API, drawing the object borders using the vertices, and finally adding the display text to the image.

1. Retrieve the vertices of the detected objects:
– Utilize the Google Vision API to detect objects in an image.
– Extract the vertices of each detected object from the API response. The vertices represent the four corners of the bounding box that surrounds the object.

2. Draw object borders using the vertices:
– Load the image using the Pillow library in Python.
– Create an instance of the ImageDraw module from the Pillow library.
– Iterate over the vertices of each object and draw a rectangle using the "draw.rectangle" function from the ImageDraw module.
– The "draw.rectangle" function takes the coordinates of the top-left and bottom-right corners of the rectangle as arguments.

3. Add display text to the image:
– Create another instance of the ImageDraw module.
– Iterate over the vertices of each object and add the display text using the "draw.text" function from the ImageDraw module.
– The "draw.text" function takes the coordinates of the text position and the text string as arguments.
– You can customize the font, size, color, and other properties of the text by specifying additional parameters in the "draw.text" function.

Here's an example code snippet that demonstrates the process described above:

python
from PIL import Image, ImageDraw, ImageFont

# Step 1: Retrieve the vertices of the detected objects
# (Assuming you have already obtained the vertices from the Google Vision API)
vertices = [
    [(100, 100), (200, 100), (200, 200), (100, 200)],  # Example vertices of object 1
    [(300, 150), (400, 150), (400, 250), (300, 250)]   # Example vertices of object 2
]

# Step 2: Draw object borders using the vertices
image = Image.open("input_image.jpg")
draw = ImageDraw.Draw(image)

for vertex in vertices:
    draw.rectangle(vertex, outline="red")

# Step 3: Add display text to the image
font = ImageFont.truetype("arial.ttf", 12)
text_draw = ImageDraw.Draw(image)

for i, vertex in enumerate(vertices):
    text_position = vertex[0][0], vertex[0][1] - 20
    text_draw.text(text_position, f"Object {i+1}", font=font, fill="red")

# Save the modified image
image.save("output_image.jpg")

In this example, we assume that the vertices of the objects have already been obtained from the Google Vision API. We then load the image using the Pillow library, draw the object borders using the vertices, and add display text above each object.

Remember to adjust the code according to your specific requirements, such as the font, font size, and text color.

Other recent questions and answers regarding Drawing object borders using pillow python library:

  • Can Google Vision API be applied to detecting and labelling objects with pillow Python library in videos rather than in images?
  • How to implement drawing object borders around animals in images and videos and labelling these borders with particular animal names?
  • What are the parameters of the "draw.line" method in the provided code, and how are they used to draw lines between vertices values?
  • How can the pillow library be used to draw object borders in Python?
  • What is the purpose of the "draw_vertices" function in the provided code?
  • How can the Google Vision API help in understanding shapes and objects in an image?

More questions and answers:

  • Field: Artificial Intelligence
  • Programme: EITC/AI/GVAPI Google Vision API (go to the certification programme)
  • Lesson: Understanding shapes and objects (go to related lesson)
  • Topic: Drawing object borders using pillow python library (go to related topic)
  • Examination review
Tagged under: Artificial Intelligence, Google Vision API, Image Processing, Object Detection, Pillow, Python
Home » Artificial Intelligence / Drawing object borders using pillow python library / EITC/AI/GVAPI Google Vision API / Examination review / Understanding shapes and objects » How can the display text be added to the image when drawing object borders using the "draw_vertices" function?

Certification Center

USER MENU

  • My Account

CERTIFICATE CATEGORY

  • EITC Certification (105)
  • EITCA Certification (9)

What are you looking for?

  • Introduction
  • How it works?
  • EITCA Academies
  • EITCI DSJC Subsidy
  • Full EITC catalogue
  • Your order
  • Featured
  •   IT ID
  • EITCA reviews (Medium publ.)
  • About
  • Contact

EITCA Academy is a part of the European IT Certification framework

The European IT Certification framework has been established in 2008 as a Europe based and vendor independent standard in widely accessible online certification of digital skills and competencies in many areas of professional digital specializations. The EITC framework is governed by the European IT Certification Institute (EITCI), a non-profit certification authority supporting information society growth and bridging the digital skills gap in the EU.

Eligibility for EITCA Academy 80% EITCI DSJC Subsidy support

80% of EITCA Academy fees subsidized in enrolment by

    EITCA Academy Secretary Office

    European IT Certification Institute ASBL
    Brussels, Belgium, European Union

    EITC / EITCA Certification Framework Operator
    Governing European IT Certification Standard
    Access contact form or call +32 25887351

    Follow EITCI on X
    Visit EITCA Academy on Facebook
    Engage with EITCA Academy on LinkedIn
    Check out EITCI and EITCA videos on YouTube

    Funded by the European Union

    Funded by the European Regional Development Fund (ERDF) and the European Social Fund (ESF) in series of projects since 2007, currently governed by the European IT Certification Institute (EITCI) since 2008

    Information Security Policy | DSRRM and GDPR Policy | Data Protection Policy | Record of Processing Activities | HSE Policy | Anti-Corruption Policy | Modern Slavery Policy

    Automatically translate to your language

    Terms and Conditions | Privacy Policy
    EITCA Academy
    • EITCA Academy on social media
    EITCA Academy


    © 2008-2025  European IT Certification Institute
    Brussels, Belgium, European Union

    TOP
    Chat with Support
    Chat with Support
    Questions, doubts, issues? We are here to help you!
    End chat
    Connecting...
    Do you have any questions?
    Do you have any questions?
    :
    :
    :
    Send
    Do you have any questions?
    :
    :
    Start Chat
    The chat session has ended. Thank you!
    Please rate the support you've received.
    Good Bad