Sends a video to be processed in order to be analyzed later by GeneXus Cognitive API - Analyze procedure. This task is performed asynchronously due to the processing latency.
The following table resumes the configuration properties (access credentials) you must set in order to use this AI task.
|
PropertyKey |
ProviderType |
Key |
KeySecret |
Account |
Alibaba |
内容安全 app-key |
用户AccessKey |
用户AccessKey |
Amazon |
- |
- |
- |
Baidu |
视频内容分析 |
视频内容分析 |
|
Google |
Video Intelligence API |
- |
- |
IBM |
- |
- |
- |
Microsoft |
Video Indexer |
- |
Azure Connect |
SAP |
- |
- |
- |
Tencent |
- |
- |
- |
This section describes two alternatives for processing a video: synchronously or asynchronously. Once processed, you can get the analysis made by the provider. In other words, you need to use both Process and Analyze tasks.
The way you process a video synchronously is by polling for the processing status. The example below shows how you can do it.
&callbackObject = "" // It's not necessary to indicate a callback object for this strategy
&VideoId = GeneXusAI.Video.Process(&video,&locale,&callbackObject,&provider,&Messages)
if &Messages.Count > 0
<process_errors>
else
do while True
&outputAnalysis = GeneXusAI.Video.Analyze(&videoId,&provider,&Messages) // Polling
if &outputAnalysis.Completed OR &Messages.Count > 0
exit // Exit from the loop
endIf
&x = Sleep(30) // Wait 30 seconds until poll again
endDo
if &Messages.Count > 0
<process_errors>
else
<analyze_result>
endIf
endIf
Note that for large video files this strategy may take a long time. Consider using asynchronous strategy in these cases.
The way you process a video asynchronously is by indicating a callback-object to this task.
For example, you can write a code as follows:
&callbackObject = Link(VideoHandler) // It gets the object name mantaining a reference to it
&VideoId = GeneXusAI.Video.Process(&video,&locale,&callbackObject,&provider,&Messages)
if &Messages.Count > 0
<process_errors>
endIf
Where VideoHandler is a Procedure object with Expose as Web Service property = True, and defined as follows:
Rules:
parm(in:&videoId); // Mandatory :: video identifier
Source:
&OutputAnalysis = GeneXusAI.Video.Analyze(&videoId,&provider,&Messages)
if &Messages.Count > 0
<process_errors>
else
<analyze_result>
endIf
Alternatively, instead of getting the analysis in this object, you can send a notification and call the GeneXus Cognitive API - Analyze procedure on a Panel for Web or Smart Devices. This can be done by using Server.Socket external object for Web, or Notification Provider API for Smart Devices.
Warning: For testing your asynchronous solution, your application must be accessible for the external provider (e.g. your IP must be remotely accessible, or you can host your application on a real server -- Deploy To Cloud option can be a good alternative).
- For the asynchronous strategy, the callback-object must include a Parm rule with the incoming video identifier.
- Special considerations
- For Microsoft:
- To get the Key/Account, please refer to this document.
- Despite no region is filled up on the 'Faces' field items (top, left, width, height fields are zero -- or empty), you will have a property with 'thumbnail' key whose value is a cropped image of the identified face.
- For Baidu:
- Only supports synchronous mode (not callback-url is available).
This procedure is available as of GeneXus 16 upgrade 1.