PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • Video control: Initialization
CameraChangeDriver (Example)
Video control: Initialization
This example is used to initialize a Video control according to the computer drivers.
arrCameraDrivers is array of strings
nIndex is int
 
// Retrieve the name of the camera driver that was used beforehand
sCurrentDriver is string = LoadParameter(CAM_WEBCAM.FullName, CAM_WEBCAM.Driver)
 
// Llist of available camera drivers in the following format:
// Name of Driver 1> + TAB + <Version of Driver 1> + CR + ...
sListVideoDriver is string = CameraListDriver(viDirectShow))
// or CameraListDriver(viDirectShow)
// The list of drivers is stored in an array variable
StringToArray(sListVideoDriver, arrCameraDrivers, RC, TAB)
// Is there at least one camera driver or WebCam?
SWITCH arrCameraDrivers.Count
CASE 0
// None
ToastDisplay("No camera driver was found on the computer, " +
"the control was disabled", toastShort, vaMiddle,haCenter, LightRed)
CAM_WEBCAM.State = Grayed
CASE 1
// a single driver: take it
nIndex = 1
 
OTHER CASE
// several drivers
// check whether the driver that was stored beforehand is found in the list
nIndex = ArraySeek(arrCameraDrivers, asLinear, sCurrentDriver)
IF nIndex < 1 THEN
// Not found: take the first one in the list
nIndex = 1
END
END
 
// A driver other than the control one is selected?
IF nIndex>0 _AND_ NOT CAM_WEBCAM.Driver = arrCameraDrivers[nIndex] _AND_ ...
// Change the driver used (and check whether the change is operating)
NOT CameraChangeDriver(CAM_WEBCAM, arrCameraDrivers[nIndex]) THEN
//or NOT CameraChangeDriver(CAM_WEBCAM, arrCameraDrivers[nIndex])
ToastDisplay("Unable to use the camera driver " +
arrCameraDrivers[nIndex] + ", the control was disabled" + CR +
ErrorInfo(), toastShort, vaMiddle, haCenter, LightRed)
CAM_WEBCAM.State = Grayed
END
 
// Store the driver
// This same paramer must be saved if a window option is used to change camera
// in order for this camera driver to be taken into account by default
SaveParameter(CAM_WEBCAM.FullName, CAM_WEBCAM.Driver)
Minimum version required
  • Version 22
This page is also available for…
Comments
Click [Add] to post a comment