hacksider / Deep-Live-Cam

real time face swap and one-click video deepfake with only a single image
GNU Affero General Public License v3.0
34.78k stars 4.9k forks source link

[experimental] doesn't show the camera I want.. #243

Open b3ck opened 1 month ago

b3ck commented 1 month ago

I'm using the experimental branch so I could choose the camera I wanted (OBS Virtual Camera) which is (2) but it only shows "Camera 0", so I made a test script and I was able to pull my OBS Virtual Camera using 'matplotlib',

(venv) (base) PS E:\deep-live-cam> python list.py
[ WARN:0@10.769] global cap_msmf.cpp:1769 CvCapture_MSMF::grabFrame videoio(MSMF): can't grab frame. Error: -2147483638
[ WARN:0@10.839] global cap.cpp:304 cv::VideoCapture::open VIDEOIO(DSHOW): raised OpenCV exception:

OpenCV(4.10.0) D:\a\opencv-python\opencv-python\opencv\modules\videoio\src\cap_dshow.cpp:2763: error: (-215:Assertion failed) pVih in function 'videoInput::start'

[ERROR:0@10.846] global obsensor_uvc_stream_channel.cpp:158 cv::obsensor::getStreamChannelGroup Camera index out of range
[ERROR:0@16.478] global obsensor_uvc_stream_channel.cpp:158 cv::obsensor::getStreamChannelGroup Camera index out of range
[ERROR:0@16.563] global obsensor_uvc_stream_channel.cpp:158 cv::obsensor::getStreamChannelGroup Camera index out of range
[ERROR:0@16.635] global obsensor_uvc_stream_channel.cpp:158 cv::obsensor::getStreamChannelGroup Camera index out of range
[ERROR:0@16.711] global obsensor_uvc_stream_channel.cpp:158 cv::obsensor::getStreamChannelGroup Camera index out of range
[ERROR:0@16.787] global obsensor_uvc_stream_channel.cpp:158 cv::obsensor::getStreamChannelGroup Camera index out of range
[ERROR:0@16.862] global obsensor_uvc_stream_channel.cpp:158 cv::obsensor::getStreamChannelGroup Camera index out of range
Available camera indices: [2]
Enter the camera index you want to use: 2
Camera 2 opened successfully. Press 'q' to quit.
Press 'q' and Enter to quit, or just Enter to continue: q
(venv) (base) PS E:\deep-live-cam>

It shows up like this:

Screen Shot 2024-08-12 at 8 31 51 PM

So I know it's possible, is there a way to force 'deep-live-cam' to use "Camera (2)" ?

b3ck commented 1 month ago

I did another test with this code and it worked:

import cv2

cap = cv2.VideoCapture(2)

if not (cap.isOpened()):
    print("Could not open video device")

while True:
    ret, frame = cap.read()
    cv2.imshow("Live", frame)
    cv2.waitKey(1)

cv2.destroyAllWindows()
cap.release()

But still unable to get 'deep-live-cam' working with it.

b3ck commented 1 month ago

got it working, just changed line 322 in ui.py

cap = cv2.VideoCapture(camera_index)

to

cap = cv2.VideoCapture(2)

bamjun commented 1 month ago

@b3ck there is no line 322 in ui.py https://github.com/hacksider/Deep-Live-Cam/blob/main/modules/ui.py

b3ck commented 1 month ago

@bamjun

checkout the experimental branch and there will be =) https://github.com/hacksider/Deep-Live-Cam/tree/experimental

Screen Shot 2024-08-12 at 9 56 07 PM