Recent

Author Topic: Capture Frame from camera in Windows  (Read 4248 times)

Dzandaa

  • New Member
  • *
  • Posts: 41
Capture Frame from camera in Windows
« on: January 18, 2022, 01:23:13 pm »
 Hi everybody,

 Working with Lazarus Pascal 2.012 FPC 2.3.0 on Windows, Linux and MacOS

Is there a good solution to grab a frame from a camera in windows with examples.

In Linux I have the 5dpo Component Library TSdpoVideo4L2 that work fine and easy to grab a frame from a WebCam,
but I didn't found an equivalent for Windows where all solution depends of external programs like VLC or MPlay...

Thank you.




af0815

  • Hero Member
  • *****
  • Posts: 937
Re: Capture Frame from camera in Windows
« Reply #1 on: January 18, 2022, 07:24:24 pm »
In windows you can use directshow for it.
regards
Andreas

Dzandaa

  • New Member
  • *
  • Posts: 41
Re: Capture Frame from camera in Windows
« Reply #2 on: January 22, 2022, 03:04:34 pm »
Hi,

What library do I need?
I'm on Windows 64 Bits.

Do you have an example for Lazarus?

Thank you.

af0815

  • Hero Member
  • *****
  • Posts: 937
Re: Capture Frame from camera in Windows
« Reply #3 on: January 22, 2022, 04:47:03 pm »
i'm too. For me this works. https://github.com/afriess/fpcVideo4L2/tree/master/demos/DemoAlf

Sone info. Look for DSPack.
https://forum.lazarus.freepascal.org/index.php?topic=16797.0

There are some Libs like RVMedia, this works too, but is not for free, but have a good support
https://forum.lazarus.freepascal.org/index.php/topic,46562.msg355599.html#msg355599
regards
Andreas

Dzandaa

  • New Member
  • *
  • Posts: 41
Re: Capture Frame from camera in Windows
« Reply #4 on: January 22, 2022, 08:23:03 pm »
Hi,

Thank you,

I also fond the DSPack library, but not a working example.

All I found was for Delphy and there are some missing Definition (or different)

I'll look at your link.

I'm converting one of my C# program to Pascal Lazarus (3D digitizer with a camera and 4 lasers)
On Linux, I have a library that can grab frames from a WebCam,
but I'm also looking for a similar Windows solution.



af0815

  • Hero Member
  • *****
  • Posts: 937
Re: Capture Frame from camera in Windows
« Reply #5 on: January 22, 2022, 08:29:17 pm »
On win i use DSPack (DirectShow) on Linux v4l(2). I have tested gestreamer too. It can work on Linux and Windows, but i have to insert more manpower ( i have this actual not), to make a working sample for the community. It is possible (i have done some tests here https://github.com/afriess/GSTCamera/tree/master/pasgst/demos/GstreamerOnly ).
« Last Edit: January 22, 2022, 08:33:23 pm by af0815 »
regards
Andreas

Dzandaa

  • New Member
  • *
  • Posts: 41
Re: Capture Frame from camera in Windows
« Reply #6 on: January 23, 2022, 06:09:36 pm »
Thank you very much.

I cannot open the .lpi of /fpcVideo4L2/tree/master/demos/DemoAlf that freeze my Lazarus, but I found interesting things in the .pas files :)

No success with DSPack until now, I didn't find a working example for Lazarus to capture a Frame.

But as the goal is to convert C# Windows programs to Pascal Linux programs, I don't care a lot :)

Its easier with the Accord library on C# with Microsoft Visual Studio :)


af0815

  • Hero Member
  • *****
  • Posts: 937
Re: Capture Frame from camera in Windows
« Reply #7 on: January 23, 2022, 06:15:01 pm »
I cannot open the .lpi of /fpcVideo4L2/tree/master/demos/DemoAlf that freeze my Lazarus, but I found interesting things in the .pas files :)

No success with DSPack until now, I didn't find a working example for Lazarus to capture a Frame.
Two questions - what is your version of Lazarus ? And have you the needed Packages installed, before you open the package ?

Edit: It was not my day: https://github.com/afriess/LazarusVideoUtilities.git and there the branch WIP_andi is the correct one. Sorry fpcVideo4L2 is for Linux only - this is the reason for not working.

in the dir ....\LazarusVideoUtilities\Packages\Laz_Win_DSPack is the needed Laz_win_DS_Pack and in ....\LazarusVideoUtilities\Packages\Laz_Win_DirectX is the needed Laz_Win_DirectX package.

Laz_Win_DSPack should installed to Lazarus. The directX should not installed, only compiled. Both should work with Lazarus 2.2.

After this the samples should work. I can compile it on my system now under win10.

Sorry, but i was blind and working the last time only on Linux (Raspian) so  i have overseen it was V4L, dor DirectX. After the correct installtion you shoul see the new Components on your palette.

One interesting link : http://www.vwlowen.co.uk/directshow/page01.htm
« Last Edit: January 23, 2022, 06:35:31 pm by af0815 »
regards
Andreas

Dzandaa

  • New Member
  • *
  • Posts: 41
Re: Capture Frame from camera in Windows
« Reply #8 on: January 24, 2022, 12:53:44 pm »
Hi again,

Thank you very much.

I'm Using Pascal Lazarus 2.0.12 FPC 3.2.0

I already realized that the examples for Video4L2 are for Raspbian :)
I'm on Linux Mint 2.0 and Windows 7 pro 64bit (I also have a Windows 10, but I don't use it a lot)

I used 5DPO Video Library, but fpcVideo4L2 seems to be more complete.

https://sourceforge.net/projects/sdpo-cl/

The fpcVideo4L2 Demo is running on my Linux Mint.


I'll try DSPack tomorrow.

Thank you again!!!






af0815

  • Hero Member
  • *****
  • Posts: 937
Re: Capture Frame from camera in Windows
« Reply #9 on: January 24, 2022, 01:01:43 pm »
BTW: I have a experimental version of gstreamer too. This can work in Linux and Win, because gstreamer is available for this platforms. :-)

DirectShow have a Limit in Videosize, it cannot handle IMHO 4K Resolution, but this is by design in windows. If you want to make some tests in windows, so use graphedt(_x84) or graphstudionext(64) . All what can build with this graphical tools is possible in Lazarus too, with the knowledge of the correct programming of the componnets. I have used this tools always as a starter and than build this later with lazarus in code.
regards
Andreas

Dzandaa

  • New Member
  • *
  • Posts: 41
Re: Capture Frame from camera in Windows
« Reply #10 on: January 24, 2022, 04:14:58 pm »
Hi,

Thank you again,

Gstreamer is perhaps another solution, I just want to grab a Frame, convert it in BGRABitmap, rotate it and make some computation on it.

The resolution is fixed: 1280x720 YUYV mode.

At the moment, I have a solution working in Linux with fpcVideo4L2.

Would be better if I can run on Linux AND Windows, but as I said, I've already a working Windows program written in C#.

I'll take a look to GStreamer.




winni

  • Hero Member
  • *****
  • Posts: 3057
Re: Capture Frame from camera in Windows
« Reply #11 on: January 24, 2022, 04:37:52 pm »
Hi!

There is no component for it, but ffmpeg is the swiss knife for Linux and Windows.

How to extract a frame you'll find here:

https://superuser.com/questions/1009969/how-to-extract-a-frame-out-of-a-video-using-ffmpeg


That can be achieved with runcommand from unit process.

That reduces the overhead of all the players.

Winni

 

TinyPortal © 2005-2018