←Select platform

AcquireImageFromVideo Method

Summary
Extracts a still image from the video stream, and saves the image as a JPEG file.

Syntax
C#
C++/CLI
Python
public string AcquireImageFromVideo() 
public: 
String^ AcquireImageFromVideo();  
def AcquireImageFromVideo(self): 

Return Value

A System.String containing the full path and file name of the captured JPEG file from the camera device.

Remarks

This method will capture a still image from the video stream and save it as a JPEG file.

To change the directory where the captured image is saved, set the new folder path in the value parameter and then call the WiaSession.SetPropertyString method, passing WiaPropertyId.VideoDeviceImagesDirectory for the propertyId parameter of this method.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Wia; 
 
 
       
public void IsVideoPreviewAvailableExample(IntPtr parent) 
{ 
   if (!WiaSession.IsAvailable(WiaVersion.Version1)) 
   { 
      Console.WriteLine("WIA version 1.0 not installed."); 
      return; 
   } 
 
   WiaSession wiaSession = new WiaSession(); 
   wiaSession.Startup(WiaVersion.Version1); 
 
   DialogResult res = wiaSession.SelectDeviceDlg(parent, WiaDeviceType.StreamingVideo, WiaSelectSourceFlags.NoDefault); 
   if (res != DialogResult.OK) 
   { 
      Console.WriteLine("Error selecting WIA device."); 
      wiaSession.Shutdown(); 
      return; 
   } 
 
   // start the video preview 
   wiaSession.StartVideoPreview(parent, false); 
 
   // determine whether a video preview is available 
   bool available = wiaSession.IsVideoPreviewAvailable(); 
   if (!available) 
   { 
      Console.WriteLine("No streaming video available."); 
      wiaSession.EndVideoPreview(); 
      wiaSession.Shutdown(); 
      return; 
   } 
 
   // Resize the video preview area to fit the parent window. 
   // I am calling this resize function here only for demonstration purposes, but you 
   // should call it in your window resize event. 
   wiaSession.ResizeVideoPreview(true); 
 
   // acquire an image from the video source. 
   string takenPictureFileName = wiaSession.AcquireImageFromVideo(); 
 
   string strMsg = String.Format("Acquired image was saved to the following path:\n{0}", takenPictureFileName); 
   Console.WriteLine(strMsg); 
 
   wiaSession.EndVideoPreview(); 
   wiaSession.Shutdown(); 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Wia Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.