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

Port to OpenCV 4.6.0 #38

Merged
merged 6 commits into from
Nov 9, 2022
Merged

Port to OpenCV 4.6.0 #38

merged 6 commits into from
Nov 9, 2022

Conversation

silhusk
Copy link
Contributor

@silhusk silhusk commented Oct 23, 2022

No description provided.

@discordianfish
Copy link

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
Copy link
Contributor Author

silhusk commented Oct 24, 2022

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


#if defined(linux)
// FIXME(silhusk): reimplement for `frame` instead of `pImage`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this conversion still needed? Doesn't ocv take care itself? We don't get any such information form a cv::Mat, we would have to check camera properties in advance.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure. This was for an old camera model, perhaps is safe to delete it.

(pImg->nChannels== 3 &&
((pImg->channelSeq[0]== 'R' && pImg->channelSeq[1]== 'G' && pImg->channelSeq[2]== 'B') ||
(pImg->channelSeq[0]== 'B' && pImg->channelSeq[1]== 'G' && pImg->channelSeq[2]== 'R')),
wxASSERT_MSG (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have any information about the format here. Does the assertion make any sense?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so.

}

bool CCameraWDM::DoQueryFrame(CIplImage& image)
bool CCameraWDM::DoQueryFrame(cv::Mat &frame)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are native drivers still relevant or can they be dropped entirely? The driver selection seems to be hard-coded to opencv.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure

@jjsarton
Copy link

jjsarton commented Nov 8, 2022

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
Copy link
Contributor Author

silhusk commented Nov 8, 2022

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
Copy link

jjsarton commented Nov 9, 2022

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
Copy link

jjsarton commented Nov 9, 2022

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.

cmauri
cmauri approved these changes Nov 9, 2022
@cmauri cmauri marked this pull request as ready for review November 9, 2022 15:45
@cmauri cmauri merged commit a4032ed into cmauri:master Nov 9, 2022
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

Successfully merging this pull request may close these issues.

None yet

4 participants