How to capture video and store it in file in LEAD image processing technology

LEADTOOLS Recognition Imaging SDK is a selected LEADTOOLS SDK feature set designed to build end-to-end document imaging applications in enterprise-level document automation solutions. These solutions require OCR, MICR, OMR, barcode, form recognition and processing, PDF , Print capture, archive, annotation and image viewing functions. This powerful tool utilizes LEAD's award-winning image processing technology to intelligently recognize documents that can be used to identify and extract any type of scanned or faxed image data.

Download LEADTOOLS Recognition Imaging SDK trial version

The LEADTOOLS video capture SDK contains advanced features to simplify the process of capturing video from devices and cameras. Our SDK provides developers with all the tools needed to work with different video sources, including webcams, webcams, capture cards, TV tuners, DV cameras, etc. After capturing the video, developers can easily convert and store the video using various codecs (such as H.265, H.264, MJPEG and MPEG-2). The LEAD library provides the highest compression, speed and playback quality of any other multimedia SDK on the market.

Integrating video capture into your application? Quickly start with the code below, or view the complete tutorial to capture from video source to file.

using System.Windows.Forms;
using Leadtools;
using Leadtools.Multimedia;

static void Main(string[] args)
{
UnlockMultimedia();
CaptureVideo();
}

static void CaptureVideo()
{
string outputFile = @"C:\LEADTOOLS21\Resources\Images\captured.avi";
CaptureCtrl capture = new CaptureCtrl(true);
int deviceCount = capture.VideoDevices.Count;
if (deviceCount < 1)
{
Console.WriteLine("No compatible devices found. Exiting.");
return;
}
Console.WriteLine("Select device by typing its number and pressing Enter:");
for (int n = 0; n < deviceCount; n++)
Console.WriteLine(n.ToString() + " : " + capture.VideoDevices[n].FriendlyName);
int deviceIndex = int.Parse(Console.ReadLine());
Console.WriteLine("Preparing to capture . .");
capture.VideoDevices.Selection = deviceIndex;
capture.TargetFile = outputFile;
capture.TargetFormat = TargetFormatType.AVI;
// select a suitable compressor
capture.VideoCompressors.MJpeg.Selected = true;
//use CaptureMode.VideoAndAudio if an audio device is also selected.
capture.StartCapture(CaptureMode.Video);
Console.WriteLine("Capturing to file. Press any key to stop capture...");
while (!Console.KeyAvailable)
{
System.Windows.Forms.Application.DoEvents();
int capMilliSeconds = (int)(1000 * capture.CaptureTime);
if (capMilliSeconds % 1000 == 0) // print a dot every second
{
Console.Write(". ");
System.Threading.Thread.Sleep(1);
}
}
capture.StopCapture();
Console.ReadKey(true);
Console.WriteLine($"\nFinished capturing {capture.CaptureTime} seconds to file {outputFile}. Press any key to continue...");
Console.ReadKey(true);
}
Try it!
To test it yourself, make sure to get the latest LEADTOOLS SDK evaluation for free from our website (if you haven't already). The trial version is valid for 60 days and provides unlimited chat and email support.

stand by

Need help to obtain this sample? Please contact our support team for free technical support! For pricing or licensing issues, you can contact our sales team.

Stay tuned, because as promised in our previous post, we will provide more tutorials that programmers can use to develop applications that directly affect data capture, identification, exchange, and other urgent business needs.

Guess you like

Origin blog.51cto.com/14874181/2554966