Commit fbd3199c authored by fengzch-das's avatar fengzch-das
Browse files

Initial commit

parents
# # Byte-compiled / optimized / DLL files
# __pycache__/
# *.py[cod]
# *$py.class
# # C extensions
# *.so
# # Distribution / packaging
# .Python
# env/
# build/
# develop-eggs/
# dist/
# downloads/
# eggs/
# .eggs/
# lib/
# lib64/
# parts/
# sdist/
# var/
# *.egg-info/
# .installed.cfg
# *.egg
# # PyInstaller
# # Usually these files are written by a python script from a template
# # before PyInstaller builds the exe, so as to inject date/other infos into it.
# *.manifest
# *.spec
# # Installer logs
# pip-log.txt
# pip-delete-this-directory.txt
# # Unit test / coverage reports
# htmlcov/
# .tox/
# .coverage
# .coverage.*
# .cache
# nosetests.xml
# coverage.xml
# *,cover
# .hypothesis/
# # Translations
# *.mo
# *.pot
# # Django stuff:
# *.log
# # Sphinx documentation
# docs/_build/
# # PyBuilder
# target/
# #Ipython Notebook
# .ipynb_checkpoints
# #PyCharm
# /.idea
# # Build temporary files
# /contrib.enabled
# /cv_version.py
# /cv2/version.py
# _skbuild/
# [submodule "opencv"]
# path = opencv
# url = https://github.com/opencv/opencv.git
# [submodule "opencv_contrib"]
# path = opencv_contrib
# url = https://github.com/opencv/opencv_contrib.git
# [submodule "multibuild"]
# path = multibuild
# url = https://github.com/multi-build/multibuild.git
# [submodule "opencv_extra"]
# path = opencv_extra
# url = https://github.com/opencv/opencv_extra.git
## Contributing
Thank you for considering contributing to opencv-python.
### 1. Where do I go from here?
If you've noticed a bug or have a question that doesn't belong on
[Stack Overflow](http://stackoverflow.com/questions/tagged/opencv-python),
[search the project issue tracker](https://github.com/opencv/opencv-python/issues?q=something) or
[search OpenCV issue tracker](https://github.com/opencv/opencv/issues?q=is%3Aissue+is%3Aopen+label%3A%22category%3A+python+bindings%22)
to see if someone else in the community has already created a ticket.
If not, go ahead and:
- [make new one for opencv-python](https://github.com/opencv/opencv-python/issues/new) if you cannot load package or some functionality is not available!
- [make new one for OpenCV](https://github.com/opencv/opencv-python/issues/new) if something went wrong with some function, class or method in code!
### 2. Fork & create a branch
If this is something you think you can fix, then
[fork opencv-python](https://help.github.com/articles/fork-a-repo)
and create a branch with a descriptive name.
### 3. Make your changes
Make required changes.
### 4. Create a pull request
[Make a Pull Request.](https://help.github.com/articles/creating-a-pull-request)
This diff is collapsed.
MIT License
Copyright (c) Olli-Pekka Heinisuo
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
\ No newline at end of file
include LICENSE-3RD-PARTY.txt
include LICENSE.txt
include README.md
include find_version.py
include setup.py
include pyproject.toml
recursive-include cv2 *
recursive-include docker *
recursive-include opencv *
recursive-include opencv_contrib *
recursive-include patches *
recursive-include scripts *.py
# OpenCV-python 构建流程及使用方法
## 1、构建流程
### 1.1 容器创建及基础环境搭建
&emsp;&emsp;在 61 节点上创建容器:<br/>
```bash
# 容器创建
docker run -i -t --name opencv --device=/dev/kfd --network=host --device=/dev/dri --cap-add=SYS_PTRACE -p 6666:6006 --security-opt seccomp=unconfined -v /opt/hyhal:/opt/hyhal/:ro -v /parastor/home/fengzch/:/home/ --group-add video --privileged=true --shm-size 16G 8deabd4d542a
```
&emsp;&emsp;创建好容器之后,安装DTK、torch、numpy、fastpt:<br/>
```bash
# DTK 安装
cd /opt
wget http://10.6.10.68:8000/dtk-pkg/dtk25.04/20250124/DTK-25.04-rc4-ubuntu20.04-x86_64.tar.gz
tar -zxvf DTK-25.04-rc4-ubuntu20.04-x86_64.tar.gz
# torch 安装
cd /
mkdir test
cd test
wget http://10.6.10.68:8000/customized/pytorch/dtk25.04-rc4/torch-2.4.1%2Bdas.opt1.dtk2504-cp310-cp310-manylinux_2_28_x86_64.whl
pip install torch-2.4.1+das.opt1.dtk2504-cp310-cp310-manylinux_2_28_x86_64.whl
# fastpt 安装
# 下载地址:https://download.sourcefind.cn:65024/4/main/fastpt/DAS1.5
pip install fastpt-2.0.0+das.dtk2504-py3-none-any.whl
pip install numpy==1.24.3
pip install wheel==0.45.1
pip install scikit-build
```
### 1.2 代码拉取
&emsp;&emsp;拉取Pytorch、Opencv、Opencv-contrib 以及 Opencv-python 代码:<br/>
```bash
# Pytorch 代码拉取
cd /test
git clone -b 2.4.1-dev http://10.6.10.68/dcutoolkit/deeplearing/pytorch.git
# OpenCV 代码拉取
cd /test
git clone http://10.6.10.68/fengzch/opencv.git
# OpenCV_contrib 代码拉取,该模块与 opencv 在同一目录下
cd /test
git clone http://10.6.10.68/fengzch/opencv_contrib.git
# OpenCV-Python 代码拉取
cd /test
git clone http://10.6.10.68/fengzch/opencv-python.git
```
### 1.3 环境初始化
&emsp;&emsp;初始化环境:<br/>
```bash
source /opt/dtk-25.04-rc4/env.sh
source /opt/dtk-25.04-rc4/cuda/env.sh
export TORCH_PATH=/usr/local/lib/python3.10/site-packages/torch
export HIP_TORCH_PATH=/test/pytorch
export LD_LIBRARY_PATH=/usr/local/lib/python3.10/site-packages/torch/lib:$LD_LIBRARY_PATH
export USE_FASTPT_CUDA=True
# 下面的两个环境变量需要开启
export CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_C_COMPILER=/usr/bin/gcc-9 -DCMAKE_CXX_COMPILER=/usr/bin/g++-9"
export ENABLE_CONTRIB=1
```
### 1.4 依赖下载
&emsp;&emsp;下载相关依赖:<br/>
```bash
sudo apt update
sudo apt install -y build-essential cmake git pkg-config libgtk-3-dev libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev libjpeg-dev libpng-dev libtiff-dev gfortran openexr libatlas-base-dev libhdf5-mpich-dev libhdf5-dev libvtk6-dev libopenblas-dev libeigen3-dev python3-dev python3-pip libogre-1.12-dev libxaw7-dev
# apt无法下载时处理
# 备份原镜像源
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
# 将原镜像源更换为阿里云镜像源
sudo sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list
# 如果还有错误,则添加清华镜像源/etc/apt/sources.list
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
```
### 1.5 npps 库下载拷贝
&emsp;&emsp;目前,DTk 中暂未提供 npps 动态库,因此暂时使用 cuda 原生的 npps 库:<br/>
```bash
cp /test/opencv-python/npps/libnpps* /opt/dtk-25.04-rc4/cuda/lib64/
```
### 1.6 OIS 编译构建(ovis 模块依赖,默认ovis 模块不构建)
&emsp;&emsp;由于,Opencv_contrib 中的 ovis 模块需要该库的支持,所以需要构建相关依赖库,编译构建指令如下:<br/>
```bash
cd /test
git clone http://10.6.10.68/fengzch/ois.git
cd ois
mkdir build && cd build && cmake ../
make -j32 install
```
**PS: 如果需要构建 ovis 模块,在 setup.py 文件的 226 行 "-DBUILD_opencv_ovis" 设为 ON**
### 1.7 ogre 编译构建(ovis 模块依赖,默认ovis 模块不构建)
&emsp;&emsp;编译构建指令如下:<br/>
```bash
cd /test
git clone http://10.6.10.68/fengzch/orge.git
cd orge
mkdir build && cd build && cmake ../
make -j32 install
```
### 1.8 创建软链接
&emsp;&emsp;在 OpenCV-Python 中创建软链接到OpenCV 和 OpenCV_Contrib:<br/>
```bash
cd /test/opencv-python
ln -sf ../opencv opencv
ln -sf ../opencv_contrib opencv_contrib
```
### 1.9 编译 wheel 包
&emsp;&emsp;执行下面的指令,编译 wheel 包<br/>
```bash
cd /test/opencv-python
python setup.py bdist_wheel
```
### 1.10 安装使用
```bash
cd /test/opencv-python/dist
pip install opencv-4.8.0+das.opt1.dtk2504-cp310-cp310-linux_x86_64.whl
# 验证
# python
# import cv2
# cv2.__version__
# '4.8.0'
# cv2.__hcu_version__
# '4.8.0+das.opt1.dtk2504'
```
## 2 OpenCV 使用
&emsp;&emsp;如果直接使用提供的 wheel 包,首先按照1.1、1.2配置好基础环境,接着通过 pip install 安装 **(需要首先安转 numpy:pip install numpy==1.24.3)****(如果需要 ovis 模块,需要手动编译 OIS 和 ogre,)**最后安装 libxaw7-dev<br/>
```bash
pip install numpy==1.24.3
sudo apt install -y libxaw7-dev
pip install
```
\ No newline at end of file
import os
haarcascades = os.path.join(os.path.dirname(__file__), "")
### Customized manylinux images for opencv-python
The subfolders include Dockerfiles for extending both ``i686`` and ``x86_64`` manylinux1 and manylinux2014 images.
Manylinux2014 is used in wheels with version 3.4.10.* / 4.3.0.* and above.
The extended images were created to be able to build OpenCV in reasonable time with Travis. The images are hosted at https://quay.io/user/skvark.
See the dockerfiles for more info.
FROM quay.io/pypa/manylinux1_i686:latest
RUN curl -O -L https://download.qt.io/archive/qt/4.8/4.8.7/qt-everywhere-opensource-src-4.8.7.tar.gz && \
tar -xf qt-everywhere-opensource-src-4.8.7.tar.gz && \
cd qt-everywhere* && \
#configure does a bootstrap make under the hood
#manylinux1 is too old to have `nproc`
export MAKEFLAGS=-j$(getconf _NPROCESSORS_ONLN) && \
#OpenCV only links against QtCore, QtGui, QtTest
./configure -prefix /opt/Qt4.8.7 -release -opensource -confirm-license -make && \
make && \
make install && \
cd .. && \
rm -rf qt-everywhere-opensource-src-4.8.7 && \
rm qt-everywhere-opensource-src-4.8.7.tar.gz
ENV QTDIR /opt/Qt4.8.7
ENV PATH "$QTDIR/bin:$PATH"
RUN curl -O -L https://cmake.org/files/v3.9/cmake-3.9.0.tar.gz && \
tar -xf cmake-3.9.0.tar.gz && \
cd cmake-3.9.0 && \
#manylinux1 provides curl-devel equivalent and libcurl statically linked
# against the same newer OpenSSL as other source-built tools
# (1.0.2s as of this writing)
yum -y install zlib-devel && \
#configure does a bootstrap make under the hood
export MAKEFLAGS=-j$(getconf _NPROCESSORS_ONLN) && \
./configure --system-curl && \
make && \
make install && \
cd .. && \
rm -rf cmake-3.9.0*
# https://trac.ffmpeg.org/wiki/CompilationGuide/Centos#GettheDependencies
# manylinux provides the toolchain and git; we provide cmake
RUN yum install freetype-devel bzip2-devel zlib-devel -y && \
mkdir ~/ffmpeg_sources
# Newer openssl configure requires newer perl
RUN curl -O -L https://www.cpan.org/src/5.0/perl-5.20.1.tar.gz && \
tar -xf perl-5.20.1.tar.gz && \
cd perl-5.20.1 && \
./Configure -des -Dprefix="$HOME/openssl_build" && \
#perl build scripts do much redundant work
# if running "make install" separately
make install -j$(getconf _NPROCESSORS_ONLN) && \
cd .. && \
rm -rf perl-5.20.1*
RUN cd ~/ffmpeg_sources && \
curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_1_1_1c.tar.gz && \
tar -xf OpenSSL_1_1_1c.tar.gz && \
cd openssl-OpenSSL_1_1_1c && \
#in i686, ./config detects x64 in i686 container without linux32
# when run from "docker build"
PERL="$HOME/openssl_build/bin/perl" linux32 ./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" shared zlib && \
make -j$(getconf _NPROCESSORS_ONLN) && \
#skip installing documentation
make install_sw && \
rm -rf ~/openssl_build
RUN cd ~/ffmpeg_sources && \
curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/2.14.01/nasm-2.14.01.tar.bz2 && \
tar -xf nasm-2.14.01.tar.bz2 && cd nasm-2.14.01 && ./autogen.sh && \
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \
make -j$(getconf _NPROCESSORS_ONLN) && \
make install
RUN cd ~/ffmpeg_sources && \
curl -O -L http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz && \
tar -xf yasm-1.3.0.tar.gz && \
cd yasm-1.3.0 && \
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \
make -j$(getconf _NPROCESSORS_ONLN) && \
make install
RUN cd ~/ffmpeg_sources && \
git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git && \
cd libvpx && \
./configure --prefix="$HOME/ffmpeg_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm --enable-pic --enable-shared && \
make -j$(getconf _NPROCESSORS_ONLN) && \
make install
RUN cd ~/ffmpeg_sources && \
curl -O -L https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 && \
tar -xf ffmpeg-snapshot.tar.bz2 && \
cd ffmpeg && \
PATH=~/bin:$PATH && \
PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" --enable-openssl --enable-libvpx --enable-shared --enable-pic --bindir="$HOME/bin" && \
make -j$(getconf _NPROCESSORS_ONLN) && \
make install && \
echo "/root/ffmpeg_build/lib/" >> /etc/ld.so.conf && \
ldconfig && \
rm -rf ~/ffmpeg_sources
ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/root/ffmpeg_build/lib/pkgconfig
ENV LDFLAGS -L/root/ffmpeg_build/lib
RUN curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/uapi/linux/videodev2.h && \
curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/uapi/linux/v4l2-common.h && \
curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/uapi/linux/v4l2-controls.h && \
curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/linux/compiler.h && \
mv videodev2.h v4l2-common.h v4l2-controls.h compiler.h /usr/include/linux
#in i686, yum metadata ends up with slightly wrong timestamps
#which inhibits its update
#https://github.com/skvark/opencv-python/issues/148
RUN yum clean all
ENV PATH "$HOME/bin:$PATH"
FROM quay.io/pypa/manylinux1_x86_64:latest
RUN curl -O -L https://download.qt.io/archive/qt/4.8/4.8.7/qt-everywhere-opensource-src-4.8.7.tar.gz && \
tar -xf qt-everywhere-opensource-src-4.8.7.tar.gz && \
cd qt-everywhere* && \
#configure does a bootstrap make under the hood
#manylinux1 is too old to have `nproc`
export MAKEFLAGS=-j$(getconf _NPROCESSORS_ONLN) && \
#OpenCV only links against QtCore, QtGui, QtTest
./configure -prefix /opt/Qt4.8.7 -release -opensource -confirm-license \
-no-sql-sqlite -no-qt3support -no-xmlpatterns -no-multimedia \
-no-webkit -no-script -no-declarative -no-dbus -make libs && \
make && \
make install && \
cd .. && \
rm -rf qt-everywhere-opensource-src-4.8.7 && \
rm qt-everywhere-opensource-src-4.8.7.tar.gz
ENV QTDIR /opt/Qt4.8.7
ENV PATH "$QTDIR/bin:$PATH"
RUN curl -O -L https://cmake.org/files/v3.9/cmake-3.9.0.tar.gz && \
tar -xf cmake-3.9.0.tar.gz && \
cd cmake-3.9.0 && \
#manylinux1 provides curl-devel equivalent and libcurl statically linked
# against the same newer OpenSSL as other source-built tools
# (1.0.2s as of this writing)
yum -y install zlib-devel && \
#configure does a bootstrap make under the hood
export MAKEFLAGS=-j$(getconf _NPROCESSORS_ONLN) && \
./configure --system-curl && \
make && \
make install && \
cd .. && \
rm -rf cmake-3.9.0*
# https://trac.ffmpeg.org/wiki/CompilationGuide/Centos#GettheDependencies
# manylinux provides the toolchain and git; we provide cmake
RUN yum install freetype-devel bzip2-devel zlib-devel -y && \
mkdir ~/ffmpeg_sources
# Newer openssl configure requires newer perl
RUN curl -O -L https://www.cpan.org/src/5.0/perl-5.20.1.tar.gz && \
tar -xf perl-5.20.1.tar.gz && \
cd perl-5.20.1 && \
./Configure -des -Dprefix="$HOME/openssl_build" && \
#perl build scripts do much redundant work
# if running "make install" separately
make install -j$(getconf _NPROCESSORS_ONLN) && \
cd .. && \
rm -rf perl-5.20.1*
RUN cd ~/ffmpeg_sources && \
curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_1_1_1c.tar.gz && \
tar -xf OpenSSL_1_1_1c.tar.gz && \
cd openssl-OpenSSL_1_1_1c && \
PERL="$HOME/openssl_build/bin/perl" ./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" shared zlib && \
make -j$(getconf _NPROCESSORS_ONLN) && \
#skip installing documentation
make install_sw && \
rm -rf ~/openssl_build
RUN cd ~/ffmpeg_sources && \
curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/2.14.01/nasm-2.14.01.tar.bz2 && \
tar -xf nasm-2.14.01.tar.bz2 && cd nasm-2.14.01 && ./autogen.sh && \
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \
make -j$(getconf _NPROCESSORS_ONLN) && \
make install
RUN cd ~/ffmpeg_sources && \
curl -O -L http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz && \
tar -xf yasm-1.3.0.tar.gz && \
cd yasm-1.3.0 && \
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \
make -j$(getconf _NPROCESSORS_ONLN) && \
make install
RUN cd ~/ffmpeg_sources && \
git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git && \
cd libvpx && \
./configure --prefix="$HOME/ffmpeg_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm --enable-pic --enable-shared && \
make -j$(getconf _NPROCESSORS_ONLN) && \
make install
RUN cd ~/ffmpeg_sources && \
curl -O -L https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 && \
tar -xf ffmpeg-snapshot.tar.bz2 && \
cd ffmpeg && \
PATH=~/bin:$PATH && \
PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" --enable-openssl --enable-libvpx --enable-shared --enable-pic --bindir="$HOME/bin" && \
make -j$(getconf _NPROCESSORS_ONLN) && \
make install && \
echo "/root/ffmpeg_build/lib/" >> /etc/ld.so.conf && \
ldconfig && \
rm -rf ~/ffmpeg_sources
ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/root/ffmpeg_build/lib/pkgconfig
ENV LDFLAGS -L/root/ffmpeg_build/lib
RUN curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/uapi/linux/videodev2.h && \
curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/uapi/linux/v4l2-common.h && \
curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/uapi/linux/v4l2-controls.h && \
curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/linux/compiler.h && \
mv videodev2.h v4l2-common.h v4l2-controls.h compiler.h /usr/include/linux
ENV PATH "$HOME/bin:$PATH"
# Version: 20230628
# Image name: quay.io/opencv-ci/opencv-python-manylinux2014-aarch64
FROM quay.io/pypa/manylinux2014_aarch64:latest
ARG CCACHE_VERSION=3.7.9
ARG FFMPEG_VERSION=5.1.3
ARG FREETYPE_VERSION=2.13.1
ARG LIBPNG_VERSION=1.6.40
ARG NASM_VERSION=2.15.04
ARG OPENSSL_VERSION=1_1_1u
ARG QT_VERSION=5.15.0
ARG YASM_VERSION=1.3.0
ENV LD_LIBRARY_PATH /usr/local/lib:$LD_LIBRARY_PATH
# epel-release need for aarch64 to get openblas packages
RUN yum install zlib-devel curl-devel xcb-util-renderutil-devel xcb-util-devel xcb-util-image-devel xcb-util-keysyms-devel xcb-util-wm-devel mesa-libGL-devel libxkbcommon-devel libxkbcommon-x11-devel libXi-devel lapack-devel epel-release -y && \
yum install openblas-devel dejavu-sans-fonts -y && \
cp /usr/include/lapacke/lapacke*.h /usr/include/ && \
curl https://raw.githubusercontent.com/xianyi/OpenBLAS/v0.3.3/cblas.h -o /usr/include/cblas.h && \
# libpng will be built from source
yum remove libpng -y
RUN mkdir ~/libpng_sources && \
cd ~/libpng_sources && \
curl -O -L https://download.sourceforge.net/libpng/libpng-${LIBPNG_VERSION}.tar.gz && \
tar -xf libpng-${LIBPNG_VERSION}.tar.gz && \
cd libpng-${LIBPNG_VERSION} && \
./configure --prefix=/usr/local && \
make && \
make install && \
cd .. && \
rm -rf ~/libpng_sources
RUN mkdir ~/freetype_sources && \
cd ~/freetype_sources && \
curl -O -L https://download.savannah.gnu.org/releases/freetype/freetype-${FREETYPE_VERSION}.tar.gz && \
tar -xf freetype-${FREETYPE_VERSION}.tar.gz && \
cd freetype-${FREETYPE_VERSION} && \
./configure --prefix="/ffmpeg_build" --enable-freetype-config && \
make && \
make install && \
cd .. && \
rm -rf ~/freetype_sources
RUN curl -O -L https://download.qt.io/official_releases/qt/5.15/${QT_VERSION}/single/qt-everywhere-src-${QT_VERSION}.tar.xz && \
tar -xf qt-everywhere-src-${QT_VERSION}.tar.xz && \
cd qt-everywhere-src-${QT_VERSION} && \
export MAKEFLAGS=-j$(nproc) && \
./configure -prefix /opt/Qt${QT_VERSION} -release -opensource -confirm-license -qtnamespace QtOpenCVPython -xcb -xcb-xlib -bundled-xcb-xinput -no-openssl -no-dbus -skip qt3d -skip qtactiveqt -skip qtcanvas3d -skip qtconnectivity -skip qtdatavis3d -skip qtdoc -skip qtgamepad -skip qtgraphicaleffects -skip qtimageformats -skip qtlocation -skip qtmultimedia -skip qtpurchasing -skip qtqa -skip qtremoteobjects -skip qtrepotools -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qttranslations -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview -skip xmlpatterns -skip declarative -make libs && \
make && \
make install && \
cd .. && \
rm -rf qt-everywhere*
ENV QTDIR /opt/Qt${QT_VERSION}
ENV PATH "$QTDIR/bin:$PATH"
RUN mkdir ~/openssl_sources && \
cd ~/openssl_sources && \
curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_${OPENSSL_VERSION}.tar.gz && \
tar -xf OpenSSL_${OPENSSL_VERSION}.tar.gz && \
cd openssl-OpenSSL_${OPENSSL_VERSION} && \
./config --prefix="/ffmpeg_build" --openssldir="/ffmpeg_build" no-pinshared shared zlib && \
make -j$(getconf _NPROCESSORS_ONLN) && \
# skip installing documentation
make install_sw && \
cd .. && \
rm -rf ~/openssl_build ~/openssl_sources
RUN mkdir ~/nasm_sources && \
cd ~/nasm_sources && \
curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/${NASM_VERSION}/nasm-${NASM_VERSION}.tar.gz && \
tar -xf nasm-${NASM_VERSION}.tar.gz && cd nasm-${NASM_VERSION} && ./autogen.sh && \
./configure --prefix="/ffmpeg_build" --bindir="$HOME/bin" && \
make -j$(getconf _NPROCESSORS_ONLN) && \
make install && \
cd .. && \
rm -rf ~/nasm_sources
RUN mkdir ~/yasm_sources && \
cd ~/yasm_sources && \
curl -O -L http://www.tortall.net/projects/yasm/releases/yasm-${YASM_VERSION}.tar.gz && \
tar -xf yasm-${YASM_VERSION}.tar.gz && \
cd yasm-${YASM_VERSION} && \
./configure --prefix="/ffmpeg_build" --bindir="$HOME/bin" && \
make -j$(getconf _NPROCESSORS_ONLN) && \
make install && \
cd .. && \
rm -rf ~/yasm_sources
RUN mkdir ~/libvpx_sources && \
cd ~/libvpx_sources && \
git clone --depth 1 https://github.com/webmproject/libvpx.git && \
cd libvpx && \
./configure --prefix="/ffmpeg_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm --enable-pic --enable-shared && \
make -j$(getconf _NPROCESSORS_ONLN) && \
make install && \
cd .. && \
rm -rf ~/libvpx_sources
RUN mkdir ~/ffmpeg_sources && \
cd ~/ffmpeg_sources && \
curl -O -L https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.gz && \
tar -xf ffmpeg-${FFMPEG_VERSION}.tar.gz && \
cd ffmpeg-${FFMPEG_VERSION} && \
PATH=~/bin:$PATH && \
PKG_CONFIG_PATH="/ffmpeg_build/lib/pkgconfig" ./configure --prefix="/ffmpeg_build" --extra-cflags="-I/ffmpeg_build/include" --extra-ldflags="-L/ffmpeg_build/lib" --enable-openssl --enable-libvpx --enable-shared --enable-pic --bindir="$HOME/bin" && \
make -j$(getconf _NPROCESSORS_ONLN) && \
make install && \
echo "/ffmpeg_build/lib/" >> /etc/ld.so.conf && \
ldconfig && \
rm -rf ~/ffmpeg_sources
RUN curl -O -L https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}.tar.gz && \
tar -xf ccache-${CCACHE_VERSION}.tar.gz && \
cd ccache-${CCACHE_VERSION} && \
linux32 ./configure && \
make -j$(getconf _NPROCESSORS_ONLN) && \
make install && \
cd .. && \
rm -rf ccache-${CCACHE_VERSION}.tar.gz
# Self-hosted runner UID is 1004
RUN useradd ci -m -s /bin/bash -G users --uid=1004 && \
mkdir /io && \
chown -R ci:ci /io && \
# This needs to find ffmpeg packages from ci user
chown -R ci:ci /ffmpeg_build && \
# This calls in mutlibuild scripts and cannot be run without permissions
chown -R ci:ci /opt/_internal/pipx/venvs/auditwheel
USER ci
# Git security vulnerability: https://github.blog/2022-04-12-git-security-vulnerability-announced
RUN git config --global --add safe.directory /io
ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/ffmpeg_build/lib/pkgconfig
ENV LDFLAGS -L/ffmpeg_build/lib
ENV PATH "$HOME/bin:$PATH"
FROM quay.io/pypa/manylinux2014_i686:latest
ARG CCACHE_VERSION=3.7.9
ARG CMAKE_VERSION=3.17.0
ARG FFMPEG_VERSION=5.1.2
ARG NASM_VERSION=2.15.04
ARG OPENSSL_VERSION=1_1_1s
ARG QT_VERSION=5.15.0
ARG YASM_VERSION=1.3.0
RUN yum install bzip2-devel curl-devel zlib-devel xcb-util-renderutil-devel xcb-util-devel xcb-util-image-devel xcb-util-keysyms-devel xcb-util-wm-devel mesa-libGL-devel libxkbcommon-devel libxkbcommon-x11-devel libXi-devel freetype-devel -y
RUN curl -O -L https://download.qt.io/official_releases/qt/5.15/${QT_VERSION}/single/qt-everywhere-src-${QT_VERSION}.tar.xz && \
tar -xf qt-everywhere-src-${QT_VERSION}.tar.xz && \
cd qt-everywhere* && \
export MAKEFLAGS=-j$(nproc) && \
./configure -prefix /opt/Qt${QT_VERSION} -release -opensource -confirm-license -qtnamespace QtOpenCVPython -xcb -xcb-xlib -bundled-xcb-xinput -no-openssl -no-dbus -skip qt3d -skip qtactiveqt -skip qtcanvas3d -skip qtconnectivity -skip qtdatavis3d -skip qtdoc -skip qtgamepad -skip qtgraphicaleffects -skip qtimageformats -skip qtlocation -skip qtmultimedia -skip qtpurchasing -skip qtqa -skip qtremoteobjects -skip qtrepotools -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qttranslations -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview -skip xmlpatterns -skip declarative -make libs && \
make && \
make install && \
cd .. && \
rm -rf qt-everywhere-src-${QT_VERSION} && \
rm qt-everywhere-src-${QT_VERSION}.tar.xz
ENV QTDIR /opt/Qt${QT_VERSION}
ENV PATH "$QTDIR/bin:$PATH"
RUN mkdir ~/ffmpeg_sources && \
cd ~/ffmpeg_sources && \
curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_${OPENSSL_VERSION}.tar.gz && \
tar -xf OpenSSL_${OPENSSL_VERSION}.tar.gz && \
cd openssl-OpenSSL_${OPENSSL_VERSION} && \
# in i686, ./config detects x64 in i686 container without linux32
# when run from "docker build"
linux32 ./config --prefix="$HOME/ffmpeg_build" no-pinshared shared zlib && \
make -j$(getconf _NPROCESSORS_ONLN) && \
#skip installing documentation
make install_sw && \
rm -rf ~/openssl_build
RUN cd ~/ffmpeg_sources && \
curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/${NASM_VERSION}/nasm-${NASM_VERSION}.tar.bz2 && \
tar -xf nasm-${NASM_VERSION}.tar.bz2 && cd nasm-${NASM_VERSION} && ./autogen.sh && \
linux32 ./configure && \
make -j$(getconf _NPROCESSORS_ONLN) && \
make install
RUN cd ~/ffmpeg_sources && \
curl -O -L http://www.tortall.net/projects/yasm/releases/yasm-${YASM_VERSION}.tar.gz && \
tar -xf yasm-${YASM_VERSION}.tar.gz && \
cd yasm-${YASM_VERSION} && \
linux32 ./configure && \
make -j$(getconf _NPROCESSORS_ONLN) && \
make install
RUN cd ~/ffmpeg_sources && \
git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git && \
cd libvpx && \
linux32 ./configure --prefix="$HOME/ffmpeg_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm --enable-pic --enable-shared && \
make -j$(getconf _NPROCESSORS_ONLN) && \
make install
RUN cd ~/ffmpeg_sources && \
curl -O -L https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2 && \
tar -xf ffmpeg-${FFMPEG_VERSION}.tar.bz2 && \
cd ffmpeg-${FFMPEG_VERSION} && \
PATH=~/bin:$PATH && \
PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" linux32 ./configure --prefix="$HOME/ffmpeg_build" --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" --enable-openssl --enable-libvpx --enable-shared --enable-pic --bindir="$HOME/bin" && \
make -j$(getconf _NPROCESSORS_ONLN) && \
make install && \
echo "/root/ffmpeg_build/lib/" >> /etc/ld.so.conf && \
ldconfig && \
rm -rf ~/ffmpeg_sources
RUN curl -O -L https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}.tar.gz && \
tar -xf ccache-${CCACHE_VERSION}.tar.gz && \
cd ccache-${CCACHE_VERSION} && \
linux32 ./configure && \
make -j$(getconf _NPROCESSORS_ONLN) && \
make install
RUN curl -O -L https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}.tar.gz && \
tar -xf cmake-${CMAKE_VERSION}.tar.gz && \
cd cmake-${CMAKE_VERSION} && \
export MAKEFLAGS=-j$(getconf _NPROCESSORS_ONLN) && \
./configure --system-curl && \
make && \
make install && \
cd .. && \
rm -rf cmake-${CMAKE_VERSION}*
ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/root/ffmpeg_build/lib/pkgconfig
ENV LDFLAGS -L/root/ffmpeg_build/lib
# in i686, yum metadata ends up with slightly wrong timestamps
# which inhibits its update
# https://github.com/skvark/opencv-python/issues/148
RUN yum clean all
ENV PATH "$HOME/bin:$PATH"
# Version: 20230628
# Image name: quay.io/opencv-ci/opencv-python-manylinux2014-x86-64
FROM quay.io/pypa/manylinux2014_x86_64:latest
ARG CCACHE_VERSION=3.7.9
ARG FFMPEG_VERSION=5.1.3
ARG FREETYPE_VERSION=2.13.1
ARG LIBPNG_VERSION=1.6.40
ARG NASM_VERSION=2.15.04
ARG OPENSSL_VERSION=1_1_1u
ARG QT_VERSION=5.15.0
ARG YASM_VERSION=1.3.0
ENV LD_LIBRARY_PATH /usr/local/lib:$LD_LIBRARY_PATH
# epel-release need for aarch64 to get openblas packages
RUN yum install zlib-devel curl-devel xcb-util-renderutil-devel xcb-util-devel xcb-util-image-devel xcb-util-keysyms-devel xcb-util-wm-devel mesa-libGL-devel libxkbcommon-devel libxkbcommon-x11-devel libXi-devel lapack-devel epel-release -y && \
yum install openblas-devel dejavu-sans-fonts -y && \
cp /usr/include/lapacke/lapacke*.h /usr/include/ && \
curl https://raw.githubusercontent.com/xianyi/OpenBLAS/v0.3.3/cblas.h -o /usr/include/cblas.h && \
# libpng will be built from source
yum remove libpng -y
RUN mkdir ~/libpng_sources && \
cd ~/libpng_sources && \
curl -O -L https://download.sourceforge.net/libpng/libpng-${LIBPNG_VERSION}.tar.gz && \
tar -xf libpng-${LIBPNG_VERSION}.tar.gz && \
cd libpng-${LIBPNG_VERSION} && \
./configure --prefix=/usr/local && \
make && \
make install && \
cd .. && \
rm -rf ~/libpng_sources
RUN mkdir ~/freetype_sources && \
cd ~/freetype_sources && \
curl -O -L https://download.savannah.gnu.org/releases/freetype/freetype-${FREETYPE_VERSION}.tar.gz && \
tar -xf freetype-${FREETYPE_VERSION}.tar.gz && \
cd freetype-${FREETYPE_VERSION} && \
./configure --prefix="/ffmpeg_build" --enable-freetype-config && \
make && \
make install && \
cd .. && \
rm -rf ~/freetype_sources
RUN curl -O -L https://download.qt.io/official_releases/qt/5.15/${QT_VERSION}/single/qt-everywhere-src-${QT_VERSION}.tar.xz && \
tar -xf qt-everywhere-src-${QT_VERSION}.tar.xz && \
cd qt-everywhere-src-${QT_VERSION} && \
export MAKEFLAGS=-j$(nproc) && \
./configure -prefix /opt/Qt${QT_VERSION} -release -opensource -confirm-license -qtnamespace QtOpenCVPython -xcb -xcb-xlib -bundled-xcb-xinput -no-openssl -no-dbus -skip qt3d -skip qtactiveqt -skip qtcanvas3d -skip qtconnectivity -skip qtdatavis3d -skip qtdoc -skip qtgamepad -skip qtgraphicaleffects -skip qtimageformats -skip qtlocation -skip qtmultimedia -skip qtpurchasing -skip qtqa -skip qtremoteobjects -skip qtrepotools -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qttranslations -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview -skip xmlpatterns -skip declarative -make libs && \
make && \
make install && \
cd .. && \
rm -rf qt-everywhere*
ENV QTDIR /opt/Qt${QT_VERSION}
ENV PATH "$QTDIR/bin:$PATH"
RUN mkdir ~/openssl_sources && \
cd ~/openssl_sources && \
curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_${OPENSSL_VERSION}.tar.gz && \
tar -xf OpenSSL_${OPENSSL_VERSION}.tar.gz && \
cd openssl-OpenSSL_${OPENSSL_VERSION} && \
./config --prefix="/ffmpeg_build" --openssldir="/ffmpeg_build" no-pinshared shared zlib && \
make -j$(getconf _NPROCESSORS_ONLN) && \
# skip installing documentation
make install_sw && \
cd .. && \
rm -rf ~/openssl_build ~/openssl_sources
RUN mkdir ~/nasm_sources && \
cd ~/nasm_sources && \
curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/${NASM_VERSION}/nasm-${NASM_VERSION}.tar.gz && \
tar -xf nasm-${NASM_VERSION}.tar.gz && cd nasm-${NASM_VERSION} && ./autogen.sh && \
./configure --prefix="/ffmpeg_build" --bindir="$HOME/bin" && \
make -j$(getconf _NPROCESSORS_ONLN) && \
make install && \
cd .. && \
rm -rf ~/nasm_sources
RUN mkdir ~/yasm_sources && \
cd ~/yasm_sources && \
curl -O -L http://www.tortall.net/projects/yasm/releases/yasm-${YASM_VERSION}.tar.gz && \
tar -xf yasm-${YASM_VERSION}.tar.gz && \
cd yasm-${YASM_VERSION} && \
./configure --prefix="/ffmpeg_build" --bindir="$HOME/bin" && \
make -j$(getconf _NPROCESSORS_ONLN) && \
make install && \
cd .. && \
rm -rf ~/yasm_sources
RUN mkdir ~/libvpx_sources && \
cd ~/libvpx_sources && \
git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git && \
cd libvpx && \
./configure --prefix="/ffmpeg_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm --enable-pic --enable-shared && \
make -j$(getconf _NPROCESSORS_ONLN) && \
make install && \
cd .. && \
rm -rf ~/libvpx_sources
RUN mkdir ~/ffmpeg_sources && \
cd ~/ffmpeg_sources && \
curl -O -L https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.gz && \
tar -xf ffmpeg-${FFMPEG_VERSION}.tar.gz && \
cd ffmpeg-${FFMPEG_VERSION} && \
PATH=~/bin:$PATH && \
PKG_CONFIG_PATH="/ffmpeg_build/lib/pkgconfig" ./configure --prefix="/ffmpeg_build" --extra-cflags="-I/ffmpeg_build/include" --extra-ldflags="-L/ffmpeg_build/lib" --enable-openssl --enable-libvpx --enable-shared --enable-pic --bindir="$HOME/bin" && \
make -j$(getconf _NPROCESSORS_ONLN) && \
make install && \
echo "/ffmpeg_build/lib/" >> /etc/ld.so.conf && \
ldconfig && \
rm -rf ~/ffmpeg_sources
RUN curl -O -L https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}.tar.gz && \
tar -xf ccache-${CCACHE_VERSION}.tar.gz && \
cd ccache-${CCACHE_VERSION} && \
./configure && \
make -j$(getconf _NPROCESSORS_ONLN) && \
make install && \
cd .. && \
rm -rf ccache-${CCACHE_VERSION}.tar.gz
# GitHub Actions user`s UID is 1001
RUN useradd ci -m -s /bin/bash -G users --uid=1001 && \
mkdir /io && \
chown -R ci:ci /io && \
# This needs to find ffmpeg packages from ci user
chown -R ci:ci /ffmpeg_build && \
# This calls in mutlibuild scripts and cannot be run without permissions
chown -R ci:ci /opt/_internal/pipx/venvs/auditwheel
USER ci
# Git security vulnerability: https://github.blog/2022-04-12-git-security-vulnerability-announced
RUN git config --global --add safe.directory /io
ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/ffmpeg_build/lib/pkgconfig
ENV LDFLAGS -L/ffmpeg_build/lib
ENV PATH "$HOME/bin:$PATH"
import sys
import subprocess
from datetime import date
import os
UNKNOWN = "Unknown"
def dtk_version_value():
try:
dtk_path=os.getenv('ROCM_PATH')
dtk_version_path = os.path.join(dtk_path, '.info', "version-dev")
with open(dtk_version_path, 'r',encoding='utf-8') as file:
lines = file.readlines()
dtk_version="dtk"+lines[0][:].replace(".", "")
return dtk_version
except Exception:
return UNKNOWN
def opencv_whl_name():
try:
if (os.getenv('DAS_VERSION')):
das_version=str(os.getenv('DAS_VERSION'))
else:
das_version= "1.1"
if (os.getenv('OPT_VERSION')):
opt_version=str(os.getenv('OPT_VERSION'))
else:
opt_version= "1"
whl_name = "das"+ "." + "opt" + opt_version
return whl_name
except Exception:
return UNKNOWN
if __name__ == "__main__":
contrib = sys.argv[1]
headless = sys.argv[2]
rolling = sys.argv[3]
ci_build = sys.argv[4]
opencv_version = ""
# dig out the version from OpenCV sources
version_file_path = "opencv/modules/core/include/opencv2/core/version.hpp"
with open(version_file_path, "r") as f:
for line in f:
words = line.split()
if "CV_VERSION_MAJOR" in words:
opencv_version += words[2]
opencv_version += "."
if "CV_VERSION_MINOR" in words:
opencv_version += words[2]
opencv_version += "."
if "CV_VERSION_REVISION" in words:
opencv_version += words[2]
break
# # used in local dev releases
# git_hash = (
# subprocess.check_output(["git", "rev-parse", "--short", "HEAD"])
# .splitlines()[0]
# .decode()
# )
# # this outputs the annotated tag if we are exactly on a tag, otherwise <tag>-<n>-g<shortened sha-1>
# try:
# tag = (
# subprocess.check_output(
# ["git", "describe", "--tags"], stderr=subprocess.STDOUT
# )
# .splitlines()[0]
# .decode()
# .split("-")
# )
# except subprocess.CalledProcessError as e:
# # no tags reachable (e.g. on a topic branch in a fork), see
# # https://stackoverflow.com/questions/4916492/git-describe-fails-with-fatal-no-names-found-cannot-describe-anything
# if e.output.rstrip() == b"fatal: No names found, cannot describe anything.":
# tag = []
# else:
# print(e.output)
# raise
# if len(tag) == 1:
# # tag identifies the build and should be a sequential revision number
# version = tag[0]
# opencv_version += ".{}".format(version)
# # rolling has converted into string using get_and_set_info() function in setup.py
# elif rolling == "True":
# # rolling version identifier, will be published in a dedicated rolling PyPI repository
# version = date.today().strftime('%Y%m%d')
# opencv_version += ".{}".format(version)
# else:
# # local version identifier, not to be published on PyPI
# version = git_hash
# opencv_version += "+{}".format(version)
opencv_version += f"+{opencv_whl_name()}.{dtk_version_value()}"
with open("cv2/version.py", "w") as f:
f.write('opencv_version = "{}"\n'.format(opencv_version))
f.write("contrib = {}\n".format(contrib))
f.write("headless = {}\n".format(headless))
f.write("rolling = {}\n".format(rolling))
f.write("ci_build = {}".format(ci_build))
# https://editorconfig.org/
root = true
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4
[{CMakeLists.*,*.cmake}]
indent_style = space
indent_size = 2
[Makefile]
indent_style = tab
[*.{bat,cmd,cmd.*}]
end_of_line = crlf
indent_style = space
indent_size = 2
[*.{ps1,ps1.*}]
end_of_line = crlf
indent_style = space
indent_size = 4
[*.{md,markdown}]
indent_size = 2
cmake_minimum_required(VERSION ${MIN_VER_CMAKE} FATAL_ERROR)
project(Carotene)
set(CAROTENE_NS "carotene" CACHE STRING "Namespace for Carotene definitions")
set(CAROTENE_INCLUDE_DIR include)
set(CAROTENE_SOURCE_DIR src)
file(GLOB_RECURSE carotene_headers RELATIVE "${CMAKE_CURRENT_LIST_DIR}" "${CAROTENE_INCLUDE_DIR}/*.hpp")
file(GLOB_RECURSE carotene_sources RELATIVE "${CMAKE_CURRENT_LIST_DIR}" "${CAROTENE_SOURCE_DIR}/*.cpp"
"${CAROTENE_SOURCE_DIR}/*.hpp")
include_directories(${CAROTENE_INCLUDE_DIR})
if(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_CXX_FLAGS "-fvisibility=hidden ${CMAKE_CXX_FLAGS}")
# allow more inlines - these parameters improve performance for:
# - matchTemplate about 5-10%
# - goodFeaturesToTrack 10-20%
# - cornerHarris 30% for some cases
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "10.0.0")
set_source_files_properties(${carotene_sources} COMPILE_FLAGS "--param ipcp-unit-growth=100000 --param inline-unit-growth=100000 --param large-stack-frame-growth=5000")
else()
set_source_files_properties(${carotene_sources} COMPILE_FLAGS "--param ipa-cp-unit-growth=100000 --param inline-unit-growth=100000 --param large-stack-frame-growth=5000")
endif()
endif()
if(APPLE AND CV_CLANG AND WITH_NEON)
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-unused-function)
endif()
add_library(carotene_objs OBJECT EXCLUDE_FROM_ALL
${carotene_headers}
${carotene_sources}
)
if(NOT CAROTENE_NS STREQUAL "carotene")
target_compile_definitions(carotene_objs PUBLIC "-DCAROTENE_NS=${CAROTENE_NS}")
endif()
if(WITH_NEON)
target_compile_definitions(carotene_objs PRIVATE "-DWITH_NEON")
endif()
# we add dummy file to fix XCode build
add_library(carotene STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} "$<TARGET_OBJECTS:carotene_objs>" "${CAROTENE_SOURCE_DIR}/dummy.cpp")
This is Carotene, a low-level library containing optimized CPU routines
that are useful for computer vision algorithms.
cmake_minimum_required(VERSION ${MIN_VER_CMAKE} FATAL_ERROR)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
set(TEGRA_HAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(CAROTENE_DIR "${TEGRA_HAL_DIR}/../")
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm.*|ARM.*)")
set(ARM TRUE)
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64.*|AARCH64.*")
set(AARCH64 TRUE)
endif()
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wunused-function)
set(TEGRA_COMPILER_FLAGS "")
if(CV_GCC OR CV_CLANG)
# Generate unwind information even for functions that can't throw/propagate exceptions.
# This lets debuggers and such get non-broken backtraces for such functions, even without debugging symbols.
list(APPEND TEGRA_COMPILER_FLAGS -funwind-tables)
endif()
if(CV_GCC OR CV_CLANG)
if(X86 OR ARMEABI_V6 OR (MIPS AND ANDROID_COMPILER_VERSION VERSION_LESS "4.6"))
list(APPEND TEGRA_COMPILER_FLAGS -fweb -fwrapv -frename-registers -fsched-stalled-insns-dep=100 -fsched-stalled-insns=2)
elseif(CV_CLANG)
list(APPEND TEGRA_COMPILER_FLAGS -fwrapv)
else()
list(APPEND TEGRA_COMPILER_FLAGS -fweb -fwrapv -frename-registers -fsched2-use-superblocks -fsched2-use-traces
-fsched-stalled-insns-dep=100 -fsched-stalled-insns=2)
endif()
if((ANDROID_COMPILER_IS_CLANG OR NOT ANDROID_COMPILER_VERSION VERSION_LESS "4.7") AND ANDROID_NDK_RELEASE STRGREATER "r8d" )
list(APPEND TEGRA_COMPILER_FLAGS -fgraphite -fgraphite-identity -floop-block -floop-flatten -floop-interchange
-floop-strip-mine -floop-parallelize-all -ftree-loop-linear)
endif()
endif()
string(REPLACE ";" " " TEGRA_COMPILER_FLAGS "${TEGRA_COMPILER_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TEGRA_COMPILER_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TEGRA_COMPILER_FLAGS}")
if(ARMEABI_V7A)
if(CV_GCC OR CV_CLANG)
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-tree-vectorize" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-tree-vectorize" )
endif()
endif()
if(WITH_LOGS)
add_definitions(-DHAVE_LOGS)
endif()
set(CAROTENE_NS "carotene_o4t" CACHE STRING "" FORCE)
function(compile_carotene)
if(";${CPU_BASELINE_FINAL};" MATCHES ";NEON;")
set(WITH_NEON ON)
endif()
add_subdirectory("${CAROTENE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/carotene")
endfunction()
compile_carotene()
include_directories("${CAROTENE_DIR}/include")
get_target_property(carotene_defs carotene_objs INTERFACE_COMPILE_DEFINITIONS)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS ${carotene_defs})
if(CV_GCC)
# allow more inlines - these parameters improve performance for:
# matchTemplate about 5-10%
# goodFeaturesToTrack 10-20%
# cornerHarris 30% for some cases
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "10.0.0")
set_source_files_properties(impl.cpp $<TARGET_OBJECTS:carotene_objs> COMPILE_FLAGS "--param ipcp-unit-growth=100000 --param inline-unit-growth=100000 --param large-stack-frame-growth=5000")
else()
set_source_files_properties(impl.cpp $<TARGET_OBJECTS:carotene_objs> COMPILE_FLAGS "--param ipa-cp-unit-growth=100000 --param inline-unit-growth=100000 --param large-stack-frame-growth=5000")
endif()
# set_source_files_properties(impl.cpp $<TARGET_OBJECTS:carotene_objs> COMPILE_FLAGS "--param ipcp-unit-growth=100000 --param inline-unit-growth=100000 --param large-stack-frame-growth=5000")
endif()
# we add dummy file to fix XCode build
add_library(tegra_hal STATIC $<TARGET_OBJECTS:carotene_objs> "dummy.cpp")
set_target_properties(tegra_hal PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH})
set(OPENCV_SRC_DIR "${CMAKE_SOURCE_DIR}")
if(NOT BUILD_SHARED_LIBS)
ocv_install_target(tegra_hal EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
endif()
target_include_directories(tegra_hal PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${OPENCV_SRC_DIR}/modules/core/include)
set(CAROTENE_HAL_VERSION "0.0.1" PARENT_SCOPE)
set(CAROTENE_HAL_LIBRARIES "tegra_hal" PARENT_SCOPE)
set(CAROTENE_HAL_HEADERS "carotene/tegra_hal.hpp" PARENT_SCOPE)
set(CAROTENE_HAL_INCLUDE_DIRS "${CMAKE_BINARY_DIR}" PARENT_SCOPE)
configure_file("tegra_hal.hpp" "${CMAKE_BINARY_DIR}/carotene/tegra_hal.hpp" COPYONLY)
configure_file("${CAROTENE_DIR}/include/carotene/definitions.hpp" "${CMAKE_BINARY_DIR}/carotene/definitions.hpp" COPYONLY)
configure_file("${CAROTENE_DIR}/include/carotene/functions.hpp" "${CMAKE_BINARY_DIR}/carotene/functions.hpp" COPYONLY)
configure_file("${CAROTENE_DIR}/include/carotene/types.hpp" "${CMAKE_BINARY_DIR}/carotene/types.hpp" COPYONLY)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment