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.
<code WL>
arrCameraDrivers is array of strings
nSubscript 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
nSubscript = 1
 
OTHER CASE
// several drivers
// check whether the driver that was stored beforehand is found in the list
nSubscript = ArraySeek(arrCameraDrivers, asLinear, sCurrentDriver)
IF nSubscript < 1 THEN
// Not found: take the first one in the list
nSubscript=1
END
END
 
// A driver other than the control one is selected?
IF nSubscript>0 _AND_ NOT CAM_WEBCAM..Driver = arrCameraDrivers[nSubscript] _AND_ ...
// Change the driver used (and check whether the change is operating)
NOT CameraChangeDriver(CAM_WEBCAM, arrCameraDrivers[nSubscript]) THEN
//or NOT CameraChangeDriver(CAM_WEBCAM, arrCameraDrivers[nSubscript])
ToastDisplay("Unable to use the camera driver " +
arrCameraDrivers[nSubscript] + ", 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