External USB camera support

Using digital endoscopes during medical examinations are more and more a daily practice nowadays.

Would it be possible to create support for an OTG adapter in order to operate an external USB camera?

Why?
For those who are unknown with the daily work of a equine dentistry vet, we use iPads, Android phones etc, in combination with our endoscopes for the field work. Not all medical treatments and exams/diagnostics are done in a clinic, often we need to go in the field outside or in stables.

3 Likes

No way actual medical equipment is bring-your-own-phone. Garage stuff, sure… But i guess that’s besides the point.

Yes, of course. Maybe some 3rd-party camera app already supports it or could be tweaked.
I made a thermal camera app, copying that and peeling away all the thermal stuff would work.
So why don’t i do that? Well, a CHUM-only app that depends on OpenCV would not be very accessible to the average user. It also doesn’t record, so better it gets baked in to something more camera-focused.

Au contraire, for example there are multiple portable ultrasound heads for mobile phone or tablet. By now these are around for at least 10 years, iirc the earlier models used cable connection t iphone, by now they work via wifi.
so definitely a thing , and potentially a challenge for sfos.

For those who are unknown with the daily work of a equine dentistry vet, we use iPads, Android phones etc, in combination with our endoscopes for the field work. Not all medical treatments and exams/diagnostics are done in a clinic, often we need to go in the field outside or in stables.
So, if you are not familiar with the topic, maybe you could ask questions instead of giving a judgment.

4 Likes

You should check available stores at first. PipeCam is the first at Openrepos after put ‘usb camera’ in search.

Thanks for pointing me out.

I installed PipeCam on my Jolla 2 withtout problems.

The program though cannot find the endoscope USB camera while on Android devices, iPads and PC’s it has never be a problem.
Is there something I can do on my side? (The camera gets powered with 5V, I can see that)

The camera is a standard Sony IMX179 USB camera

Maybe it is an idea to ask the author of Pipecam, I think he might be quite responsive

If I plug a standard USB-C webcam into the USB port of the Jolla phone, the list of /dev/video* expands, suggesting one can be optimistic about the Linux side recognising standard webcameras you’ve plugged in.

Tested a chinese endoscope camera with the jp2, I can see the camera and it adds /dev/video3, /dev/video4

# lsusb
Bus 001 Device 002: ID 1bcf:0b15 Sunplus Innovation Technology Inc. SPCA2650 PC Camera

However there is nothing on the device to do much with it by default. (And I also tried the various apps on the various repos, but I think their issue is that they are not for general display of v4l2 devices.)

If you have v4l2-ctl you could query the cameras etc, but it is not available by default on sfos.

There seems to be a v4l-utils package for sfos (GitHub - sailfishos-native/v4l-utils: libv4l2 packaging for mer-core · GitHub) but build.sailfishos.org is down, so I compiled it myself with sailfish-sdk build-engine:

git clone https://github.com/sailfishos-native/v4l-utils.git
cd v4l-utils/
git submodule update --init --recursive
/path/to/sailfish-sdk/bin/sfdk -c target="SailfishOS-5.1.0.11-aarch64" build-init
/path/to/sailfish-sdk/bin/sfdk -c target="SailfishOS-5.1.0.11-aarch64" -c specfile=rpm/v4l-utils.spec build

and copied them from the dir RPMS/ to the phone and installed:

pkcon install-local libv4l-1.26.1+git3-1.aarch64.rpm libdvbv5-1.26.1+git3-1.aarch64.rpm v4l-utils-1
.26.1+git3-1.aarch64.rpm

And I could query the device:

# v4l2-ctl -d 3 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
	Type: Video Capture

	[0]: 'MJPG' (Motion-JPEG, compressed)
		Size: Discrete 1280x720
			Interval: Discrete 0.067s (15.000 fps)
		Size: Discrete 1280x712
			Interval: Discrete 0.067s (15.000 fps)
		Size: Discrete 1280x480
			Interval: Discrete 0.050s (20.000 fps)
		Size: Discrete 640x480
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 640x472
			Interval: Discrete 0.033s (30.000 fps)
	[1]: 'YUYV' (YUYV 4:2:2)
		Size: Discrete 1280x720
			Interval: Discrete 0.100s (10.000 fps)
		Size: Discrete 1280x712
			Interval: Discrete 0.100s (10.000 fps)
		Size: Discrete 1280x480
			Interval: Discrete 0.100s (10.000 fps)
		Size: Discrete 640x480
			Interval: Discrete 0.100s (10.000 fps)
		Size: Discrete 640x472
			Interval: Discrete 0.100s (10.000 fps)

Now that I identified the correct dev, I tried to show the image with gst-launch-1.0 v4l2src device=/dev/video3 ! autovideosink and it seems to correctly turn on etc. but the video stream did not appear anywhere on sfos.

I managed to save a stream to a .avi though with gst-launch-1.0 v4l2src device=/dev/video3 ! jpegenc ! avimux ! filesink location=test.avi. It played fine with mvp with my quick testing.

Update: I messed with the camera on the computer and on the phone. I made an sfos test app to query camera apis, and did similiar qml app on the linux pc. On the pc the usb camera shows up on the camera list, but not on phone. I could view the camera on the pc qml application.

On further inspection, on the PC the QMultimedia camera API only gave me the YUYV pixel format, and it could not be changed to the cameras mjpeg.

All this to say that in any case, Qt API seems limited for these v4l2 cameras, however gstreamer can set the format, here again we save to .avi but use the MJPEG format:

gst-launch-1.0 v4l2src device=/dev/video3 ! "image/jpeg,width=1280,height=712,framerate=15/1" ! avimux ! filesink location=test.avi

(On this camera the different resolution/fps combos gotten via v4l2-ctl -d 3 --list-formats-ext switch between 2 camera lenses, so this way we can get image of each lens)

Now there remains the issue of displaying the realtime image. As I understand it might be possible to get the gstreamer directly to a qml app somehow, but I have yet to research it. Any pointers?