• English
    • 日本語 (Japanese)
Avinton JapanAvinton JapanAvinton JapanAvinton Japan
  • Services
    • Avinton Data Platform
    • Edge AI Camera
    • Private Cloud
    • AI Service Development
  • Blog
  • Avinton Academy
  • Careers
    • Jobs
  • About
    • Company Profile
    • Message from the CEO
    • Sustainability
  • Contact

OpenCV Simple Exercise

  • Infrastructure (Server components, RAID)
  • Machine Learning Engineer Skills Required
  • Front End Technologies: Environment
  • Front End Technologies: Demo API
  • Setting Up Ubuntu
  • PostgreSQL Setup
  • REDIS
  • Privacy Policy
  • Loading Data into PostgreSQL & Redis
  • Python with Redis & PostgreSQL
  • Install Python2.7 & OpenCV
  • OpenCV Simple Exercise
  • Image Classification Task
  • Questions
  • Extending VirtualBox Virtual Drive
  • PostgreSQL Data Analyses
  • Infrastructure (server components, RAID)
  • PostgreSQL – Python – Apache – Bootstrap
  • Data Scientist
  • Google Chrome DevTools Basics for Web App Development
Home Avinton Academy OpenCV Simple Exercise

OpenCV Exercise

Make sure we are in our home directory

1
2
3
[code lang="bash"]
cd ~
[/code]

Create a new directory for this exercise

1
2
3
4
[code lang="bash"]
mkdir pytest
cd pytest
[/code]

Download the image below to this new directory

Copy the following code:
# import the necessary packages
import numpy as np
import cv2
 
# load the games image
image = cv2.imread("test.png")
 
# find the red color game in the image
upper = np.array([65, 65, 255])
lower = np.array([0, 0, 200])
mask = cv2.inRange(image, lower, upper)
 
# find contours in the masked image and keep the largest one
(_, cnts, _) = cv2.findContours(mask.copy(), cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_SIMPLE)
c = max(cnts, key=cv2.contourArea)
 
# approximate the contour
peri = cv2.arcLength(c, True)
approx = cv2.approxPolyDP(c, 0.05 * peri, True)
 
# draw a green bounding box surrounding the red game
cv2.drawContours(image, [approx], -1, (0, 255, 0), 4)
cv2.imshow("Image", image)
cv2.waitKey(0)

Paste the code into a file called pytest.py

1
2
3
[code lang="bash"]
vi pytest.py
[/code]

Paste then save and exit vi

Run the python program

1
2
3
[code lang="python"]
python pytest.py
[/code]

Now it should make a green square around the red logo box.

The exercise is to make it make the square around the blue logo box (middle one).

Email me back the result

採用情報

採用情報

Avinton SDGs

SDGsへの貢献

Search

Tags

5G AI AI Big Data careers Commodity Hardware Construction Industry Consulting Corporate Innovation Data-Driven Company Data Science Digital Transformation Edge AI Edge Computing Imagine Analysis Infrastructure Interface IoT IT engineering Kubernetes Linux LPIC-2 Machine Learning Machine Vision Manufacturing Industry PostgreSQL Precision Farming Predictive Maintenance Programmer Safety Management Smart Agriculture Smart Drones Smart Factory Smart Manufacturing Society 5.0 Sound Analysis Storage Study Guide Yield Forecasting インフラ エッジコンピューティング キャリア コンテナ技術 技術ブログ 資格
© 2023 Avinton | All Rights Reserved | プライバシーポリシー
  • Services
    • Avinton Data Platform
    • Edge AI Camera
    • Private Cloud
    • AI Service Development
  • Blog
  • Avinton Academy
  • Careers
    • Jobs
  • About
    • Company Profile
    • Message from the CEO
    • Sustainability
  • Contact
  • English
    • 日本語 (Japanese)
Avinton Japan