Author Topic: Use of webcam  (Read 78111 times)

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2092
  • Karma: +159/-0
    • View Profile
Re: Use of webcam
« Reply #60 on: June 08, 2020, 02:59:41 am »
Hi Dave,

Hi Paul, looking at it a bit harder, libuvc seems to require opencv https://opencv.org/, which doesn't look that easy to build. The Linux version requires GTK though it looks like on Windows it can use QT. Everything uses CMAKE by the looks of it.

On Ubuntu, all I need for a successful run of cmake was the install the latest libusb-1.0.0-dev package....

I forgot about libusb - that may need to be enhanced to support iso transfers too...

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2092
  • Karma: +159/-0
    • View Profile
Re: Use of webcam
« Reply #61 on: June 08, 2020, 03:01:50 am »
-- Found PkgConfig: u:/extras/bin/pkg-config.exe (found version "0.29.2")
-- libusb-1.0 found using pkgconfig
-- Found JPEG: u:/extras/lib/jpeg.lib (found version "62")
-- Found JPEG library using standard module
-- Found JPEG: u:/extras/lib/jpeg.lib
-- Building libuvc with JPEG support.
-- Configuring done
-- Generating done
-- Build files have been written to: U:/DEV/libuvc/build

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2092
  • Karma: +159/-0
    • View Profile
Re: Use of webcam
« Reply #62 on: June 08, 2020, 03:12:56 am »
Apparently libusb-1.0.16-rc6 is too old....

Ignoring unresolved externals reported from weak prelinker.
Error! E2028: _libusb_get_ss_endpoint_companion_descriptor is an undefined reference
Error! E2028: _libusb_free_ss_endpoint_companion_descriptor is an undefined reference

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2092
  • Karma: +159/-0
    • View Profile
Re: Use of webcam
« Reply #63 on: June 08, 2020, 03:17:30 am »
Apparently libusb-1.0.16-rc6 is too old....

Ignoring unresolved externals reported from weak prelinker.
Error! E2028: _libusb_get_ss_endpoint_companion_descriptor is an undefined reference
Error! E2028: _libusb_free_ss_endpoint_companion_descriptor is an undefined reference

yum had libusb 1.0.21

http://smedley.id.au/tmp/uvc.zip has an example.exe which presumably is supposed to show output from a supported webcam...

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2092
  • Karma: +159/-0
    • View Profile
Re: Use of webcam
« Reply #64 on: June 08, 2020, 08:43:55 am »
Anyone know where the source for libusb 1.0.21 is? I don't see it in the bww github, and the netlabs usb still has 1.0.16

I can't tell if ISO transfer are supposed to work or not in libusb. When I ported 1.0.16 the functionality wasn't available in usbcalls - I guess this has changed now given Wim's success.

Wim Brul

  • Sr. Member
  • ****
  • Posts: 295
  • Karma: +25/-0
    • View Profile
    • Wim's home page
Re: Use of webcam
« Reply #65 on: June 08, 2020, 01:33:38 pm »
I can't tell if ISO transfer are supposed to work or not in libusb. When I ported 1.0.16 the functionality wasn't available in usbcalls - I guess this has changed now given Wim's success.
Right. From my notes: The 1.0.16 libusb 1.0 implementation for OS/2 by Paul Smedley supports synchronous transfers. The application gets control back when the transfer request has been completed. But this is not the way the original libusb 1.0 has been designed. It actually supports asynchronous transfers. The application gets control back already when the transfer request has been submitted. The application gets notified later on when that transfer request has been completed by means of a callback function.

For that to work I produced matched sets of usbcalls.dll and usbresmg.sys that are backwards compatible. I removed old code for functions that were never properly supported and added new code to support asynchronous transfers. I reworked existing code to make synchronous transfer functions work well again (these actually are using the asynchronous transfer functions). After that I added code to support isochronous  transfers. I also implemented the REXX/2 External Functions. Since then these changes have been incorporated into the ArcaOS and the Lars Erdmann USB driver sets.

I have attached usbcalls-info.zip containing the USBCALLS - API Reference Guide and the USBCALLS - REXX/2 Reference Guide.

