|
|
|
|
Example for managing videos (broadcasted by a Camera control) (prefix syntax)
In this example, the application allows you to: - view the video sequence currently broadcasted by the camera installed on the current computer.
- modify the configuration of the driver for video capture.
- save the video currently broadcasted by the specified camera as an image (BMP file) or as a video sequence (AVI file).
To develop this application: - Create a blank window:
- Click in the quick access buttons.
- The creation window appears: click "Window" then "Window".
- In the wizard, select "Blank".
- In this new window:
- Create a Camera control named "CAM_Camera": on the "Creation" tab, "Graphic controls" group, expand "Video and capture" and click "Camera".
Remark: By default, the camera associated with this control will correspond to the default camera found on the current computer. - Create a Button control and name it "BTN_Film": on the "Creation" tab, in the "Usual controls" group, click "Button".
This Button control will be used to display the video sequence in the Camera control. - Create a Button control and name it "BTN_Configuration": on the "Creation" tab, in the "Usual controls" group, click "Button".
This Button control will be used to modify the configuration of the driver for video capture. - Create a Button control and name it "BTN_Image": on the "Creation" tab, in the "Usual controls" group, click "Button".
This Button control will be used to save the video sequence currently transmitted, as an image (BMP file). - Create a Button control and name it "BTN_Video": on the "Creation" tab, in the "Usual controls" group, click "Button".
This Button control will be used to save the video sequence currently transmitted, as a video sequence (AVI file). - Create a Button control and name it "BTN_Stop": on the "Creation" tab, in the "Usual controls" group, click "Button".
This Button control will be used to stop displaying and/or saving the video sequence in the Camera control.
- Write the following code in the "Click" event of "BTN_Film":
// Displays the video sequence currently transmitted in the "CAM_Camera" control ResDisplay is boolean ResDisplay = CAM_Camera.Display() // Displays an error message if a problem occurs IF ResDisplay = False THEN Error(ErrorInfo())
- Write the following code in the "Click" event of "BTN_Configuration":
// Displays the standard dialog box used to // configure the driver for video capture used by the "CAM_Camera" control CAM_Camera.Configure()
- Write the following code in the "Click" event of "BTN_Image":
// Save the image currently broadcasted in the "CAM_Camera" control ResImgBck is boolean ResImgBck = CAM_Camera.Capture("Temp.gif", viPictureCapture) IF ResImgBck = False THEN Error(ErrorInfo()) END Â // Select the file to create ImageFile is string ImageFile = fSelect(fExeDir(), "Image", ... "Save as...", "BMP" + TAB + "*.BMP", "bmp", fselCreate + fselExist) Â // Renames the created BMP file IF ImageFile ~= "" THEN // Delete the temporary file fDelete("Temp.BMP") ELSE // Renames and moves the generated file fRename("Temp.BMP", ImageFile) END
- Write the following code in the "Click" event of "BTN_Video":
// Save the video sequence currently broadcasted // in the "CAM_Camera" control in the format of a 3-minute AVI ResVideoBck is boolean ResVideoBck = CAM_Camera.Capture("Temp.avi", viVideoCapture, 180) IF ResVideoBck = False THEN Error(ErrorInfo()) END Â // Select the file to create VideoFile is string = fSelect(fExeDir(), "Video", ... "Save as...", "AVI" + TAB + "*.avi", "avi", fselCreate + fselExist) Â // Renames the created AVI file IF VideoFile ~= "" THEN // Delete the temporary file fDelete("Temp.avi") ELSE // Renames and moves the generated file fRename("Temp.avi", ImageFile) END
- Write the following code in the "Click" event of "BTN_Stop":
// Displays the display or the backup of the video sequence ResStop is boolean ResStop = CAM_Camera.Stop() // Displays an error message if a problem occurs IF ResStop = False THEN Error(ErrorInfo())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|