Hi programming experts,
I am having an extreme challenge trying to understand an error dispensed from my code:
I am running code to process 6 classes of 40 videos per class, one class is continuously causing the system to throw errors:
What did I do?
-
I tried reviewing all of the videos from the problems class A and compared this with what is working in B and nothing seems to be an issue there.
-
I checked the size of the videos, colour and resolutions in the working class B and it is a range of RGB and grayscale, what is constant is that the size of such is 320 x 240 resolution. In problem class A this is the same as well as all of the file extensions (.avi).
-
In online forums they mentioned the label names, but I tried using the label names from the working class and that was useless. There are various labelling strategies I tried and that was also pointless.
-
So now that the videos seem to be ok, I targeted the code but everywhere I google the solutions seems to be evading me. And this is challenging me to get a full understanding of what is actually happening.
Can someone guide me here, please?
This is literally consuming my time and I am pretty sure it is something trivial but yet I cannot seem to see this!
*** The Code***
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
NOW THE ERRORS
**********************************************************
Processing All Class Labels For Video Data Input Completed
0%| | 0/6 [00:00<?, ?it/s]**********************************************************
Generating/Join Class Labels For Video Dataset For Input Completed
100%|█████████████████████████████████████████████| 6/6 [00:12<00:00, 2.72s/it]OpenCV: Couldn't read video stream from file "./dataset/Shooting/.DS_Store"
[ERROR:0@13.430] 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/Shooting/.DS_Store in function 'icvExtractPattern'
Traceback (most recent call last):
File "3dcnn9.py", line 1009, in <module>
main()
File "3dcnn9.py", line 321, in main
x, y = loaddata(args.videos, vid3d, args.nclass,
File "3dcnn9.py", line 208, 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%|█████████████████████████████████████████████| 6/6 [00:12<00:00, 2.14s/it]
'''