Wim Brul

  • Sr. Member
  • ****
  • Posts: 295
  • Karma: +25/-0
    • View Profile
    • Wim's home page
Re: Use of webcam
« Reply #66 on: June 09, 2020, 10:10:23 am »
Anyone know where the source for libusb 1.0.21 is? I don't see it in the bww github, and the netlabs usb still has 1.0.16

Perhaps ports - Revision 2376:/libusb1/vendor/1.0.21 ?

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2092
  • Karma: +159/-0
    • View Profile
Re: Use of webcam
« Reply #67 on: June 09, 2020, 11:53:51 am »
Hi Wim,

Anyone know where the source for libusb 1.0.21 is? I don't see it in the bww github, and the netlabs usb still has 1.0.16

Perhaps ports - Revision 2376:/libusb1/vendor/1.0.21 ?

Thanks! That's the original vendor code, but looks like http://svn.netlabs.org/repos/ports/libusb1/trunk/ is updated.

FFS the 1.0.16 was deliberatly put in the netlabs USB repository, yet someone decides to clone it and stick it somewhere else.

Anyway, looking at http://svn.netlabs.org/repos/ports/libusb1/trunk/libusb/os/os2_usb.c confirms that isosynchronous isn't supported yet... A possible job for the weekend :)

Cheers,

Paul

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2092
  • Karma: +159/-0
    • View Profile
Re: Use of webcam
« Reply #68 on: June 13, 2020, 11:31:24 am »
OK I have libusb 1.0.21 compiling locally and  get the same results with example.exe with both a locally built libusb and the yum installed one:
UVC initialized
Device found
uvc: device has a status interrupt endpoint, but unable to read from it
uvc_open: Unknown error (-99)
UVC exited

Lars

  • Hero Member
  • *****
  • Posts: 1271
  • Karma: +65/-0
    • View Profile
Re: Use of webcam
« Reply #69 on: June 14, 2020, 07:24:58 pm »
By the way: can I remove USBLIB from the Netlabs USB repository or is this still needed ? I'd like to remove it in order to avoid any confusion of where the latest version would be.

Regards,
Lars

Wim Brul

  • Sr. Member
  • ****
  • Posts: 295
  • Karma: +25/-0
    • View Profile
    • Wim's home page
Re: Use of webcam
« Reply #70 on: June 14, 2020, 08:31:10 pm »
Hi Rémy,

Derived from weblook I concocted "WebCam Server for OS/2 (ArcaOS/eComStation)". See WebCam.txt for parameters. See xplay.cmd for use with ffplay.

Acting as an HTTP server for mjpg video is the default. Use "webcam /n" to video stream to named pipe. Use "webcam /s" to video stream to stdout.

CAUTION: This is beta test software! May only be used at your own risk!

Best regards,
Wim.

Remy

  • Hero Member
  • *****
  • Posts: 645
  • Karma: +9/-1
    • View Profile
Re: Use of webcam
« Reply #71 on: June 14, 2020, 10:44:10 pm »
Hi Rémy,

Derived from weblook I concocted "WebCam Server for OS/2 (ArcaOS/eComStation)". See WebCam.txt for parameters. See xplay.cmd for use with ffplay.

Acting as an HTTP server for mjpg video is the default. Use "webcam /n" to video stream to named pipe. Use "webcam /s" to video stream to stdout.

CAUTION: This is beta test software! May only be used at your own risk!

Best regards,
Wim.

Hi Wim,

No sound and only video from what I could test.

I tested all options and got video in all cases
video was ok too from webpage pointing to the http webcam server.
I've got repeated message by ffplay but this seems to be normal using logitec webcam
( [mjpeg @ 0x2fba80] unable to decode APP fields )

found: https://stackoverflow.com/questions/55439184/getting-unable-to-decode-app-fields-while-playing-usb-webcam-stream-through-ff
"The mjpeg stream contains a sequence of jpeg images, some are key frames, the complete image, and some are other frames such as delta frames, describing the differences between frames. What Logitech does is embed an H264 stream into the mjpeg stream by attaching H264 data onto the jpeg frames as APP attachments, i.e. it's a stream within a stream"

