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

Could not open video at /content/subway.mp4 #267

Open
1 of 2 tasks
v479038280 opened this issue Mar 28, 2024 · 2 comments
Open
1 of 2 tasks

Could not open video at /content/subway.mp4 #267

v479038280 opened this issue Mar 28, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@v479038280
Copy link

Search before asking

  • I have searched the Roboflow Notebooks issues and found no similar bug report.

Notebook name

how-to-detect-and-count-objects-in-polygon-zone.ipynb

Bug

Exception                                 Traceback (most recent call last)
[<ipython-input-27-ef352d094252>](https://localhost:8080/#) in <cell line: 6>()
      4 generator = sv.get_video_frames_generator(SUBWAY_VIDEO_PATH)
      5 iterator = iter(generator)
----> 6 frame = next(iterator)
      7 
      8 # detect

[/usr/local/lib/python3.10/dist-packages/supervision/video.py](https://localhost:8080/#) in get_video_frames_generator(source_path)
    118     video = cv2.VideoCapture(source_path)
    119     if not video.isOpened():
--> 120         raise Exception(f"Could not open video at {source_path}")
    121     success, frame = video.read()
    122     while success:

Exception: Could not open video at /content/subway.mp4

Environment

  • Google colab

Minimal Reproducible Example

import supervision as sv

# extract video frame
generator = sv.get_video_frames_generator(SUBWAY_VIDEO_PATH)
iterator = iter(generator)
frame = next(iterator)

# detect
outputs = predictor(frame)
detections = sv.Detections(
    xyxy=outputs["instances"].pred_boxes.tensor.cpu().numpy(),
    confidence=outputs["instances"].scores.cpu().numpy(),
    class_id=outputs["instances"].pred_classes.cpu().numpy().astype(int)
)

# annotate
box_annotator = sv.BoxAnnotator(thickness=4, text_thickness=4, text_scale=2)
frame = box_annotator.annotate(scene=frame, detections=detections)

%matplotlib inline  
sv.show_frame_in_notebook(frame, (16, 16))

Additional

the file subway.mp4 is a Invalidation file .

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!
@v479038280 v479038280 added the bug Something isn't working label Mar 28, 2024
@el634dev
Copy link

el634dev commented May 15, 2024

I fixed this by creating a content folder and placing the video inside the folder. The dot before {HOME} is necessary for Colab to look at the root directory and search for the folder named content. I included a small code sample below that fixes this issue:

import os

HOME = os.getcwd()
# HOME = './content'
SUBWAY_VIDEO_PATH = f".{HOME}/subway.mp4"

If you use the line that is commented out, then the dot before {HOME} is not necessary; it's only necessary with os.getcwd(). The folder would also be unnecessary and you can avoid creating one if you use the line that is commented out. You can use either HOME variable for your project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants
@v479038280 @el634dev and others