Recent

Author Topic: Installing V4L Webcam software on my Ubuntu linux system  (Read 2148 times)

Curt Carpenter

  • Sr. Member
  • ****
  • Posts: 403
Installing V4L Webcam software on my Ubuntu linux system
« on: February 21, 2023, 03:10:51 am »
I recently installed the usb webcam software from fpcVideo4L2.zip ( https://github.com/uaply/fpcVideo4L2 ) on my Ubuntu18.04 (linux) PC.  To make it work on my system, I had to open a terminal and execute   sudo apt-get install -y libv4l-dev on my system .  With that, the demonstration program included in the .zip worked and displayed my camera output when I checked the "capture" box at the top of the demo's main form. 

Some of the controls in the demo don't appear to work but it's a good starting point and you can easily modify the demo to capture images from the camera.  This is the only lazarus webcam program I have been able to make work.

af0815

  • Hero Member
  • *****
  • Posts: 1291
Re: Installing V4L Webcam software on my Ubuntu linux system
« Reply #1 on: February 21, 2023, 03:46:40 pm »
Ist this the same ? https://github.com/afriess/fpcVideo4L2/tree/master/demos/DemoAlf

I work with such a soloution in production for years to make pictures from a videostream with industrieal usb cameras with upt 20mpx.

You can do it with gstreamer too and there are some soloutions (paid with acceptable fee) also working with lazarus, but you have to buy it with source code for fpc/lazarus. But v4l2 is relative easy to handle, you can say if the v4ldemo works, you can work with lazarus.
regards
Andreas

Curt Carpenter

  • Sr. Member
  • ****
  • Posts: 403
Re: Installing V4L Webcam software on my Ubuntu linux system
« Reply #2 on: February 22, 2023, 12:51:40 am »
Thanks for the link.  I believe they are the same, but the DemoAlf program is not included in the .zip I mentioned.  I will see if I can get DemoAlf working. 

The project options for DemoAlf needed to be configured to my system, and with that done I could compile it with no errors.  The unit YUV2RGB fails at runtime though, and it will take some effort to figure out what's going on.  The other demo project included in the .zip compiles and runs well on my system though, and is identical to the one I've been playing with.
« Last Edit: February 22, 2023, 02:53:06 am by Curt Carpenter »

af0815

  • Hero Member
  • *****
  • Posts: 1291
Re: Installing V4L Webcam software on my Ubuntu linux system
« Reply #3 on: February 22, 2023, 07:13:38 am »
One of the goals is, to have the correct converter for the raw data, and the package like YUV2RGB is such a converter. I had working with a camera delivery raw data in a Bayer Format. With the help from this forum and the german forum, it was possible to handle the data coming from the camera ( a model from https://www.theimagingsource.com/ ).
The working of controls depends on the capabilities of the camera. And this can be very very different from camera and used mode in the camera. The only way is to query the camera itself and then you will some parameters are not changeable or will be overwritten by the camera itself. And it can be funny, eg. you fix the framerate, the camera decide to change other parameters to fullfill the framerate, and if you change one of these parameters, the camera decide to change the framerate yet :-) If you dive deeper in the camera you see why this happens - the camera is in a semi auto mode. If you want to control all, you must find how you can switch the camera in a complete manual mode - but then you have to control all and deliver the correct parameters.

But cheap usb cameras have often only a small set of parameters. For control what is going on with the camera, the demo/viewer inside of the v4l2 package is helpful, because it shows the controlelemnts depending on the capabilities of the camera, you can test the different modes and raw data formats of the camera. One of the best tools if you work often with (usb) cameras   
regards
Andreas

Curt Carpenter

  • Sr. Member
  • ****
  • Posts: 403
Re: Installing V4L Webcam software on my Ubuntu linux system
« Reply #4 on: February 22, 2023, 05:10:24 pm »
Now that I can actually see video from my USB camera using the original demo, I begin to understand how v4l is organized.  It is the "hello world" program for using inexpensive webcams with fpc/lazarus :)

The problem with interrelated controls (change one control and three others are changed or need to be changed whether you like it or not!) is a problem with many instruments I've worked with, and I've never found a good way to deal with the problem in my software.  The v4l way of dealing with different control sets across many different cameras is interesting, and I will study it further.

af0815

  • Hero Member
  • *****
  • Posts: 1291
Re: Installing V4L Webcam software on my Ubuntu linux system
« Reply #5 on: February 22, 2023, 06:14:34 pm »
Now that I can actually see video from my USB camera using the original demo, I begin to understand how v4l is organized.  It is the "hello world" program for using inexpensive webcams with fpc/lazarus :)
Not correct, you can it for very expensive USB Camaeras too :-)

The goal is to know, what kind of rawdata you must proceed. you get from the camara raw data and have to transform it to a useable format. THis done in VideoFrameSynchronized , and this procedure is the heart. you get a buffer with anonymous bytes and you have to transform in your needed format normal you have some standard conversions with the types of V4L2_PIX_FMT_YUYV and V4L2_PIX_FMT_MJPEG . THis is used by the most cheaper usb-cams. But hight end cameras use more compley raw data and then you have to get the correct decoder.

To see what kind of format the camera use, i use the v4l2 demo.

But you can use gstreamer too.
« Last Edit: February 22, 2023, 06:16:31 pm by af0815 »
regards
Andreas

 

TinyPortal © 2005-2018