cmauri / eviacam

webcam based mouse emulator
GNU General Public License v3.0
145 stars 38 forks source link

Port to OpenCV 4.6.0 #38

Closed silhusk closed 1 year ago

discordianfish commented 1 year ago

Ah great someone is trying to update this. I just successfully built your branch on ubuntu 22.04. Unfortunately it's still not working for me:

$ eviacam
[libwebcam] Invalid V4L2 control type encountered: ctrl_id = 0x00980001, name = 'User Controls', type = 6
[libwebcam] Invalid or unsupported V4L2 control encountered: ctrl_id = 0x00980001, name = 'User Controls'
[libwebcam] Invalid V4L2 control type encountered: ctrl_id = 0x009A0001, name = 'Camera Controls', type = 6
[libwebcam] Invalid or unsupported V4L2 control encountered: ctrl_id = 0x009A0001, name = 'Camera Controls'
[libwebcam] Invalid V4L2 control type encountered: ctrl_id = 0x00980001, name = 'User Controls', type = 6
[libwebcam] Invalid or unsupported V4L2 control encountered: ctrl_id = 0x00980001, name = 'User Controls'
[libwebcam] Invalid V4L2 control type encountered: ctrl_id = 0x009A0001, name = 'Camera Controls', type = 6
[libwebcam] Invalid or unsupported V4L2 control encountered: ctrl_id = 0x009A0001, name = 'Camera Controls'
[ WARN:0] global ./modules/videoio/src/cap_gstreamer.cpp (1100) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
[ WARN:0] global ./modules/videoio/src/cap_gstreamer.cpp (2075) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module v4l2src1 reported: Device '/dev/video1' is not a capture device.
[ WARN:0] global ./modules/videoio/src/cap_gstreamer.cpp (1053) open OpenCV | GStreamer warning: unable to start pipeline
[ WARN:0] global ./modules/videoio/src/cap_gstreamer.cpp (616) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
[ WARN:0] global ./modules/videoio/src/cap_v4l.cpp (890) open VIDEOIO(V4L2:/dev/video1): can't open camera by index

(eviacam:58547): Gtk-CRITICAL **: 13:01:07.034: gtk_widget_get_scale_factor: assertion 'GTK_IS_WIDGET (widget)' failed
Segmentation fault (core dumped)

Also, looks like no matter which camera I select, it tries to open /dev/video1.. both webcams connected are working fine in chrome

silhusk commented 1 year ago

Thank you for testing! You can try eviacam --debug to better see which cameras are found. It enumerates cameras starting from 0, which is the "default camera". So on my system, which has only one, it finds two. And although they should be the same device, only one of them is working (ID 0). My output (below) is similar, so I'm not sure the warning is indicating any problem. The segfault is much more concerning. Could you run it with gdb and see where it fails?

P.S.: Did you install before running? If I don't, I get assert "wxDynamicCast(ptr, T)" failed in wxCheckCast() which could be a segfault. For instance:

./autogen.sh
./configure --enable-debug --prefix=/home/neon/eviacam/build/
make install
./build/bin/eviacam
neon@kubuntu-2004:~/eviacam$ ./build/bin/eviacam 
[libwebcam] Unknown V4L2 camera class (UVC) control ID encountered: 0x009A0912 (V4L2_CID_CAMERA_CLASS_BASE + 18)
DEBUG:   Opened device 'video0' successfully (handle = 1)
...
DEBUG:   Closed device 'video1' (handle = 0)

INFO: Detected 2 camera(s)

