Skip to content

Commit 9f8b7b9

Browse files
authored
Try fixing opencv (#338)
* Try fixing opencv * Add numpy * Try without 3.11 * Different strategy * Debug * More debug * Fix * Another fix * Remove call * Fix * Add missing file * Final fix * Try fixing tests
1 parent a4e54ec commit 9f8b7b9

File tree

6 files changed

+33332
-25
lines changed

6 files changed

+33332
-25
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,14 @@ on:
99
jobs:
1010
build:
1111
runs-on: ubuntu-22.04
12-
strategy:
13-
matrix:
14-
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
1512
steps:
1613
- uses: actions/checkout@v2
17-
- name: Set up Python ${{ matrix.python-version }}
18-
uses: actions/setup-python@v2
19-
with:
20-
python-version: ${{ matrix.python-version }}
2114
- name: Install Ubuntu dependencies
22-
run: sudo apt-get -y install gettext appstream pkg-config libcairo2-dev gir1.2-gtk-3.0 libgirepository1.0-dev libicu-dev
15+
run: sudo apt-get -y install gettext appstream pkg-config libcairo2-dev gir1.2-gtk-3.0 libgirepository1.0-dev libicu-dev libopencv-dev python3-opencv python3-numpy gramps
2316
- name: Install Python dependencies
2417
run: |
2518
python -m pip install --upgrade pip wheel
26-
pip install pycairo PyGObject pytest PyYAML jsonschema pyICU opencv-python celery[pytest]
27-
python -m pip install git+https://github.com/gramps-project/gramps#egg=gramps
19+
pip install pycairo PyGObject pytest PyYAML jsonschema pyICU celery[pytest]
2820
pip install .
2921
pip list
3022
- name: Test with pytest

gramps_webapi/api/image.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import os
2626
import tempfile
2727
from pathlib import Path
28+
from pkg_resources import resource_filename
2829
from typing import BinaryIO, Callable, List, Tuple
2930

3031
import ffmpeg
@@ -220,8 +221,8 @@ def detect_faces(stream: BinaryIO) -> List[Tuple[float, float, float, float]]:
220221
file_bytes = np.asarray(bytearray(stream.read()), dtype=np.uint8)
221222
cv_image = cv2.imdecode(file_bytes, cv2.IMREAD_COLOR)
222223
cv_image = cv2.cvtColor(cv_image, cv2.COLOR_BGR2GRAY)
223-
haarcascade_path = os.path.join(
224-
cv2.data.haarcascades, "haarcascade_frontalface_default.xml"
224+
haarcascade_path = resource_filename(
225+
"gramps_webapi", "data/haarcascade_frontalface_default.xml"
225226
)
226227
cascade = cv2.CascadeClassifier(haarcascade_path)
227228
faces = cascade.detectMultiScale(cv_image, 1.1, 4)

0 commit comments

Comments
 (0)