LWia::IsVideoPreviewAvailable

#include "ltwrappr.h"

virtual L_BOOL LWia::IsVideoPreviewAvailable()

Determines whether there is an available video preview.

Returns

TRUE

The video preview feature is available and the user can start it.

FALSE

The video preview feature is not available.

Comments

This feature is available in LEADTOOLS version 16 or higher.

If the function LWia::IsVideoPreviewAvailable is called and succeeded then this function will return TRUE, otherwise it will return FALSE.

Required DLLs and Libraries

LTWIA

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

See Also

Functions:

LWia::StartVideoPreview, LWia::ResizeVideoPreview, LWia::EndVideoPreview, LWia::AcquireImageFromVideo, LWia::InitSession, LWia::EndSession, Class Members

Topics:

Working with Video Devices

 

WIA Functionality: Property Functions

Example

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName
L_LTWIASAM_CLIB L_INT LWIA__IsVideoPreviewAvailableExample()
{
   LWia MyClass;
   L_TCHAR szSavedFileName[MAX_PATH];
   lstrcpy(szSavedFileName,MAKE_IMAGE_PATH(TEXT("")));
   L_TCHAR szImagesDirectory[MAX_PATH] ;
   lstrcpy(szImagesDirectory,MAKE_IMAGE_PATH(TEXT("")));
   L_TCHAR szMsg[MAX_PATH] = TEXT("");
   L_BOOL bAvailable = FALSE;
   L_SIZE_T uLength = MAX_PATH;
   IWiaItem * pRootItem = NULL;
   L_INT nRet;
   /* Select video streaming device first */
   nRet = MyClass.SelectDeviceDlg(WiaDeviceTypeStreamingVideo, L_WIA_SELECT_DEVICE_NODEFAULT);
   if(nRet != WIA_SUCCESS)
      return nRet;
   nRet = MyClass.StartVideoPreview(FALSE);
   if (nRet != WIA_SUCCESS)
      return nRet;
   bAvailable = MyClass.IsVideoPreviewAvailable();
   if(!bAvailable)
   {
      MessageBox(NULL, 
                 TEXT("No streaming video available, please call MyClass.StartVideoPreview first"),
                 TEXT("ERROR"),
                 MB_OK | MB_ICONERROR);
      MyClass.EndVideoPreview();
      return FALSE;
   }
   /* 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.
   nRet = MyClass.ResizeVideoPreview(TRUE);
   if(nRet != WIA_SUCCESS)
      return nRet;
   nRet = MyClass.AcquireImageFromVideo(szSavedFileName, &uLength);
   if(nRet != WIA_SUCCESS && nRet == ERROR_BUFFER_TOO_SMALL)
   {
      MyClass.EndVideoPreview();
      nRet = MyClass.GetRootItem(NULL, (L_VOID**)&pRootItem);
      if(nRet != WIA_SUCCESS)
         return FALSE;
      nRet = MyClass.GetPropertyString(pRootItem, NULL, WIA_DPV_IMAGES_DIRECTORY, szImagesDirectory, &uLength);
      if(nRet == WIA_SUCCESS)
      {
         wsprintf(szMsg, 
            TEXT("Provided string buffer is too small to be updated.\n")
            TEXT("But still an image was saved to the following directory:\n\n%s"),
            szImagesDirectory);
         MessageBox(NULL, szMsg, TEXT("ERROR"), MB_OK | MB_ICONERROR);
      }
      return FALSE;
   }
   wsprintf(szMsg, 
      TEXT("Captured still image was saved to the following path:\n\n%s"),
      szSavedFileName);
   MessageBox(NULL, szMsg, TEXT("Captured Image Path"), MB_OK | MB_ICONINFORMATION);
   MyClass.EndVideoPreview();
   return SUCCESS;
}