简体   繁体   English

错误:(-215:断言失败)函数 cv::imshow 中的 size.width>0 && size.height>0

[英]error: (-215:Assertion failed) size.width>0 && size.height>0 in function cv::imshow

Need help finding why the error with cv2.imshow('frame',frame) (Working in Jupyter Notebook)需要帮助找出 cv2.imshow('frame',frame) 错误的原因(在 Jupyter Notebook 中工作)

This program is to collect many images so that I can train a model that has 10 gestures.这个程序是收集许多图像,以便我可以训练一个有 10 个手势的模型。

        import cv2 #opencv
        import os
        import time
        import uuid

       # Directory to collect images for training 
       IMAGES_PATH='Tensorflow/workspace/images/collectedimages'

      # Setting an array with all the labels
      labels = ['gest-1', 'gest-2', 'gest-3','gest-4','gest-5','gest-6','gest-7','gest-8', 'gest- 
      9', 'gest-10']
      number_imgs = 20

      # loop throught each of the labels in the array
      for label in labels:
        #create a directory for each of the labels
        os.mkdir ('Tensorflow/workspace/images/collectedimages/'+label)
        # Initialize the webcam (openCV)
        cap = cv2.VideoCapture(0)
        # time.sleep(2)
        print('Collecting images for {}'.format(label))
    
       time.sleep(5)
    
       #Loop through the number of images we want to collect
      for imgnum in range(number_imgs):
        ret,frame = cap.read()
        # Naming of the pictures
        # .format(str(uuid.uuid1())) makes sure that we dont duplicate names
        imgname = os.path.join(IMAGES_PATH, label, label+'.'+'{}.jpg'.format(str(uuid.uuid1())))
        cv2.imwrite(imgname, frame)
        
        cv2.imshow('frame',frame)
        time.sleep(2)
        
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
            
        cap.release()

1- Your path image is false : Image == None --> generate error 1- 您的路径图像是错误的:图像 == 无 --> 生成错误

2- for show image in jupyter you need do this: 2- 要在 jupyter 中显示图像,您需要执行以下操作:

image = cv2.imread('example/image.png')
cv2.imshow("test", image)
cv2.waitKey(0)
cv2.destroyAllWindows()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 opencv 错误:(-215:断言失败)size.width>0 && size.height>0 in function 'cv::imshow' - opencv error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow' 相机流 - OpenCV 错误:(-215:断言失败)size.width>0 && size.height>0 in function 'cv::imshow' - Camera Streaming - OpenCV error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow' OpenCV(4.2.0) 错误: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow' - OpenCV(4.2.0) error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow' 错误:(-215:断言失败)函数“imshow”中的 size.width>0 && size.height>0 - error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow' OpenCV 错误:(-215:断言失败)size.width>0 && size.height>0 in function 'imshow' - OpenCV error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow' 错误:函数imshow中的(-215)size.width> 0 && size.height> 0 - error: (-215) size.width>0 && size.height>0 in function imshow OpenCV错误:在cv :: imshow(Python)中断言失败(size.width> 0 && size.height> 0) - OpenCV Error: Assertion failed (size.width>0 && size.height>0) in cv::imshow (Python) 断言失败:function imshow 中的 size.width>0 && size.height>0 - Assertion failure : size.width>0 && size.height>0 in function imshow OpenCV 错误:(-215)size.width>0 && size.height>0 in function imshow - OpenCV Error: (-215)size.width>0 && size.height>0 in function imshow OpenCV错误:在imshow中断言失败(size.width> 0 && size.height> 0) - OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM