المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : AForge.net writer.Open problem



C# Programming
07-01-2009, 01:12 PM
Good day

I want to save a video stream to file from my webcam. I looked at Andrew Kirillov's example on "motion detection algorithms" and used the exact same code to test the saving of a video file, but it seams that the writer.Open() method is unable to execute properly.

In my own code (using the "saving video" snippet) I'm given an exception, and when running Andrew's complete source code on the motion detector the program freezes as soon as I start recording.

I am running Vista, so I don't know whether that might be the cause?

This is my code I'm currently using:

SaveFileDialog sfd = new SaveFileDialog( );
if ( sfd.ShowDialog( ) == DialogResult.OK )
{
AVIWriter writer = new AVIWriter( "wmv3" );
try
{
writer.Open( sfd.FileName, 320, 240 ); //where the exception is thrown
Bitmap bmp = new Bitmap( 320, 240, PixelFormat.Format24bppRgb );
for ( int i = 0; i < 100; i++ )
{
bmp.SetPixel( i, i, Color.FromArgb( i, 0, 255 - i ) );
writer.AddFrame( bmp );
}
bmp.Dispose( );
}
catch ( ApplicationException ex )
{
lblFps.Text = "Exception thrown";
}
writer.Dispose( );
}