Beispiel #1
0
import cv2
import time
import PoseModule as pm

cap = cv2.VideoCapture('videos/a.mp4')
pTime = 0
detector = pm.PoseDetector()
while True:
    success, img = cap.read()
    img = detector.findPose(img)
    lmList = detector.getPosition(img)
    print(lmList)

    cTime = time.time()
    fps = 1 / (cTime - pTime)
    pTime = cTime

    cv2.putText(img, str(int(fps)), (50, 50), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 0, 0), 3)
    cv2.imshow("Image", img)
    cv2.waitKey(1)
import cv2
import numpy as np
import time
import PoseModule as pm

cap = cv2.VideoCapture("AiTrainer/joseph.mov")

detector = pm.poseDetector()
left_count = 0
left_dir = 0
right_count = 0
right_dir = 0
pTime = 0
while True:
    success, img = cap.read()
    img = cv2.resize(img, (1280, 720))
    # img = cv2.imread("AiTrainer/test.jpg")
    img = detector.findPose(img, True)
    lmList = detector.findPosition(img, True)
    if len(lmList) != 0:
        # Right Arm
        right_angle = detector.findAngle(img, 12, 14, 16)
        right_per = 100 - np.interp(right_angle, (100, 160), (0, 100))
        right_bar = np.interp(right_angle, (100, 160), (100, 650))

        # Left Arm
        left_angle = detector.findAngle(img, 11, 13, 15)
        left_per = np.interp(left_angle, (195, 250), (0, 100))
        left_bar = np.interp(left_angle, (195, 250), (650, 100))
        # print(angle, per)
Beispiel #3
0
import cv2
import time
import PoseModule as pm

cap = cv2.VideoCapture(0)
pTime = 0
detector = pm.poseDetection()

while True:
    success, img = cap.read()
    img = detector.findPose(img)
    lmList = detector.findPosition(img, draw=False)
    if len(lmList) != 0:
        print(lmList[14])
        cv2.circle(img, (lmList[14][1], lmList[14][2]), 15, (150, 0, 0),
                   cv2.FILLED)
    cTime = time.time()
    fps = 1 / (cTime - pTime)
    pTime = cTime

    cv2.putText(img, str(int(fps)), (70, 58), cv2.FONT_HERSHEY_COMPLEX_SMALL,
                3, (0, 255, 0), 2)

    cv2.imshow("img", img)
    cv2.waitKey(1)