Help with Movie2

#1

I’ve been going through each CVB.Net tools but I can’t figure out how to use Movie2, can someone explain how to get it to work? thanks

#2

Hi Adam, see this for a short example:

void Main()
{
	// load device
	using(var device = Stemmer.Cvb.DeviceFactory.Open("GenICam.vin"))
	{
		string fileName = "TestVideo.avi";
		var stream = device.Stream;
		try
		{
			// create recorder object
			using(var recorder = new Stemmer.Cvb.Movie2.Recorder(fileName, device.DeviceImage.Size, RecorderPixelFormat.Mono))
			{
			 	// start acquisition of images
				stream.Start();
				
				// acquire 10 images and save to video file
				for(int i = 0; i < 10; i++)
				{
					var img = stream.WaitFor(TimeSpan.FromSeconds(3));
					recorder.Write(img);
				}
			}
		}
		catch
		{			
			// delete file if error occured
			if(File.Exists(fileName))
				File.Delete(fileName);
		}
		finally
		{
			// stop stream
			if(stream.IsRunning)
				stream.Abort();
		}
	}
}

Hope this helps.
If you have any more questions feel free to ask.

Cheers,
Tim

5 Likes
#3

Thanks Tim! I’m wondering if its possible to display a camera stream in a VS forms display and also save the video at the same time? I’ve been trying this for a few hours but i can’t get it to work. Using streamHandler or not, either is fine

#4

Hi Adam,

you should be able to just set the image after aquiring it.

display.Image = img;

It is best to use this in conjunction with WaitForAsync instead of WaitFor, to keep the UI fluid.

Cheers,
Tim

1 Like