Recent

Author Topic: DSPack for Lazarus - Win32 DirectShow Multimedia components  (Read 80889 times)

Gyuri

  • Newbie
  • Posts: 5
Re: DSPack for Lazarus - Win32 DirectShow Multimedia components
« Reply #45 on: April 16, 2015, 04:18:23 pm »
Hello to All,

I apologise if my post sounds too simple for some of you, but I am a novice in Pascal programming.

I am testing a USB camera with DirectShow, using the DSPACK, and I encountered some problems.
I can visualise the live picture of the camera in a VideoWindow, but I would like to superipose over the
live picture a simple crosshair (see the attached picture). I am using a VMRBitmap to transfer the drawing
to mix it with the live video image.

I draw the pair of horizontal and vertical red lines which form a crosshair on a Bitmap (TBitmap) with white
background. The bitmap could be transferred to the VMRABitmap with the Loadbitmap procedure. However,
this directly is not working (I mean, it does not gives result). I am using the vmrbSrcColorKey and ColorKey
for the white background, this should remain transparent over the live video image, only the crosshair should
be visible from the entire bitmap overlayed on the video. This works correctly under Delphi.

Code: [Select]
// crossBitmap is a TBitmap with the red haircross on it over a white background, it is created previously
try
VMRBitmap.LoadBitmap(crossBitmap);             
VMRBitmap.Source := VMRBitmap.Canvas.ClipRect;
VMRBitmap.Options := VMRBitmap.Options + [vmrbSrcColorKey];
VMRBitmap.ColorKey := clWhite;
VMRBitmap.DrawTo(0,0,1,1, 1);
finally
crossBitmap.Free;
 end;

I found a "brute force" way to solve this, first I am saving the bitmap to a file, load the file, and pass the bitmap to the
VMRABitmap. Yes, I admit, this is not a correct way, and I would not use this, but for now it is the only working solution.
The crosshair position has to be moved on the video image, so I can't save and load every time the bitmap.

Code: [Select]
// crossBitmap is a TBitmap with the red haircross on it over a white background, it is created previously
crossBitmap.SaveToFile('test.bmp');
try
crossBitmap.LoadFromFile('test.bmp');
VMRBitmap.LoadBitmap(crossBitmap);             
VMRBitmap.Source := VMRBitmap.Canvas.ClipRect;
VMRBitmap.Options := VMRBitmap.Options + [vmrbSrcColorKey];
VMRBitmap.ColorKey := clWhite;
VMRBitmap.DrawTo(0,0,1,1, 1);
finally
crossBitmap.Free;
end;

I have a clue, that this behaviour is due to the native TBitmap format of Lazarus, which is different than the Windows
bitmap, and since VMRABitmap is expecting a Windows type bitmap, it does not mix over the video the desired content.

But I am not able to find a solution. Can anyone recommend another way?

I also noticed the problem mentioned on the first page of the topic, the VMRBitmap.LoadEmptyBitmap
does not work for me either. Instead, to clear the overlay on the video, I am using the same trick, I create
a bitmap, and pass it to VMRBitmap. This could be a compromise, but is acceptable.

Code: [Select]

//emptyBitmap is a TBitmap
emptyBitmap := TBitmap.Create;                 
VMRBitmap.LoadEmptyBitmap(400,300,pf24bit ,clWhite);    //a pixel formattal van valami baj
//VMRBitmap.LoadBitmap( emptyBitmap );
VMRBitmap.Source := VMRBitmap.Canvas.ClipRect;
VMRBitmap.DrawTo(0,0,1,1,0);
emptyBitmap.Free;
end;

Thanks in advance,
Gyuri
using Lazarus 1.4RC, FPC version 2.6.4,SVN rev 48058, Windows XP SP3/32bit, Windows7 SP1/64bit

af0815

  • Hero Member
  • *****
  • Posts: 1289
Re: DSPack for Lazarus - Win32 DirectShow Multimedia components
« Reply #46 on: November 03, 2017, 10:58:53 am »
For the records, i have done a Fork on GitHub  O:-)  https://github.com/afriess/LazarusVideoUtilities

Thanks to the holder of the original codebase -> Mike.Cornflake  :) https://sourceforge.net/projects/lazarusvideoutilities/

The actual code is working with Lazarus 1.8.0RC5 r56092M FPC 3.1.1 i386-win32-win32/win64 too. It is only working on Windows, because of using MS-DirectShow.

I use this package to work with USB-Cameras in Win7 and WIn10 with resolution up to 1920x1080. This looks like a natural limitation of DirtectShow. Because 4k resolution (eg. Logitech BRIO) are only working with M$ UWP programming on the last version Win 10 (1709) - if the hardware support the 4k.

Andreas
regards
Andreas

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1260
Re: DSPack for Lazarus - Win32 DirectShow Multimedia components
« Reply #47 on: November 03, 2017, 05:35:23 pm »
For the records, i have done a Fork on GitHub  O:-)  https://github.com/afriess/LazarusVideoUtilities

Thanks to the holder of the original codebase -> Mike.Cornflake  :) https://sourceforge.net/projects/lazarusvideoutilities/

The actual code is working with Lazarus 1.8.0RC5 r56092M FPC 3.1.1 i386-win32-win32/win64 too. It is only working on Windows, because of using MS-DirectShow.

Awesome stuff, many thanks for this :-).  I've been unable to find time for any of the plans I had for this, let alone maintain it.
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

fin

  • Newbie
  • Posts: 1
Re: DSPack for Lazarus - Win32 DirectShow Multimedia components
« Reply #48 on: December 17, 2017, 01:26:32 pm »
Thanks af0815 :)

mtron

  • Guest
Re: DSPack for Lazarus - Win32 DirectShow Multimedia components
« Reply #49 on: December 19, 2017, 08:03:37 pm »
I use this package to work with USB-Cameras in Win7 and WIn10 with resolution up to 1920x1080. This looks like a natural limitation of DirtectShow. Because 4k resolution (eg. Logitech BRIO) are only working with M$ UWP programming on the last version Win 10 (1709) - if the hardware support the 4k.

This is great, Andreas!

Do you have any Lazarus example on how to work with camera capture, just still images?

Thanks and best

 

TinyPortal © 2005-2018