opencv-facial-filters
opencv-facial-filters copied to clipboard
Index Out Of Range when running Demo.py
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
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 !
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:
I verified if this is supported via :
This has had no effect though.
Edit: The glasses filter is working though, since its within my default resolution, but its quite glitchy...
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:
- You can stand farther away from your camera, which would make sure that the
top_lip_coords
andleft_lip_coords
(Used for the beard filter) are not near the edge of the video feed. - You can reduce and tweak the values around the
top_lip_coords
(i.e. i, y, and 20) andleft_lip_coords
(i.e. j, x, 60).
Hope this helps :)