Skip to content

Commit

Permalink
.github, ci: Add dlib-models package flow for Fedora
Browse files Browse the repository at this point in the history
  • Loading branch information
norihiro committed Jun 7, 2024
1 parent 03772db commit f812778
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .github/containers/fedora-common/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ sed \
< ci/plugin.spec \
> $rpmbuild/SPECS/$PLUGIN_NAME_FEDORA.spec

DESTDIR='dlib-models-data/' ci/download-dlib-models.sh

git archive --format=tar --prefix=$PLUGIN_NAME_FEDORA-$VERSION/ HEAD | bzip2 > $rpmbuild/SOURCES/$PLUGIN_NAME_FEDORA-$VERSION.tar.bz2
(cd libvisca && git archive --format=tar --prefix=libvisca/ HEAD) | bzip2 > $rpmbuild/SOURCES/$PLUGIN_NAME_FEDORA-$VERSION-libvisca.tar.bz2
(cd dlib-models-data && tar cj .) > $rpmbuild/SOURCES/$PLUGIN_NAME_FEDORA-$VERSION-dlib-models.tar.bz2

docker run -v $rpmbuild:/home/rpm/rpmbuild $docker_image bash -c "
sudo dnf builddep -y ~/rpmbuild/SPECS/$PLUGIN_NAME_FEDORA.spec &&
Expand Down
10 changes: 1 addition & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,7 @@ jobs:
- name: Download dlib-models
run: |
set -ex
mkdir data/dlib_hog_model
curl -LO https://github.com/norihiro/obs-face-tracker/releases/download/0.7.0-hogdata/frontal_face_detector.dat.bz2
bunzip2 < frontal_face_detector.dat.bz2 > data/dlib_hog_model/frontal_face_detector.dat
git clone --depth 1 https://github.com/davisking/dlib-models
mkdir data/{dlib_cnn_model,dlib_face_landmark_model}
bunzip2 < dlib-models/mmod_human_face_detector.dat.bz2 > data/dlib_cnn_model/mmod_human_face_detector.dat
bunzip2 < dlib-models/shape_predictor_5_face_landmarks.dat.bz2 > data/dlib_face_landmark_model/shape_predictor_5_face_landmarks.dat
cp dlib/LICENSE.txt data/LICENSE-dlib
cp dlib-models/LICENSE data/LICENSE-dlib-models
DESTDIR='./' ci/download-dlib-models.sh
- name: Build plugin
run: |
Expand Down
13 changes: 13 additions & 0 deletions ci/download-dlib-models.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#! /bin/bash

mkdir -p ${DESTDIR}data

mkdir ${DESTDIR}data/dlib_hog_model
curl -LO https://github.com/norihiro/obs-face-tracker/releases/download/0.7.0-hogdata/frontal_face_detector.dat.bz2
bunzip2 < frontal_face_detector.dat.bz2 > ${DESTDIR}data/dlib_hog_model/frontal_face_detector.dat
git clone --depth 1 https://github.com/davisking/dlib-models
mkdir ${DESTDIR}data/{dlib_cnn_model,dlib_face_landmark_model}
bunzip2 < dlib-models/mmod_human_face_detector.dat.bz2 > ${DESTDIR}data/dlib_cnn_model/mmod_human_face_detector.dat
bunzip2 < dlib-models/shape_predictor_5_face_landmarks.dat.bz2 > ${DESTDIR}data/dlib_face_landmark_model/shape_predictor_5_face_landmarks.dat
cp dlib/LICENSE.txt ${DESTDIR}data/LICENSE-dlib
cp dlib-models/LICENSE ${DESTDIR}data/LICENSE-dlib-models
15 changes: 14 additions & 1 deletion ci/plugin.spec
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ License: GPLv3+

Source0: %{name}-%{version}.tar.bz2
Source1: %{name}-%{version}-libvisca.tar.bz2
Source2: %{name}-%{version}-dlib-models.tar.bz2
Requires: obs-studio >= @OBS_VERSION@
BuildRequires: cmake, gcc, gcc-c++
BuildRequires: obs-studio-devel
BuildRequires: qt6-qtbase-devel qt6-qtbase-private-devel
BuildRequires: dlib-devel ffmpeg-free-devel sqlite-devel blas-devel lapack-devel
# dlib-devel requires /usr/include/ffmpeg so that install ffmpeg-free-devel

%package data
Summary: Model file for %{name}
BuildArch: noarch
License: Nonfree

%description
This plugin tracks face of a person by detecting and tracking a face.

Expand All @@ -21,9 +27,13 @@ the source is periodically taken to face detection algorithm. Once a face is
found, the face is tracked. Based on the location and the size of the face
under tracking, the frame will be cropped.

%description data
Model files for @PLUGIN_NAME_FEDORA@.

%prep
%autosetup -p1
%setup -T -D -a 1
%setup -T -D -a 2

%build
%{cmake} \
Expand All @@ -38,4 +48,7 @@ under tracking, the frame will be cropped.

%files
%{_libdir}/obs-plugins/@[email protected]
%{_datadir}/obs/obs-plugins/@PLUGIN_NAME@/
%{_datadir}/obs/obs-plugins/@PLUGIN_NAME@/locale/

%files data
%{_datadir}/obs/obs-plugins/@PLUGIN_NAME@/*dlib*

0 comments on commit f812778

Please sign in to comment.