(eviacam:3258): Gtk-CRITICAL **: 20:31:39.075: gtk_box_gadget_distribute: assertion 'size >= 0' failed in GtkScrollbar
INFO: Selected camera: 0
INFO: Try to open the camera to make sure it works...
[ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (935) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
[ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (1758) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module v4l2src1 reported: Device '/dev/video1' is not a capture device.
[ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (888) open OpenCV | GStreamer warning: unable to start pipeline
[ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
[ WARN:0] global ../modules/videoio/src/cap_v4l.cpp (887) open VIDEOIO(V4L2:/dev/video1): can't open camera by index
jjsarton commented 1 year ago

I have compiled the silhusk feat/openc4-460 and tested it. I have 7 camera device video0 and video1 the integrated camera, video2 and video3 a USB camera and video10, video11, video12 which are virtual cams. The device ls presented at the firsts start (on no ~/.eviacam present, seem to be wrong. If I don't chhose the first device in the list (the USB camera) eviacam end. If I choose the USB camera, eviacam work, but with the integrated camera (m_id = 0). The parameter passed to cv::VideoCapture seem to be wrong.

silhusk commented 1 year ago

The device ls presented at the firsts start (on no ~/.eviacam present, seem to be wrong. If I don't chhose the first device in the list (the USB camera) eviacam end. If I choose the USB camera, eviacam work, but with the integrated camera (m_id = 0).

Does this happen only on this branch and not in master? The device list is populated by enumerating the "native driver" but then the same index is used with the opencv driver. This could lead to inconsistencies. But this mode of device discovery shouldn't have changed between the two branches. If you can confirm that it happens in master maybe that's the cause and we can fix it there.

jjsarton commented 1 year ago

I had to modify the file viacamcontroller.cpp, line 252 from

CCamera* cam = CCameraEnum::getCamera(1, camId);

to

CCamera* cam = CCameraEnum::getCamera(0, camId);

The value 1 mean CAMERA_CV_ID and not NATIVE_CAM_CLASS as used in order to get the devices list.

jjsarton commented 1 year ago

The native enumeration tell the following:

DEBUG:   Opened device 'video10' successfully (handle = 1)
DEBUG:     { shortName = 'video10', name = 'virt10', driver = 'v4l2 loopback', location = 'platform:v4l2loopback-000', vid = 0000, pid = 0000, bcd = 0 }
DEBUG:   Closed device 'video10' (handle = 0)

DEBUG:   Opened device 'video0' successfully (handle = 2)
DEBUG:     { shortName = 'video0', name = 'Integrated_Webcam_HD: Integrate', driver = 'uvcvideo', location = 'usb-0000:00:14.0-3', vid = 0bda, pid = 565c, bcd = 33366 }
DEBUG:   Closed device 'video0' (handle = 0)

DEBUG:   Opened device 'video12' successfully (handle = 3)
DEBUG:     { shortName = 'video12', name = 'virt12', driver = 'v4l2 loopback', location = 'platform:v4l2loopback-002', vid = 0000, pid = 0000, bcd = 0 }
DEBUG:   Closed device 'video12' (handle = 0)

DEBUG:   Opened device 'video2' successfully (handle = 4)
DEBUG:     { shortName = 'video2', name = 'C922 Pro Stream Webcam', driver = 'uvcvideo', location = 'usb-0000:00:14.0-9.1', vid = 046d, pid = 085c, bcd = 22 }
DEBUG:   Closed device 'video2' (handle = 0)

DEBUG:   Opened device 'video11' successfully (handle = 5)
DEBUG:     { shortName = 'video11', name = 'virt11', driver = 'v4l2 loopback', location = 'platform:v4l2loopback-001', vid = 0000, pid = 0000, bcd = 0 }
DEBUG:   Closed device 'video11' (handle = 0)

DEBUG:   Opened device 'video1' successfully (handle = 6)
DEBUG:     { shortName = 'video1', name = 'Integrated_Webcam_HD: Integrate', driver = 'uvcvideo', location = 'usb-0000:00:14.0-3', vid = 0bda, pid = 565c, bcd = 33366 }
DEBUG:   No controls found (ret = 0).
DEBUG:   Closed device 'video1' (handle = 0)

DEBUG:   Opened device 'video3' successfully (handle = 7)
DEBUG:     { shortName = 'video3', name = 'C922 Pro Stream Webcam', driver = 'uvcvideo', location = 'usb-0000:00:14.0-9.1', vid = 046d, pid = 085c, bcd = 22 }
DEBUG:   No controls found (ret = 0).
DEBUG:   Closed device 'video3' (handle = 0)

INFO: Detected 7 camera(s)

The list presented within the chooser is:

ID:0 -> C922 Pro Stream Webcam                 vide03
ID:1 -> Integrated_Webcam_HD: IntegrateI       video1
ID:2 -> virt11                                 video11
ID:3 -> C922 Pro Stream Webcam                 video2
ID:4 -> virt12                                 video12
ID:5 -> Integrated_Webcam_HD: Integrate        video0
ID:6 -> virt10                                 video10

This order is strange and it will probably possible to eliminate the entries which don't have controls.