本次主題是以colab的環境進行學習的,在本篇文章中,我將講解影像辨識的基礎技能在接下來的文章中這些技能將多次出現,先讀過這些語法再繼續去看後面的文章會比較能快速上手喔。依照進度每個禮拜都會記錄不同的影像辨識方法,基本順序會從:
載入雲端硬碟:
from google.colab import drive
drive.mount('/content/drive')
下載mediapipe:
!pip install mediapipe
讀入照片及辨識:
import cv2 as cv
import mediapipe as med
import numpy as np
import matplotlib.pyplot as plt
dr = med.solutions.drawing_utils
dr_sty = med.solutions.drawing_styles
poses = med.solutions.pose
cap = cv.imread('/content/drive/MyDrive/hand/20220804153652-d31f1d62-me.jpg')
img = cap
with poses.Pose(
min_detection_confidence=0.5,
min_tracking_confidence=0.5) as pose:
img2 = cv.cvtColor(img, cv.COLOR_BGR2RGB)
results = pose.process(img2)
dr.draw_landmarks(
img,
results.pose_landmarks,
poses.POSE_CONNECTIONS,
landmark_drawing_spec=dr_sty.get_default_pose_landmarks_style())
cap = cv.cvtColor(cv.imread('/content/drive/MyDrive/hand/20220804153652-d31f1d62-me.jpg'), cv.COLOR_BGR2RGB)
plt.imshow(cap,cmap="gray")
plt.show()
img = cv.cvtColor(img, cv.COLOR_BGR2RGB)
plt.imshow(img,cmap="gray")
plt.show()
原始圖片:
實際預測結果:
文章主題一覽:
粗體字為額外更新的文章。