ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Use imageENView as frame grabber
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Zahra

Iran
7 Posts

Posted - Aug 25 2019 :  00:46:30  Show Profile  Reply
i'm using ImageENView object as a video grabber, but i don't know which procedure recevies new frame for an imageEnView? i test "OnDShowNewFrame" and "OnAcquireBitmap" but the program don't enter to these events;
for this purpose i follow:
ImageEnView2 := TImageEnView.Create(nil);
ImageEnView2.IO.Create(nil);
MyClass.Create;
ImageEnView2.OnDShowNewFrame := MyClass.ImageEnView2DShowNewFrame;
ImageEnView2.OnAcquireBitmap := MyClass.ImageEnView2AcquireBitmap;

type
MyClass = class
public
class procedure ImageEnView2DShowNewFrame(Sender: TObject);
end;

this is while putting an imgeENView object on the form works correctly..
how should i use an ImageENView object without using it's object on the form?
is there any other property for imageENView that should be initialize?

xequte

38191 Posts

Posted - Aug 25 2019 :  19:05:06  Show Profile  Reply
Hi

So the code works correctly when TImageEnView is on a form, but not when you create a TImageEnView in code, correct?

Can you show me the rest of your capture code.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

Zahra

Iran
7 Posts

Posted - Aug 26 2019 :  00:30:05  Show Profile  Reply
Hi Nigel,

yes, the code works correctly when TImageEnView object is on form. the following code contain 2 imageENView, imageENView1 has its corresponding object on the form and grabs frames correctly and imageENView2 does not have a related component and is create as a variable but never enter into "OnDshowNewFrame" event.


var
ImageEnView2 : TImageEnView;

-----------------------------------------------------------------------------------
ImageEnView2 := TImageEnView.Create(nil);
ImageEnView2.IO.Create(ImageEnView2);
ImageEnView2.IO.AsyncMode := True;
ImageEnView2.IO.DShowParams.EnableSampleGrabber := true;
MyClass.Create;

-----------------------------------------------------------------------------------

ImageEnView1.OnDShowNewFrame := MyClass.ImageEnView1DShowNewFrame;
//ImageEnView2.OnDShowNewFrame := MyClass.ImageEnView2DShowNewFrame;

-----------------------------------------------------------------------------------
if (not ImageEnView1.IO.DShowParams.Connected) then
begin
  ImageEnView1.IO.DShowParams.SetVideoInput(0 , 0 , w , h , f);
  ImageEnView1.IO.DShowParams.EnableSampleGrabber := true;
  ImageEnView1.IO.DShowParams.Connect;
end;



if (not ImageEnView2.IO.DShowParams.Connected) then
begin
  ImageEnView2.IO.DShowParams.SetVideoInput(0 , 1 , w , h , f);
  ImageEnView2.IO.DShowParams.EnableSampleGrabber := true;
  ImageEnView2.IO.DShowParams.Connect;
end;

ImageEnView1.IO.DShowParams.GetCurrentVideoFormat(w, h, f);
ImageEnView1.IO.DShowParams.Run;

ImageEnView2.IO.DShowParams.GetCurrentVideoFormat(w, h, f);
ImageEnView2.IO.DShowParams.Run;

-----------------------------------------------------------------------------------

class procedure MyClass.ImageEnView2DShowNewFrame(Sender: TObject);
begin
  ImageEnView2.IO.DShowParams.GetSample(ImageEnView2.IEBitmap);
  Form1.Image2.Picture.Bitmap.Assign(ImageEnView2.Bitmap);
end;

class procedure MyClass.ImageEnView1DShowNewFrame(Sender: TObject);
begin
  ImageEnView1.IO.DShowParams.GetSample(ImageEnView1.IEBitmap);
  Form1.Image1.Picture.Bitmap.Assign(ImageEnView1.Bitmap);
end;



and when i show the owner name of imageEnView2.Io.Ownar.name the ownar name is empty while in ImageEnView2.IO.Create(ImageEnView2); the ImageEnView2 assigned as ownar of ImageEnView2.IO...
Go to Top of Page

xequte

38191 Posts

Posted - Aug 26 2019 :  21:50:40  Show Profile  Reply
Hi

Firstly, please don't do this:

ImageEnView2.IO.Create(ImageEnView2);

TImageEnView will create IO as needed.


Unfortunately, because of the way DirectShow notifies of events a handle/parent is needed, so DShowParams cannot be used with a parentless TImageEnView.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

Zahra

Iran
7 Posts

Posted - Aug 27 2019 :  00:04:21  Show Profile  Reply
Hi,
thanks for your reply,
but i want to use the imageEnView in a delphi DLL, so what should be the parent of imageEnView?

and about "ImageEnView2.IO.Create(ImageEnView2); " , without specifying ImageEnview2 as parent of IO, the "Control has no parent window" error occurs if no parent have been associated to IO.
Go to Top of Page

Zahra

Iran
7 Posts

Posted - Aug 27 2019 :  00:21:29  Show Profile  Reply
and this is worth to mention that within a form application i do the following:
ImageEnView2 := TImageEnView.Create(Form1);

and i put ImageEnView1 object on the form, but like before the event DShowNewFrame for ImageEnView2 does not execute.... and for ImageEnView1 there is no problem...

Go to Top of Page

xequte

38191 Posts

Posted - Aug 27 2019 :  01:09:32  Show Profile  Reply
Firstly, With TControl.Create( XYZ );
XYZ is the Owner, not the Parent.
https://www.thoughtco.com/owner-vs-parent-in-delphi-applications-1058218


> I want to use the ImageEnView in a delphi DLL, so what should be the parent of imageEnView?

If your DLL does not use a form, then you will need to pass a parent (ImageEnView can still be non-visible)


> Without specifying ImageEnView2 as parent of IO, the "Control has no parent window"

Any call to ImageEnView2.IO creates the TImageEnIO if it does not exist (and makes Self as owner). TImageEnIO is a TComponent, so it does not have a parent.

The following call will give you a memory leak (second TImageEnIO is created):

ImageEnView2.IO.Create(ImageEnView2)

Because ImageEnView2.IO is never nil.


If you can reproduce "Control has no parent window", please give me the steps.


> and this is worth to mention that within a form application i do the following...

Yes, because you need to specify the parent:

ImageEnView1 := TImageEnView.Create(Self);
ImageEnView1.Parent := Form1;

This works when I test it here.


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

Zahra

Iran
7 Posts

Posted - Aug 27 2019 :  04:33:52  Show Profile  Reply
this works for me, too
Thank you
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: