Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: (-215:Assertion failed) !ssize.empty() in function 'resize #1405

Open
Symbadian opened this issue Jan 31, 2022 · 0 comments
Open

error: (-215:Assertion failed) !ssize.empty() in function 'resize #1405

Symbadian opened this issue Jan 31, 2022 · 0 comments

Comments

@Symbadian
Copy link

  • activity recognition:
  • Python version: 3.8.12 64 bit
  • Operating System: Mac

Description

I am processing the loading operations of 150 VIDEO data files from the datastore, this works efficiently sometimes and on the same data, the error below is generated.

this operation involves loading all of the data for the training
what is expected is that the data has been loaded 100% so that the operations can move on to the training via hyperparameters.

What I Did

I tried googling the error to get an understanding but every solution relates to the directory and the location of the files is not accurate. BUT, this works sometimes and the output is what I am expecting. The challenge is that I am uncertain of the way forward due to lacking the understanding of the error to proceed.


import numpy as np
import cv2


class Videoto3D:

    def __init__(self, width, height, depth):
        self.width = width
        self.height = height
        self.depth = depth

    def video3d(self, filename, color=False, skip=True):
        cap = cv2.VideoCapture(filename)
        nframe = cap.get(cv2.CAP_PROP_FRAME_COUNT)
        if skip:
            frames = [x * nframe / self.depth for x in range(self.depth)]
        else:
            frames = [x for x in range(self.depth)]
        framearray = []

        for i in range(self.depth):
            cap.set(cv2.CAP_PROP_POS_FRAMES, frames[i])
            ret, frame = cap.read()
            frame = cv2.resize(frame, (self.height, self.width))
            if color:
                framearray.append(frame)
            else:
                framearray.append(cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY))

        cap.release()
        return np.array(framearray)



    def get_UCF_classname(self, filename):
        return filename# Controls the length of the class Name

#ORIGINAL CODE
 # def get_UCF_classname(self, filename):
 #     return filename[filename.find('_') + 1:filename.find('_', 20)]# Controls the length of the class Name

%%%%%%% THE ERROR I RECEIVED REPEATEDLY

Generating/Join Class Labels For Video Dataset For Input Completed
100%|█████████████████████████████████████████████| 5/5 [00:21<00:00,  5.49s/it]OpenCV: Couldn't read video stream from file "./dataset/Fighting/.DS_Store"
[ERROR:[email protected]] global /Users/runner/work/opencv-python/opencv-python/opencv/modules/videoio/src/cap.cpp (166) open VIDEOIO(CV_IMAGES): raised OpenCV exception:

OpenCV(4.5.5) /Users/runner/work/opencv-python/opencv-python/opencv/modules/videoio/src/cap_images.cpp:253: error: (-5:Bad argument) CAP_IMAGES: can't find starting number (in the name of file): ./dataset/Fighting/.DS_Store in function 'icvExtractPattern'


Traceback (most recent call last):
  File "3dcnn9.py", line 1053, in <module>
    main()
  File "3dcnn9.py", line 318, in main
    x, y = loaddata(args.videos, vid3d, args.nclass,
  File "3dcnn9.py", line 205, in loaddata
    X.append(vid3d.video3d(name, color=color, skip=skip))  
  File "/Users/mmgp0hotmail.com/opt/3DCNN/3DCNNtesting/videoto3d.py", line 25, in video3d
    frame = cv2.resize(frame, (self.height, self.width))
cv2.error: OpenCV(4.5.5) /Users/runner/work/opencv-python/opencv-python/opencv/modules/imgproc/src/resize.cpp:4052: error: (-215:Assertion failed) !ssize.empty() in function 'resize'

100%|█████████████████████████████████████████████| 5/5 [00:24<00:00,  4.90s/it]



Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant