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

Index Out Of Range when running Demo.py #2

Open
Raja-Salman-Tariq opened this issue Jan 13, 2021 · 2 comments
Open

Index Out Of Range when running Demo.py #2

Raja-Salman-Tariq opened this issue Jan 13, 2021 · 2 comments

Comments

@Raja-Salman-Tariq
Copy link

Hi ! Your work's really interesting ! I was trying to run your demo.py though on my computer, but the programme crashed saying :

Traceback (most recent call last):
File "demo.py", line 75, in
img_copy[top_lip_coords[1]+i+y-20, left_lip_coords[0]+j+x-60] = santa_filter[i,j]
IndexError: index 480 is out of bounds for axis 0 with size 480

I suppose that this might have something to do with
(A) that I'm an absolute noob ( still hoping my issue isn't too naive), and
(B) frame size generated by my webcam is 640x480 ?

I also commented out some stuff from your training.py and read_data.py (which I felt weren't being used in the demo - they needed the training/test datasets) but am confident that's not the source of the issue.

Could you please guide where I might need to make changes so that the filter images are appropriately scaled and apply to my webcam's frames (and do not out-size them)?

Eager to hear from you, thank you for bearing with me !

@Raja-Salman-Tariq
Copy link
Author

Raja-Salman-Tariq commented Jan 13, 2021

I've used the below lines of code to see if I can get my cam's resolution upped (so I can at least with the glasses only ) using the following:
image

I verified if this is supported via :
image

This has had no effect though.

Edit: The glasses filter is working though, since its within my default resolution, but its quite glitchy...

@agrawal-rohit
Copy link
Owner

Hey @Raja-Salman-Tariq! I think you're correct about it being a video resolution issue. I was using a 1280x720 video feed from my webcam, while you are using a 640x480. This means that the manual pixel adjustments I was making for my feed, would not work for yours out of the box (as you can see from the error you're getting).

IndexError: index 480 is out of bounds for axis 0 with size 480

What this error is trying to tell you is that you are trying to access an index that is greater than your video frame array. There are 2 ways you can deal with this:

  1. You can stand farther away from your camera, which would make sure that the top_lip_coords and left_lip_coords (Used for the beard filter) are not near the edge of the video feed.
  2. You can reduce and tweak the values around the top_lip_coords (i.e. i, y, and 20) and left_lip_coords (i.e. j, x, 60).

Hope this helps :)

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

2 participants