Help with Movie2

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

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

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

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