# 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'

**URL:** <https://forum.opencv.org/t/opencv-4-5-5-users-runner-work-opencv-python-opencv-python-opencv-modules-videoio-src-cap-images-cpp-error-5-bad-argument-cap-images-cant-find-starting-number-in-the-name-of-file-dataset-fighting-ds-store-in-function-icvextractpattern/7359>\
**Category:** Python\
**Tags:** videoio\
**Created:** [January 31, 2022, 12:21pm UTC](https://forum.opencv.org/t/opencv-4-5-5-users-runner-work-opencv-python-opencv-python-opencv-modules-videoio-src-cap-images-cpp-error-5-bad-argument-cap-images-cant-find-starting-number-in-the-name-of-file-dataset-fighting-ds-store-in-function-icvextractpattern/7359 "2022-01-31T12:21:32Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![NiNhaqui](https://avatars.discourse-cdn.com/v4/letter/n/34f0e0/32.png) [@NiNhaqui](https://forum.opencv.org/u/NiNhaqui)\
**Post date:** [January 31, 2022, 12:21pm UTC](https://forum.opencv.org/t/opencv-4-5-5-users-runner-work-opencv-python-opencv-python-opencv-modules-videoio-src-cap-images-cpp-error-5-bad-argument-cap-images-cant-find-starting-number-in-the-name-of-file-dataset-fighting-ds-store-in-function-icvextractpattern/7359/1 "2022-01-31T12:21:33Z")

</div>

Hi all,

I am conducting my processing and I am getting an unusual error that I am not sure how to interpret.  
Can someone help me understand this error, please?

I have my code located in the datastore and what is funny is that the same code is running efficiently sometimes on the same data and then suddenly I am presented with this error.

MY CODE:\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

```auto
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

```

My Errors\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

```auto

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:0@25.086] 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'

```

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [January 31, 2022, 10:33pm UTC](https://forum.opencv.org/t/opencv-4-5-5-users-runner-work-opencv-python-opencv-python-opencv-modules-videoio-src-cap-images-cpp-error-5-bad-argument-cap-images-cant-find-starting-number-in-the-name-of-file-dataset-fighting-ds-store-in-function-icvextractpattern/7359/2 "2022-01-31T22:33:51Z")

</div>

> [@NiNhaqui](#):
>
> `Couldn't read video stream from file "./dataset/Fighting/.DS_Store"`

that’s some macos-specific file. don’t read that.

how does that path manage to reach VideoCapture?

---

<div class="post-metadata">

**Author:** ![NiNhaqui](https://avatars.discourse-cdn.com/v4/letter/n/34f0e0/32.png) [@NiNhaqui](https://forum.opencv.org/u/NiNhaqui)\
**Post date:** [February 1, 2022, 11:02am UTC](https://forum.opencv.org/t/opencv-4-5-5-users-runner-work-opencv-python-opencv-python-opencv-modules-videoio-src-cap-images-cpp-error-5-bad-argument-cap-images-cant-find-starting-number-in-the-name-of-file-dataset-fighting-ds-store-in-function-icvextractpattern/7359/3 "2022-02-01T11:02:38Z")

</div>

My initialisation packages.p file code below that calls another 3dcnn.py file

```auto
# %% Initialise 3DCNN Activity Recognition
!python 3dcnn9.py --batch 130 --epoch 2 --videos ./dataset/ --nclass 2 --output 3dcnnresult/ --color True --skip False --depth 12

```

```auto
def loaddata(video_dir, vid3d, nclass, result_dir, color=False, skip=True):
    # This loads the .DS_Store in the class incrementing the number of classes by one
    
    
    files = os.listdir(video_dir)
    root = '/Users/mmgp0hotmail.com/opt/3DCNN/3DCNNtesting/dataset'
    
    dirlist = [item for item in os.listdir(
        root) if os.path.isdir(os.path.join(root, item))]
    print(' **********************************************************')
    print('DIRLIST Directory Completed', dirlist)

    file_paths = []
    for file_name in os.listdir(root):
        file_path = os.path.join(root, file_name)
        if os.path.isfile(file_path):
            file_paths.append(file_path)
            print(' **********************************************************')
            print('ALL Directory File Paths Completed', file_paths)

    # folder_names = []
    # for entry_name in os.listdir(root):
    # entry_path = os.path.join(root, entry_name)
    # if os.path.isdir(entry_path):
    # folder_names.append(entry_name)
    # print(' **********************************************************')
    # print('ALL Directory Folder Names Completed',file_paths)

    roots, dirsy, fitte = next(os.walk(root), ([], [], []))
    print(' **********************************************************')
    print('ALL Directory ROOTED', roots, fitte, dirsy)

    print(' **********************************************************')
    print('Processing All Class Labels For Video Data Input Completed')
    
    
    
    X = []
    # print('X labels==>', X)
    labels = []
    # print('The Processed Labels ==>', labels)
    labellist = []
    # print('Lablelist', labellist)

    pbar = tqdm(total=len(files)) # generate progress bar for file processing

    print(' **********************************************************')
    print('Generating/Join Class Labels For Video Dataset For Input Completed')
# Accessing files and labels from dataset directory

    for filename in files:
        # print(' **********************************************************')
        # print('This is my Filename before join',filename)
        pbar.update(1)
        if filename == '.DS_Store':
            continue

        namelist = os.path.join(video_dir, filename)
        # print(' **********************************************************')
        # print('This is my namelist after join',namelist)#PRINTS ALL CLASSName Files
        # print(' **********************************************************')
        # print('This is the name list',namelist)

        files2 = os.listdir(namelist)
        # print(' **********************************************************')
        # print('This is the files2 For Class Filename',files2)#PRINTS ALL CLASSName Files

        for files3 in files2:
            
            name = os.path.join(namelist, files3)
           
            # print(' **********************************************************')
            # print('This is Name For Class Filename',name)#PRINTS ALL CLASSName Files
            # print("ok")
            #print("dir is ", name)
            # getting all class names for processing
            # Calls the filename from Video3d.py
            label = vid3d.get_UCF_classname(filename)
            
            labels.append(label)

            if label not in labellist:
                if len(labellist) >= nclass:
                    continue
                labellist.append(label) # storing labellist of files
                # print("This is the labellist ",labellist.append(label))
            # labels.append(label) # storing labels
            #print("This is the labels ",labels.append(label))
    
            X.append(vid3d.video3d(name, color=color, skip=skip)) 

```

---

<div class="post-metadata">

**Author:** ![NiNhaqui](https://avatars.discourse-cdn.com/v4/letter/n/34f0e0/32.png) [@NiNhaqui](https://forum.opencv.org/u/NiNhaqui)\
**Post date:** [February 1, 2022, 11:04am UTC](https://forum.opencv.org/t/opencv-4-5-5-users-runner-work-opencv-python-opencv-python-opencv-modules-videoio-src-cap-images-cpp-error-5-bad-argument-cap-images-cant-find-starting-number-in-the-name-of-file-dataset-fighting-ds-store-in-function-icvextractpattern/7359/4 "2022-02-01T11:04:07Z")

</div>

I reckon it has something to do with the directory but I am finding this rather challenging to decipher, please help and thanx in advance.  
Oh by the way I tried this morning and this is the approach that was taken:

I have two classes with its subfolders: Class 1 Neutral & Class 2 Violence

Class1: Neutral which is one folder and then its subclasses inside that folder WlkFast & WlkSlow  
Class2: Violence which is one folder and then its subclasses inside that folder Kicking & Punching

This approach was futile:  
What i am really trying to do is call or rather pass all of the classes inclusive of the subclasses in the process  
This will help me to understand what action is being performed from a high level and then sub level  
for example the action detected is Netrual subclass walking

This is the best way i can represent my efforts and I am hoping that you may get the gist of the operations

thank you loads in advance… standing by

---

<div class="post-metadata">

**Author:** ![NiNhaqui](https://avatars.discourse-cdn.com/v4/letter/n/34f0e0/32.png) [@NiNhaqui](https://forum.opencv.org/u/NiNhaqui)\
**Post date:** [February 1, 2022, 11:17am UTC](https://forum.opencv.org/t/opencv-4-5-5-users-runner-work-opencv-python-opencv-python-opencv-modules-videoio-src-cap-images-cpp-error-5-bad-argument-cap-images-cant-find-starting-number-in-the-name-of-file-dataset-fighting-ds-store-in-function-icvextractpattern/7359/5 "2022-02-01T11:17:31Z")

</div>

How do I get rid of the .DS\_Store file? I’ve been looking this morning at this as well but nothing seems to be functioning

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [February 1, 2022, 12:02pm UTC](https://forum.opencv.org/t/opencv-4-5-5-users-runner-work-opencv-python-opencv-python-opencv-modules-videoio-src-cap-images-cpp-error-5-bad-argument-cap-images-cant-find-starting-number-in-the-name-of-file-dataset-fighting-ds-store-in-function-icvextractpattern/7359/6 "2022-02-01T12:02:01Z")

</div>

`os.listdir` call… when you iterate over those names, filter them (`continue` if conditions don’t match). everything has to be a file, and it’s best to check the file extension. if you have only pictures of one type, you could just check `file_name.endswith(".png")`

that code uses listdir for listing directories too, so don’t touch that. mind the directory structure.

---

<div class="post-metadata">

**Author:** ![NiNhaqui](https://avatars.discourse-cdn.com/v4/letter/n/34f0e0/32.png) [@NiNhaqui](https://forum.opencv.org/u/NiNhaqui)\
**Post date:** [February 1, 2022, 12:16pm UTC](https://forum.opencv.org/t/opencv-4-5-5-users-runner-work-opencv-python-opencv-python-opencv-modules-videoio-src-cap-images-cpp-error-5-bad-argument-cap-images-cant-find-starting-number-in-the-name-of-file-dataset-fighting-ds-store-in-function-icvextractpattern/7359/7 "2022-02-01T12:16:55Z")

</div>

this is what is confusing me!!!???!

the files are located in the right place?? this works for four classes of the same data for example

‘’’  
ALL Directory ROOTED /Users/mmgp0hotmail.com/opt/3DCNN/3DCNNtesting/dataset [’.DS\_Store’] [‘Violence’, ‘Neutral’]  
‘’’

What i tried?  
I add four different classes in the same location to see if that would do anything and that worked  
I have four classes:  
wlk fast 40 videos  
Wlk slow 40 vids  
Punching 40 vids  
Kicking 40 vids

so, if I am using the same data as above in two classes as per the Neutral and Violence:  
Why is it causing the error!!!

‘’’  
Generating/Join Class Labels For Video Dataset For Input Completed  
100%|█████████████████████████████████████████████| 3/3 [00:08\<00:00, 2.98s/it]OpenCV: Couldn’t read video stream from file “./dataset/Neutral/.DS\_Store”  
[ERROR:0@10.270] 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/Neutral/.DS\_Store in function ‘icvExtractPattern’

Traceback (most recent call last):  
File “3dcnn9.py”, line 1055, in   
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%|█████████████████████████████████████████████| 3/3 [00:09\<00:00, 3.22s/it]  
‘’’

---

<div class="post-metadata">

**Author:** ![NiNhaqui](https://avatars.discourse-cdn.com/v4/letter/n/34f0e0/32.png) [@NiNhaqui](https://forum.opencv.org/u/NiNhaqui)\
**Post date:** [February 1, 2022, 12:18pm UTC](https://forum.opencv.org/t/opencv-4-5-5-users-runner-work-opencv-python-opencv-python-opencv-modules-videoio-src-cap-images-cpp-error-5-bad-argument-cap-images-cant-find-starting-number-in-the-name-of-file-dataset-fighting-ds-store-in-function-icvextractpattern/7359/8 "2022-02-01T12:18:57Z")

</div>

the file types are all .avi videos by the way. that was the first thing I checked… and thanx for your response but this is still ongoing…  
Please help if you canthis is mind-boggling!!

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [February 1, 2022, 6:19pm UTC](https://forum.opencv.org/t/opencv-4-5-5-users-runner-work-opencv-python-opencv-python-opencv-modules-videoio-src-cap-images-cpp-error-5-bad-argument-cap-images-cant-find-starting-number-in-the-name-of-file-dataset-fighting-ds-store-in-function-icvextractpattern/7359/9 "2022-02-01T18:19:03Z")

</div>

if `.DS_Store` is a directory, you need to skip it in your code.

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [February 2, 2022, 8:08am UTC](https://forum.opencv.org/t/opencv-4-5-5-users-runner-work-opencv-python-opencv-python-opencv-modules-videoio-src-cap-images-cpp-error-5-bad-argument-cap-images-cant-find-starting-number-in-the-name-of-file-dataset-fighting-ds-store-in-function-icvextractpattern/7359/10 "2022-02-02T08:08:58Z")

</div>

maybe you can use [python’s builtin glob function](https://docs.python.org/3/library/glob.html)  
as it allows you to filter for specific file types (like .avi)

---

<div class="post-metadata">

**Author:** ![NiNhaqui](https://avatars.discourse-cdn.com/v4/letter/n/34f0e0/32.png) [@NiNhaqui](https://forum.opencv.org/u/NiNhaqui)\
**Post date:** [February 2, 2022, 9:26am UTC](https://forum.opencv.org/t/opencv-4-5-5-users-runner-work-opencv-python-opencv-python-opencv-modules-videoio-src-cap-images-cpp-error-5-bad-argument-cap-images-cant-find-starting-number-in-the-name-of-file-dataset-fighting-ds-store-in-function-icvextractpattern/7359/11 "2022-02-02T09:26:18Z")

</div>

Hi programming analysts,

I think I figured it out, it has to do with the labelling of the dataset. For example:

Some of the data are not been initialised as the operations are searching for the files in sequence and the dataset labelling format was not in sequence. As soon as this was altered, the processing was concluded. See below and thanx so much in advance, I really appreciated your efforts!

cheers!

Previous Labelling  
‘’’  
v\_WalkingWithDog\_g01\_c01  
v\_WalkingWithDog\_g01\_c02  
v\_WalkingWithDog\_g02\_c03  
v\_WalkingWithDog\_g02\_c04  
v\_WalkingWithDog\_g03\_c05  
v\_WalkingWithDog\_g03\_c06  
‘’’  
Current labelling  
‘’’  
v\_WalkingWithDog\_g01\_c0  
v\_WalkingWithDog\_g01\_c1  
v\_WalkingWithDog\_g01\_c2  
v\_WalkingWithDog\_g01\_c3  
v\_WalkingWithDog\_g01\_c4  
v\_WalkingWithDog\_g01\_c5  
‘’’
