AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

using videoSourcePlayer to display an array of byte

Forum to discuss AForge.NET Framework, its features, API, how-tos, etc.

using videoSourcePlayer to display an array of byte

Postby btb4198 » Mon May 21, 2018 1:17 pm

can I use videoSourcePlayer to display an array of bytes?
so I get a frame from a Cam and i get a array of byte.
try
{
pictureBox1.Image = ByteToImage(transfer.FormattedBuf);
// videoSourcePlayer.
}

right now I am displaying it to a pictureBox, but how do I display it to a videoSourcePlayer?
btb4198
 
Posts: 34
Joined: Fri May 18, 2018 2:31 am

Re: using videoSourcePlayer to display an array of byte

Postby andrew.kirillov » Mon May 21, 2018 2:37 pm

VideoSourcePlayer control displays video frames (bitmaps) coming from an object implementing IVideoSource interface. You can create your own class implementing that interface and generate bitmaps from byte array.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3453
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: using videoSourcePlayer to display an array of byte

Postby btb4198 » Mon May 21, 2018 6:52 pm

ok can you show me an example?

I see it have a void play ()

and a void stop()

how should play ?
mainly how do I display the frames I am getting ?
btb4198
 
Posts: 34
Joined: Fri May 18, 2018 2:31 am

Re: using videoSourcePlayer to display an array of byte

Postby andrew.kirillov » Mon May 21, 2018 9:10 pm

btb4198 wrote:mainly how do I display the frames I am getting ?

You don't need to display anything - VideoSourcePlayer will do it for you once you implement IVideoSource interface. Have a look at the source code of AForge.NET Framework. Just run a search and you will find several classes implementing IVideoSource.

Anyway, if you can do it all with PictureBox, why do you need it so much to work with VideoSourcePlayer?
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3453
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: using videoSourcePlayer to display an array of byte

Postby btb4198 » Mon May 21, 2018 9:20 pm

I am using two cams.
I can get one cam to work with picture box,
but not the other cam.
I was able to get the other cam to work using Aforge.
but I need both two display from the same control .

right now I have two control: picture box and videoSourcePlayer .
btb4198
 
Posts: 34
Joined: Fri May 18, 2018 2:31 am

Re: using videoSourcePlayer to display an array of byte

Postby andrew.kirillov » Tue May 22, 2018 7:00 am

Not really sure I understand the difficulty of what you are trying to do. If you have two video sources, you need to display them in two controls. Those could be either two VideoSourcePlayer controls or two PictureBox controls, whatever.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3453
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: using videoSourcePlayer to display an array of byte

Postby btb4198 » Tue May 22, 2018 1:11 pm

can you show me some sample code of how to display:
pictureBox1.Image = ByteToImage(transfer.FormattedBuf);

that in a VideoSourcePlayer?

or how to display
videoSourcePlayer.VideoSource = source;

in a picture box ?
btb4198
 
Posts: 34
Joined: Fri May 18, 2018 2:31 am

Re: using videoSourcePlayer to display an array of byte

Postby btb4198 » Tue May 22, 2018 1:25 pm

so for picture box if I do
pictureBox1.Image = ByteToImage(transfer.FormattedBuf);
i can update my picture box with a new image.
what line can I do that with for videoSourcePlayer?
I did not see a videoSourcePlayer.image

can someone post some sample code ?
I tried looking in the source code but so for I do not see anything
btb4198
 
Posts: 34
Joined: Fri May 18, 2018 2:31 am

Re: using videoSourcePlayer to display an array of byte

Postby btb4198 » Tue May 22, 2018 2:12 pm

is it :
// notify clients
if ( NewFrame != null )
{
NewFrame( this, new NewFrameEventArgs( image ) );
}

image.Dispose( );

?
btb4198
 
Posts: 34
Joined: Fri May 18, 2018 2:31 am

Re: using videoSourcePlayer to display an array of byte

Postby andrew.kirillov » Tue May 22, 2018 2:28 pm

You don't get the concept. PictureBox must be set by someone, like pictureBox.Image = whatever.

With VideoSourcePlayer it all works differently. An object implementing IVideoSource interface fires NewFrame events. The VideoSourcePlayer gets those
events and then refreshes itself. You don't feed anything to it.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3453
Joined: Fri Jan 23, 2009 9:12 am
Location: UK



Next

Return to AForge.NET Framework

cron