The most easy and convienent way to communicate with DRES is via its supported OpenAPI description, which allows you to automatically generate communication classes for several programming languages. The generated classes support various methods for login, logout, result-submission, and logging. The latter is important for evaluations that are performed by the VBS community after they actual event (and typically published in a joint paper – see also Interaction Logging).
The DRES developers have kindly provided many examples for several programming languages in their Client-Examples repository: https://github.com/dres-dev/Client-Examples
Example: OpenAPI with Angular
If you are using a web application with Angular, you can simply integrate the OpenAPI of DRES with the following steps:
Install OpenAPI generator tools:
npm install @openapitools/openapi-generator-cli -g
npm install -g ng-openapi-gen
Next, add the following lines to your package.json
file:
"scripts": {
"gen-dres-client": "openapi-generator-cli generate -g typescript-angular -i https://raw.githubusercontent.com/dres-dev/DRES/master/doc/oas-client.json -o openapi/dres --skip-validate-spec --additional-properties npmName=@dres-client-openapi/api,ngVersion=13.0.0,enumPropertyNaming=original",
},
"dependencies": {
"@openapitools/openapi-generator-cli": "2.4.26"
},
Finally, generate TypeScript files with these commands:
npm run-script gen-dres-client
Simply import the generated files like this (the relation of the path depends on your app):
import {SubmissionService} from '../../openapi/dres/api/submission.service';
Submission Without OpenAPI
Since DRES uses an HTTP API you can also communicate via simple HTTP requests (even with entering a URL in a browser). In order to submit a result to DRES this way, please make sure you are logged on to the server in another browser window and your code uses the token that is connected to your user profile on DRES (click at your user name at right top and select user profile). Please note that the token may change from time to time!
The format of the HTTP requests is described in detail in the ReadMe of DRES. The most important parameters are item and frame (or shot or timecode). For example, this request would submit the 150th frame of video 00815 to a DRES instance running on vbs.videobrowsing.org (please note that this server is not always online):
https://vbs.videobrowsing.org/api/v1/submit?item=00815&frame=150
Frame Numbers or Time Code?
DRES accepts (1) the frame number, (2) the shot number of the master-shot reference of V3C, and (3) time codes (whereas the latter is preferred, see client examples). However, when computing time code, please make sure that you use the correct format (HH:MM:SS:FF) and the same frame-rate as the ones we use on the DRES server (if you transcoded the videos or use non-ffmpeg libraries, you might sometimes get different frame-rates, unfortunately). For your convenience, we provide a list of all frame-rates used with our encodings:
These frame-rates were extracted with the following ffmpeg statement:
ffmpeg -i $file 2>&1 | grep -E -o ".{0,7} fps" | cut -d" " -f2
Related: If you want to extract frames from videos with ffmpeg, you can use this statement, for example (-r 0.1 is the rate and means that every 10 seconds one frame will be extracted):
ffmpeg -i videofile -r 0.1 -f image2 video-frame%04d.jpg