0

I do not use to work with python, and I a need your help. This is my code:

import cv2
from cvzone.PoseModule import PoseDetector

cap = cv2.VideoCapture('Video.mp4')

detector = PoseDetector()
posList = []
while True:
    success, img = cap.read()
    img = detector.findPose(img)                        /*Here is the error*/
    lmList, bboxInfo = detector.findPosition(img)

    if bboxInfo:
        lmString = ''
        for lm in lmList:
            lmString += f'{lm[1]},{img.shape[0] - lm[2]},{lm[3]},'
        posList.append(lmString)

    print(len(posList))

    cv2.imshow("Image", img)
    key = cv2.waitKey(1)
    if key == ord('s'):
        with open("AnimationFile.txt", 'w') as f:
            f.writelines(["%s\n" % item for item in posList])

The error is: 215:Assertion failed) !_src.empty() in function 'cv::cvtColor'

I've read some forums, but I could't find a solution

I try with:

if img is not None: 

and

import cv2
from cvzone.PoseModule import PoseDetector

cap = cv2.VideoCapture('Video.mp4')

detector = PoseDetector()
posList = []
while True:
    success, img = cap.read()
    if not success:
        print("Can't receive frame (stream end?). Exiting ...")
        break
    img = detector.findPose(img)
    lmList, bboxInfo = detector.findPosition(img)
Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
  • so you *tried*, but what *happened* then? – Christoph Rackwitz Jul 28 '23 at 23:45
  • 1
    Where is cvtColor in your code? Can you please provide the full error message? – tintin98 Jul 29 '23 at 07:34
  • Does this answer your question? [imread returns None, violating assertion !\_src.empty() in function 'cvtColor' error](https://stackoverflow.com/questions/52676020/imread-returns-none-violating-assertion-src-empty-in-function-cvtcolor-er) – Yunus Temurlenk Jul 30 '23 at 17:09
  • @ChristophRackwitz I tried and it didn't work. just the print funtion – Dixlan Barrios Jul 31 '23 at 18:15
  • @tintin98 this is the complete error: Mensaje = OpenCV(4.8.0) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor' Origen = C:\Users\Dixlan\Desktop\UNITY PROYECTS\Python\Motion Capture\Motion_Capture.py Seguimiento de la pila: File "C:\Users\Dixlan\Desktop\UNITY PROYECTS\Python\Motion Capture\Motion_Capture.py", line 10, in (Current frame) img = detector.findPose(img) – Dixlan Barrios Jul 31 '23 at 18:29

0 Answers0