<< to CrossControl homepage

Support & Service Center

Video in CODESYS

Printer-friendly versionPrinter-friendly versionPDF versionPDF version

To show video feed from a connected video camera on our devices you should use the CCAux api.

Below you will find a basic example how to show a Video feed in CODESYS (example on a CCpilot VC). as well as an example of how to switch between multiple camera inputs or feeds.
For extended functionallity more information is found in the CCAux documentation.

 

PROGRAM PLC_PRG
VAR
	result: eErr;
	initVideoDevice_1: BOOL := TRUE;
	channel: VideoChannel := Channel_1;
	videoDevice_1_Active: BOOL := TRUE;
	activeVideoDevice: VideoDevice;
 
	horizontalPosition_Dev1: UINT := 0;
	verticalPosition_Dev1: UINT := 0;
	width_Dev1: UINT := 800;
	height_Dev1: UINT := 600;
 
	horizontalScaling_Dev1: REAL := 1;
	verticalScaling_Dev1: REAL := 1;
	showVideo: BOOL := TRUE;
	Standardd: CCAUX.VideoStandard;
END_VAR
IF showVideo THEN
	result := Video_ShowVideo(deviceNr:=activeVideoDevice, show:=TRUE);
	showVideo := FALSE;	
END_IF
 
IF initVideoDevice_1 THEN
	IF Video_Init(deviceNr:= VideoDevice_1) = CCAUX.ERR_SUCCESS THEN		
		result := Video_SetActiveChannel(deviceNr:=VideoDevice_1, channel:= Channel_1);
		result := Video_SetVideoArea(deviceNr:=VideoDevice_1, topLeftX:=horizontalPosition_Dev1, topLeftY:=verticalPosition_Dev1, bottomRigthX:=horizontalPosition_Dev1 + width_Dev1, bottomRigthY:=verticalPosition_Dev1 + height_Dev1);
		result := Video_SetScaling(deviceNr:=VideoDevice_1, horizontalScaling:=horizontalScaling_Dev1, verticalScaling:=verticalScaling_Dev1);
		result := Video_GetVideoStandard(deviceNr:=VideoDevice_1 , standard=>Standardd);		
	END_IF
	initVideoDevice_1 := FALSE;			
END_IF

Environment and Versions: 

CCAux 2.7.3 and newer

ARMv7 platform

whatever