I did some test with ffmpeg and could record video in different codec.
Adding the video copy frames to mp4 output prevents of getting lot of [mjpeg @ 0x2fba80] unable to decode APP fields message

webcam /s | ffmpeg -f mjpeg -framerate 30 -i - -y -c:v copy -f rawvideo test.mpg
webcam /s | ffmpeg -f mjpeg -framerate 30 -i - -y -t 10s -c:v copy -f mp4 test.mp4   (here, I limited recording to 10s)
webcam /s | ffmpeg -f mjpeg -framerate 30 -i - -y test.avi

I could see that adding a "-" after the /s parm has no effect and this is good to have a syntax like with other programs.
e.g.  webcam /s - | ffmpeg -f mjpeg -framerate 30 -i - -y h264.avi
May be  webcan could be updated to use  - as a generic parm for /s , could it be done ?

Great work.
Regards
Rémy   

PS: It looks using a lot of CPUs (between 20% and 45% on 3 of 4 CPUs which looks to be very high ! any idea why ? 
« Last Edit: June 14, 2020, 10:51:55 pm by Remy »

Remy

  • Hero Member
  • *****
  • Posts: 645
  • Karma: +9/-1
    • View Profile
Re: Use of webcam
« Reply #72 on: June 15, 2020, 09:29:36 pm »
Hi Wim,

Output is 640x480
How to get 480p and 720p out of the webcam which is able to deliver 720p ?
Could an additional parm provide this option e.g.  /r480  or /r720 ?  (r for resolution)

Could I get video from http and stdout at the same time ?
(this would allow record the video "via stdout" and play it during recording 'http')

Best regards
Rémy

Playing  with the command, ffplay allows to correct some parms e.g.
webcam /s | ffplay -f mjpeg -framerate 30 -vf eq=gamma_r=1:gamma_b=1.02:gamma_g=1.04:gamma=1.05:contrast=1.06:brightness=0.04:saturation=1.6 -window_title WebCam -i -

Update: New test gives now a very low CPU utilization (nearly 4% on one CPU - didn't find what's wrong during first tests)

tested a quick and simple webCam control GUI  (rxutilex required - base installed under ArcaOS)
(big button to toggle on/off WebCam under whish are a show button for ffplay 640x480 and a smaller [ ] button for a small 160x120 display)
- ffplay supposed been under a path from path statement  (if not, then put wcc under ffplay path)
wcc var1 var2 var3
var1: can be TL TR BL BR  (screen corner position)
var2: only choice between /h or /n
var3: WebCam.exe path only

gui updated and added:
Update alpha 2 : rxutilex.dll required (this dll is base installed under ArcaOs)
- RMB click between webcam on/off button and [] button opens a parameter dialog
  These parameters are used with ffplay displaying output from the webcam
  > gamma
  > gamma red
  > gamma green
  > gamma blue
  > brightness
  > contrast
  > saturation
  > Show video size (max size)
  > reduced video size (min size)

Hi Wim, may this small gui be usefull ?

Updt: just succeffully tested a Logitech QuickCam Pro 9000 (colors balance, brightness, contrast are better but with a visible delay and not   as smooth as c270) 
(high resolution up to 1600x1200) - Of course, webcam only sends 640x480 mjpegs (could it be increased ?)
« Last Edit: June 17, 2020, 05:20:30 pm by Remy »

Roderick Klein

  • Hero Member
  • *****
  • Posts: 655
  • Karma: +14/-0
    • View Profile
Re: Use of webcam
« Reply #73 on: June 15, 2020, 11:27:19 pm »
By the way: can I remove USBLIB from the Netlabs USB repository or is this still needed ? I'd like to remove it in order to avoid any confusion of where the latest version would be.

Regards,
Lars

Well where is the code stored then ??

Roderick

Lars

  • Hero Member
  • *****
  • Posts: 1271
  • Karma: +65/-0
    • View Profile
Re: Use of webcam
« Reply #74 on: June 17, 2020, 06:56:47 am »
Read Paul's answer:

1) it is stored here (Netlabs "PORTS" repo):
 http://svn.netlabs.org/repos/ports/libusb1/trunk/

2) bww have their own updated version in their github account

Another good example where things drift apart.


Lars