├── .dockerignore ├── .github └── workflows │ └── main.yml ├── .gitignore ├── CMakeLists.txt ├── LICENSE ├── README.rst ├── SECURITY.md ├── assets ├── demo-alive ├── demo-bash ├── demo-setup ├── gva │ └── setup.py ├── hello-bash ├── info └── setup-apt-proxy ├── doc ├── apt.rst ├── docker.rst ├── gstreamer.rst ├── howto.rst ├── infostats.rst ├── man │ ├── Makefile │ ├── ObjectClassification.asciidoc │ ├── ObjectDetection.asciidoc │ ├── SamplePipeline.asciidoc │ ├── demo-alive.asciidoc │ ├── demo-bash.asciidoc │ ├── demo-setup.asciidoc │ ├── demo.env.asciidoc │ ├── hello-bash.asciidoc │ └── readme.rst ├── open_vino_tools.rst └── pic │ ├── media-analytics-sw-stack.png │ ├── media_analytics_pipeline.png │ ├── media_analytics_pipeline_detailed.png │ ├── use_cases.png │ ├── va-sample-full-pipeline-arch.png │ ├── va-sample-oc-arch.png │ └── va-sample-od-arch.png ├── docker ├── CMakeLists.txt ├── devel │ ├── CMakeLists.txt │ └── ubuntu20.04 │ │ ├── CMakeLists.txt │ │ └── intel-gfx │ │ ├── Dockerfile │ │ ├── Dockerfile.local │ │ └── Dockerfile.m4 ├── gst-gva │ ├── CMakeLists.txt │ └── ubuntu20.04 │ │ ├── CMakeLists.txt │ │ └── intel-gfx │ │ ├── Dockerfile │ │ └── Dockerfile.m4 ├── helpers │ └── ubuntu20.04 │ │ └── intel-gfx │ │ └── Dockerfile └── va-samples │ ├── CMakeLists.txt │ └── ubuntu20.04 │ ├── CMakeLists.txt │ └── intel-gfx │ ├── Dockerfile │ └── Dockerfile.m4 ├── patches └── readme.rst ├── templates ├── content.m4 ├── defs.m4 ├── gst-gva-sample.m4 ├── intel-gfx-local.m4 ├── intel-gpu-tools.m4 ├── m4docker │ ├── LICENSE │ ├── components │ │ ├── dldt-ie.m4 │ │ ├── gst-core.m4 │ │ ├── gst-gva.m4 │ │ ├── gst-plugins-bad.m4 │ │ ├── gst-plugins-base.m4 │ │ ├── gst-plugins-good.m4 │ │ ├── gst-vaapi.m4 │ │ ├── intel-gfx.m4 │ │ └── opencv.m4 │ └── system │ │ ├── begin.m4 │ │ ├── centos-repo.m4 │ │ ├── end.m4 │ │ └── ubuntu.m4 ├── manuals.m4 ├── models.m4 ├── open_model_zoo.m4 ├── readme.rst ├── samples.m4 └── va_sample.m4 └── va_sample ├── CMakeLists.txt ├── libs ├── CMakeLists.txt └── inference │ ├── CMakeLists.txt │ ├── Inference.cpp │ ├── Inference.h │ ├── InferenceMobileSSD.cpp │ ├── InferenceMobileSSD.h │ ├── InferenceOV.cpp │ ├── InferenceOV.h │ ├── InferenceRCAN.cpp │ ├── InferenceRCAN.h │ ├── InferenceResnet50.cpp │ ├── InferenceResnet50.h │ ├── InferenceSISR.cpp │ ├── InferenceSISR.h │ ├── InferenceYOLO.cpp │ └── InferenceYOLO.h └── src ├── CMakeLists.txt ├── common ├── common.cpp ├── common.h ├── logs.cpp ├── logs.h └── va_srcs.cmake ├── execution ├── Connector.cpp ├── Connector.h ├── ConnectorDispatch.cpp ├── ConnectorDispatch.h ├── ConnectorRR.cpp ├── ConnectorRR.h ├── DataPacket.cpp ├── DataPacket.h ├── ThreadBlock.cpp ├── ThreadBlock.h └── va_srcs.cmake ├── function ├── CropThreadBlock.cpp ├── CropThreadBlock.h ├── DecodeThreadBlock.cpp ├── DecodeThreadBlock.h ├── DecodeThreadBlock2.cpp ├── DecodeThreadBlock2.h ├── DisplayThreadBlock.cpp ├── DisplayThreadBlock.h ├── EncodeThreadBlock.cpp ├── EncodeThreadBlock.h ├── InferenceThreadBlock.cpp ├── InferenceThreadBlock.h ├── MfxSessionMgr.cpp ├── MfxSessionMgr.h ├── Statistics.cpp ├── Statistics.h └── va_srcs.cmake └── tests ├── CMakeLists.txt ├── DecodeCrop_test.cpp ├── Decode_SR_Encode.cpp ├── InferenceOV_test.cpp ├── InferenceThreadBlock_test.cpp ├── ObjectClassification.cpp ├── ObjectDetection.cpp ├── SamplePipeline.cpp └── SingleChannel_test.cpp /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | .github 3 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | permissions: read-all 10 | 11 | jobs: 12 | verify: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v2 16 | - name: Verify dockefiles are up-to-date 17 | run: | 18 | cmake . 19 | make -j$(nproc) 20 | git diff --exit-code 21 | 22 | gst-gva: 23 | runs-on: ubuntu-latest 24 | steps: 25 | - uses: actions/checkout@v2 26 | - name: Building DL-Streamer samples w/ Intel pkgs 27 | run: docker build --no-cache --force-rm -f docker/gst-gva/ubuntu20.04/intel-gfx/Dockerfile -t intel-gva-samples . 28 | 29 | va-samples: 30 | runs-on: ubuntu-latest 31 | steps: 32 | - uses: actions/checkout@v2 33 | - name: Building VA samples w/ Intel pkgs 34 | run: docker build --no-cache --force-rm -f docker/va-samples/ubuntu20.04/intel-gfx/Dockerfile -t intel-va-samples . 35 | 36 | devel: 37 | runs-on: ubuntu-latest 38 | steps: 39 | - uses: actions/checkout@v2 40 | - name: Building VA samples w/ Intel pkgs 41 | run: docker build --no-cache --force-rm -f docker/devel/ubuntu20.04/intel-gfx/Dockerfile -t intel-va-devel . 42 | 43 | helper: 44 | runs-on: ubuntu-latest 45 | steps: 46 | - uses: actions/checkout@v2 47 | - id: build 48 | run: | 49 | docker build --no-cache --force-rm -f docker/helpers/ubuntu20.04/intel-gfx/Dockerfile -t intel-ma-helper . 50 | mkdir assets/packages 51 | docker run --rm -u $(id -u):$(id -g) -v $(pwd)/assets/packages:/opt/packages intel-ma-helper /bin/bash -c "cp /opt/apt-pkgs/* /opt/packages/" 52 | - uses: actions/upload-artifact@v2 53 | with: 54 | path: assets/packages/ 55 | name: packages 56 | 57 | devel-local: 58 | needs: helper 59 | runs-on: ubuntu-latest 60 | steps: 61 | - uses: actions/checkout@v2 62 | - uses: actions/download-artifact@v2 63 | with: 64 | name: packages 65 | path: assets/packages/ 66 | - id: build 67 | run: | 68 | docker build --no-cache --force-rm -f docker/devel/ubuntu20.04/intel-gfx/Dockerfile.local -t intel-ma-devel-local . 69 | 70 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | CMakeCache.txt 2 | CMakeFiles 3 | cmake_install.cmake 4 | Makefile 5 | __pycache__ 6 | build 7 | cl_cache 8 | assets/packages 9 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Intel Corporation 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in all 11 | # copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | # SOFTWARE. 20 | 21 | cmake_minimum_required(VERSION 3.12) 22 | 23 | project(media-analytics VERSION 1.0.0 LANGUAGES NONE) 24 | 25 | find_program(M4 m4 REQUIRED) 26 | 27 | add_subdirectory(docker) 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2020 Intel Corporation 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | Intel is committed to rapidly addressing security vulnerabilities affecting our 3 | customers and providing clear guidance on the solution, impact, severity and 4 | mitigation. 5 | 6 | ## Reporting a Vulnerability 7 | Please report any security vulnerabilities in this project [utilizing the guidelines 8 | here](https://www.intel.com/content/www/us/en/security-center/vulnerability-handling-guidelines.html). 9 | -------------------------------------------------------------------------------- /assets/demo-alive: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (c) 2020 Intel Corporation 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | 23 | # This is a healthcheck script following docker HEALTHCHECK expectations: 24 | # 0 - all is OK 25 | # 1 - something is WRONG 26 | 27 | exit 0 28 | -------------------------------------------------------------------------------- /assets/demo-bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (c) 2020 Intel Corporation 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | 23 | # These 2 files should be provided by particular solution 24 | # - /etc/demo.env contains environment variables needed to run a solution 25 | # - demo-setup contains container runtime setup steps 26 | source /etc/demo.env 27 | 28 | VAS_IGNORE_ERRORS=${VAS_IGNORE_ERRORS:-no} 29 | 30 | if ! demo-setup; then 31 | if [[ "${VAS_IGNORE_ERRORS}" = "no" ]]; then 32 | echo "error: failed to setup demo" >&2 33 | exit -1 34 | else 35 | echo "warning: demo setup failed which means that demo won't run properly" >&2 36 | echo "warning: however you can look inside the container, check package versions" >&2 37 | fi 38 | fi 39 | 40 | "$@" 41 | -------------------------------------------------------------------------------- /assets/demo-setup: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (c) 2020 Intel Corporation 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | 23 | if [[ ! ( -n "$DEVICE" && "$DEVICE" =~ /dev/dri/ && -e $DEVICE ) ]]; then 24 | echo "error: device not available: $DEVICE" 25 | echo "error: if you run under docker add host device(s) with:" >&2 26 | echo "error: --device=$DEVICE (preferred)" >&2 27 | echo "error: --device=/dev/dri/" >&2 28 | echo "error: --privileged" >&2 29 | echo "error: you can change device you want to use with:" >&2 30 | echo "error: -e DEVICE=${DEVICE:-/dev/dri/renderD128}" >&2 31 | exit -1 32 | fi 33 | 34 | function get_gid() 35 | { 36 | local grp=$1 37 | local gid=$(grep "^$grp:" /etc/group | cut -d: -f3) 38 | if [ -n "$gid" ]; then 39 | echo "$gid" 40 | else 41 | echo "$grp" # $grp _is_ GID which does not have group name 42 | fi 43 | } 44 | 45 | device_grp=$(ls -g $DEVICE | awk '{print $3}' | uniq) 46 | device_gid=$(get_gid $device_grp) 47 | 48 | if ! groups | grep -q "$device_grp"; then 49 | echo "error: user (UID=`id -u`) is not a member of GID=$device_gid" >&2 50 | echo "error: if you run under docker rerun with:" >&2 51 | echo "error: --group-add=$device_gid" >&2 52 | echo "error: if you run on bare metal add user to group (see 'man 8 usermod')" >&2 53 | exit -1 54 | fi 55 | 56 | if ! capsh --print | grep Current | grep -q cap_sys_admin; then 57 | echo "error: no CAP_SYS_ADMIN capability (required to get GPU% metrics)" >&2 58 | echo "error: if you run under docker, rerun with:" >&2 59 | echo "error: --cap-add SYS_ADMIN" >&2 60 | exit -1 61 | fi 62 | 63 | content=/opt/data/content 64 | artifacts=/opt/data/artifacts 65 | 66 | function get_perm() { 67 | if [ "$1" = "r" ]; then 68 | echo "reading" 69 | elif [ "$1" = "w" ]; then 70 | echo "writing" 71 | else 72 | echo "bug: script does not support specified permission: $1" >&2 73 | fi 74 | } 75 | 76 | function print_error() { 77 | folder=$1 78 | perm=$2 79 | user=$3 80 | echo "error: can't access $folder for $(get_perm $perm) (UID=$(id -u))" >&2 81 | echo "error: if you attempt to map a host folder under docker" >&2 82 | echo "error: you might need to adjust its access permissions on a host side" >&2 83 | } 84 | 85 | function check_access() { 86 | folder=$1 87 | perm=$2 88 | if ! test -$perm $folder; then 89 | print_error $folder $perm $u 90 | exit -1 91 | fi 92 | } 93 | 94 | # verifying access rights to input/output folders 95 | check_access $content "r" user 96 | # demo scripts write logs and some output files (captured streaming 97 | # video) to $artifacts folder, and scripts also read and parse logs 98 | # to display monitoring statistics 99 | check_access $artifacts "r" user 100 | check_access $artifacts "w" user 101 | 102 | # cleaning up any prev. artifacts 103 | if find $artifacts -mindepth 1 | read; then 104 | echo "error: artifacts folder is not empty: $artifacts" >&2 105 | echo "error: if you run under docker, please, make sure to map" >&2 106 | echo "error: empty folder for output artifacts" >&2 107 | exit -1 108 | fi 109 | -------------------------------------------------------------------------------- /assets/gva/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | """ 4 | DL Streamer Python Tools 5 | 6 | DL Streamer is a streaming media analytics framework based on GStreamer* 7 | multimedia framework, for creating complex media analytics pipelines. 8 | It ensures pipeline interoperability and provides optimized media, 9 | and inference operations using Intel OpenVINO Toolkit Inference Engine 10 | backend. 11 | """ 12 | 13 | import pathlib 14 | from setuptools import setup, find_packages 15 | 16 | 17 | PYTHON_PROJECT = pathlib.Path(__file__).parent.resolve() 18 | 19 | version = (PYTHON_PROJECT / "build" / "version.txt").read_text(encoding="utf-8").rstrip() 20 | long_description = (PYTHON_PROJECT / "README.md").read_text(encoding="utf-8") 21 | 22 | 23 | setup( 24 | name="gstgva", 25 | version=version, 26 | author="Dmitry Rogozhkin", 27 | author_email="dmitry.v.rogozhkin@intel.com", 28 | description="DL Streamer Python Tools", 29 | long_description=long_description, 30 | long_description_content_type="text/markdown", 31 | url="https://github.com/openvinotoolkit/dlstreamer_gst.git", 32 | package_dir={"": "python"}, 33 | packages=[ 34 | "gstgva", 35 | "gstgva.audio" 36 | ], 37 | install_requires=[ 38 | "numpy>=1.19.2", 39 | "opencv-python>=4.2.0.34", 40 | ] 41 | ) 42 | -------------------------------------------------------------------------------- /assets/hello-bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (c) 2020 Intel Corporation 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | 23 | # This is samples default entrypoint script which prints out welcome 24 | # message, mimimal usage instructions and enters into container. 25 | 26 | source /etc/demo.env 27 | 28 | echo "Welcome to Media Analytics Demo!" 29 | echo 30 | echo "You've entered demo container with /bin/bash and can play around." 31 | echo 32 | echo "Have fun!" 33 | 34 | /bin/bash 35 | -------------------------------------------------------------------------------- /assets/info: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | commands=( 4 | "lsb_release -rdi" 5 | "uname -a" 6 | "cat /proc/cmdline" 7 | "cat /proc/cpuinfo | grep \"model name\" | uniq" 8 | "ls /dev/dri/" 9 | "lspci -nn | grep VGA" 10 | "cat /proc/sys/kernel/perf_event_paranoid") 11 | 12 | res=0 13 | 14 | for c in "${commands[@]}"; do 15 | echo "$ $c" 16 | eval "$c" 17 | tmp=$? 18 | [ $res -eq 0 ] && res=$tmp 19 | echo 20 | done 21 | 22 | exit $res 23 | -------------------------------------------------------------------------------- /assets/setup-apt-proxy: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (c) 2020 Intel Corporation 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | 23 | set -ex 24 | 25 | rm -f /etc/apt/apt.conf 26 | 27 | if [ -n "$http_proxy" ]; then 28 | echo "Acquire::http::proxy \"$http_proxy\";" >> /etc/apt/apt.conf 29 | fi 30 | 31 | if [ -n "$https_proxy" ]; then 32 | echo "Acquire::https::proxy \"$https_proxy\";" >> /etc/apt/apt.conf 33 | fi 34 | 35 | echo "http_proxy=$http_proxy" 36 | echo "https_proxy=$https_proxy" 37 | cat /etc/apt/apt.conf 38 | -------------------------------------------------------------------------------- /doc/apt.rst: -------------------------------------------------------------------------------- 1 | Local APT Repository 2 | ==================== 3 | 4 | This section provides steps on how to configure your own http:// APT repository 5 | to fetch packages from. This might be useful if you have some customized packages 6 | and need to build against these packages. If you build docker image, this helps 7 | to reduce image size since you avoid storing packages in the image. 8 | 9 | We will demonstrate configuring of APT repository via dedicated docker container. 10 | First, build a docker image with APT web server using the following Dockerfile:: 11 | 12 | $ cat Dockerfile 13 | FROM ubuntu:20.04 14 | 15 | RUN apt-get update && \ 16 | DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ 17 | aptly && \ 18 | rm -rf /var/lib/apt/lists/* 19 | 20 | # substituite this with other command to populate /opt/pkgs 21 | # directory with required *.deb packages 22 | COPY pkgs /opt/pkgs 23 | 24 | RUN aptly repo create intel-gfx 25 | RUN aptly repo add intel-gfx /opt/pkgs 26 | RUN aptly publish repo -skip-signing -distribution=intel-gfx intel-gfx 27 | CMD ["/usr/bin/aptly", "serve", "-listen=:8080"] 28 | 29 | $ docker build $(env | grep -E '(_proxy=|_PROXY)' | sed 's/^/--build-arg /') \ 30 | -f Dockerfile -t apt-webserver . 31 | 32 | Above docker file assumes that .deb packages are stored locally in ``pkgs`` directory. 33 | 34 | Now start APT webserver:: 35 | 36 | docker network create build 37 | docker create --network=build --name=local-apt apt-webserver 38 | docker start apt-webserver 39 | 40 | Now you should be able to fetch packages from your APT repository adding this line 41 | to /etc/apt/sources.list:: 42 | 43 | echo "deb [trusted=yes] http://:8080/ intel-gfx main" 44 | 45 | If you are using this under docker, make sure to run docker build under same network 46 | as we've created for apt-webserver and use IP address in this network, i.e.:: 47 | 48 | IP=$(docker inspect -f '{{.NetworkSettings.Networks.build.IPAddress}}' apt-webserver) 49 | docker build --network=build \ 50 | --build-arg INTEL_GFX_KEY_URL="" \ 51 | --build-arg INTEL_GFX_APT_REPO="deb [trusted=yes] http://$IP:8080/ intel-gfx main" \ 52 | ... 53 | 54 | -------------------------------------------------------------------------------- /doc/docker.rst: -------------------------------------------------------------------------------- 1 | Generating Dockerfiles 2 | ====================== 3 | 4 | .. contents:: 5 | 6 | Overview 7 | -------- 8 | 9 | Project includes pre-generated dockerfiles in the `docker <../docker>`_ 10 | folder for the key possible setups. If you've done any customizations to the 11 | dockefiles template sources, regenerate dockerfiles with the following 12 | commands:: 13 | 14 | cmake . 15 | make 16 | 17 | Dockerfiles Templates Structure 18 | ------------------------------- 19 | 20 | Top level Dockerfile templates are located in the subfolders of 21 | `docker <../docker>`_ folder: 22 | 23 | * `docker/va-samples/ubuntu20.04/intel-gfx/Dockerfile.m4 <../docker/va-samples/ubuntu20.04/intel-gfx/Dockerfile.m4>`_ 24 | * `docker/gst-gva/ubuntu20.04/intel-gfx/Dockerfile.m4 <../docker/gst-gva/ubuntu20.04/intel-gfx/Dockerfile.m4>`_ 25 | 26 | These templates include component ingredients defined in the .m4 files 27 | stored in `templates <../templates>`_ folder. 28 | 29 | Templates Parameters 30 | -------------------- 31 | 32 | It is possible to customize dockerfile setup passing some parameters during 33 | Dockerfile generation from templates. 34 | 35 | DEVEL 36 | Possible values: ``yes|no``. Default value: ``yes`` 37 | 38 | Switches on/off development build type with which container user is 39 | created with sudo privileges. 40 | 41 | -------------------------------------------------------------------------------- /doc/gstreamer.rst: -------------------------------------------------------------------------------- 1 | GStreamer 2 | ========= 3 | 4 | .. contents:: 5 | 6 | Overview 7 | -------- 8 | 9 | GStreamer is a framework for creating streaming media applications. 10 | 11 | The framework is based on plugins that will provide the various codec and other 12 | functionality. The plugins can be linked and arranged in a pipeline. This 13 | pipeline defines the flow of the data. 14 | 15 | Please refer to the official `documentation `_ for more details. 16 | 17 | GStreamer packages that are present in the containers: 18 | 19 | * gstreamer: the core package (gst-launch-1.0, filesrc, fakesink) 20 | * gst-plugins-base: an essential exemplary set of elements (playbin, decodebin, videoconvert) 21 | * gst-plugins-good: a set of good-quality plug-ins under LGPL (imagefreeze, qtdemux) 22 | * gst-plugins-bad: a set of plug-ins that need more quality (h265parse, fpsdisplaysink) 23 | * gstreamer-vaapi: a set of plug-ins that wrap libva for decoding and encoding (vaapih265dec, vaapih265enc) 24 | * DL Streamer: a set of GStreamer plugins for visual analytics (gvadetect, gvaclassify) 25 | 26 | Other packages not included into the container:: 27 | 28 | * gst-plugins-ugly: a set of good-quality plug-ins that might pose distribution problems 29 | 30 | You can use next command to get help about a GStreamer plugin (its capabilities and parameters):: 31 | 32 | gst-inspect-1.0 33 | 34 | Pipeline Examples 35 | ----------------- 36 | 37 | #. Playback media file and let GStreamer detect input type:: 38 | 39 | gst-launch-1.0 playbin uri=file://somefile.mp4 40 | 41 | #. Source media file and let GStreamer automatically apply demuxer / decoder:: 42 | 43 | gst-launch-1.0 filesrc location=somefile.mp4 ! decodebin ! fakesink 44 | 45 | #. Source media file (MP4 container) with specified demuxer and decoder:: 46 | 47 | gst-launch-1.0 filesrc location=somefile.mp4 ! qtdemux ! vaapih264dec ! \ 48 | fakesink 49 | 50 | #. Source video file (H265) and decode it:: 51 | 52 | gst-launch-1.0 filesrc location=somefile.h265 ! h265parse ! vaapih265dec ! \ 53 | fakesink 54 | 55 | #. Source video file and specify output memory type and image format for decoder:: 56 | 57 | gst-launch-1.0 filesrc location=somefile.h265 ! h265parse ! vaapih265dec ! \ 58 | video/x-raw(memory:DMABuf),format=RGBA ! fakesink 59 | 60 | #. Source video file, decode it and stop after 5th frame:: 61 | 62 | gst-launch-1.0 filesrc location=somefile.h265 ! h265parse ! vaapih265dec ! \ 63 | identity eos-after=5 ! fakesink 64 | 65 | #. Source image file and play it 1000 times (decoding happens only onces):: 66 | 67 | gst-launch-1.0 filesrc location=somefile.jpeg ! jpegparse ! vaapijpegdec ! \ 68 | imagefreeze num-buffers=1000 ! fakesink 69 | 70 | #. Run object detection on source video file using GPU device and save results 71 | to json:: 72 | 73 | gst-launch-1.0 filesrc location=somefile.h265 ! h265parse ! vaapih265dec ! \ 74 | gvadetect model=somemodel.xml device=GPU ! gvametaconvert ! \ 75 | gvametapublish file-path=results.json ! fakesink 76 | 77 | #. Run object detection and classification, draw bounding boxes and labels and 78 | save result video to a file:: 79 | 80 | gst-launch-1.0 filesrc location=somefile.h265 ! h265parse ! vaapih265dec ! \ 81 | gvadetect model=detectionmodel.xml device=GPU ! \ 82 | gvaclassify model=classificationmodel.xml device=GPU ! \ 83 | gvawatermark ! encodebin ! filesink location=result.h265 84 | -------------------------------------------------------------------------------- /doc/infostats.rst: -------------------------------------------------------------------------------- 1 | Info and Statistics 2 | =================== 3 | 4 | .. contents:: 5 | 6 | Overview 7 | -------- 8 | 9 | Docker images include some tools to query basic system information relevant 10 | to the key installed software and suggested workloads. This articles gives 11 | instruction on how to use these tools. 12 | 13 | We would like to pay attention on the following tools: 14 | 15 | info 16 | See: `info <../assets/info>`_ 17 | 18 | This is a small script which prints key system information. Provide this 19 | info to help triage issues you've met. 20 | 21 | vainfo 22 | This is a tool which reports media driver capabilities. 23 | 24 | clinfo 25 | This is a tool which reports OpenCL driver capabilities. 26 | 27 | perf 28 | This is a Linux perf tool which allows to get variety of HW and SW 29 | performance metrics. 30 | 31 | intel_gpu_top 32 | This is a tool which reports Intel GPU utilization along with few other 33 | useful characteristics such as current GPU frequency and interrupts 34 | number. 35 | 36 | Running tool in parallel to workload 37 | ------------------------------------ 38 | 39 | Usage of some tools is clear - you just enter container and execute them. 40 | This would go for ``info``, ``vainfo``, ``clinfo`` and Linux ``perf`` (till 41 | you use ``perf`` as a proxy command to actual workload). We still will give 42 | some advices on particular command lines to use. At the moment, however, 43 | let's focus on another type of usage specific to ``intel_gpu_top`` and Linux 44 | ``perf`` - when these tools are being executed in parallel to the running 45 | workload. Container specifics here is that you need to get additional 46 | console to actually run these tool in parrallel to your application. 47 | 48 | The advice here is to use ``--name `` docker-run option, i.e. assign 49 | container a name to ease accessing container 2nd time from another shell:: 50 | 51 | DEVICE=${DEVICE:-/dev/dri/renderD128} 52 | DEVICE_GRP=$(ls -g $DEVICE | awk '{print $3}' | \ 53 | xargs getent group | awk -F: '{print $3}') 54 | if [ -e /dev/dri/by-path ]; then BY_PATH="-v /dev/dri/by-path:/dev/dri/by-path"; fi 55 | docker run --rm -it \ 56 | -e DEVICE=$DEVICE --device $DEVICE --group-add $DEVICE_GRP $BY_PATH \ 57 | --cap-add SYS_ADMIN \ 58 | --name ma \ 59 | intel-media-analytics 60 | 61 | So, assuming you've entered container with the docker-run command above and 62 | started some workload, you now can add ``intel_gpu_top`` running in the same 63 | container in parallel to your workload:: 64 | 65 | docker exec ma /bin/demo-bash intel_gpu_top -d drm:$DEVICE 66 | 67 | Mind explicit specification if ``demo-bash`` entrypoint script. It is 68 | needed instead of generic ``bash`` to fetch container environment, i.e. 69 | location of apps installed in the container. 70 | 71 | If you just need to enter container, run:: 72 | 73 | docker exec ma /bin/hello-bash 74 | 75 | Tips on vainfo 76 | -------------- 77 | 78 | You can specify which backend and which device to use as follows:: 79 | 80 | vainfo --display drm --device $DEVICE 81 | 82 | Also pay attention on ``-a`` option which gives detailed driver 83 | capabilities:: 84 | 85 | vainfo --display drm --device $DEVICE -a 86 | 87 | Tips on intel_gpu_top 88 | --------------------- 89 | 90 | Use ``-d`` option to specify device you want to monitor:: 91 | 92 | intel_gpu_top -d drm:$DEVICE 93 | 94 | Pay attention on option ``-L`` which lists all available GPU devices:: 95 | 96 | intel_gpu_top -L 97 | 98 | You may find useful to use option ``-l`` to dump data in rough text format. 99 | -------------------------------------------------------------------------------- /doc/man/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Intel Corporation 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in all 11 | # copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | # SOFTWARE. 20 | 21 | # This is simple Makefile to build and install demo manual pages. It is supposed 22 | # to be run under docker build, so we skip comprehensive configure stage for now. 23 | 24 | INSTALL=install 25 | 26 | prefix?=$(HOME) 27 | mandir?=$(prefix)/share/man 28 | man1dir=$(mandir)/man1 29 | 30 | MAN:= 31 | MAN+=demo-bash.asciidoc 32 | MAN+=demo.env.asciidoc 33 | MAN+=demo-setup.asciidoc 34 | MAN+=demo-alive.asciidoc 35 | MAN+=ObjectDetection.asciidoc 36 | MAN+=ObjectClassification.asciidoc 37 | MAN+=SamplePipeline.asciidoc 38 | 39 | DOC_MAN1=$(patsubst %.asciidoc,%.1,$(MAN)) 40 | 41 | all: $(DOC_MAN1) 42 | 43 | %.1: %.asciidoc 44 | a2x --format manpage --no-xmllint $< 45 | 46 | clean: 47 | $(RM) *.1 48 | 49 | install: all 50 | $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir) 51 | $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir) 52 | -------------------------------------------------------------------------------- /doc/man/ObjectClassification.asciidoc: -------------------------------------------------------------------------------- 1 | ObjectClassification(1) 2 | ======================= 3 | 4 | NAME 5 | ---- 6 | ObjectClassification - run object classification for input video stream 7 | 8 | SYNOPSIS 9 | -------- 10 | [verse] 11 | 'ObjectClassification' [options] 12 | 13 | DESCRIPTION 14 | ----------- 15 | 16 | Runs object classification for the input stream specified with '-i' option. It is 17 | assumed that each frame contains a single object to classify. By default 18 | INT8 quantized resnet-50-tf model is used. Use '-m_classify' option to change the model. 19 | 20 | '-b' option sets batch size. 21 | 22 | In order to evaluate performance on multiple input streams, use '-c' option to 23 | emulate multiple inputs. Variate '-infer' to adjust number of inference 24 | instances (which will handle incoming requests from all of the input streams) and 25 | '-nireq' to adjust number of requests each inference instance can handle in parallel. 26 | 27 | OPTIONS 28 | ------- 29 | --help:: 30 | Print help 31 | 32 | -codec 264|265:: 33 | Use this codec to decode the video (default: 264) 34 | 35 | -c channels:: 36 | Number of input channels (default: 1). This option allows to emulate 37 | processing of multiple input streams (channels) in the same application. 38 | With this option input stream will be used specified number of times in 39 | parallel decoding+inference sessions. Each channel will be handled by 40 | dedicated decoder. Mind however that inference instances work independently 41 | and might process requests from different channels. Number of inference 42 | instances and how many requests can be processed by each are controlled 43 | by '-infer' and '-nireq' options respectively. 44 | 45 | -m_classify model:: 46 | xml model file name with absolute path, no .xml needed (default: /opt/intel/samples/models/resnet-50-tf_INT8/resnet-50-tf_i8) 47 | 48 | -b batch_number:: 49 | Batch number in the inference model (default: 1) 50 | 51 | -infer inference_instances_number:: 52 | Number of independent inference instances to process incoming inference 53 | requests in parallel (default: 1). Each inference instance can accept few 54 | requests for parallel processing, number of such requests is controlled 55 | by '-nireq' option. 56 | 57 | -nireq req_number:: 58 | Number of requests (default: 1) 59 | 60 | -r vp_ratio:: 61 | Ratio of decoded frames to inference frames (default: 1), =2 means doing inference every other frame. 62 | "vp" stands for video processing meaning scaling operation to get input for the inference. 63 | 64 | -scale hq|fast_inplace|fast:: 65 | Scaling mode to use: 66 | * hq - run scaling on EUs thru rcs or ccs depending on the platform 67 | * fast_inplace - run scaling with affinity to decoding, i.e. on the same vcs; scaling is done thru SFC 68 | * fast - run scaling via vecs, scaling is done thru SFC (this is default) 69 | 70 | -t seconds:: 71 | How many seconds this app should run. If this option is specified 72 | input stream is being used in a loop. 73 | 74 | -d:: 75 | Dump inference input (= vp output). 76 | 77 | -p:: 78 | Toggle performance mode, don't dump the csv results. 79 | 80 | -va_share:: 81 | Share surfaces between media and inferece. This is performance 82 | optimization option and is strongly recommended. 83 | 84 | OUTPUTS 85 | ------- 86 | 87 | output.csv:: 88 | This is major output containing detected objects label IDs and bounding box 89 | coordinates. Output can be disabled with '-p' option. File format: 90 | 91 | ------------ 92 | channel#, frame#, object#, left, top, right, bottom, id, probability 93 | ------------ 94 | 95 | VPOut_%d.300x300.rgbp:: 96 | Rough output in RGBP of the inference input (these are frames scaled per model 97 | requirements). Output is produced per each channel (mind '%d' in the file 98 | name pattern) only if '-d' option is specified on a command line. 99 | 100 | SEE ALSO 101 | -------- 102 | link:ObjectDetection.asciidoc[ObjectDetection] 103 | link:SamplePipeline.asciidoc[SamplePipeline] 104 | 105 | -------------------------------------------------------------------------------- /doc/man/ObjectDetection.asciidoc: -------------------------------------------------------------------------------- 1 | ObjectDetection(1) 2 | ================== 3 | 4 | NAME 5 | ---- 6 | ObjectDetection - run object detection for input video stream 7 | 8 | SYNOPSIS 9 | -------- 10 | [verse] 11 | 'ObjectDetection' [options] 12 | 13 | DESCRIPTION 14 | ----------- 15 | 16 | Runs object detection for the input stream specified with '-i' option. By default 17 | INT8 quantized ssd_mobilenet_v1_coco model is used. Use '-detect_type yolo' with '-m_detect' to change 18 | model type and point to Yolov4 model location. 19 | 20 | '-dconf' option specifies confidence threshold: only results with the higher confidence 21 | then the threshold will be posted. '-b' options sets batch size. 22 | 23 | In order to evaluate performance on multiple input streams, use '-c' option to 24 | emulate multiple inputs. Variate '-infer' to adjust number of inference 25 | instances (which will handle incoming requests from all of the input streams) and 26 | '-nireq' to adjust number of requests each inference instance can handle in parallel. 27 | 28 | OPTIONS 29 | ------- 30 | --help:: 31 | Print help 32 | 33 | -codec 264|265:: 34 | Use this codec to decode the video (default: 264) 35 | 36 | -c channels:: 37 | Number of input channels (default: 1). This option allows to emulate 38 | processing of multiple input streams (channels) in the same application. 39 | With this option input stream will be used specified number of times in 40 | parallel decoding+inference sessions. Each channel will be handled by 41 | dedicated decoder. Mind however that inference instances work independently 42 | and might process requests from different channels. Number of inference 43 | instances and how many requests can be processed by each are controlled 44 | by '-infer' and '-nireq' options respectively. 45 | 46 | -m_detect model:: 47 | xml model file name with absolute path, no .xml needed (default: /opt/intel/samples/models/ssd_mobilenet_v1_coco_INT8/ssd_mobilenet_v1_coco) 48 | 49 | -detect_type ssd|yolo:: 50 | Detection model type (default: ssd) 51 | 52 | -dshape_w width:: 53 | Detection model input reshape width 54 | * ssd default: 300 55 | * yolo default: 416 56 | 57 | -dshape_h height:: 58 | Detection model input reshape height 59 | * ssd default: 300 60 | * yolo default: 416 61 | 62 | -dconf threshold:: 63 | Minimum detection output confidence, range [0-1] (default: 0.8) 64 | 65 | -b batch_number:: 66 | Batch number in the inference model (default: 1) 67 | 68 | -infer inference_instances_number:: 69 | Number of independent inference instances to process incoming inference 70 | requests in parallel (default: 1). Each inference instance can accept few 71 | requests for parallel processing, number of such requests is controlled 72 | by '-nireq' option. 73 | 74 | -nireq req_number:: 75 | Number of requests (default: 1) 76 | 77 | -r vp_ratio:: 78 | Ratio of decoded frames to inference frames (default: 1), =2 means doing inference every other frame. 79 | "vp" stands for video processing meaning scaling operation to get input for the inference. 80 | 81 | -scale hq|fast_inplace|fast:: 82 | Scaling mode to use: 83 | * hq - run scaling on EUs thru rcs or ccs depending on the platform 84 | * fast_inplace - run scaling with affinity to decoding, i.e. on the same vcs; scaling is done thru SFC 85 | * fast - run scaling via vecs, scaling is done thru SFC (this is default) 86 | 87 | -t seconds:: 88 | How many seconds this app should run. If this option is specified 89 | input stream is being used in a loop. 90 | 91 | -d:: 92 | Dump inference input (= vp output). 93 | 94 | -p:: 95 | Toggle performance mode, don't dump the csv results. 96 | 97 | -va_share:: 98 | Share surfaces between media and inferece. This is performance 99 | optimization option and is strongly recommended. 100 | 101 | OUTPUTS 102 | ------- 103 | 104 | output.csv:: 105 | This is major output containing detected objects label IDs and bounding box 106 | coordinates. Output can be disabled with '-p' option. File format: 107 | 108 | ------------ 109 | channel#, frame#, object#, left, top, right, bottom, id, probability 110 | ------------ 111 | 112 | VPOut_%d.300x300.rgbp:: 113 | Rough output in RGBP of the inference input (these are frames scaled per model 114 | requirements). Output is produced per each channel (mind '%d' in the file 115 | name pattern) only if '-d' option is specified on a command line. 116 | 117 | SEE ALSO 118 | -------- 119 | link:ObjectClassification.asciidoc[ObjectClassification] 120 | link:SamplePipeline.asciidoc[SamplePipeline] 121 | 122 | -------------------------------------------------------------------------------- /doc/man/demo-alive.asciidoc: -------------------------------------------------------------------------------- 1 | demo-alive(1) 2 | ============= 3 | 4 | NAME 5 | ---- 6 | demo-alive - run a healthcheck 7 | 8 | SYNOPSIS 9 | -------- 10 | [verse] 11 | 'demo-alive' 12 | 13 | DESCRIPTION 14 | ----------- 15 | `demo-alive` performs a healthcheck of the running demo. Under docker this 16 | script is connected to the docker HEALTHCHECK command. With that you can 17 | check container health status with: 18 | 19 | ------------ 20 | docker inspect --format='{{json .State.Health}}' 21 | ------------ 22 | 23 | -------------------------------------------------------------------------------- /doc/man/demo-bash.asciidoc: -------------------------------------------------------------------------------- 1 | demo-bash(1) 2 | ============ 3 | 4 | NAME 5 | ---- 6 | demo-bash - media analytics containers entrypoint 7 | 8 | SYNOPSIS 9 | -------- 10 | [verse] 11 | 'demo-bash' [ []] 12 | 13 | DESCRIPTION 14 | ----------- 15 | 'demo-bash' is media analytics containers entrypoint. It gets executed anytime 16 | you try to run anything via container. This script assures that correct 17 | environment is setup and acts as follows. First it `source /etc/demo.env` to 18 | get demo environment variables. Then it executes `demo-setup` script which 19 | should setup demo environment and return non-zero exit status in case of 20 | any errors. If 'demo-bash' sees an error form `demo-setup` it exits 21 | immediately dumping error message to `stderr`. This behavior can be 22 | overwritten with `IGNORE_ERRORS=yes` enviroment variable. 23 | 24 | In the very end 'demo-bash' executes specified command. 25 | 26 | Media analytics containers are configured in a way that if no command is 27 | specified they just enter shell displaying welcome message. The latter 28 | is achieved via helper 'hello-bash' script which gets passed to 29 | 'demo-bash' as a command by default. 30 | 31 | ENVIRONMENT VARIABLES 32 | --------------------- 33 | 34 | IGNORE_ERRORS=yes|no:: 35 | Ignore any errors during demo setup and enter the container. This 36 | can be useful if you want to check container structure or component versions 37 | without really running the demo on a system without GPU. (default: `no`) 38 | 39 | SEE ALSO 40 | -------- 41 | link:demo.env.asciidoc[demo.env] 42 | link:demo-setup.asciidoc[demo-setup] 43 | link:hello-bash.asciidoc[hello-bash] 44 | 45 | -------------------------------------------------------------------------------- /doc/man/demo-setup.asciidoc: -------------------------------------------------------------------------------- 1 | demo-setup(1) 2 | ============= 3 | 4 | NAME 5 | ---- 6 | demo-setup - script which setups a demo 7 | 8 | SYNOPSIS 9 | -------- 10 | [verse] 11 | 'demo-setup' 12 | 13 | DESCRIPTION 14 | ----------- 15 | `demo setup` is a script which helps to setup a demo on a container launch. 16 | It checks for a various issues which might prevent successful demo and 17 | returns non-zero exit status if any detected. 18 | 19 | Script checks that container user: 20 | 21 | * Has enough permissions to access GPU for media and inference operations 22 | * Can run Intel GPU Top to get GPU utilization metrics 23 | * Can access input/output directories to read input data or store output artifacts 24 | 25 | USER ACCOUNTS 26 | ------------- 27 | user:: 28 | This is a default generic user account configured for containers. 29 | 30 | PATHS 31 | ----- 32 | /opt/data/artifacts:: 33 | Location for various demo output artifacts. 34 | 'user' needs 'rw' permissions for this location. 35 | 36 | /opt/data/content:: 37 | Location where you can put your own content for the demo to see. 38 | 'user' needs 'r' permission for this location. 39 | 40 | EXIT STATUS 41 | ----------- 42 | 0 - setup was successful 43 | 44 | 255 - setup failed 45 | 46 | SEE ALSO 47 | -------- 48 | link:demo-bash.asciidoc[demo-bash] 49 | link:demo-setup.asciidoc[demo-setup] 50 | 51 | -------------------------------------------------------------------------------- /doc/man/demo.env.asciidoc: -------------------------------------------------------------------------------- 1 | demo.env(1) 2 | =========== 3 | 4 | NAME 5 | ---- 6 | demo.env - script w/ solution environment variables 7 | 8 | SYNOPSIS 9 | -------- 10 | [verse] 11 | 'source /etc/demo.env' 12 | 13 | DESCRIPTION 14 | ----------- 15 | 'demo.env' is a script which contains solution environment variables. It 16 | might adjust some standard environemnt variables as well. For example, 17 | 'PATH'. 18 | 19 | ENVIRONMENT VARIABLES 20 | --------------------- 21 | DEMO_PREFIX:: 22 | Path prefix pointing to the location of demo scripts, applications, 23 | libraries. 24 | 25 | SEE ALSO 26 | -------- 27 | link:demo-bash.asciidoc[demo-bash] 28 | link:demo-setup.asciidoc[demo-setup] 29 | -------------------------------------------------------------------------------- /doc/man/hello-bash.asciidoc: -------------------------------------------------------------------------------- 1 | hello-bash(1) 2 | ============= 3 | 4 | NAME 5 | ---- 6 | hello-bash - default visual analytic solutions entrypoint 7 | 8 | SYNOPSIS 9 | -------- 10 | [verse] 11 | 'hello-bash' 12 | 13 | DESCRIPTION 14 | ----------- 15 | Default and trivial visual analytic solutions entrypoint which gets executed 16 | if you started container without any command. It just prints welcome message 17 | where it gives some advice to run some demo commands and enters bash shell. 18 | If you run container in interactive mode you can wander about and check 19 | what's going on. 20 | 21 | SEE ALSO 22 | -------- 23 | link:demo-bash.asciidoc[demo-bash] 24 | -------------------------------------------------------------------------------- /doc/man/readme.rst: -------------------------------------------------------------------------------- 1 | Manual Pages 2 | ============ 3 | 4 | Media Analytics Software Stack comes with comprehensive manual pages available 5 | from inside the running container via `man ` command and online. 6 | 7 | Tools manual pages 8 | ================== 9 | 10 | * `ObjectDetection `_ 11 | * `ObjectClassification `_ 12 | * `SamplePipeline `_ 13 | 14 | Container entrypoints and setup manual pages 15 | ============================================ 16 | 17 | * `demo-bash `_ 18 | * `demo.env `_ 19 | * `demo-setup `_ 20 | * `hello-bash `_ 21 | -------------------------------------------------------------------------------- /doc/open_vino_tools.rst: -------------------------------------------------------------------------------- 1 | OpenVINO tools 2 | ============== 3 | 4 | .. contents:: 5 | 6 | Overview 7 | -------- 8 | 9 | The OpenVINO Toolkit Open Model Zoo includes pre-trained optimized deep 10 | learning models along with download and conversion tools. 11 | 12 | The detailed listing of all publicly available models is `here 13 | `_. 14 | 15 | A detailed overview of all Intel's pre-trained models is `here 16 | `_. 17 | 18 | Print all available models 19 | -------------------------- 20 | 21 | Models available in the zoo can be listed with the following command:: 22 | 23 | omz_downloader --print_all 24 | 25 | Download available models 26 | ------------------------- 27 | 28 | To download the tensorflow version of `ssd_mobilenet_v1_coco `_ model:: 29 | 30 | omz_downloader --name ssd_mobilenet_v1_coco -o models 31 | 32 | To download the tensorflow version of `resnet-50-tf `_ model:: 33 | 34 | omz_downloader --name resnet-50-tf -o models 35 | 36 | Converting Available Models 37 | --------------------------- 38 | 39 | Public models which are not stored in OpenVINO IR representation must be 40 | converted before use with the OpenVINO inference engine. 41 | For models that are already stored in OpenVINO IR (e.g. Intel models) 42 | no conversion is required - they can be used right away. 43 | 44 | To convert the ssd_mobilenet_v1_coco model into openvino IR use the command:: 45 | 46 | omz_converter --name ssd_mobilenet_v1_coco -d models 47 | 48 | After execution of ``omz_converter`` command, the converted model 49 | in OV IR format will be created in directories ``FP32`` and ``FP16``:: 50 | 51 | $ ls models/public/ssd_mobilenet_v1_coco/FP32/ 52 | ssd_mobilenet_v1_coco.bin ssd_mobilenet_v1_coco.mapping ssd_mobilenet_v1_coco.xml 53 | 54 | $ ls models/public/ssd_mobilenet_v1_coco/FP16/ 55 | ssd_mobilenet_v1_coco.bin ssd_mobilenet_v1_coco.mapping ssd_mobilenet_v1_coco.xml 56 | 57 | To convert the resnet-50-tf model into opevino IR use the command:: 58 | 59 | omz_converter --name resnet-50-tf -d models 60 | 61 | After execution of the above command, the converted model 62 | in OV IR format will be created in directories ``FP32`` and ``FP16``:: 63 | 64 | $ ls models/public/resnet-50-tf/FP32/ 65 | resnet-50-tf.bin resnet-50-tf.mapping resnet-50-tf.xml 66 | 67 | $ ls models/public/resnet-50-tf/FP16/ 68 | resnet-50-tf.bin resnet-50-tf.mapping resnet-50-tf.xml 69 | 70 | The above models (FP32/ FP16) can now be used to execute inference applications using open vino backend. 71 | 72 | Using open vino IR models in inference applications 73 | --------------------------------------------------- 74 | 75 | Object Detection 76 | ^^^^^^^^^^^^^^^^ 77 | Using *VA Sample* :: 78 | 79 | ObjectDetection -m_detect models/public/ssd_mobilenet_v1_coco/FP32/ssd_mobilenet_v1_coco \ 80 | -codec 264 -c 1 \ 81 | -i /opt/data/embedded/pexels-1388365.h264 \ 82 | -infer 1 -b 1 -r 1 \ 83 | -scale fast \ 84 | -d -t 3 85 | 86 | Using *gstreamer/DLStreamer* :: 87 | 88 | gst-launch-1.0 filesrc location=/opt/data/embedded/pexels-1388365.h264 ! \ 89 | video/x-h264 ! h264parse ! video/x-h264 ! vaapih264dec ! video/x-raw\(memory:VASurface\) ! \ 90 | gvadetect device=GPU nireq=1 batch-size=1 pre-process-backend=vaapi inference-interval=1 \ 91 | model=models/public/ssd_mobilenet_v1_coco/FP32/ssd_mobilenet_v1_coco.xml \ 92 | model-instance-id=detect ! \ 93 | gvametaconvert ! gvametapublish file-path=results.jsonl method=file file-format=json-lines ! \ 94 | gvafpscounter ! fakesink async=false 95 | 96 | Sample Pipeline 97 | ^^^^^^^^^^^^^^^ 98 | Using *VA Sample* :: 99 | 100 | SamplePipeline \ 101 | -m_detect models/public/ssd_mobilenet_v1_coco/FP32/ssd_mobilenet_v1_coco \ 102 | -m_classify models/public/resnet-50-tf/FP32/resnet-50-tf \ 103 | -codec 264 -c 1 \ 104 | -i /opt/data/embedded/pexels-1388365.h264 105 | -infer 1 -b 1 -r 1 \ 106 | -scale fast \ 107 | -d -t 3 108 | 109 | Using *gstreamer/DLStreamer* :: 110 | 111 | gst-launch-1.0 filesrc location=/opt/data/embedded/pexels-1388365.h264 ! \ 112 | video/x-h264 ! h264parse ! video/x-h264 ! vaapih264dec name=decode0 ! video/x-raw\(memory:VASurface\) ! \ 113 | gvaclassify device=GPU nireq=1 batch-size=1 pre-process-backend=vaapi inference-interval=1 \ 114 | model=models/public/resnet-50-tf/FP32/resnet-50-tf.xml model-instance-id=classify \ 115 | inference-region=full-frame ! \ 116 | gvametaconvert ! gvametapublish file-path=results.jsonl method=file file-format=json-lines ! \ 117 | gvafpscounter ! fakesink async=false 118 | 119 | -------------------------------------------------------------------------------- /doc/pic/media-analytics-sw-stack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/media-analytics/f63c0c3e9ef08322c8de6ff756254067f84a116a/doc/pic/media-analytics-sw-stack.png -------------------------------------------------------------------------------- /doc/pic/media_analytics_pipeline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/media-analytics/f63c0c3e9ef08322c8de6ff756254067f84a116a/doc/pic/media_analytics_pipeline.png -------------------------------------------------------------------------------- /doc/pic/media_analytics_pipeline_detailed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/media-analytics/f63c0c3e9ef08322c8de6ff756254067f84a116a/doc/pic/media_analytics_pipeline_detailed.png -------------------------------------------------------------------------------- /doc/pic/use_cases.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/media-analytics/f63c0c3e9ef08322c8de6ff756254067f84a116a/doc/pic/use_cases.png -------------------------------------------------------------------------------- /doc/pic/va-sample-full-pipeline-arch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/media-analytics/f63c0c3e9ef08322c8de6ff756254067f84a116a/doc/pic/va-sample-full-pipeline-arch.png -------------------------------------------------------------------------------- /doc/pic/va-sample-oc-arch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/media-analytics/f63c0c3e9ef08322c8de6ff756254067f84a116a/doc/pic/va-sample-oc-arch.png -------------------------------------------------------------------------------- /doc/pic/va-sample-od-arch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/media-analytics/f63c0c3e9ef08322c8de6ff756254067f84a116a/doc/pic/va-sample-od-arch.png -------------------------------------------------------------------------------- /docker/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Intel Corporation 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in all 11 | # copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | # SOFTWARE. 20 | 21 | add_subdirectory(va-samples) 22 | add_subdirectory(gst-gva) 23 | add_subdirectory(devel) 24 | 25 | -------------------------------------------------------------------------------- /docker/devel/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Intel Corporation 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in all 11 | # copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | # SOFTWARE. 20 | 21 | add_subdirectory(ubuntu20.04) 22 | -------------------------------------------------------------------------------- /docker/devel/ubuntu20.04/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Intel Corporation 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in all 11 | # copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | # SOFTWARE. 20 | 21 | file(GLOB_RECURSE srcs ${CMAKE_SOURCE_DIR}/templates/*.m4) 22 | 23 | set(M4FLAGS ${M4FLAGS} -E 24 | -I ${CMAKE_SOURCE_DIR}/templates 25 | -I ${CMAKE_SOURCE_DIR}/templates/m4docker/system 26 | -I ${CMAKE_SOURCE_DIR}/templates/m4docker/components 27 | -D BUILD_PATCHES=patches -D DEVEL) 28 | 29 | add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/intel-gfx/Dockerfile 30 | DEPENDS ${srcs} 31 | ${CMAKE_CURRENT_SOURCE_DIR}/intel-gfx/Dockerfile.m4 32 | COMMAND ${M4} ${M4FLAGS} -D OS_NAME=ubuntu -D OS_VERSION=20.04 -D LOCAL_REPO=false 33 | ${CMAKE_CURRENT_SOURCE_DIR}/intel-gfx/Dockerfile.m4 > ${CMAKE_CURRENT_SOURCE_DIR}/intel-gfx/Dockerfile 34 | VERBATIM 35 | ) 36 | 37 | add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/intel-gfx/Dockerfile.local 38 | DEPENDS ${srcs} 39 | ${CMAKE_CURRENT_SOURCE_DIR}/intel-gfx/Dockerfile.m4 40 | COMMAND ${M4} ${M4FLAGS} -D OS_NAME=ubuntu -D OS_VERSION=20.04 -D LOCAL_REPO=true 41 | ${CMAKE_CURRENT_SOURCE_DIR}/intel-gfx/Dockerfile.m4 > ${CMAKE_CURRENT_SOURCE_DIR}/intel-gfx/Dockerfile.local 42 | VERBATIM 43 | ) 44 | 45 | add_custom_target(devel-ubuntu20.04-dockerfiles ALL DEPENDS 46 | ${CMAKE_CURRENT_SOURCE_DIR}/intel-gfx/Dockerfile 47 | ${CMAKE_CURRENT_SOURCE_DIR}/intel-gfx/Dockerfile.local) 48 | 49 | include(sources_ext.cmake OPTIONAL) 50 | -------------------------------------------------------------------------------- /docker/devel/ubuntu20.04/intel-gfx/Dockerfile.m4: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021 Intel Corporation 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in all 11 | # copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | # SOFTWARE. 20 | 21 | define(`DLDT_WITH_MO',true)dnl 22 | include(defs.m4) 23 | include(begin.m4) 24 | ifelse(LOCAL_REPO,true, 25 | `include(intel-gfx-local.m4)', 26 | `include(intel-gfx.m4)') 27 | include(content.m4) 28 | include(models.m4) 29 | include(opencv.m4) 30 | include(dldt-ie.m4) 31 | include(gst-gva-sample.m4) 32 | include(va_sample.m4) 33 | include(open_model_zoo.m4) 34 | include(manuals.m4) 35 | include(samples.m4) 36 | include(end.m4) 37 | PREAMBLE 38 | 39 | ARG IMAGE=OS_NAME:OS_VERSION 40 | FROM $IMAGE AS base 41 | 42 | ENABLE_INTEL_GFX_REPO 43 | 44 | FROM base as content 45 | 46 | GET_CONTENT 47 | GET_MODELS 48 | 49 | FROM base as build 50 | 51 | BUILD_ALL()dnl 52 | CLEANUP()dnl 53 | 54 | # Ok, here goes the final image end-user will actually see 55 | FROM base 56 | 57 | LABEL vendor="Intel Corporation" 58 | 59 | INSTALL_CONTENT(content) 60 | INSTALL_MODELS(content) 61 | 62 | INSTALL_ALL(runtime,build) 63 | 64 | USER user 65 | WORKDIR /home/user 66 | -------------------------------------------------------------------------------- /docker/gst-gva/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Intel Corporation 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in all 11 | # copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | # SOFTWARE. 20 | 21 | add_subdirectory(ubuntu20.04) 22 | -------------------------------------------------------------------------------- /docker/gst-gva/ubuntu20.04/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Intel Corporation 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in all 11 | # copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | # SOFTWARE. 20 | 21 | file(GLOB_RECURSE srcs ${CMAKE_SOURCE_DIR}/templates/*.m4) 22 | 23 | set(M4FLAGS ${M4FLAGS} -E 24 | -I ${CMAKE_SOURCE_DIR}/templates 25 | -I ${CMAKE_SOURCE_DIR}/templates/m4docker/system 26 | -I ${CMAKE_SOURCE_DIR}/templates/m4docker/components 27 | -D BUILD_PATCHES=patches -D DEVEL) 28 | 29 | add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/intel-gfx/Dockerfile 30 | DEPENDS ${srcs} 31 | ${CMAKE_CURRENT_SOURCE_DIR}/intel-gfx/Dockerfile.m4 32 | COMMAND ${M4} ${M4FLAGS} -D OS_NAME=ubuntu -D OS_VERSION=20.04 33 | ${CMAKE_CURRENT_SOURCE_DIR}/intel-gfx/Dockerfile.m4 > ${CMAKE_CURRENT_SOURCE_DIR}/intel-gfx/Dockerfile 34 | VERBATIM 35 | ) 36 | 37 | add_custom_target(gst-gva-ubuntu20.04-dockerfiles ALL DEPENDS 38 | ${CMAKE_CURRENT_SOURCE_DIR}/intel-gfx/Dockerfile) 39 | 40 | include(sources_ext.cmake OPTIONAL) 41 | 42 | -------------------------------------------------------------------------------- /docker/gst-gva/ubuntu20.04/intel-gfx/Dockerfile.m4: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Intel Corporation 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in all 11 | # copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | # SOFTWARE. 20 | 21 | include(defs.m4)dnl 22 | include(begin.m4) 23 | include(intel-gfx.m4) 24 | include(content.m4) 25 | include(models.m4) 26 | include(dldt-ie.m4) 27 | include(opencv.m4) 28 | include(gst-gva-sample.m4) 29 | include(manuals.m4) 30 | include(samples.m4) 31 | include(end.m4) 32 | PREAMBLE 33 | 34 | ARG IMAGE=OS_NAME:OS_VERSION 35 | FROM $IMAGE AS base 36 | 37 | ENABLE_INTEL_GFX_REPO 38 | 39 | FROM base as content 40 | 41 | GET_CONTENT 42 | GET_MODELS 43 | 44 | FROM base as build 45 | 46 | BUILD_ALL()dnl 47 | CLEANUP()dnl 48 | 49 | # Ok, here goes the final image end-user will actually see 50 | FROM base 51 | 52 | LABEL vendor="Intel Corporation" 53 | 54 | INSTALL_CONTENT(content) 55 | INSTALL_MODELS(content) 56 | 57 | INSTALL_ALL(runtime,build) 58 | 59 | USER user 60 | WORKDIR /home/user 61 | 62 | -------------------------------------------------------------------------------- /docker/helpers/ubuntu20.04/intel-gfx/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021 Intel Corporation 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in all 11 | # copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | # SOFTWARE. 20 | 21 | ARG IMAGE=ubuntu:20.04 22 | FROM $IMAGE AS base 23 | 24 | RUN apt-get update && \ 25 | DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ 26 | curl dpkg-dev ca-certificates gpg-agent software-properties-common && \ 27 | rm -rf /var/lib/apt/lists/* 28 | 29 | RUN curl -fsSL https://repositories.intel.com/graphics/intel-graphics.key | apt-key add - 30 | RUN apt-add-repository "deb https://repositories.intel.com/graphics/ubuntu focal main" 31 | 32 | RUN apt-get update && apt-get install -y -d \ 33 | intel-media-va-driver-non-free \ 34 | intel-opencl-icd \ 35 | libdrm-dev \ 36 | libigfxcmrt7 \ 37 | libigfxcmrt-dev \ 38 | libmfx1 \ 39 | libmfx-dev \ 40 | libva2 \ 41 | libva-drm2 \ 42 | libva-x11-2 \ 43 | libva-wayland2 \ 44 | libva-dev \ 45 | vainfo \ 46 | >/tmp/downloaded.txt 2>&1 47 | 48 | RUN cat /tmp/downloaded.txt | grep "repositories.intel.com" | cut -f5 -d\ >/tmp/list.txt; 49 | RUN mkdir /opt/apt-pkgs && while read p; do cp /var/cache/apt/archives/$p*.deb /opt/apt-pkgs/; done Packages 51 | -------------------------------------------------------------------------------- /docker/va-samples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Intel Corporation 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in all 11 | # copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | # SOFTWARE. 20 | 21 | add_subdirectory(ubuntu20.04) 22 | -------------------------------------------------------------------------------- /docker/va-samples/ubuntu20.04/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Intel Corporation 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in all 11 | # copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | # SOFTWARE. 20 | 21 | file(GLOB_RECURSE srcs ${CMAKE_SOURCE_DIR}/templates/*.m4) 22 | 23 | set(M4FLAGS ${M4FLAGS} -E 24 | -I ${CMAKE_SOURCE_DIR}/templates 25 | -I ${CMAKE_SOURCE_DIR}/templates/m4docker/system 26 | -I ${CMAKE_SOURCE_DIR}/templates/m4docker/components 27 | -D BUILD_PATCHES=patches -D DEVEL) 28 | 29 | add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/intel-gfx/Dockerfile 30 | DEPENDS ${srcs} 31 | ${CMAKE_CURRENT_SOURCE_DIR}/intel-gfx/Dockerfile.m4 32 | COMMAND ${M4} ${M4FLAGS} -D OS_NAME=ubuntu -D OS_VERSION=20.04 33 | ${CMAKE_CURRENT_SOURCE_DIR}/intel-gfx/Dockerfile.m4 > ${CMAKE_CURRENT_SOURCE_DIR}/intel-gfx/Dockerfile 34 | VERBATIM 35 | ) 36 | 37 | add_custom_target(va-samples-ubuntu20.04-dockerfiles ALL DEPENDS 38 | ${CMAKE_CURRENT_SOURCE_DIR}/intel-gfx/Dockerfile) 39 | 40 | include(sources_ext.cmake OPTIONAL) 41 | 42 | -------------------------------------------------------------------------------- /docker/va-samples/ubuntu20.04/intel-gfx/Dockerfile.m4: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Intel Corporation 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in all 11 | # copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | # SOFTWARE. 20 | 21 | include(defs.m4)dnl 22 | include(begin.m4) 23 | include(intel-gfx.m4) 24 | include(content.m4) 25 | include(models.m4) 26 | include(opencv.m4) 27 | include(dldt-ie.m4) 28 | include(va_sample.m4) 29 | include(manuals.m4) 30 | include(samples.m4) 31 | include(end.m4) 32 | PREAMBLE 33 | 34 | ARG IMAGE=OS_NAME:OS_VERSION 35 | FROM $IMAGE AS base 36 | 37 | ENABLE_INTEL_GFX_REPO 38 | 39 | FROM base as content 40 | 41 | GET_CONTENT 42 | GET_MODELS 43 | 44 | FROM base as build 45 | 46 | BUILD_ALL()dnl 47 | CLEANUP()dnl 48 | 49 | # Ok, here goes the final image end-user will actually see 50 | FROM base 51 | 52 | LABEL vendor="Intel Corporation" 53 | 54 | INSTALL_CONTENT(content) 55 | INSTALL_MODELS(content) 56 | 57 | INSTALL_ALL(runtime,build) 58 | 59 | USER user 60 | WORKDIR /home/user 61 | 62 | -------------------------------------------------------------------------------- /patches/readme.rst: -------------------------------------------------------------------------------- 1 | Patches 2 | ======= 3 | 4 | This folder contains patches for the software included in Media Delivery 5 | Software Stacks. Folder is structured in the following way:: 6 | 7 | / 8 | / 9 | / 10 | / 11 | 12 | So, there is a folder for each component which can be patched. Each 13 | patch is applied with `patch` command like:: 14 | 15 | patch -p1 < patches// 16 | -------------------------------------------------------------------------------- /templates/content.m4: -------------------------------------------------------------------------------- 1 | dnl # Copyright (c) 2020 Intel Corporation 2 | dnl # 3 | dnl # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | dnl # of this software and associated documentation files (the "Software"), to deal 5 | dnl # in the Software without restriction, including without limitation the rights 6 | dnl # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | dnl # copies of the Software, and to permit persons to whom the Software is 8 | dnl # furnished to do so, subject to the following conditions: 9 | dnl # 10 | dnl # The above copyright notice and this permission notice shall be included in all 11 | dnl # copies or substantial portions of the Software. 12 | dnl # 13 | dnl # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | dnl # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | dnl # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | dnl # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | dnl # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | dnl # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | dnl # SOFTWARE. 20 | dnl # 21 | include(begin.m4) 22 | 23 | define(`GET_CONTENT',`dnl 24 | INSTALL_PKGS(`ca-certificates ffmpeg wget') 25 | 26 | RUN mkdir -p /opt/downloads && cd /opt/downloads && \ 27 | wget -O pexels-1388365.mp4 --progress=bar:force https://www.pexels.com/photo/1388365/download 28 | 29 | RUN cd /opt/downloads && \ 30 | ffmpeg -i pexels-1388365.mp4 -an -vcodec copy pexels-1388365.h264 31 | 32 | RUN rm -rf /opt/downloads/*.mp4') 33 | 34 | define(`INSTALL_CONTENT',`dnl 35 | COPY --from=$1 /opt/downloads /opt/data/embedded') 36 | 37 | include(end.m4) 38 | -------------------------------------------------------------------------------- /templates/defs.m4: -------------------------------------------------------------------------------- 1 | dnl # Copyright (c) 2020 Intel Corporation 2 | dnl # 3 | dnl # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | dnl # of this software and associated documentation files (the "Software"), to deal 5 | dnl # in the Software without restriction, including without limitation the rights 6 | dnl # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | dnl # copies of the Software, and to permit persons to whom the Software is 8 | dnl # furnished to do so, subject to the following conditions: 9 | dnl # 10 | dnl # The above copyright notice and this permission notice shall be included in all 11 | dnl # copies or substantial portions of the Software. 12 | dnl # 13 | dnl # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | dnl # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | dnl # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | dnl # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | dnl # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | dnl # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | dnl # SOFTWARE. 20 | dnl # 21 | divert(-1) 22 | 23 | define(`BUILD_PREFIX',/opt/intel/samples) 24 | define(`BUILD_WHEEL',/opt/wheel) 25 | define(`CLEANUP_MAN',no) 26 | define(`DLDT_WARNING_AS_ERRORS',ON) 27 | define(`DLDT_WITH_MKL',false) 28 | define(`DLDT_WITH_OPENCL',true) 29 | dnl define(`DLDT_PATCH_DIR',patches/dldt-ie) 30 | define(`OPENCV_EIGEN',false) 31 | define(`OPENCV_GSTREAMER',false) 32 | 33 | define(`ECHO_SEP',` \ 34 | ') 35 | 36 | define(`WHEEL_EXTRAS',`ifelse($1,`',,`patsubst($1,` +',``,'')')') 37 | 38 | divert(0)dnl 39 | -------------------------------------------------------------------------------- /templates/gst-gva-sample.m4: -------------------------------------------------------------------------------- 1 | dnl # Copyright (c) 2020 Intel Corporation 2 | dnl # 3 | dnl # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | dnl # of this software and associated documentation files (the "Software"), to deal 5 | dnl # in the Software without restriction, including without limitation the rights 6 | dnl # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | dnl # copies of the Software, and to permit persons to whom the Software is 8 | dnl # furnished to do so, subject to the following conditions: 9 | dnl # 10 | dnl # The above copyright notice and this permission notice shall be included in all 11 | dnl # copies or substantial portions of the Software. 12 | dnl # 13 | dnl # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | dnl # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | dnl # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | dnl # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | dnl # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | dnl # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | dnl # SOFTWARE. 20 | dnl # 21 | include(begin.m4) 22 | 23 | dnl v1.6 (2022.1) release 24 | DECLARE(`GVA_VER',v1.6) 25 | DECLARE(`GST_VAAPI_GVA_PATCH_URL',dnl 26 | dnl Commits from: https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/435 27 | https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/commit/c27c158cb2efe285f6fcf909cb49e8a0ac88c568.patch dnl 28 | https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/commit/7809c58664519e8af2266fbb1da8dd93e78b5bc3.patch) 29 | 30 | include(gst-gva.m4) 31 | include(gst-plugins-good.m4) 32 | 33 | define(`GST_GVA_SAMPLE_INSTALL_DEPS',`intel-media-va-driver-non-free intel-opencl-icd libigfxcmrt7 libmfx1') 34 | 35 | REG(GST_GVA_SAMPLE) 36 | 37 | include(end.m4) 38 | -------------------------------------------------------------------------------- /templates/intel-gfx-local.m4: -------------------------------------------------------------------------------- 1 | dnl # Copyright (c) 2020 Intel Corporation 2 | dnl # 3 | dnl # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | dnl # of this software and associated documentation files (the "Software"), to deal 5 | dnl # in the Software without restriction, including without limitation the rights 6 | dnl # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | dnl # copies of the Software, and to permit persons to whom the Software is 8 | dnl # furnished to do so, subject to the following conditions: 9 | dnl # 10 | dnl # The above copyright notice and this permission notice shall be included in all 11 | dnl # copies or substantial portions of the Software. 12 | dnl # 13 | dnl # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | dnl # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | dnl # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | dnl # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | dnl # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | dnl # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | dnl # SOFTWARE. 20 | dnl # 21 | include(begin.m4) 22 | 23 | include(ubuntu.m4) 24 | 25 | pushdef(`_install_ubuntu',`dnl 26 | ARG PACKAGES_DIR=assets/packages 27 | COPY ${PACKAGES_DIR} /opt/apt-pkgs 28 | 29 | RUN cd /opt/apt-pkgs && \ 30 | echo "deb [trusted=yes arch=amd64] file:///opt/apt-pkgs ./" > /etc/apt/sources.list.d/intel-graphics-local.list') 31 | 32 | ifelse(OS_NAME,ubuntu,ifelse(OS_VERSION,20.04, 33 | `define(`ENABLE_INTEL_GFX_REPO',defn(`_install_ubuntu'))')) 34 | 35 | popdef(`_install_ubuntu') 36 | 37 | ifdef(`ENABLE_INTEL_GFX_REPO',,dnl 38 | `ERROR(`OS_NAME:OS_VERSION is not supported')') 39 | 40 | include(end.m4) 41 | -------------------------------------------------------------------------------- /templates/intel-gpu-tools.m4: -------------------------------------------------------------------------------- 1 | dnl # Copyright (c) 2020 Intel Corporation 2 | dnl # 3 | dnl # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | dnl # of this software and associated documentation files (the "Software"), to deal 5 | dnl # in the Software without restriction, including without limitation the rights 6 | dnl # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | dnl # copies of the Software, and to permit persons to whom the Software is 8 | dnl # furnished to do so, subject to the following conditions: 9 | dnl # 10 | dnl # The above copyright notice and this permission notice shall be included in all 11 | dnl # copies or substantial portions of the Software. 12 | dnl # 13 | dnl # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | dnl # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | dnl # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | dnl # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | dnl # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | dnl # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | dnl # SOFTWARE. 20 | dnl # 21 | include(begin.m4) 22 | 23 | # We need igt older than the following commit to be able to select desired device 24 | # for intel_gpu_top on multi-gpu systems: 25 | # 26 | # commit a627439eb5e39d927306055b1e540ef5940d7396 27 | # Author: Ayaz A Siddiqui 28 | # Date: Fri Oct 23 23:21:58 2020 +0530 29 | # 30 | # lib/igt_device_scan: Select intel as default vendor for intel_gpu_top 31 | # 32 | # intel_gpu_top is selecting first discrete device as default drm subsystem. 33 | # In case of multi-gpu system if the first device is not intel gpu 34 | # then it will lead to an error while running intel_gpu_top. 35 | # 36 | # Signed-off-by: Ayaz A Siddiqui 37 | # Cc: Petri Latvala 38 | # Cc: Zbigniew Kempczynski 39 | # Cc: Dixit Ashutosh 40 | # Reviewed-by: Zbigniew Kempczyński 41 | DECLARE(`IGT_VER',`1869d560c550ac273f495076ead46f8a337fc20b') 42 | 43 | define(`IGT_BUILD_DEPS',`ca-certificates gcc bison flex git libcairo-dev libdrm-dev dnl 44 | libdw-dev libkmod-dev libpciaccess-dev libpixman-1-dev libprocps-dev libudev-dev dnl 45 | meson pkg-config') 46 | define(`IGT_INSTALL_DEPS',`') 47 | 48 | define(`BUILD_IGT',dnl 49 | ARG IGT_REPO=https://gitlab.freedesktop.org/drm/igt-gpu-tools.git 50 | RUN git clone $IGT_REPO BUILD_HOME/igt 51 | RUN cd BUILD_HOME/igt \ 52 | && git checkout IGT_VER \ 53 | && meson build \ 54 | --buildtype=release \ 55 | --prefix=BUILD_PREFIX \ 56 | --libdir=BUILD_LIBDIR \ 57 | -Ddocs=disabled -Dman=disabled -Dlibdrm_drivers=intel \ 58 | -Doverlay=disabled -Drunner=disabled -Dtests=disabled \ 59 | && ninja -j $(nproc --all) -C build \ 60 | && DESTDIR=BUILD_DESTDIR ninja -C build install \ 61 | && ninja -C build install 62 | ) 63 | 64 | define(`INSTALL_IGT',dnl 65 | RUN setcap cap_sys_admin+ep $(find /opt -name intel_gpu_top) 66 | ) 67 | 68 | REG(IGT) 69 | 70 | include(end.m4) 71 | -------------------------------------------------------------------------------- /templates/m4docker/LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2020, Intel Corporation 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /templates/m4docker/components/gst-core.m4: -------------------------------------------------------------------------------- 1 | dnl BSD 3-Clause License 2 | dnl 3 | dnl Copyright (c) 2020, Intel Corporation 4 | dnl All rights reserved. 5 | dnl 6 | dnl Redistribution and use in source and binary forms, with or without 7 | dnl modification, are permitted provided that the following conditions are met: 8 | dnl 9 | dnl * Redistributions of source code must retain the above copyright notice, this 10 | dnl list of conditions and the following disclaimer. 11 | dnl 12 | dnl * Redistributions in binary form must reproduce the above copyright notice, 13 | dnl this list of conditions and the following disclaimer in the documentation 14 | dnl and/or other materials provided with the distribution. 15 | dnl 16 | dnl * Neither the name of the copyright holder nor the names of its 17 | dnl contributors may be used to endorse or promote products derived from 18 | dnl this software without specific prior written permission. 19 | dnl 20 | dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | dnl AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | dnl IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | dnl DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | dnl FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | dnl SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | dnl CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | dnl OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | dnl 31 | include(begin.m4) 32 | 33 | DECLARE(`GSTCORE_VER',1.18.4) 34 | 35 | ifelse(OS_NAME,ubuntu,dnl 36 | `define(`GSTCORE_BUILD_DEPS',`ca-certificates meson tar g++ wget pkg-config libglib2.0-dev flex bison ')' 37 | `define(`GSTCORE_INSTALL_DEPS',`libglib2.0-0 ')' 38 | ) 39 | 40 | ifelse(OS_NAME,centos,dnl 41 | `define(`GSTCORE_BUILD_DEPS',`meson wget tar gcc-c++ glib2-devel bison flex ')' 42 | `define(`GSTCORE_INSTALL_DEPS',`glib2')' 43 | ) 44 | 45 | define(`BUILD_GSTCORE', 46 | ARG GSTCORE_REPO=https://github.com/GStreamer/gstreamer/archive/GSTCORE_VER.tar.gz 47 | RUN cd BUILD_HOME && \ 48 | wget -O - ${GSTCORE_REPO} | tar xz 49 | RUN cd BUILD_HOME/gstreamer-GSTCORE_VER && \ 50 | meson build --libdir=BUILD_LIBDIR --libexecdir=BUILD_LIBDIR \ 51 | --prefix=BUILD_PREFIX --buildtype=plain \ 52 | -Dbenchmarks=disabled \ 53 | -Dexamples=disabled \ 54 | -Dtests=disabled \ 55 | -Dgtk_doc=disabled && \ 56 | cd build && \ 57 | ninja install && \ 58 | DESTDIR=BUILD_DESTDIR ninja install 59 | ) 60 | 61 | define(`ENV_VARS_GSTCORE', 62 | ENV GST_PLUGIN_PATH=BUILD_LIBDIR/gstreamer-1.0 63 | ENV GST_PLUGIN_SCANNER=BUILD_LIBDIR/gstreamer-1.0/gst-plugin-scanner 64 | ) 65 | 66 | REG(GSTCORE) 67 | 68 | include(end.m4) 69 | -------------------------------------------------------------------------------- /templates/m4docker/components/gst-gva.m4: -------------------------------------------------------------------------------- 1 | dnl BSD 3-Clause License 2 | dnl 3 | dnl Copyright (c) 2020, Intel Corporation 4 | dnl All rights reserved. 5 | dnl 6 | dnl Redistribution and use in source and binary forms, with or without 7 | dnl modification, are permitted provided that the following conditions are met: 8 | dnl 9 | dnl * Redistributions of source code must retain the above copyright notice, this 10 | dnl list of conditions and the following disclaimer. 11 | dnl 12 | dnl * Redistributions in binary form must reproduce the above copyright notice, 13 | dnl this list of conditions and the following disclaimer in the documentation 14 | dnl and/or other materials provided with the distribution. 15 | dnl 16 | dnl * Neither the name of the copyright holder nor the names of its 17 | dnl contributors may be used to endorse or promote products derived from 18 | dnl this software without specific prior written permission. 19 | dnl 20 | dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | dnl AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | dnl IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | dnl DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | dnl FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | dnl SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | dnl CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | dnl OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | dnl 31 | include(begin.m4) 32 | 33 | # formerly https://github.com/opencv/gst-video-analytics 34 | DECLARE(`GVA_REPO_URL',https://github.com/openvinotoolkit/dlstreamer_gst.git) 35 | DECLARE(`GVA_VER',v1.6) 36 | DECLARE(`GVA_ENABLE_PAHO_INST',OFF) 37 | DECLARE(`GVA_ENABLE_RDKAFKA_INST',OFF) 38 | DECLARE(`GVA_ENABLE_VAS_TRACKER',OFF) 39 | 40 | DECLARE(`GST_VAAPI_WITH_GVA_PATCH',true) 41 | DECLARE(`GST_VAAPI_GVA_PATCH_VER',GVA_VER) 42 | DECLARE(`GST_VAAPI_GVA_PATCH_URL',https://raw.githubusercontent.com/openvinotoolkit/dlstreamer_gst/${GSTREAMER_VAAPI_PATCH_VER}/patches/gstreamer-vaapi/vasurface_qdata.patch) 43 | 44 | include(gst-plugins-base.m4) 45 | include(gst-vaapi.m4) 46 | 47 | define(`GVA_BUILD_DEPS',cmake git ocl-icd-opencl-dev opencl-headers pkg-config dnl 48 | python3 python3-dev python-gi-dev python3-setuptools python3-wheel) 49 | 50 | # TODO: bug in DL Streamer, it tries to load dev symlinks, thus libglib2.0-dev is needed 51 | define(`GVA_INSTALL_DEPS',`python3-pip python3-gst-1.0 libglib2.0-dev') 52 | 53 | define(`BUILD_GVA', 54 | ARG GVA_REPO=GVA_REPO_URL 55 | 56 | RUN git clone ${GVA_REPO} BUILD_HOME/gst-video-analytics && \ 57 | cd BUILD_HOME/gst-video-analytics && \ 58 | git checkout GVA_VER && \ 59 | git submodule update --init 60 | 61 | RUN mkdir -p BUILD_HOME/gst-video-analytics/build && \ 62 | cd BUILD_HOME/gst-video-analytics/build && \ 63 | cmake \ 64 | -DCMAKE_INSTALL_PREFIX=BUILD_PREFIX \ 65 | -DENABLE_SAMPLES=OFF \ 66 | -DENABLE_TESTS=OFF \ 67 | -DENABLE_PAHO_INSTALLATION=GVA_ENABLE_PAHO_INST \ 68 | -DENABLE_RDKAFKA_INSTALLATION=GVA_ENABLE_RDKAFKA_INST \ 69 | -DENABLE_VAAPI=ON \ 70 | -DENABLE_VAS_TRACKER=GVA_ENABLE_VAS_TRACKER \ 71 | .. && \ 72 | make -j $(nproc) && \ 73 | make install DESTDIR=BUILD_DESTDIR 74 | 75 | COPY assets/gva/setup.py BUILD_HOME/gst-video-analytics/ 76 | RUN cd BUILD_HOME/gst-video-analytics/ && \ 77 | python3 setup.py build && \ 78 | python3 setup.py bdist_wheel --dist-dir=BUILD_WHEEL 79 | ) 80 | 81 | define(`INSTALL_GVA', 82 | COPY --from=$2 BUILD_WHEEL BUILD_WHEEL 83 | RUN python3 -m pip install --prefix=BUILD_PREFIX BUILD_WHEEL/* && rm -rf /opt/wheel 84 | ) 85 | 86 | REG(GVA) 87 | 88 | include(end.m4) 89 | -------------------------------------------------------------------------------- /templates/m4docker/components/gst-vaapi.m4: -------------------------------------------------------------------------------- 1 | dnl BSD 3-Clause License 2 | dnl 3 | dnl Copyright (c) 2020, Intel Corporation 4 | dnl All rights reserved. 5 | dnl 6 | dnl Redistribution and use in source and binary forms, with or without 7 | dnl modification, are permitted provided that the following conditions are met: 8 | dnl 9 | dnl * Redistributions of source code must retain the above copyright notice, this 10 | dnl list of conditions and the following disclaimer. 11 | dnl 12 | dnl * Redistributions in binary form must reproduce the above copyright notice, 13 | dnl this list of conditions and the following disclaimer in the documentation 14 | dnl and/or other materials provided with the distribution. 15 | dnl 16 | dnl * Neither the name of the copyright holder nor the names of its 17 | dnl contributors may be used to endorse or promote products derived from 18 | dnl this software without specific prior written permission. 19 | dnl 20 | dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | dnl AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | dnl IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | dnl DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | dnl FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | dnl SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | dnl CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | dnl OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | dnl 31 | include(begin.m4) 32 | 33 | DECLARE(`GST_VAAPI_WITH_DRM',yes) 34 | DECLARE(`GST_VAAPI_WITH_X11',no) 35 | DECLARE(`GST_VAAPI_WITH_GLX',no) 36 | DECLARE(`GST_VAAPI_WITH_WAYLAND',no) 37 | DECLARE(`GST_VAAPI_WITH_EGL',no) 38 | DECLARE(`GST_VAAPI_WITH_GVA_PATCH',false) 39 | 40 | ifelse(GST_VAAPI_WITH_GVA_PATCH,true,dnl 41 | `DECLARE(`GST_VAAPI_DRM_CHOOSE_PATCH_URL',dnl 42 | dnl Commits from: https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/409 43 | https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/commit/85284f4aacc9cfc059c59aa033166fedc247e117.patch dnl 44 | https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/commit/4ff4bcd725290c8f1a52e791496f164c3090ecaa.patch dnl 45 | dnl Commits from: https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/422 46 | https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/commit/0193751ce844776ef1823f99aff053ee423f7004.patch)' 47 | `DECLARE(`GST_VAAPI_GVA_PATCH_VER',v1.5.2)' 48 | `DECLARE(`GST_VAAPI_GVA_PATCH_URL',https://raw.githubusercontent.com/openvinotoolkit/dlstreamer_gst/${GSTREAMER_VAAPI_PATCH_VER}/patches/gstreamer-vaapi/vasurface_qdata.patch)' 49 | `DECLARE(`GST_VAAPI_PATCH_URL',GST_VAAPI_DRM_CHOOSE_PATCH_URL GST_VAAPI_GVA_PATCH_URL)' 50 | ) 51 | 52 | ifdef(`ENABLE_INTEL_GFX_REPO',`dnl 53 | pushdef(`LIBVA_DEV_BUILD_DEP',`ifelse(OS_NAME,ubuntu,libva-dev)') 54 | pushdef(`LIBVA_INSTALL_DEP',`ifelse(OS_NAME,ubuntu,libva2 libva-drm2 libva-x11-2 libva-wayland2)') 55 | ',`dnl 56 | pushdef(`LIBVA_DEV_BUILD_DEP',) 57 | pushdef(`LIBVA_INSTALL_DEP',) 58 | include(libva2.m4) 59 | ') 60 | 61 | include(gst-plugins-bad.m4) 62 | 63 | ifelse(OS_NAME,ubuntu,dnl 64 | `define(`GSTVAAPI_BUILD_DEPS',ca-certificates curl meson tar g++ wget pkg-config libdrm-dev libglib2.0-dev libudev-dev flex bison LIBVA_DEV_BUILD_DEP)' 65 | `define(`GSTVAAPI_INSTALL_DEPS',libdrm2 libglib2.0-0 libpciaccess0 libgl1-mesa-glx LIBVA_INSTALL_DEP)' 66 | ) 67 | 68 | ifelse(OS_NAME,centos,dnl 69 | `define(`GSTVAAPI_BUILD_DEPS',meson wget tar gcc-c++ glib2-devel libdrm-devel LIBVA_DEV_BUILD_DEP bison flex)' 70 | `define(`GSTVAAPI_INSTALL_DEPS',glib2 libdrm libpciaccess LIBVA_INSTALL_DEP)' 71 | ) 72 | 73 | popdef(`LIBVA_DEV_BUILD_DEP') 74 | 75 | define(`BUILD_GSTVAAPI', 76 | ARG GSTVAAPI_REPO=https://github.com/GStreamer/gstreamer-vaapi/archive/GSTCORE_VER.tar.gz 77 | RUN cd BUILD_HOME && \ 78 | wget -O - ${GSTVAAPI_REPO} | tar xz 79 | 80 | ifelse(GST_VAAPI_WITH_GVA_PATCH,true,`dnl 81 | ARG GSTREAMER_VAAPI_PATCH_VER=GST_VAAPI_GVA_PATCH_VER 82 | ARG GSTREAMER_VAAPI_PATCH_URL="GST_VAAPI_PATCH_URL" 83 | RUN cd BUILD_HOME/gstreamer-vaapi-GSTCORE_VER && \ 84 | ( for url in ${GSTREAMER_VAAPI_PATCH_URL}; do \ 85 | curl -nfsSL ${url} | git apply || exit 1; \ 86 | done ) 87 | ')dnl 88 | 89 | RUN cd BUILD_HOME/gstreamer-vaapi-GSTCORE_VER && \ 90 | meson build \ 91 | --prefix=BUILD_PREFIX \ 92 | --libdir=BUILD_LIBDIR \ 93 | --libexecdir=BUILD_LIBDIR \ 94 | --buildtype=release \ 95 | -Dgtk_doc=disabled \ 96 | -Dexamples=disabled \ 97 | -Dtests=disabled \ 98 | -Ddoc=disabled \ 99 | -Dwith_drm=GST_VAAPI_WITH_DRM \ 100 | -Dwith_x11=GST_VAAPI_WITH_X11 \ 101 | -Dwith_glx=GST_VAAPI_WITH_GLX \ 102 | -Dwith_wayland=GST_VAAPI_WITH_WAYLAND \ 103 | -Dwith_egl=GST_VAAPI_WITH_EGL && \ 104 | cd build && \ 105 | ninja install && \ 106 | DESTDIR=BUILD_DESTDIR ninja install 107 | ) 108 | 109 | define(`ENV_VARS_GSTVAAPI', 110 | ENV GST_VAAPI_ALL_DRIVERS=1 111 | ) 112 | 113 | REG(GSTVAAPI) 114 | 115 | include(end.m4) 116 | -------------------------------------------------------------------------------- /templates/m4docker/components/intel-gfx.m4: -------------------------------------------------------------------------------- 1 | dnl BSD 3-Clause License 2 | dnl 3 | dnl Copyright (c) 2020, Intel Corporation 4 | dnl All rights reserved. 5 | dnl 6 | dnl Redistribution and use in source and binary forms, with or without 7 | dnl modification, are permitted provided that the following conditions are met: 8 | dnl 9 | dnl * Redistributions of source code must retain the above copyright notice, this 10 | dnl list of conditions and the following disclaimer. 11 | dnl 12 | dnl * Redistributions in binary form must reproduce the above copyright notice, 13 | dnl this list of conditions and the following disclaimer in the documentation 14 | dnl and/or other materials provided with the distribution. 15 | dnl 16 | dnl * Neither the name of the copyright holder nor the names of its 17 | dnl contributors may be used to endorse or promote products derived from 18 | dnl this software without specific prior written permission. 19 | dnl 20 | dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | dnl AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | dnl IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | dnl DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | dnl FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | dnl SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | dnl CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | dnl OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | dnl 31 | include(begin.m4) 32 | 33 | include(ubuntu.m4) 34 | 35 | define(`INTEL_GFX_URL',https://repositories.intel.com/graphics) 36 | 37 | pushdef(`_install_ubuntu',`dnl 38 | pushdef(`_tmp',`ifelse($1,`',UBUNTU_CODENAME(OS_VERSION),UBUNTU_CODENAME(OS_VERSION)-$1)')dnl 39 | INSTALL_PKGS(PKGS(curl ca-certificates gpg-agent software-properties-common)) 40 | 41 | ARG INTEL_GFX_KEY_URL="INTEL_GFX_URL/intel-graphics.key" 42 | RUN if [ -n "$INTEL_GFX_KEY_URL" ]; then curl -fsSL "$INTEL_GFX_KEY_URL" | apt-key add -; fi 43 | 44 | ARG INTEL_GFX_APT_REPO="deb INTEL_GFX_URL/ubuntu _tmp main" 45 | RUN if [ -n "$INTEL_GFX_APT_REPO" ]; then echo "$INTEL_GFX_APT_REPO" >> /etc/apt/sources.list && apt-get update; fi 46 | popdef(`_tmp')') 47 | 48 | ifelse(OS_NAME,ubuntu,ifelse(OS_VERSION,20.04, 49 | `define(`ENABLE_INTEL_GFX_REPO',defn(`_install_ubuntu'))')) 50 | 51 | popdef(`_install_ubuntu') 52 | 53 | ifdef(`ENABLE_INTEL_GFX_REPO',,dnl 54 | `ERROR(`Intel Graphics Repositories don't support OS_NAME:OS_VERSION')') 55 | 56 | include(end.m4) 57 | -------------------------------------------------------------------------------- /templates/m4docker/components/opencv.m4: -------------------------------------------------------------------------------- 1 | dnl BSD 3-Clause License 2 | dnl 3 | dnl Copyright (c) 2020, Intel Corporation 4 | dnl All rights reserved. 5 | dnl 6 | dnl Redistribution and use in source and binary forms, with or without 7 | dnl modification, are permitted provided that the following conditions are met: 8 | dnl 9 | dnl * Redistributions of source code must retain the above copyright notice, this 10 | dnl list of conditions and the following disclaimer. 11 | dnl 12 | dnl * Redistributions in binary form must reproduce the above copyright notice, 13 | dnl this list of conditions and the following disclaimer in the documentation 14 | dnl and/or other materials provided with the distribution. 15 | dnl 16 | dnl * Neither the name of the copyright holder nor the names of its 17 | dnl contributors may be used to endorse or promote products derived from 18 | dnl this software without specific prior written permission. 19 | dnl 20 | dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | dnl AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | dnl IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | dnl DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | dnl FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | dnl SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | dnl CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | dnl OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | dnl 31 | include(begin.m4) 32 | 33 | DECLARE(`OPENCV_VER',4.5.5) 34 | DECLARE(`OPENCV_EIGEN',true) 35 | DECLARE(`OPENCV_GTK2',false) 36 | DECLARE(`OPENCV_OPENEXR',false) 37 | DECLARE(`OPENCV_OPENJPEG',false) 38 | DECLARE(`OPENCV_GSTREAMER',true) 39 | DECLARE(`OPENCV_JASPER',false) 40 | 41 | define(`OPENCV_EIGEN_BUILD',dnl 42 | ifelse(OPENCV_EIGEN,true,`ifelse( 43 | OS_NAME,ubuntu,libeigen3-dev, 44 | OS_NAME,centos,eigen3-devel)'))dnl 45 | 46 | define(`OPENCV_EIGEN_INSTALL',dnl 47 | ifelse(OPENCV_EIGEN,true,`ifelse( 48 | OS_NAME,ubuntu,libeigen3-dev, 49 | OS_NAME,centos,gtk2-devel)'))dnl 50 | 51 | define(`OPENCV_GTK2_BUILD',dnl 52 | ifelse(OPENCV_GTK2,true,`ifelse( 53 | OS_NAME,ubuntu,libgtk2.0-dev, 54 | OS_NAME,centos,gtk2-devel)'))dnl 55 | 56 | define(`OPENCV_GTK2_INSTALL',dnl 57 | ifelse(OPENCV_GTK2,true,`ifelse( 58 | OS_NAME,ubuntu,libgtk2.0-0, 59 | OS_NAME,centos,gtk2)'))dnl 60 | 61 | define(`OPENCV_OPENJPEG_BUILD',dnl 62 | ifelse(OPENCV_OPENJPEG,true,`ifelse( 63 | OS_NAME,ubuntu,libopenjp2-7-dev, 64 | OS_NAME,centos,openjpeg2-devel)'))dnl 65 | 66 | define(`OPENCV_OPENJPEG_INSTALL',dnl 67 | ifelse(OPENCV_OPENJPEG,true,`ifelse( 68 | OS_NAME,ubuntu,libopenjp2-7, 69 | OS_NAME,centos,openjpeg2)'))dnl 70 | 71 | ifelse(OS_NAME,ubuntu,dnl 72 | `define(`OPENCV_BUILD_DEPS',`ca-certificates gcc g++ make wget cmake pkg-config OPENCV_EIGEN_BUILD OPENCV_GTK2_BUILD OPENCV_OPENJPEG_BUILD')' 73 | `define(`OPENCV_INSTALL_DEPS',`OPENCV_EIGEN_INSTALL OPENCV_GTK2_INSTALL OPENCV_OPENJPEG_INSTALL')' 74 | ) 75 | 76 | ifelse(OS_NAME,centos,dnl 77 | `define(`OPENCV_BUILD_DEPS',`gcc gcc-c++ make wget cmake OPENCV_EIGEN_BUILD OPENCV_GTK2_BUILD OPENCV_OPENJPEG_BUILD')' 78 | `define(`OPENCV_INSTALL_DEPS',`OPENCV_EIGEN_INSTALL OPENCV_GTK2_INSTALL OPENCV_OPENJPEG_INSTALL')' 79 | ) 80 | 81 | ifelse(OPENCV_GSTREAMER,true,`include(gst-plugins-base.m4)')dnl 82 | 83 | define(`BUILD_OPENCV', 84 | ARG OPENCV_REPO=https://github.com/opencv/opencv/archive/OPENCV_VER.tar.gz 85 | RUN cd BUILD_HOME && \ 86 | wget -O - ${OPENCV_REPO} | tar xz 87 | # TODO: file a bug against opencv since they do not accept full libdir 88 | RUN cd BUILD_HOME/opencv-OPENCV_VER && mkdir build && cd build && \ 89 | cmake \ 90 | -DCMAKE_BUILD_TYPE=Release \ 91 | -DCMAKE_INSTALL_PREFIX=BUILD_PREFIX \ 92 | -DCMAKE_INSTALL_LIBDIR=patsubst(BUILD_LIBDIR,BUILD_PREFIX/) \ 93 | -DOPENCV_GENERATE_PKGCONFIG=ON \ 94 | -DBUILD_DOCS=OFF \ 95 | -DBUILD_EXAMPLES=OFF \ 96 | -DBUILD_PERF_TESTS=OFF \ 97 | -DBUILD_TESTS=OFF \ 98 | -DWITH_OPENEXR=ifelse(OPENCV_OPENEXR,false,OFF,ON) \ 99 | -DWITH_OPENJPEG=ifelse(OPENCV_OPENJPEG,true,ON,OFF) \ 100 | -DWITH_GSTREAMER=ifelse(OPENCV_GSTREAMER,true,ON,OFF) \ 101 | -DWITH_JASPER=ifelse(OPENCV_JASPER,true,ON,OFF) \ 102 | .. && \ 103 | make -j "$(nproc)" && \ 104 | make install DESTDIR=BUILD_DESTDIR && \ 105 | make install 106 | ) 107 | 108 | REG(OPENCV) 109 | 110 | include(end.m4)dnl 111 | -------------------------------------------------------------------------------- /templates/m4docker/system/centos-repo.m4: -------------------------------------------------------------------------------- 1 | dnl BSD 3-Clause License 2 | dnl 3 | dnl Copyright (c) 2020, Intel Corporation 4 | dnl All rights reserved. 5 | dnl 6 | dnl Redistribution and use in source and binary forms, with or without 7 | dnl modification, are permitted provided that the following conditions are met: 8 | dnl 9 | dnl * Redistributions of source code must retain the above copyright notice, this 10 | dnl list of conditions and the following disclaimer. 11 | dnl 12 | dnl * Redistributions in binary form must reproduce the above copyright notice, 13 | dnl this list of conditions and the following disclaimer in the documentation 14 | dnl and/or other materials provided with the distribution. 15 | dnl 16 | dnl * Neither the name of the copyright holder nor the names of its 17 | dnl contributors may be used to endorse or promote products derived from 18 | dnl this software without specific prior written permission. 19 | dnl 20 | dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | dnl AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | dnl IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | dnl DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | dnl FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | dnl SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | dnl CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | dnl OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | define(`ENABLE_CENTOS_REPO',`dnl 32 | RUN sed -i "s/enabled=0/enabled=1/g" /etc/yum.repos.d/CentOS-$1.repo 33 | ') 34 | 35 | define(`INSTALL_CENTOS_REPO',`dnl 36 | RUN yum install -y -q $1 37 | ') 38 | 39 | define(`INSTALL_CENTOS_RPMFUSION_REPO', 40 | RUN dnf install -y https://download1.rpmfusion.org/free/el/rpmfusion-free-release-$1.noarch.rpm && \ 41 | dnf install -y https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-$1.noarch.rpm) 42 | 43 | define(`INSTALL_CENTOS_OKEY_REPO', 44 | RUN dnf install -y http://repo.okay.com.mx/centos/$1/x86_64/release/okay-release-1-2.el$1.noarch.rpm) 45 | 46 | define(`INSTALL_CENTOS_RAVEN_RELEASE_REPO', 47 | RUN dnf install -y https://pkgs.dyn.su/el$1/base/x86_64/raven-release-1.0-1.el$1.noarch.rpm 48 | RUN sed -i "s/enabled=0/enabled=1/g" /etc/yum.repos.d/raven.repo)dnl 49 | -------------------------------------------------------------------------------- /templates/m4docker/system/end.m4: -------------------------------------------------------------------------------- 1 | dnl BSD 3-Clause License 2 | dnl 3 | dnl Copyright (c) 2020, Intel Corporation 4 | dnl All rights reserved. 5 | dnl 6 | dnl Redistribution and use in source and binary forms, with or without 7 | dnl modification, are permitted provided that the following conditions are met: 8 | dnl 9 | dnl * Redistributions of source code must retain the above copyright notice, this 10 | dnl list of conditions and the following disclaimer. 11 | dnl 12 | dnl * Redistributions in binary form must reproduce the above copyright notice, 13 | dnl this list of conditions and the following disclaimer in the documentation 14 | dnl and/or other materials provided with the distribution. 15 | dnl 16 | dnl * Neither the name of the copyright holder nor the names of its 17 | dnl contributors may be used to endorse or promote products derived from 18 | dnl this software without specific prior written permission. 19 | dnl 20 | dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | dnl AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | dnl IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | dnl DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | dnl FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | dnl SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | dnl CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | dnl OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | divert(_n)popdef(`_n')dnl 32 | -------------------------------------------------------------------------------- /templates/m4docker/system/ubuntu.m4: -------------------------------------------------------------------------------- 1 | dnl BSD 3-Clause License 2 | dnl 3 | dnl Copyright (c) 2020, Intel Corporation 4 | dnl All rights reserved. 5 | dnl 6 | dnl Redistribution and use in source and binary forms, with or without 7 | dnl modification, are permitted provided that the following conditions are met: 8 | dnl 9 | dnl * Redistributions of source code must retain the above copyright notice, this 10 | dnl list of conditions and the following disclaimer. 11 | dnl 12 | dnl * Redistributions in binary form must reproduce the above copyright notice, 13 | dnl this list of conditions and the following disclaimer in the documentation 14 | dnl and/or other materials provided with the distribution. 15 | dnl 16 | dnl * Neither the name of the copyright holder nor the names of its 17 | dnl contributors may be used to endorse or promote products derived from 18 | dnl this software without specific prior written permission. 19 | dnl 20 | dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | dnl AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | dnl IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | dnl DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | dnl FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | dnl SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | dnl CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | dnl OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | define(`UBUNTU_CODENAME',`ifelse( 32 | $1,18.04,bionic, 33 | $1,20.04,focal, 34 | `ERROR(`ubuntu codename not known for the $1 version')')')dnl 35 | -------------------------------------------------------------------------------- /templates/manuals.m4: -------------------------------------------------------------------------------- 1 | dnl # Copyright (c) 2020 Intel Corporation 2 | dnl # 3 | dnl # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | dnl # of this software and associated documentation files (the "Software"), to deal 5 | dnl # in the Software without restriction, including without limitation the rights 6 | dnl # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | dnl # copies of the Software, and to permit persons to whom the Software is 8 | dnl # furnished to do so, subject to the following conditions: 9 | dnl # 10 | dnl # The above copyright notice and this permission notice shall be included in all 11 | dnl # copies or substantial portions of the Software. 12 | dnl # 13 | dnl # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | dnl # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | dnl # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | dnl # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | dnl # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | dnl # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | dnl # SOFTWARE. 20 | dnl # 21 | include(begin.m4) 22 | 23 | define(`MANUALS_BUILD_DEPS',`asciidoc-base docbook-utils docbook-xsl make xmlto xsltproc') 24 | define(`MANUALS_INSTALL_DEPS',`less man-db') 25 | 26 | define(`BUILD_MANUALS', 27 | # Building some manual pages for the sample 28 | COPY doc/man BUILD_HOME/manuals 29 | RUN cd BUILD_HOME/manuals && make -j $(nproc --all) && \ 30 | DESTDIR=BUILD_DESTDIR make prefix=BUILD_PREFIX install 31 | RUN rm -rf BUILD_HOME/manuals 32 | ) 33 | 34 | define(`INSTALL_MANUALS', 35 | # Restoring man which is excluded from the minimal ubuntu image 36 | ``RUN rm -f /usr/bin/man && dpkg-divert --quiet --remove --rename /usr/bin/man'' 37 | ) 38 | 39 | REG(MANUALS) 40 | 41 | include(end.m4) 42 | -------------------------------------------------------------------------------- /templates/models.m4: -------------------------------------------------------------------------------- 1 | dnl # Copyright (c) 2020 Intel Corporation 2 | dnl # 3 | dnl # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | dnl # of this software and associated documentation files (the "Software"), to deal 5 | dnl # in the Software without restriction, including without limitation the rights 6 | dnl # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | dnl # copies of the Software, and to permit persons to whom the Software is 8 | dnl # furnished to do so, subject to the following conditions: 9 | dnl # 10 | dnl # The above copyright notice and this permission notice shall be included in all 11 | dnl # copies or substantial portions of the Software. 12 | dnl # 13 | dnl # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | dnl # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | dnl # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | dnl # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | dnl # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | dnl # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | dnl # SOFTWARE. 20 | dnl # 21 | include(begin.m4) 22 | 23 | DECLARE(`MODELS_REPO',https://github.com/dlstreamer/pipeline-zoo-models.git) 24 | DECLARE(`MODELS_VER',ca51c02) 25 | 26 | define(`GET_MODELS',`dnl 27 | INSTALL_PKGS(`ca-certificates git git-lfs') 28 | 29 | RUN mkdir -p BUILD_HOME && cd BUILD_HOME && \ 30 | git clone MODELS_REPO && \ 31 | cd pipeline-zoo-models && git checkout MODELS_VER') 32 | 33 | define(`INSTALL_MODELS',`dnl 34 | COPY --from=$1 BUILD_HOME/pipeline-zoo-models/storage/ssd_mobilenet_v1_coco_INT8 BUILD_PREFIX/models/ssd_mobilenet_v1_coco_INT8 35 | COPY --from=$1 BUILD_HOME/pipeline-zoo-models/storage/resnet-50-tf_INT8 BUILD_PREFIX/models/resnet-50-tf_INT8 36 | ') 37 | 38 | include(end.m4) 39 | -------------------------------------------------------------------------------- /templates/open_model_zoo.m4: -------------------------------------------------------------------------------- 1 | dnl # Copyright (c) 2020 Intel Corporation 2 | dnl # 3 | dnl # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | dnl # of this software and associated documentation files (the "Software"), to deal 5 | dnl # in the Software without restriction, including without limitation the rights 6 | dnl # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | dnl # copies of the Software, and to permit persons to whom the Software is 8 | dnl # furnished to do so, subject to the following conditions: 9 | dnl # 10 | dnl # The above copyright notice and this permission notice shall be included in all 11 | dnl # copies or substantial portions of the Software. 12 | dnl # 13 | dnl # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | dnl # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | dnl # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | dnl # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | dnl # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | dnl # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | dnl # SOFTWARE. 20 | dnl # 21 | include(begin.m4) 22 | 23 | DECLARE(`OMZ_VER',2022.1.0) 24 | DECLARE(`OMZ_SRC_REPO',https://github.com/opencv/open_model_zoo/archive/OMZ_VER.tar.gz) 25 | 26 | DECLARE(`OMZ_CAFFE2',false) # ~850GB 27 | DECLARE(`OMZ_PYTORCH',false) # ~850GB 28 | DECLARE(`OMZ_TENSORFLOW',true) # ~400GB 29 | 30 | define(`omz_extras',`') 31 | 32 | ifelse(OMZ_CAFFE2,true,`APPEND_TO_DEF(`omz_extras',caffe2)') 33 | ifelse(OMZ_PYTORCH,true,`APPEND_TO_DEF(`omz_extras',torch)') 34 | ifelse(OMZ_TENSORFLOW,true,`APPEND_TO_DEF(`omz_extras',tensorflow)') 35 | 36 | define(`OMZ_BUILD_DEPS',`python3 python3-pip python3-setuptools python3-wheel wget') 37 | define(`OMZ_INSTALL_DEPS',`python3 python3-pip python3-requests python3-yaml') 38 | 39 | define(`BUILD_OMZ',`dnl 40 | ARG OMZ_REPO=OMZ_SRC_REPO 41 | RUN cd BUILD_HOME && \ 42 | wget -O - ${OMZ_REPO} | tar xz 43 | 44 | RUN cd BUILD_HOME/open_model_zoo-OMZ_VER/tools/model_tools && \ 45 | python3 setup.py build && \ 46 | python3 setup.py bdist_wheel --dist-dir=BUILD_WHEEL 47 | ') 48 | 49 | define(`INSTALL_OMZ',`dnl 50 | COPY --from=$2 BUILD_WHEEL/omz_tools* BUILD_WHEEL/ 51 | RUN pip3 install --prefix=BUILD_PREFIX --find-links=BUILD_WHEEL omz_tools WHEEL_EXTRAS(omz_extras) 52 | 53 | VOLUME BUILD_PREFIX/models 54 | ') 55 | 56 | REG(OMZ) 57 | 58 | include(end.m4) 59 | -------------------------------------------------------------------------------- /templates/readme.rst: -------------------------------------------------------------------------------- 1 | Templates 2 | ========= 3 | 4 | This folder contains `m4 `_ templates 5 | used to compose docker files. Each template defines commands to build 6 | and/or install one of the components used in docker image(s). 7 | 8 | `m4docker <./m4docker>`_ folder contains a copy of the (essential) templates defined 9 | in the `One Container Templates `_ 10 | project. Mind that these templates are available under `BSD-3-Clause License <./m4docker/LICENSE>`_ 11 | 12 | Links 13 | ===== 14 | 15 | * `m4 `_ 16 | * `One Container Templates `_ 17 | -------------------------------------------------------------------------------- /templates/samples.m4: -------------------------------------------------------------------------------- 1 | dnl # Copyright (c) 2020 Intel Corporation 2 | dnl # 3 | dnl # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | dnl # of this software and associated documentation files (the "Software"), to deal 5 | dnl # in the Software without restriction, including without limitation the rights 6 | dnl # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | dnl # copies of the Software, and to permit persons to whom the Software is 8 | dnl # furnished to do so, subject to the following conditions: 9 | dnl # 10 | dnl # The above copyright notice and this permission notice shall be included in all 11 | dnl # copies or substantial portions of the Software. 12 | dnl # 13 | dnl # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | dnl # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | dnl # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | dnl # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | dnl # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | dnl # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | dnl # SOFTWARE. 20 | dnl # 21 | include(begin.m4) 22 | 23 | include(intel-gpu-tools.m4) 24 | 25 | define(`SAMPLES_INSTALL_DEPS',`dnl 26 | clinfo linux-tools-generic pciutils vainfo dnl 27 | ifdef(`DEVEL',`curl sudo vim wget')') 28 | 29 | define(`INSTALL_SAMPLES',`dnl 30 | # perf is tight to particular kernel version per old WA which will never 31 | # be fixed, we just need to use some version 32 | RUN ln -fs $(find /usr/lib/linux-tools -name perf) /usr/bin/perf; 33 | 34 | # Granting CAP_SYS_ADMIN to the Linux perf to be able to get global perf 35 | # events (specifically: i915 events). Mind that this will work if container 36 | # is started with: 37 | # --cap-add SYS_ADMIN --security-opt="no-new-privileges:false" 38 | # If it was started with 39 | # --cap-add SYS_ADMIN --security-opt="no-new-privileges:true" 40 | # then you need to adjust /proc/sys/kernel/perf_event_paranoid on a host to have 41 | # value <=0 42 | RUN setcap cap_sys_admin+ep $(readlink -f $(which perf)) 43 | #RUN setcap cap_sys_admin+ep $(readlink -f $(which intel_gpu_top)) 44 | 45 | # Installing entrypoint helper scripts 46 | COPY assets/demo-alive /usr/bin/ 47 | COPY assets/demo-bash /usr/bin/ 48 | COPY assets/hello-bash /usr/bin/ 49 | COPY assets/demo-setup BUILD_PREFIX/bin 50 | COPY assets/info BUILD_PREFIX/bin 51 | COPY assets/setup-apt-proxy BUILD_PREFIX/bin 52 | 53 | RUN { \ 54 | echo "export DEMO_PREFIX=BUILD_PREFIX"; \ 55 | echo "export DEMO_MODELS=\$DEMO_PREFIX/models"; \ 56 | echo "export MANPATH=\$DEMO_PREFIX/share/man:\$MANPATH"; \ 57 | echo "export PATH=\$DEMO_PREFIX/bin:\$PATH"; \ 58 | echo "export PYTHONUSERBASE=\$DEMO_PREFIX"; \ 59 | echo "export LIBVA_DRIVER_NAME=iHD"; \ 60 | echo "export DEVICE=\${DEVICE:-/dev/dri/renderD128}"; \ 61 | } > /etc/demo.env 62 | 63 | # Create default container user 64 | RUN groupadd -r user && useradd -lrm -s /bin/bash -g user user 65 | ifdef(`DEVEL',`dnl 66 | RUN usermod -aG sudo user 67 | RUN sed -i -e "s/%sudo.*/%sudo ALL=(ALL) NOPASSWD:ALL/g" /etc/sudoers' 68 | ) 69 | # Creating locations sample will need and giving permissions 70 | # to the default user 71 | RUN mkdir -p /opt/data/content 72 | RUN mkdir -p /opt/data/artifacts && chown user /opt/data/artifacts 73 | 74 | # Setting up environment common for all samples 75 | 76 | # Declaring volumes which you might wish to optionally mount 77 | # * /opt/data/content is where you can put your own content to access from inside 78 | # the sample demos 79 | # * /opt/data/artifacts is a location where sample will produce some output 80 | # artifacts like generated or captured stream and logs. You can wish to twick 81 | # this location to get artifacts on your host system 82 | # * /var/www/hls is a location where sample demos will generate HLS streams. You 83 | # might wish to twick this location to get access to these streams. Mind that 84 | # this is server side raw HLS stream. If you run some demo client to capture 85 | # streaming video - look in the /opt/data/artifacts 86 | 87 | VOLUME /opt/data/content 88 | VOLUME /opt/data/artifacts 89 | 90 | # Check running container healthy status with: 91 | # docker inspect --format="{{json .State.Health}}" 92 | HEALTHCHECK CMD /usr/bin/demo-alive 93 | 94 | # hello-bash is a default command which will be executed by demo-bash if 95 | # user did not provide any arguments starting the container. Basically hello-bash 96 | # will print welcome message and enter regular bash with correct environment. 97 | CMD ["/usr/bin/hello-bash"] 98 | 99 | # demo-bash will execute whatever command is provided by the user making 100 | # sure that environment settings are correct. 101 | ENTRYPOINT ["/usr/bin/demo-bash"]') # define(INSTALL_SAMPLES) 102 | 103 | REG(SAMPLES) 104 | 105 | include(end.m4) 106 | -------------------------------------------------------------------------------- /templates/va_sample.m4: -------------------------------------------------------------------------------- 1 | dnl # Copyright (c) 2020 Intel Corporation 2 | dnl # 3 | dnl # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | dnl # of this software and associated documentation files (the "Software"), to deal 5 | dnl # in the Software without restriction, including without limitation the rights 6 | dnl # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | dnl # copies of the Software, and to permit persons to whom the Software is 8 | dnl # furnished to do so, subject to the following conditions: 9 | dnl # 10 | dnl # The above copyright notice and this permission notice shall be included in all 11 | dnl # copies or substantial portions of the Software. 12 | dnl # 13 | dnl # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | dnl # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | dnl # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | dnl # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | dnl # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | dnl # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | dnl # SOFTWARE. 20 | dnl # 21 | include(begin.m4) 22 | 23 | define(`VA_SAMPLE_BUILD_DEPS',`cmake g++ libigfxcmrt-dev libmfx-dev libva-dev make ocl-icd-opencl-dev opencl-headers pkg-config') 24 | define(`VA_SAMPLE_INSTALL_DEPS',`intel-media-va-driver-non-free intel-opencl-icd libigfxcmrt7 libmfx1 ifdef(`LIBMFXGEN1',LIBMFXGEN1) libva-drm2') 25 | 26 | pushdef(`CFLAGS',`-Werror') 27 | 28 | define(`BUILD_VA_SAMPLE', 29 | COPY va_sample BUILD_HOME/va_sample 30 | RUN cd BUILD_HOME/va_sample \ 31 | && mkdir build && cd build \ 32 | && cmake \ 33 | -DCMAKE_INSTALL_PREFIX=BUILD_PREFIX \ 34 | -DCMAKE_INSTALL_LIBDIR=BUILD_LIBDIR \ 35 | -DCMAKE_C_FLAGS="CFLAGS" \ 36 | -DCMAKE_CXX_FLAGS="CFLAGS" \ 37 | .. \ 38 | && make VERBOSE=1 -j $(nproc --all) \ 39 | && make install DESTDIR=BUILD_DESTDIR 40 | ) 41 | 42 | popdef(`CFLAGS') 43 | 44 | REG(VA_SAMPLE) 45 | 46 | include(end.m4) 47 | -------------------------------------------------------------------------------- /va_sample/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2019, Intel Corporation 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a 5 | # copy of this software and associated documentation files (the "Software"), 6 | # to deal in the Software without restriction, including without limitation 7 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | # and/or sell copies of the Software, and to permit persons to whom the 9 | # Software is furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | # OTHER DEALINGS IN THE SOFTWARE. 21 | # 22 | cmake_minimum_required(VERSION 3.0) 23 | 24 | project(va_sample) 25 | include(GNUInstallDirs) 26 | 27 | if(NOT CMAKE_BUILD_TYPE) 28 | set(CMAKE_BUILD_TYPE Release) 29 | message(STATUS "No CMAKE_BUILD_TYPE specified, default to: ${CMAKE_BUILD_TYPE}") 30 | endif() 31 | 32 | set(CMAKE_CXX_STANDARD 14) 33 | set(CMAKE_NO_SYSTEM_FROM_IMPORTED ON) 34 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) 35 | set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined,-z,relro,-z,now,-z,noexecstack) 36 | set(CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined,-z,relro,-z,now,-z,noexecstack) 37 | 38 | find_package(PkgConfig REQUIRED) 39 | find_package(Threads REQUIRED) 40 | find_package(OpenVINO REQUIRED) 41 | find_package(OpenCV REQUIRED) 42 | pkg_check_modules(MFX REQUIRED mfx) 43 | 44 | add_subdirectory(src) 45 | add_subdirectory(libs) 46 | -------------------------------------------------------------------------------- /va_sample/libs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2019, Intel Corporation 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a 5 | # copy of this software and associated documentation files (the "Software"), 6 | # to deal in the Software without restriction, including without limitation 7 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | # and/or sell copies of the Software, and to permit persons to whom the 9 | # Software is furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | # OTHER DEALINGS IN THE SOFTWARE. 21 | # 22 | 23 | add_subdirectory(inference) 24 | -------------------------------------------------------------------------------- /va_sample/libs/inference/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2019, Intel Corporation 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a 5 | # copy of this software and associated documentation files (the "Software"), 6 | # to deal in the Software without restriction, including without limitation 7 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | # and/or sell copies of the Software, and to permit persons to whom the 9 | # Software is furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | # OTHER DEALINGS IN THE SOFTWARE. 21 | # 22 | 23 | set(OpenCV_LIBS 24 | opencv_core 25 | opencv_video 26 | opencv_videoio 27 | opencv_imgproc 28 | opencv_photo 29 | opencv_highgui 30 | opencv_imgcodecs) 31 | 32 | include_directories( ${CMAKE_CURRENT_LIST_DIR}/../../src/execution ${MFX_INCLUDE_DIRS} ${CMAKE_CURRENT_LIST_DIR}/../../src/common) 33 | 34 | add_library(detect SHARED 35 | Inference.h 36 | Inference.cpp 37 | ${CMAKE_CURRENT_LIST_DIR}/../../src/common/logs.cpp 38 | InferenceOV.cpp 39 | InferenceMobileSSD.cpp 40 | InferenceResnet50.cpp 41 | InferenceSISR.cpp 42 | InferenceRCAN.cpp 43 | InferenceYOLO.cpp 44 | ${CMAKE_CURRENT_LIST_DIR}/../../src/execution/DataPacket.cpp) 45 | 46 | target_link_libraries(detect 47 | #${OpenCV_LIBS} 48 | opencv_core 49 | opencv_imgproc 50 | openvino::runtime 51 | OpenCL 52 | Threads::Threads) 53 | 54 | install(TARGETS detect LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) 55 | -------------------------------------------------------------------------------- /va_sample/libs/inference/Inference.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | * OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #include "Inference.h" 24 | #include "InferenceMobileSSD.h" 25 | #include "InferenceResnet50.h" 26 | #include "InferenceSISR.h" 27 | #include "InferenceRCAN.h" 28 | #include "InferenceYOLO.h" 29 | 30 | InferenceBlock* InferenceBlock::Create(InferenceModelType type) 31 | { 32 | switch (type) 33 | { 34 | case MOBILENET_SSD_U8: 35 | return new InferenceMobileSSD; 36 | case RESNET_50: 37 | return new InferenceResnet50; 38 | case SISR: 39 | return new InferenceSISR; 40 | case RCAN: 41 | return new InferenceRCAN; 42 | case YOLO: 43 | return new InferenceYOLO; 44 | default: 45 | return nullptr; 46 | } 47 | } 48 | 49 | void InferenceBlock::Destroy(InferenceBlock *infer) 50 | { 51 | delete infer; 52 | } 53 | 54 | 55 | -------------------------------------------------------------------------------- /va_sample/libs/inference/Inference.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | * OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef __INFERRENCE_H__ 24 | #define __INFERRENCE_H__ 25 | #pragma warning(disable:4251) //needs to have dll-interface to be used by clients of class 26 | 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | class VAData; 33 | 34 | enum InferenceModelType 35 | { 36 | MOBILENET_SSD_U8, 37 | RESNET_50, 38 | SISR, 39 | RCAN, 40 | YOLO 41 | }; 42 | 43 | class InferenceBlock 44 | { 45 | public: 46 | static InferenceBlock *Create(InferenceModelType type); 47 | 48 | static void Destroy(InferenceBlock *infer); 49 | 50 | virtual int Initialize(uint32_t batch_num = 1, uint32_t async_depth = 1, uint32_t stream_num = 0, float confidence_threshold = 0.8, 51 | uint32_t model_input_reshape_height = 0, uint32_t model_input_reshape_width = 0) = 0; 52 | 53 | // derived classes need to get input dimension and output dimension besides the base Load operation 54 | virtual int Load(const char *device, const char *model, const char *weights) = 0; 55 | 56 | // the img should already be in format that the model requests, otherwise, do the conversion outside 57 | virtual int InsertImage(const uint8_t *img, uint32_t channelId, uint32_t frameId, uint32_t roiId = 0) = 0; 58 | virtual int InsertImage(const cv::Mat &image, uint32_t channelId, uint32_t frameId, uint32_t roiId) = 0; 59 | virtual int InsertImage(const int surfID, uint32_t channelId, uint32_t frameId, uint32_t roiId = 0) = 0; 60 | 61 | virtual int Wait() = 0; 62 | 63 | virtual int GetOutput(std::vector &datas, std::vector &channels, std::vector &frames) = 0; 64 | 65 | virtual void GetRequirements(uint32_t *width, uint32_t *height, uint32_t *fourcc) = 0; 66 | 67 | virtual void JoinVAContext(void *va_dpy) = 0; 68 | 69 | protected: 70 | InferenceBlock() {}; 71 | virtual ~InferenceBlock() {}; 72 | }; 73 | 74 | #endif //__INFERRENCE_H__ -------------------------------------------------------------------------------- /va_sample/libs/inference/InferenceMobileSSD.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | * OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef __INFERRENCE_MOBILESSD_H__ 24 | #define __INFERRENCE_MOBILESSD_H__ 25 | 26 | #include "InferenceOV.h" 27 | 28 | class InferenceMobileSSD : public InferenceOV 29 | { 30 | public: 31 | InferenceMobileSSD(); 32 | virtual ~InferenceMobileSSD(); 33 | 34 | virtual int Load(const char *device, const char *model, const char *weights); 35 | 36 | virtual void GetRequirements(uint32_t *width, uint32_t *height, uint32_t *fourcc); 37 | 38 | protected: 39 | // derived classes need to fill the dst with the img, based on their own different input dimension 40 | void CopyImage(const uint8_t *img, void *dst, uint32_t batchIndex); 41 | 42 | // derived classes need to fill VAData by the result, based on their own different output demension 43 | int Translate(std::vector &datas, uint32_t count, void *result, uint32_t *channels, uint32_t *frames, uint32_t *roiIds); 44 | 45 | void SetDataPorts(); 46 | 47 | uint32_t GetInputWidth() {return m_inputWidth; } 48 | uint32_t GetInputHeight() {return m_inputHeight; } 49 | 50 | // model related 51 | uint32_t m_inputWidth; 52 | uint32_t m_inputHeight; 53 | uint32_t m_channelNum; 54 | uint32_t m_resultSize; // size per one result 55 | uint32_t m_maxResultNum; // result number per one request 56 | }; 57 | 58 | #endif //__INFERRENCE_MOBILESSD_H__ 59 | -------------------------------------------------------------------------------- /va_sample/libs/inference/InferenceRCAN.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021, Intel Corporation 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | * OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef __INFERRENCE_RCAN_H__ 24 | #define __INFERRENCE_RCAN_H__ 25 | 26 | #include "InferenceOV.h" 27 | 28 | class InferenceRCAN : public InferenceOV 29 | { 30 | public: 31 | InferenceRCAN(); 32 | virtual ~InferenceRCAN(); 33 | 34 | virtual int Load(const char *device, const char *model, const char *weights); 35 | 36 | virtual void GetRequirements(uint32_t *width, uint32_t *height, uint32_t *fourcc); 37 | protected: 38 | int InsertImage(const uint8_t *img, uint32_t channelId, uint32_t frameId, uint32_t roiId); 39 | int InsertImage(const cv::Mat &image, uint32_t channelId, uint32_t frameId, uint32_t roiId); 40 | void CopyImage(const uint8_t *img, void *dst, uint32_t batchIndex) { return; } 41 | void CopyImage(const uint8_t *img, void *dst, uint32_t w, uint32_t h, uint32_t c, uint32_t batchIndex); 42 | int Translate(std::vector &datas, uint32_t count, void *result, uint32_t *channels, uint32_t *frames, uint32_t *roiIds); 43 | void SetDataPorts(); 44 | 45 | uint32_t GetInputWidth() {return m_inputWidth; } 46 | uint32_t GetInputHeight() {return m_inputHeight; } 47 | 48 | // model related 49 | uint32_t m_inputWidth; 50 | uint32_t m_inputHeight; 51 | uint32_t m_channelNum; 52 | 53 | uint32_t m_outputWidth; 54 | uint32_t m_outputHeight; 55 | uint32_t m_outputChannelNum; 56 | 57 | uint8_t* m_outImg = nullptr; 58 | 59 | uint32_t m_resultSize; // size per one result 60 | }; 61 | 62 | #endif //__INFERRENCE_RCAN_H__ -------------------------------------------------------------------------------- /va_sample/libs/inference/InferenceResnet50.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | * OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef __INFERRENCE_RESNET50_H__ 24 | #define __INFERRENCE_RESNET50_H__ 25 | 26 | #include "InferenceOV.h" 27 | 28 | class InferenceResnet50 : public InferenceOV 29 | { 30 | public: 31 | InferenceResnet50(); 32 | virtual ~InferenceResnet50(); 33 | 34 | virtual int Load(const char *device, const char *model, const char *weights); 35 | 36 | virtual void GetRequirements(uint32_t *width, uint32_t *height, uint32_t *fourcc); 37 | protected: 38 | // derived classes need to fill the dst with the img, based on their own different input dimension 39 | void CopyImage(const uint8_t *img, void *dst, uint32_t batchIndex); 40 | 41 | // derived classes need to fill VAData by the result, based on their own different output demension 42 | int Translate(std::vector &datas, uint32_t count, void *result, uint32_t *channels, uint32_t *frames, uint32_t *roiIds); 43 | 44 | void SetDataPorts(); 45 | 46 | uint32_t GetInputWidth() {return m_inputWidth; } 47 | uint32_t GetInputHeight() {return m_inputHeight; } 48 | 49 | // model related 50 | uint32_t m_inputWidth; 51 | uint32_t m_inputHeight; 52 | uint32_t m_channelNum; 53 | uint32_t m_resultSize; // size per one result 54 | }; 55 | 56 | #endif //__INFERRENCE_RESNET50_H__ 57 | -------------------------------------------------------------------------------- /va_sample/libs/inference/InferenceSISR.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021, Intel Corporation 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | * OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef __INFERRENCE_SISR_H__ 24 | #define __INFERRENCE_SISR_H__ 25 | 26 | #include "InferenceOV.h" 27 | 28 | class InferenceSISR : public InferenceOV 29 | { 30 | public: 31 | InferenceSISR(); 32 | virtual ~InferenceSISR(); 33 | 34 | virtual int Load(const char *device, const char *model, const char *weights); 35 | 36 | virtual void GetRequirements(uint32_t *width, uint32_t *height, uint32_t *fourcc); 37 | protected: 38 | int InsertImage(const uint8_t *img, uint32_t channelId, uint32_t frameId, uint32_t roiId); 39 | int InsertImage(const cv::Mat &image, uint32_t channelId, uint32_t frameId, uint32_t roiId); 40 | void CopyImage(const uint8_t *img, void *dst, uint32_t batchIndex) { return; } 41 | void CopyImage(const uint8_t *img, void *dst, uint32_t w, uint32_t h, uint32_t c, uint32_t batchIndex); 42 | int Translate(std::vector &datas, uint32_t count, void *result, uint32_t *channels, uint32_t *frames, uint32_t *roiIds); 43 | void SetDataPorts(); 44 | 45 | uint32_t GetInputWidth() {return m_inputWidth; } 46 | uint32_t GetInputHeight() {return m_inputHeight; } 47 | 48 | // model related 49 | uint32_t m_inputWidth; 50 | uint32_t m_inputHeight; 51 | uint32_t m_channelNum; 52 | 53 | uint32_t m_inputWidth2; 54 | uint32_t m_inputHeight2; 55 | uint32_t m_channelNum2; 56 | 57 | uint32_t m_outputWidth; 58 | uint32_t m_outputHeight; 59 | uint32_t m_outputChannelNum; 60 | 61 | uint8_t* m_outImg = nullptr; 62 | 63 | uint32_t m_resultSize; // size per one result 64 | }; 65 | 66 | #endif //__INFERRENCE_SISR_H__ -------------------------------------------------------------------------------- /va_sample/libs/inference/InferenceYOLO.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | * OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef __INFERRENCE_YOLO_H__ 24 | #define __INFERRENCE_YOLO_H__ 25 | 26 | #include "InferenceOV.h" 27 | 28 | class InferenceYOLO : public InferenceOV 29 | { 30 | protected: 31 | class Region { 32 | public: 33 | int num = 0; 34 | int classes = 0; 35 | int coords = 0; 36 | std::vector anchors; 37 | int outputWidth = 0; 38 | int outputHeight = 0; 39 | 40 | Region(int classes, int coords, const std::vector& anchors, const std::vector& masks, int outputWidth, int outputHeight); 41 | }; 42 | public: 43 | enum YoloVersion { 44 | YOLO_V4 45 | }; 46 | 47 | enum YoloInputDim { 48 | YOLO_IN_BATCH, 49 | YOLO_IN_CHANNEL, 50 | YOLO_IN_HEIGHT, 51 | YOLO_IN_WIDTH 52 | }; 53 | 54 | enum YoloOutputShape { 55 | YOLO_OUT_BATCH, 56 | YOLO_OUT_NUM, 57 | YOLO_OUT_CELLHEIGHT, 58 | YOLO_OUT_CELLWIDTH 59 | }; 60 | 61 | InferenceYOLO(); 62 | virtual ~InferenceYOLO(); 63 | 64 | virtual int Load(const char *device, const char *model, const char *weights); 65 | 66 | virtual void GetRequirements(uint32_t *width, uint32_t *height, uint32_t *fourcc); 67 | 68 | protected: 69 | // derived classes need to fill the dst with the img, based on their own different input dimension 70 | void CopyImage(const uint8_t *img, void *dst, uint32_t batchIndex); 71 | 72 | // derived classes need to fill VAData by the result, based on their own different output demension 73 | int Translate(std::vector &datas, uint32_t count, void *result, uint32_t *channels, uint32_t *frames, uint32_t *roiIds); 74 | 75 | void SetDataPorts(); 76 | 77 | uint32_t GetInputWidth() {return m_inputWidth; } 78 | uint32_t GetInputHeight() {return m_inputHeight; } 79 | 80 | // model related 81 | static int CalculateEntryIndex(int entriesNum, int lcoords, int lclasses, int location, int entry); 82 | static double IntersectionOverUnion(VAData* vd1, VAData* vd2); 83 | void ProcessYOLOOutput(const void* result, const Region& region, 84 | const int sideW, const int sideH, const uint32_t scaledW, const uint32_t scaledH, 85 | const uint32_t frameId, const uint32_t channelId, std::vector& yolodatas); 86 | 87 | uint32_t m_inputWidth; 88 | uint32_t m_inputHeight; 89 | uint32_t m_channelNum; 90 | std::map m_regions; 91 | double m_boxIOUThreshold; 92 | bool m_useAdvancedPostProcessing; 93 | YoloVersion m_yoloVersion; 94 | const std::vector m_presetAnchors; 95 | const std::vector m_presetMasks; 96 | }; 97 | 98 | #endif //__INFERRENCE_YOLO_H__ 99 | -------------------------------------------------------------------------------- /va_sample/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2019, Intel Corporation 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a 5 | # copy of this software and associated documentation files (the "Software"), 6 | # to deal in the Software without restriction, including without limitation 7 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | # and/or sell copies of the Software, and to permit persons to whom the 9 | # Software is furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | # OTHER DEALINGS IN THE SOFTWARE. 21 | # 22 | 23 | add_subdirectory(tests) 24 | -------------------------------------------------------------------------------- /va_sample/src/common/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | * OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #pragma once 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #include "mfxvideo++.h" 36 | 37 | #include "va/va.h" 38 | #include "va/va_drm.h" 39 | #include "mfxvideo++.h" 40 | #include "mfxjpeg.h" 41 | 42 | // ================================================================= 43 | // VAAPI functionality required to manage VA surfaces 44 | mfxStatus CreateVAEnvDRM(mfxHDL* displayHandle); 45 | 46 | // utility 47 | mfxStatus va_to_mfx_status(VAStatus va_res); 48 | 49 | typedef timespec mfxTime; 50 | 51 | 52 | // ================================================================= 53 | // Helper macro definitions... 54 | #define MSDK_PRINT_RET_MSG(ERR) {PrintErrString(ERR, __FILE__, __LINE__);} 55 | #define MSDK_CHECK_RESULT(P, X, ERR) {if ((X) > (P)) {MSDK_PRINT_RET_MSG(ERR); return ERR;}} 56 | #define MSDK_CHECK_POINTER(P, ERR) {if (!(P)) {MSDK_PRINT_RET_MSG(ERR); return ERR;}} 57 | #define MSDK_CHECK_ERROR(P, X, ERR) {if ((X) == (P)) {MSDK_PRINT_RET_MSG(ERR); return ERR;}} 58 | #define MSDK_IGNORE_MFX_STS(P, X) {if ((X) == (P)) {P = MFX_ERR_NONE;}} 59 | #define MSDK_BREAK_ON_ERROR(P) {if (MFX_ERR_NONE != (P)) break;} 60 | #define MSDK_SAFE_DELETE_ARRAY(P) {if (P) {delete[] P; P = NULL;}} 61 | #define MSDK_ALIGN32(X) (((mfxU32)((X)+31)) & (~ (mfxU32)31)) 62 | #define MSDK_ALIGN16(value) (((value + 15) >> 4) << 4) 63 | #define MSDK_SAFE_RELEASE(X) {if (X) { X->Release(); X = NULL; }} 64 | #define MSDK_MAX(A, B) (((A) > (B)) ? (A) : (B)) 65 | 66 | // Usage of the following two macros are only required for certain Windows DirectX11 use cases 67 | #define WILL_READ 0x1000 68 | #define WILL_WRITE 0x2000 69 | 70 | #define MAX_ADAPTERS_NUM 64 71 | 72 | // ================================================================= 73 | // Intel Media SDK memory allocator entrypoints.... 74 | // Implementation of this functions is OS/Memory type specific. 75 | mfxStatus simple_alloc(mfxHDL pthis, mfxFrameAllocRequest* request, mfxFrameAllocResponse* response); 76 | mfxStatus simple_lock(mfxHDL pthis, mfxMemId mid, mfxFrameData* ptr); 77 | mfxStatus simple_unlock(mfxHDL pthis, mfxMemId mid, mfxFrameData* ptr); 78 | mfxStatus simple_gethdl(mfxHDL pthis, mfxMemId mid, mfxHDL* handle); 79 | mfxStatus simple_free(mfxHDL pthis, mfxFrameAllocResponse* response); 80 | 81 | 82 | 83 | // ================================================================= 84 | // Utility functions, not directly tied to Media SDK functionality 85 | // 86 | 87 | void PrintErrString(int err,const char* filestr,int line); 88 | 89 | // Read bit stream data from file. Stream is read as large chunks (= many frames) 90 | mfxStatus ReadBitStreamData(mfxBitstream* pBS, FILE* fSource); 91 | 92 | // Get free raw frame surface 93 | int GetFreeSurfaceIndex(mfxFrameSurface1** pSurfacesPool, mfxU16 nPoolSize); 94 | 95 | // Initialize Intel Media SDK Session, device/display and memory manager 96 | mfxStatus Initialize(mfxIMPL impl, mfxVersion ver, MFXVideoSession* pSession, mfxFrameAllocator* pmfxAllocator, bool bCreateSharedHandles = false); 97 | 98 | -------------------------------------------------------------------------------- /va_sample/src/common/logs.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | * OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #include 24 | 25 | // ======================================================================== 26 | // trace log utitlity 27 | 28 | #define MAX_MSG_BUF_SIZE 1024 29 | 30 | char g_MsgBuffer[MAX_MSG_BUF_SIZE]; 31 | int idx = 0; 32 | int loglvl = LOGLEVEL; 33 | 34 | int get_log_level() 35 | { 36 | return loglvl; 37 | } 38 | 39 | int set_log_level(int level) 40 | { 41 | loglvl = level; 42 | return loglvl; 43 | } 44 | 45 | void logheader(const char * format, ...) 46 | { 47 | va_list args; 48 | va_start(args, format); 49 | idx = vsnprintf(g_MsgBuffer, MAX_MSG_BUF_SIZE, format, args); 50 | va_end(args); 51 | } 52 | 53 | void logmsg(const char * format, ...) 54 | { 55 | va_list args; 56 | va_start(args, format); 57 | vsnprintf(&g_MsgBuffer[idx], MAX_MSG_BUF_SIZE, format, args); 58 | va_end(args); 59 | idx = 0; 60 | fprintf(stdout, "%s \n", g_MsgBuffer); 61 | } 62 | 63 | void errmsg(const char * format, ...) 64 | { 65 | va_list args; 66 | va_start(args, format); 67 | vsnprintf(&g_MsgBuffer[idx], MAX_MSG_BUF_SIZE, format, args); 68 | va_end(args); 69 | idx = 0; 70 | fprintf(stderr, "%s \n", g_MsgBuffer); 71 | } 72 | 73 | 74 | void startTimer(stopWatch *timer) { 75 | clock_gettime(CLOCK_MONOTONIC, &timer->start); 76 | } 77 | 78 | void stopTimer(stopWatch *timer) { 79 | clock_gettime(CLOCK_MONOTONIC, &timer->stop); 80 | timer->elapsed = (double)((1000 * 1000 * 1000 * timer->stop.tv_sec + timer->stop.tv_nsec) 81 | - (1000 * 1000 * 1000 * timer->start.tv_sec + timer->start.tv_nsec)) / 1000000; 82 | } 83 | 84 | 85 | void loglevel_setup() 86 | { 87 | const char* s = getenv("LOGLEVEL"); 88 | if (s) 89 | { 90 | printf(" ENV LOGLEVEL %s ", s); 91 | int logv = strtol(s, NULL, 10); 92 | int ret = set_log_level(logv); 93 | printf("update LOGLEVEL to %d \n", ret); 94 | 95 | } 96 | else 97 | printf(" ENV LOGLEVEL not found, use default value %d. \n", loglvl); 98 | } 99 | 100 | 101 | -------------------------------------------------------------------------------- /va_sample/src/common/logs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | * OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef __LOGS_H__ 24 | #define __LOGS_H__ 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | // ======================================================================== 34 | // trace log utitlity 35 | #define LOGLEVEL 0 36 | 37 | typedef struct { 38 | struct timespec start; 39 | struct timespec stop; 40 | double elapsed; // millisec 41 | } stopWatch; 42 | 43 | void startTimer(stopWatch *timer); 44 | void stopTimer(stopWatch *timer); 45 | 46 | int get_log_level(); 47 | int set_log_level(int level); 48 | void logheader(const char * format, ...); 49 | void logmsg(const char * format, ...); 50 | void errmsg(const char * format, ...); 51 | void loglevel_setup(); 52 | 53 | #define TRACE(_message, ...) \ 54 | { \ 55 | if (get_log_level() >1) \ 56 | { \ 57 | logheader("trace: %s %s( ) line%d: ", __FILE__, __FUNCTION__, __LINE__); \ 58 | logmsg(_message, ##__VA_ARGS__); \ 59 | } \ 60 | } 61 | 62 | #define INFO(_message, ...) \ 63 | { \ 64 | if (get_log_level() >0) \ 65 | { \ 66 | logheader("info: %s %s( ) line%d: ", __FILE__, __FUNCTION__, __LINE__); \ 67 | logmsg(_message, ##__VA_ARGS__); \ 68 | } \ 69 | else \ 70 | { \ 71 | logmsg(_message, ##__VA_ARGS__); \ 72 | } \ 73 | } 74 | 75 | #define ERRLOG(_message, ...) \ 76 | { \ 77 | logheader("error: %s %s( ) line%d: ", __FILE__, __FUNCTION__, __LINE__); \ 78 | errmsg(_message, ##__VA_ARGS__); \ 79 | } 80 | 81 | #endif //__LOGS_H__ 82 | -------------------------------------------------------------------------------- /va_sample/src/common/va_srcs.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2019, Intel Corporation 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a 5 | # copy of this software and associated documentation files (the "Software"), 6 | # to deal in the Software without restriction, including without limitation 7 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | # and/or sell copies of the Software, and to permit persons to whom the 9 | # Software is furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | # OTHER DEALINGS IN THE SOFTWARE. 21 | # 22 | 23 | set(VA_SOURCES 24 | ${VA_SOURCES} 25 | ${CMAKE_CURRENT_LIST_DIR}/common.cpp 26 | ${CMAKE_CURRENT_LIST_DIR}/logs.cpp 27 | ) 28 | 29 | include_directories(${CMAKE_CURRENT_LIST_DIR}) 30 | -------------------------------------------------------------------------------- /va_sample/src/execution/ConnectorDispatch.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | * OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #include "ConnectorDispatch.h" 24 | #include 25 | 26 | #include 27 | using namespace std::chrono; 28 | 29 | VAConnectorDispatch::VAConnectorDispatch(uint32_t maxInput, uint32_t maxOutput, uint32_t bufferNum): 30 | VAConnector(maxInput, maxOutput) 31 | { 32 | uint32_t totalBufferNum = maxOutput * bufferNum; 33 | m_packets.resize(totalBufferNum); 34 | for (int i = 0; i < totalBufferNum; i++) 35 | { 36 | m_inPipe.push_back(&m_packets[i]); 37 | } 38 | 39 | std::vector mlist(maxOutput); 40 | std::vector clist(maxOutput); 41 | 42 | m_outMutex.swap(mlist); 43 | m_conds.swap(clist); 44 | 45 | m_outPipes.resize(maxOutput); 46 | } 47 | 48 | VAConnectorDispatch::~VAConnectorDispatch() 49 | { 50 | } 51 | 52 | VADataPacket *VAConnectorDispatch::GetInput(int index) 53 | { 54 | VADataPacket *buffer = NULL; 55 | do 56 | { 57 | std::unique_lock lock(m_inMutex); 58 | if (m_inPipe.size() > 0) 59 | { 60 | buffer = m_inPipe.front(); 61 | m_inPipe.pop_front(); 62 | } 63 | else 64 | { 65 | lock.unlock(); 66 | usleep(500); 67 | } 68 | } while (buffer == NULL); 69 | return buffer; 70 | } 71 | 72 | void VAConnectorDispatch::StoreInput(int index, VADataPacket *data) 73 | { 74 | uint32_t channel = data->front()->ChannelIndex(); 75 | uint32_t outIndex = channel%m_maxOut; 76 | { 77 | std::lock_guard lock(m_outMutex[outIndex]); 78 | m_outPipes[outIndex].push_back(data); 79 | } 80 | m_conds[outIndex].notify_one(); 81 | } 82 | 83 | void VAConnectorDispatch::Trigger() 84 | { 85 | } 86 | 87 | VADataPacket *VAConnectorDispatch::GetOutput(int index, const timespec *abstime, const VAConnectorPin*) 88 | { 89 | bool timeout = false; 90 | VADataPacket *buffer = nullptr; 91 | std::unique_lock lock(m_outMutex[index]); 92 | do 93 | { 94 | if (m_outPipes[index].size() > 0) 95 | { 96 | buffer = m_outPipes[index].front(); 97 | 98 | m_outPipes[index].pop_front(); 99 | } 100 | else if (abstime == nullptr) 101 | { 102 | m_conds[index].wait(lock); 103 | } 104 | else if (!timeout) 105 | { 106 | m_conds[index].wait_until(lock, timespec2tp(*abstime)); 107 | timeout = true; 108 | } 109 | else if (timeout) 110 | { 111 | break; 112 | } 113 | } while(buffer == NULL); 114 | return buffer; 115 | } 116 | 117 | void VAConnectorDispatch::StoreOutput(int index, VADataPacket *data) 118 | { 119 | std::lock_guard lock(m_inMutex); 120 | m_inPipe.push_front(data); 121 | } 122 | 123 | -------------------------------------------------------------------------------- /va_sample/src/execution/ConnectorDispatch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | * OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef __CONNECTOR_DISPATCH_H__ 24 | #define __CONNECTOR_DISPATCH_H__ 25 | 26 | #include "Connector.h" 27 | #include 28 | #include 29 | #include 30 | 31 | class VAConnectorDispatch : public VAConnector 32 | { 33 | public: 34 | VAConnectorDispatch(uint32_t maxInput, uint32_t maxOutput, uint32_t bufferNum); 35 | ~VAConnectorDispatch(); 36 | 37 | protected: 38 | virtual VADataPacket *GetInput(int index) override; 39 | virtual void StoreInput(int index, VADataPacket *data) override; 40 | virtual VADataPacket *GetOutput(int index, const timespec *abstime, 41 | const VAConnectorPin *calledPin) override; 42 | virtual void StoreOutput(int index, VADataPacket *data) override; 43 | virtual void Trigger(); 44 | 45 | std::vector m_packets; 46 | 47 | typedef std::list PacketList; 48 | PacketList m_inPipe; 49 | std::vector m_outPipes; 50 | 51 | std::mutex m_inMutex; 52 | std::vector m_outMutex; 53 | std::vector m_conds; 54 | }; 55 | 56 | #endif 57 | 58 | -------------------------------------------------------------------------------- /va_sample/src/execution/ConnectorRR.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | * OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #include "ConnectorRR.h" 24 | #include 25 | #include 26 | 27 | VAConnectorRR::VAConnectorRR(uint32_t maxInput, uint32_t maxOutput, uint32_t bufferNum): 28 | VAConnector(maxInput, maxOutput) 29 | { 30 | uint32_t totalBufferNum = maxInput * bufferNum; 31 | m_packets = new VADataPacket[totalBufferNum]; 32 | for (int i = 0; i < totalBufferNum; i++) 33 | { 34 | m_inPipe.push_back(&m_packets[i]); 35 | } 36 | } 37 | 38 | VAConnectorRR::~VAConnectorRR() 39 | { 40 | if (m_packets) 41 | { 42 | delete[] m_packets; 43 | } 44 | } 45 | 46 | VADataPacket *VAConnectorRR::GetInput(int index) 47 | { 48 | VADataPacket *buffer = NULL; 49 | do 50 | { 51 | if (m_noInput || m_noOutput) 52 | { 53 | Trigger(); 54 | break; 55 | } 56 | 57 | std::unique_lock lock(m_mutex); 58 | if (m_inPipe.size() > 0) 59 | { 60 | buffer = m_inPipe.front(); 61 | m_inPipe.pop_front(); 62 | } 63 | else 64 | { 65 | lock.unlock(); 66 | usleep(500); 67 | } 68 | } while (buffer == NULL); 69 | return buffer; 70 | } 71 | 72 | void VAConnectorRR::StoreInput(int index, VADataPacket *data) 73 | { 74 | { 75 | std::lock_guard lock(m_mutex); 76 | m_outPipe.push_back(data); 77 | } 78 | m_cond.notify_one(); 79 | } 80 | 81 | void VAConnectorRR::Trigger() 82 | { 83 | m_cond.notify_all(); 84 | } 85 | 86 | VADataPacket *VAConnectorRR::GetOutput(int index, const timespec *abstime, 87 | const VAConnectorPin *calledPin) 88 | { 89 | bool timeout = false; 90 | VADataPacket *buffer = nullptr; 91 | 92 | std::unique_lock lock(m_mutex); 93 | do 94 | { 95 | if (m_noInput || m_noOutput) 96 | { 97 | Trigger(); 98 | break; 99 | } 100 | 101 | if (calledPin) 102 | { 103 | std::list::iterator iter = 104 | std::find(m_outputDisconnectedPins.begin(), 105 | m_outputDisconnectedPins.end(), calledPin); 106 | if (iter != m_outputDisconnectedPins.end()) // pin has been disconnected 107 | break; 108 | } 109 | 110 | if (m_outPipe.size() > 0) 111 | { 112 | buffer = m_outPipe.front(); 113 | m_outPipe.pop_front(); 114 | } 115 | else if (abstime == nullptr) 116 | { 117 | m_cond.wait(lock); 118 | } 119 | else if (!timeout) 120 | { 121 | m_cond.wait_until(lock, timespec2tp(*abstime)); 122 | timeout = true; 123 | } 124 | else if (timeout) 125 | { 126 | break; 127 | } 128 | } while(buffer == NULL); 129 | return buffer; 130 | } 131 | 132 | void VAConnectorRR::StoreOutput(int index, VADataPacket *data) 133 | { 134 | std::lock_guard lock(m_mutex); 135 | m_inPipe.push_front(data); 136 | } 137 | 138 | -------------------------------------------------------------------------------- /va_sample/src/execution/ConnectorRR.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | * OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef __CONNECTOR_RR_H__ 24 | #define __CONNECTOR_RR_H__ 25 | 26 | #include "Connector.h" 27 | #include 28 | #include 29 | 30 | class VAConnectorRR : public VAConnector 31 | { 32 | public: 33 | VAConnectorRR(uint32_t maxInput, uint32_t maxOutput, uint32_t bufferNum); 34 | ~VAConnectorRR(); 35 | 36 | VAConnectorRR(const VAConnectorRR&) = delete; 37 | VAConnectorRR& operator=(const VAConnectorRR&) = delete; 38 | 39 | protected: 40 | virtual VADataPacket *GetInput(int index) override; 41 | virtual void StoreInput(int index, VADataPacket *data) override; 42 | virtual VADataPacket *GetOutput(int index, const timespec *abstime, 43 | const VAConnectorPin *calledPin) override; 44 | virtual void StoreOutput(int index, VADataPacket *data) override; 45 | virtual void Trigger(); 46 | 47 | VADataPacket *m_packets; 48 | std::list m_inPipe; 49 | std::list m_outPipe; 50 | 51 | std::mutex m_mutex; 52 | std::condition_variable m_cond; 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /va_sample/src/execution/ThreadBlock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | * OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #include "ThreadBlock.h" 24 | #include 25 | 26 | std::vector VAThreadBlock::m_allThreads; 27 | 28 | static void *VAThreadFunc(void *arg) 29 | { 30 | VAThreadBlock *block = static_cast(arg); 31 | block->Loop(); 32 | block->Finish(); 33 | return (void *)0; 34 | } 35 | 36 | VAThreadBlock::VAThreadBlock(): 37 | m_inputPin(nullptr), 38 | m_outputPin(nullptr), 39 | m_stop(false), 40 | m_finish(false) 41 | { 42 | } 43 | 44 | VAThreadBlock::~VAThreadBlock() 45 | { 46 | } 47 | 48 | int VAThreadBlock::Prepare() 49 | { 50 | m_allThreads.push_back(this); 51 | return PrepareInternal(); 52 | } 53 | 54 | int VAThreadBlock::Run() 55 | { 56 | return pthread_create(&m_threadId, nullptr, VAThreadFunc, (void *)this); 57 | } 58 | 59 | void VAThreadBlock::Stop() 60 | { 61 | m_stop = true; 62 | DisconnectPin(); 63 | } 64 | 65 | void VAThreadBlock::Join() 66 | { 67 | pthread_join(m_threadId, nullptr); 68 | } 69 | 70 | void VAThreadBlock::RunAllThreads() 71 | { 72 | for (auto ite = m_allThreads.begin(); ite != m_allThreads.end(); ite ++) 73 | { 74 | VAThreadBlock *t = *ite; 75 | t->Run(); 76 | } 77 | } 78 | 79 | void VAThreadBlock::StopAllThreads() 80 | { 81 | for (auto ite = m_allThreads.begin(); ite != m_allThreads.end(); ite ++) 82 | { 83 | VAThreadBlock *t = *ite; 84 | t->Stop(); 85 | } 86 | 87 | for (auto ite = m_allThreads.begin(); ite != m_allThreads.end(); ite ++) 88 | { 89 | VAThreadBlock *t = *ite; 90 | t->Join(); 91 | } 92 | } 93 | 94 | -------------------------------------------------------------------------------- /va_sample/src/execution/ThreadBlock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | * OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef __THREAD_BLOCK_H__ 24 | #define __THREAD_BLOCK_H__ 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "DataPacket.h" 31 | #include "Connector.h" 32 | 33 | #define CHECK_STATUS(status) \ 34 | if (status != VA_STATUS_SUCCESS) { \ 35 | fprintf(stderr,"%s:%s (%d) failed with code %d ,exiting\n", __FILE__, __FUNCTION__, __LINE__,status); \ 36 | return -1; \ 37 | } 38 | 39 | class VAThreadBlock 40 | { 41 | public: 42 | VAThreadBlock(); 43 | virtual ~VAThreadBlock(); 44 | 45 | static void RunAllThreads(); 46 | 47 | static void StopAllThreads(); 48 | 49 | virtual int Run(); 50 | virtual void Stop(); 51 | virtual void Join(); 52 | virtual int Prepare(); 53 | virtual int Loop() = 0; 54 | 55 | inline void ConnectInput(VAConnectorPin *pin) {m_inputPin = pin; } 56 | inline void ConnectOutput(VAConnectorPin *pin) {m_outputPin = pin; } 57 | 58 | inline void Finish() {m_finish = true; } 59 | 60 | protected: 61 | VADataPacket* AcquireInput() 62 | { 63 | if (!m_inputPin) 64 | return nullptr; 65 | 66 | VADataPacket* packet = m_inputPin->Get(); 67 | return packet; 68 | } 69 | 70 | void ReleaseInput(VADataPacket* data) 71 | { 72 | if (!m_inputPin) 73 | return; 74 | 75 | data->clear(); 76 | m_inputPin->Store(data); 77 | } 78 | 79 | VADataPacket* DequeueOutput() 80 | { 81 | if (!m_outputPin) 82 | return nullptr; 83 | 84 | VADataPacket *packet = m_outputPin->Get(); 85 | if (!packet || !packet->empty()) 86 | return nullptr; 87 | 88 | return packet; 89 | } 90 | 91 | void EnqueueOutput(VADataPacket *data) 92 | { 93 | if (!m_outputPin) 94 | return; 95 | 96 | m_outputPin->Store(data); 97 | } 98 | 99 | void DisconnectPin() 100 | { 101 | if (m_inputPin) 102 | { 103 | m_inputPin->Disconnect(); 104 | m_inputPin = nullptr; 105 | } 106 | 107 | if (m_outputPin) 108 | { 109 | m_outputPin->Disconnect(); 110 | m_outputPin = nullptr; 111 | } 112 | } 113 | 114 | virtual int PrepareInternal() { return 0; } 115 | 116 | VAConnectorPin *m_inputPin; 117 | VAConnectorPin *m_outputPin; 118 | 119 | pthread_t m_threadId; 120 | 121 | static std::vector m_allThreads; 122 | 123 | bool m_stop; 124 | bool m_finish; 125 | }; 126 | 127 | #endif 128 | -------------------------------------------------------------------------------- /va_sample/src/execution/va_srcs.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2019, Intel Corporation 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a 5 | # copy of this software and associated documentation files (the "Software"), 6 | # to deal in the Software without restriction, including without limitation 7 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | # and/or sell copies of the Software, and to permit persons to whom the 9 | # Software is furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | # OTHER DEALINGS IN THE SOFTWARE. 21 | # 22 | 23 | set(VA_SOURCES 24 | ${VA_SOURCES} 25 | ${CMAKE_CURRENT_LIST_DIR}/DataPacket.cpp 26 | ${CMAKE_CURRENT_LIST_DIR}/Connector.cpp 27 | ${CMAKE_CURRENT_LIST_DIR}/ConnectorRR.cpp 28 | ${CMAKE_CURRENT_LIST_DIR}/ConnectorDispatch.cpp 29 | ${CMAKE_CURRENT_LIST_DIR}/ThreadBlock.cpp 30 | ) 31 | 32 | include_directories(${CMAKE_CURRENT_LIST_DIR}) 33 | -------------------------------------------------------------------------------- /va_sample/src/function/CropThreadBlock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | * OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef _CROP_THREAD_BLOCK_H_ 24 | #define _CROP_THREAD_BLOCK_H_ 25 | 26 | #include "ThreadBlock.h" 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include "va/va.h" 33 | 34 | class CropThreadBlock : public VAThreadBlock 35 | { 36 | public: 37 | CropThreadBlock(uint32_t index); 38 | ~CropThreadBlock(); 39 | 40 | CropThreadBlock(const CropThreadBlock&) = delete; 41 | CropThreadBlock& operator=(const CropThreadBlock&) = delete; 42 | 43 | int Loop(); 44 | 45 | inline void SetOutDump(bool flag = true) {m_dumpFlag = flag; } 46 | inline void SetVASync(bool flag = true) {m_vaSyncFlag = flag; } 47 | inline void SetOutResolution(uint32_t w, uint32_t h) {m_vpOutWidth = w; m_vpOutHeight = h; } 48 | inline void SetInputResolution(uint32_t w, uint32_t h) {m_inputWidth = w; m_inputHeight = h; } 49 | inline void SetOutFormat(uint32_t format) {m_vpOutFormat = format; } 50 | inline void SetVPMemOutTypeVideo(bool flag = false) {m_vpMemOutTypeVideo = flag; } 51 | inline void SetKeepAspectRatioFlag(bool flag){m_keepAspectRatio = flag; } 52 | inline void SetBatchSize(int batchSize) {m_batchSize = batchSize; } 53 | inline void SetPipeFlag(uint32_t pipe_flag){m_pipeflag = (pipe_flag == 0 ? 0 : VA_PROC_PIPELINE_FAST);} 54 | 55 | protected: 56 | int PrepareInternal() override; 57 | 58 | int Crop(VASurfaceID inSurf, 59 | VASurfaceID outSurf, 60 | uint32_t srcx, 61 | uint32_t srcy, 62 | uint32_t srcw, 63 | uint32_t srch, 64 | bool keepRatio); 65 | 66 | bool IsDecodeOutput(VAData *data); 67 | bool IsRoiRegion(VAData *data); 68 | 69 | int FindFreeOutput(); 70 | 71 | FILE *GetDumpFile(uint32_t channel); 72 | 73 | uint32_t m_index; 74 | 75 | uint32_t m_vpOutFormat; 76 | uint32_t m_vpOutWidth; 77 | uint32_t m_vpOutHeight; 78 | uint32_t m_inputWidth; 79 | uint32_t m_inputHeight; 80 | 81 | uint32_t m_bufferNum; 82 | 83 | uint32_t m_batchSize; 84 | 85 | VAContextID m_contextID; 86 | 87 | std::vector m_outputVASurfs; 88 | std::vector m_outBuffers; 89 | std::vector m_outRefs; 90 | 91 | bool m_dumpFlag; 92 | bool m_vpMemOutTypeVideo; 93 | bool m_keepAspectRatio; 94 | bool m_vaSyncFlag; 95 | std::map m_dumpFps; 96 | 97 | uint32_t m_pipeflag; 98 | }; 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /va_sample/src/function/DecodeThreadBlock2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | * OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef _DECODE_THREAD_2_BLOCK_H_ 24 | #define _DECODE_THREAD_2_BLOCK_H_ 25 | 26 | #include "ThreadBlock.h" 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | class DecodeThreadBlock : public VAThreadBlock 34 | { 35 | public: 36 | DecodeThreadBlock(uint32_t channel); 37 | DecodeThreadBlock(uint32_t channel, MFXVideoSession *ExtMfxSession, mfxFrameAllocator *mfxAllocator); 38 | 39 | ~DecodeThreadBlock(); 40 | 41 | void SetDecodeOutputRef(int ref) {m_decodeRefNum = ref; } 42 | void SetDecPostProc(bool flag) {m_bEnableDecPostProc = flag; } 43 | 44 | void SetVPOutputRef(int ref) {m_vpRefNum = ref;} 45 | 46 | void SetVPRatio(uint32_t ratio) {m_vpRatio = ratio; } 47 | 48 | void SetVPOutFormat(uint32_t fourcc) {m_vpOutFormat = fourcc; } 49 | 50 | void SetVPOutResolution(uint32_t width, uint32_t height) {m_vpOutWidth = width; m_vpOutHeight = height;} 51 | 52 | void SetCodecType(mfxU32 codec_type){m_CodecId = codec_type;} 53 | 54 | void SetFilterFlag(mfxU32 filter_flag){m_filterflag = (filter_flag == 0 ? MFX_SCALING_MODE_LOWPOWER : MFX_SCALING_MODE_QUALITY);} 55 | 56 | int Loop(); 57 | 58 | inline void SetVPOutDump(bool flag = true) {m_vpOutDump = flag; } 59 | inline void SetVPDumpAllframe(int flag = true){m_vpDumpAllFrame = flag; } 60 | inline void SetDumpFileName(std::string filename){m_usersetdumpname = filename;} 61 | inline void SetVPMemOutTypeVideo(bool flag = false) {m_vpMemOutTypeVideo = flag; } 62 | inline void SetDecodeOutputWithVP(bool flag = true) {m_decodeOutputWithVP = flag; } 63 | 64 | inline void GetDecodeResolution(uint32_t *width, uint32_t *height) 65 | { 66 | *width = m_mfxVideoParam.mfx.FrameInfo.CropW; 67 | *height = m_mfxVideoParam.mfx.FrameInfo.CropH; 68 | } 69 | 70 | inline void SetFrameNumber(uint32_t num) { m_frameNumber = num; } 71 | 72 | protected: 73 | int PrepareInternal() override; 74 | 75 | int ReadBitStreamData(); // fill the buffer in m_mfxBS, and store the remaining in m_buffer 76 | 77 | int GetFreeVPOutBuffer(); 78 | 79 | uint32_t m_decodeRefNum; 80 | uint32_t m_vpRefNum; 81 | uint32_t m_channel; 82 | uint32_t m_vpRatio; 83 | bool m_bEnableDecPostProc; 84 | 85 | MFXVideoSession *m_mfxSession; 86 | mfxBitstream m_mfxBS; 87 | MFXVideoDECODE_VPP *m_mfxDecodeVpp; 88 | 89 | // only used when vp output is in cpu memory 90 | uint8_t **m_vpOutBuffers; 91 | uint32_t m_vpOutBufNum; 92 | int *m_vpOutRefs; 93 | 94 | mfxVideoParam m_mfxVideoParam; 95 | mfxU32 m_CodecId; 96 | 97 | mfxVideoChannelParam m_mfxVideoChannelParam; 98 | mfxExtVPPScaling m_scalingConfig; 99 | mfxExtBuffer *m_vpExtBuf; 100 | uint32_t m_filterflag; 101 | 102 | uint8_t *m_buffer; 103 | uint32_t m_bufferOffset; 104 | uint32_t m_bufferLength; 105 | 106 | uint32_t m_vpOutFormat; 107 | uint32_t m_vpOutWidth; 108 | uint32_t m_vpOutHeight; 109 | 110 | bool m_vpOutDump; 111 | int m_vpDumpAllFrame; 112 | bool m_vpMemOutTypeVideo; 113 | 114 | bool m_decodeOutputWithVP; 115 | 116 | bool m_rgbpWA; // on some platforms RGBP is not supported 117 | 118 | std::string m_usersetdumpname; 119 | 120 | uint32_t m_frameNumber; 121 | }; 122 | 123 | #endif 124 | -------------------------------------------------------------------------------- /va_sample/src/function/DisplayThreadBlock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | * OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #pragma once 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #include "ThreadBlock.h" 35 | 36 | class DisplayThreadBlock : public VAThreadBlock 37 | { 38 | public: 39 | DisplayThreadBlock() 40 | { 41 | } 42 | 43 | ~DisplayThreadBlock() 44 | { 45 | } 46 | 47 | int Loop(); 48 | 49 | protected: 50 | int PrepareInternal() override; 51 | bool IsVpOut(VAData *data); 52 | bool IsDecodeOut(VAData *data); 53 | bool IsRoi(VAData *data); 54 | cv::Mat m_screen; 55 | 56 | private: 57 | }; -------------------------------------------------------------------------------- /va_sample/src/function/EncodeThreadBlock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | * OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef _ENCODEJPEG_THREAD_BLOCK_H_ 24 | #define _ENCODEJPEG_THREAD_BLOCK_H_ 25 | 26 | #include "ThreadBlock.h" 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | enum VAEncodeType 33 | { 34 | VAEncodeJpeg = 0, 35 | VAEncodeAvc 36 | }; 37 | 38 | class EncodeThreadBlock : public VAThreadBlock 39 | { 40 | public: 41 | EncodeThreadBlock(uint32_t channel, VAEncodeType type); 42 | EncodeThreadBlock(uint32_t channel, VAEncodeType type, MFXVideoSession *ExtMfxSession, mfxFrameAllocator *mfxAllocator); 43 | 44 | ~EncodeThreadBlock(); 45 | 46 | int Loop(); 47 | 48 | int GetFreeSurface(mfxFrameSurface1 **surfaces, uint32_t count); 49 | 50 | inline void SetEncodeOutDump(bool flag = true) {m_encodeOutDump = flag; } 51 | 52 | inline void SetAsyncDepth(uint32_t depth) {m_asyncDepth = depth; } 53 | 54 | void SetInputFormat(uint32_t fourcc) {m_inputFormat = fourcc; } 55 | 56 | void SetInputResolution(uint32_t width, uint32_t height) {m_inputWidth = width; m_inputHeight = height;} 57 | 58 | inline void SetOutputRef(uint32_t count) {m_outputRef = count; } 59 | 60 | protected: 61 | int PrepareInternal() override; 62 | 63 | bool CanBeProcessed(VAData *data); 64 | 65 | void PrepareJpeg(); 66 | 67 | void PrepareAvc(); 68 | 69 | void DumpOutput(uint8_t *data, uint32_t length, uint8_t channel, uint8_t frame); 70 | 71 | int FindFreeOutput(); 72 | 73 | uint32_t m_channel; 74 | 75 | MFXVideoSession *m_mfxSession; 76 | mfxFrameAllocator *m_mfxAllocator; 77 | mfxBitstream m_mfxBS; 78 | MFXVideoENCODE *m_mfxEncode; 79 | 80 | mfxFrameSurface1 **m_encodeSurfaces; 81 | uint32_t m_encodeSurfNum; 82 | 83 | mfxFrameSurface1 **m_inputSurfaces = nullptr; 84 | uint32_t m_inputSurfNum = 0; 85 | 86 | mfxVideoParam m_encParams; 87 | uint32_t m_asyncDepth; 88 | 89 | uint32_t m_inputFormat; 90 | uint32_t m_inputWidth; 91 | uint32_t m_inputHeight; 92 | 93 | bool m_encodeOutDump; 94 | int m_debugPrintCounter; 95 | FILE *m_fp; 96 | 97 | VAEncodeType m_encodeType; 98 | 99 | static const uint32_t m_bufferNum = 3; 100 | uint8_t *m_outBuffers[m_bufferNum]; 101 | int m_outRefs[m_bufferNum]; 102 | 103 | int m_outputRef; 104 | }; 105 | 106 | #endif 107 | -------------------------------------------------------------------------------- /va_sample/src/function/InferenceThreadBlock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | * OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #pragma once 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include "ThreadBlock.h" 32 | #include "Inference.h" 33 | 34 | class InferenceBlock; 35 | 36 | class InferenceThreadBlock : public VAThreadBlock 37 | { 38 | public: 39 | InferenceThreadBlock(uint32_t index, InferenceModelType type); 40 | ~InferenceThreadBlock(); 41 | 42 | InferenceThreadBlock(const InferenceThreadBlock&) = delete; 43 | InferenceThreadBlock& operator=(const InferenceThreadBlock&) = delete; 44 | 45 | inline void SetAsyncDepth(uint32_t depth) {m_asyncDepth = depth; } 46 | inline void SetStreamNum(uint32_t num) {m_streamNum = num; } 47 | inline void SetBatchNum(uint32_t batch) {m_batchNum = batch; } 48 | inline void SetModelInputReshapeWidth(uint32_t width) {m_modelInputReshapeWidth = width; } 49 | inline void SetModelInputReshapeHeight(uint32_t height) {m_modelInputReshapeHeight = height; } 50 | inline void SetConfidenceThreshold(float confidence) { m_confidenceThreshold = confidence; } 51 | inline void SetDevice(const char *device) {m_device = device; } 52 | inline void SetModelFile(const char *model, const char *weights) 53 | { 54 | m_modelFile = model; 55 | m_weightsFile = weights; 56 | } 57 | inline void SetOutputRef(int ref) {m_outRef = ref; } 58 | 59 | inline void EnabelSharingWithVA() {m_enableSharing = true; } 60 | 61 | int Loop(); 62 | 63 | protected: 64 | int PrepareInternal() override; 65 | 66 | bool CanBeProcessed(VAData *data); 67 | 68 | uint32_t m_index; 69 | InferenceModelType m_type; 70 | uint32_t m_asyncDepth; 71 | uint32_t m_streamNum; 72 | uint32_t m_batchNum; 73 | uint32_t m_modelInputReshapeWidth; 74 | uint32_t m_modelInputReshapeHeight; 75 | float m_confidenceThreshold; 76 | int m_outRef; 77 | const char *m_device; 78 | const char *m_modelFile; 79 | const char *m_weightsFile; 80 | InferenceBlock *m_infer; 81 | 82 | // A, B, C, D, E 83 | // insert A for inference 84 | // B, C, D pass the inference 85 | // then B, C, D are pending IDs of A, because B, C, D can only be sent to next block after A is ready 86 | std::map> m_pendingIDs; 87 | uint64_t m_lastInferID; 88 | 89 | bool m_enableSharing; 90 | }; -------------------------------------------------------------------------------- /va_sample/src/function/MfxSessionMgr.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | * OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #include "MfxSessionMgr.h" 24 | #include 25 | #include "common.h" 26 | 27 | MfxSessionMgr::MfxSessionMgr() 28 | { 29 | } 30 | 31 | MfxSessionMgr::~MfxSessionMgr() 32 | { 33 | for (auto ite = m_mfxSessions.begin(); ite != m_mfxSessions.end(); ite ++) 34 | { 35 | if (ite->second) 36 | { 37 | delete ite->second; 38 | } 39 | } 40 | m_mfxSessions.clear(); 41 | 42 | #ifndef MSDK_2_0_API 43 | for (auto ite = m_mfxAllocators.begin(); ite != m_mfxAllocators.end(); ite ++) 44 | { 45 | if (ite->second) 46 | { 47 | delete ite->second; 48 | } 49 | } 50 | m_mfxAllocators.clear(); 51 | #endif 52 | } 53 | 54 | void MfxSessionMgr::Clear(uint32_t channel) 55 | { 56 | auto ite = m_mfxSessions.find(channel); 57 | if (ite != m_mfxSessions.end()) 58 | { 59 | delete ite->second; 60 | m_mfxSessions.erase(ite); 61 | } 62 | #ifndef MSDK_2_0_API 63 | auto ite2 = m_mfxAllocators.find(channel); 64 | if (ite2 != m_mfxAllocators.end()) 65 | { 66 | delete ite2->second; 67 | m_mfxAllocators.erase(ite2); 68 | } 69 | #endif 70 | } 71 | 72 | MFXVideoSession *MfxSessionMgr::GetSession(uint32_t channel) 73 | { 74 | auto ite = m_mfxSessions.find(channel); 75 | if (ite == m_mfxSessions.end()) 76 | { 77 | if (NewChannel(channel) != MFX_ERR_NONE) 78 | { 79 | return nullptr; 80 | } 81 | } 82 | return m_mfxSessions[channel]; 83 | } 84 | 85 | #ifndef MSDK_2_0_API 86 | mfxFrameAllocator *MfxSessionMgr::GetAllocator(uint32_t channel) 87 | { 88 | auto ite = m_mfxAllocators.find(channel); 89 | if (ite == m_mfxAllocators.end()) 90 | { 91 | if (NewChannel(channel) != MFX_ERR_NONE) 92 | { 93 | return nullptr; 94 | } 95 | } 96 | return m_mfxAllocators[channel]; 97 | } 98 | #endif 99 | 100 | int MfxSessionMgr::NewChannel(uint32_t channel) 101 | { 102 | mfxStatus sts = MFX_ERR_NONE; 103 | mfxIMPL impl = MFX_IMPL_AUTO_ANY; // SDK implementation type: hardware accelerator?, software? or else 104 | mfxVersion ver = { {0, 1} }; // media sdk version 105 | 106 | #ifndef MSDK_2_0_API 107 | MFXVideoSession *session = new MFXVideoSession(); 108 | mfxFrameAllocator *allocator = new mfxFrameAllocator(); 109 | sts = Initialize(impl, ver, session, allocator); 110 | if (sts != MFX_ERR_NONE) 111 | { 112 | delete session; 113 | delete allocator; 114 | return sts; 115 | } 116 | 117 | m_mfxSessions[channel] = session; 118 | m_mfxAllocators[channel] = allocator; 119 | #else 120 | MFXVideoSession *session = new MFXVideoSession(); 121 | sts = Initialize(impl, ver, session, nullptr); 122 | if (sts != MFX_ERR_NONE) 123 | { 124 | delete session; 125 | return sts; 126 | } 127 | 128 | m_mfxSessions[channel] = session; 129 | #endif 130 | 131 | return MFX_ERR_NONE; 132 | } 133 | -------------------------------------------------------------------------------- /va_sample/src/function/MfxSessionMgr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | * OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef __MFX_SESSION_MGR_H__ 24 | #define __MFX_SESSION_MGR_H__ 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | class MfxSessionMgr 33 | { 34 | public: 35 | static MfxSessionMgr& getInstance() 36 | { 37 | static MfxSessionMgr instance; 38 | return instance; 39 | } 40 | ~MfxSessionMgr(); 41 | 42 | void Clear(uint32_t channel); 43 | 44 | MFXVideoSession *GetSession(uint32_t channel); 45 | #ifndef MSDK_2_0_API 46 | mfxFrameAllocator *GetAllocator(uint32_t channel); 47 | #endif 48 | 49 | private: 50 | MfxSessionMgr(); 51 | int NewChannel(uint32_t channel); 52 | 53 | std::map m_mfxSessions; 54 | #ifndef MSDK_2_0_API 55 | std::map m_mfxAllocators; 56 | #endif 57 | }; 58 | 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /va_sample/src/function/Statistics.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | * OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef __STATISTICS_H__ 24 | #define __STATISTICS_H__ 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | enum StatisticsType 31 | { 32 | DECODED_FRAMES = 0, 33 | INFERENCE_FRAMES_RECEIVED = 1, 34 | INFERENCE_FRAMES_PROCESSED = 2, 35 | INFERENCE_FRAMES_OD_RECEIVED = 3, 36 | INFERENCE_FRAMES_OD_PROCESSED = 4, 37 | INFERENCE_FRAMES_OC_RECEIVED = 5, 38 | INFERENCE_FRAMES_OC_PROCESSED = 6, 39 | STATISTICS_TYPE_NUM 40 | }; 41 | 42 | class Statistics 43 | { 44 | public: 45 | static Statistics& getInstance() 46 | { 47 | static Statistics instance; 48 | return instance; 49 | } 50 | ~Statistics(); 51 | 52 | void Step(StatisticsType type); 53 | 54 | void Update(StatisticsType type = STATISTICS_TYPE_NUM); 55 | 56 | void Report(); 57 | 58 | void ReportPeriodly(float period, int duration = -1); 59 | 60 | void CountDownStart(int number) { m_countdown_counter = number; } 61 | 62 | void CountDown(); 63 | 64 | inline bool IsNoFPS() { return (m_countersCurrentCycle[DECODED_FRAMES]==0 && m_countersCurrentCycle[INFERENCE_FRAMES_RECEIVED]==0); } 65 | 66 | bool IsStarted(); 67 | 68 | private: 69 | Statistics(); 70 | 71 | std::vector m_mutex; 72 | uint32_t m_countersCurrentCycle[STATISTICS_TYPE_NUM]; 73 | uint32_t m_counters[STATISTICS_TYPE_NUM]; 74 | uint64_t m_accCounters[STATISTICS_TYPE_NUM]; 75 | uint32_t m_accNum[STATISTICS_TYPE_NUM]; 76 | 77 | std::mutex m_countdown_mutex; 78 | uint32_t m_countdown_counter; 79 | }; 80 | 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /va_sample/src/function/va_srcs.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2019, Intel Corporation 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a 5 | # copy of this software and associated documentation files (the "Software"), 6 | # to deal in the Software without restriction, including without limitation 7 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | # and/or sell copies of the Software, and to permit persons to whom the 9 | # Software is furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | # OTHER DEALINGS IN THE SOFTWARE. 21 | # 22 | 23 | set(VA_SOURCES 24 | ${VA_SOURCES} 25 | ) 26 | 27 | set(DECODE_SOURCES 28 | ${DECODE_SOURCES} 29 | ${CMAKE_CURRENT_LIST_DIR}/MfxSessionMgr.cpp 30 | ${CMAKE_CURRENT_LIST_DIR}/CropThreadBlock.cpp 31 | ${CMAKE_CURRENT_LIST_DIR}/Statistics.cpp 32 | ) 33 | 34 | set(DECODE_SOURCES2 35 | ${DECODE_SOURCES} 36 | ${CMAKE_CURRENT_LIST_DIR}/DecodeThreadBlock2.cpp 37 | ) 38 | set(DECODE_SOURCES 39 | ${DECODE_SOURCES} 40 | ${CMAKE_CURRENT_LIST_DIR}/DecodeThreadBlock.cpp 41 | ) 42 | 43 | set(ENCODE_SOURCES 44 | ${ENCODE_SOURCES} 45 | ${CMAKE_CURRENT_LIST_DIR}/EncodeThreadBlock.cpp 46 | ) 47 | 48 | set(INFER_SOURCES 49 | ${INFER_SOURCES} 50 | ${CMAKE_CURRENT_LIST_DIR}/InferenceThreadBlock.cpp 51 | ) 52 | 53 | set(DISPLAY_SOURCES 54 | ${DISPLAY_SOURCES} 55 | ${CMAKE_CURRENT_LIST_DIR}/DisplayThreadBlock.cpp 56 | ) 57 | 58 | include_directories(${CMAKE_CURRENT_LIST_DIR}) 59 | -------------------------------------------------------------------------------- /va_sample/src/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2019, Intel Corporation 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a 5 | # copy of this software and associated documentation files (the "Software"), 6 | # to deal in the Software without restriction, including without limitation 7 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | # and/or sell copies of the Software, and to permit persons to whom the 9 | # Software is furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | # OTHER DEALINGS IN THE SOFTWARE. 21 | # 22 | 23 | set(MFX_INCLUDE ${MFX_INCLUDE_DIRS}) 24 | include_directories( ${MFX_INCLUDE}) 25 | 26 | set(VA_SOURCES "") 27 | set(VA_INCLUDES "") 28 | 29 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 30 | 31 | include(${CMAKE_CURRENT_LIST_DIR}/../execution/va_srcs.cmake) 32 | 33 | link_directories(/opt/intel/mediasdk/lib/) 34 | link_directories(/opt/intel/mediasdk/lib64/) 35 | 36 | include(${CMAKE_CURRENT_LIST_DIR}/../function/va_srcs.cmake) 37 | include(${CMAKE_CURRENT_LIST_DIR}/../common/va_srcs.cmake) 38 | 39 | add_executable(DecodeCropTest DecodeCrop_test.cpp "${VA_SOURCES}" "${DECODE_SOURCES}") 40 | target_link_libraries(DecodeCropTest pthread mfx va va-drm) 41 | install(TARGETS DecodeCropTest RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) 42 | 43 | include_directories(${CMAKE_CURRENT_LIST_DIR}/../../libs/inference) 44 | 45 | add_executable(InferenceOV InferenceOV_test.cpp) 46 | target_link_libraries( InferenceOV detect opencv_highgui) 47 | install(TARGETS InferenceOV RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) 48 | 49 | add_executable(InferenceBlockTest ${CMAKE_CURRENT_LIST_DIR}/InferenceThreadBlock_test.cpp "${VA_SOURCES}" "${DECODE_SOURCES}" "${INFER_SOURCES}" ) 50 | target_link_libraries(InferenceBlockTest pthread mfx va va-drm detect) 51 | install(TARGETS InferenceBlockTest RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) 52 | 53 | add_executable(ObjectClassification ${CMAKE_CURRENT_LIST_DIR}/ObjectClassification.cpp "${VA_SOURCES}" "${DECODE_SOURCES}" "${INFER_SOURCES}" "${DISPLAY_SOURCES}" ) 54 | target_link_libraries(ObjectClassification pthread mfx va va-drm detect opencv_highgui) 55 | install(TARGETS ObjectClassification RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) 56 | 57 | add_executable(ObjectDetection ${CMAKE_CURRENT_LIST_DIR}/ObjectDetection.cpp "${VA_SOURCES}" "${DECODE_SOURCES}" "${INFER_SOURCES}" "${DISPLAY_SOURCES}" ) 58 | target_link_libraries(ObjectDetection pthread mfx va va-drm detect opencv_highgui) 59 | install(TARGETS ObjectDetection RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) 60 | 61 | add_executable(SamplePipeline ${CMAKE_CURRENT_LIST_DIR}/SamplePipeline.cpp "${VA_SOURCES}" "${DECODE_SOURCES}" "${INFER_SOURCES}") 62 | target_link_libraries(SamplePipeline pthread mfx va va-drm detect) 63 | install(TARGETS SamplePipeline RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) 64 | 65 | add_executable(TranscodeSR ${CMAKE_CURRENT_LIST_DIR}/Decode_SR_Encode.cpp "${VA_SOURCES}" "${DECODE_SOURCES}" "${ENCODE_SOURCES}" "${INFER_SOURCES}" ) 66 | target_link_libraries(TranscodeSR pthread mfx va va-drm detect igfxcmrt) 67 | install(TARGETS TranscodeSR RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) 68 | 69 | if (DEFINED MSDK2_0) 70 | add_executable(DecodeCropTestVpl DecodeCrop_test.cpp "${VA_SOURCES}" "${DECODE_SOURCES2}") 71 | target_compile_definitions(DecodeCropTestVpl PRIVATE MSDK_2_0_API) 72 | target_link_libraries(DecodeCropTestVpl pthread mfx va va-drm) 73 | install(TARGETS DecodeCropTestVpl RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) 74 | endif() 75 | 76 | -------------------------------------------------------------------------------- /va_sample/src/tests/SingleChannel_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | * OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | #include "DataPacket.h" 27 | #include "ConnectorRR.h" 28 | #include "InferenceThreadBlock.h" 29 | #include "DecodeThreadBlock.h" 30 | #include "DisplayThreadBlock.h" 31 | #include "TrackingThreadBlock.h" 32 | #include "Statistics.h" 33 | 34 | std::string input_file = "/home/hefan/workspace/VA/video_analytics_Intel_GPU/test_content/video/0.h264"; 35 | int vp_ratio = 1; 36 | bool bDisplay = false; 37 | std::string model_path; 38 | 39 | void ParseOpt(int argc, char *argv[]) 40 | { 41 | if (argc < 2) 42 | { 43 | exit(0); 44 | } 45 | std::vector sources; 46 | std::string arg = argv[1]; 47 | if ((arg == "-h") || (arg == "--help")) 48 | { 49 | exit(0); 50 | } 51 | for (int i = 1; i < argc; ++i) 52 | sources.push_back(argv[i]); 53 | 54 | for (int i = 0; i < argc-1; ++i) 55 | { 56 | if (sources.at(i) == "-i") 57 | input_file = sources.at(++i); 58 | else if (sources.at(i) == "-r") 59 | vp_ratio = stoi(sources.at(++i)); 60 | else if (sources.at(i) == "-d") 61 | bDisplay = true; 62 | else if (sources.at(i) == "-m") 63 | model_path = sources.at(++i); 64 | } 65 | 66 | if (input_file.empty()) 67 | { 68 | printf("Missing input file name!!!!!!!\n"); 69 | exit(0); 70 | } 71 | if (model_path.empty()) 72 | { 73 | model_path = "../../models"; 74 | } 75 | } 76 | 77 | 78 | int main(int argc, char *argv[]) 79 | { 80 | ParseOpt(argc, argv); 81 | 82 | DecodeThreadBlock *dec = new DecodeThreadBlock(0); 83 | InferenceThreadBlock *infer = new InferenceThreadBlock(0, MOBILENET_SSD_U8); 84 | TrackingThreadBlock *track = new TrackingThreadBlock(0); 85 | DisplayThreadBlock *displayBlock = new DisplayThreadBlock(); 86 | VAConnectorRR *c1 = new VAConnectorRR(1, 1, 100); 87 | VAConnectorRR *c2 = new VAConnectorRR(1, 1, 100); 88 | VAConnectorRR *c3 = new VAConnectorRR(1, 1, 100); 89 | VAFilePin *pin = new VAFilePin(input_file.c_str()); 90 | VASinkPin *sink = new VASinkPin(); 91 | 92 | dec->ConnectInput(pin); 93 | dec->ConnectOutput(c1->NewInputPin()); 94 | dec->SetDecodeOutputRef(bDisplay?2:1); 95 | dec->SetVPOutputRef(1); 96 | dec->SetVPRatio(vp_ratio); 97 | dec->SetVPOutResolution(300, 300); 98 | dec->SetVPOutFormat(MFX_FOURCC_NV12); 99 | dec->SetVPMemOutTypeVideo(true); 100 | CHECK_STATUS(dec->Prepare()); 101 | 102 | infer->ConnectInput(c1->NewOutputPin()); 103 | infer->ConnectOutput(c2->NewInputPin()); 104 | infer->SetAsyncDepth(1); 105 | infer->SetBatchNum(1); 106 | infer->SetOutputRef(2); 107 | infer->SetDevice("GPU"); 108 | 109 | infer->EnabelSharingWithVA(); 110 | char model_file[512], coeff_file[512]; 111 | sprintf(model_file, "%s/mobilenet-ssd.xml", model_path.c_str()); 112 | sprintf(coeff_file, "%s/mobilenet-ssd.bin", model_path.c_str()); 113 | infer->SetModelFile(model_file, coeff_file); 114 | CHECK_STATUS(infer->Prepare()); 115 | 116 | if (vp_ratio > 1) 117 | { 118 | track->ConnectInput(c2->NewOutputPin()); 119 | if (bDisplay) 120 | { 121 | track->ConnectOutput(c3->NewInputPin()); 122 | displayBlock->ConnectInput(c3->NewOutputPin()); 123 | displayBlock->ConnectOutput(sink); 124 | CHECK_STATUS(displayBlock->Prepare()); 125 | } 126 | else 127 | { 128 | track->ConnectOutput(sink); 129 | } 130 | CHECK_STATUS(track->Prepare()); 131 | } 132 | else 133 | { 134 | if (bDisplay) 135 | { 136 | displayBlock->ConnectInput(c2->NewOutputPin()); 137 | displayBlock->ConnectOutput(sink); 138 | CHECK_STATUS(displayBlock->Prepare()); 139 | } 140 | else 141 | { 142 | infer->ConnectOutput(sink); 143 | } 144 | } 145 | 146 | VAThreadBlock::RunAllThreads(); 147 | 148 | Statistics::getInstance().ReportPeriodly(1.0); 149 | 150 | pause(); 151 | return 0; 152 | } 153 | --------------------------------------------------------------------------------