mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-15 10:43:15 +00:00
Set WAGTAILIMAGES_FEATURE_DETECTION_ENABLED to False by default in project template, and avoid importing OpenCV if it's false to avoid spurious errors about libdc1394
This commit is contained in:
parent
1cc64b9478
commit
39ab06722b
2 changed files with 18 additions and 7 deletions
|
|
@ -158,3 +158,7 @@ WAGTAIL_SITE_NAME = "{{ project_name }}"
|
|||
# 'INDEX': '{{ project_name }}',
|
||||
# },
|
||||
# }
|
||||
|
||||
|
||||
# Whether to use face/feature detection to improve image cropping - requires OpenCV
|
||||
WAGTAILIMAGES_FEATURE_DETECTION_ENABLED = False
|
||||
|
|
|
|||
|
|
@ -1,16 +1,23 @@
|
|||
import os
|
||||
from django.conf import settings
|
||||
|
||||
try:
|
||||
import cv
|
||||
|
||||
opencv_available = True
|
||||
except ImportError:
|
||||
# only try to import OpenCV if WAGTAILIMAGES_FEATURE_DETECTION_ENABLED is True -
|
||||
# avoids spurious "libdc1394 error: Failed to initialize libdc1394" errors on sites that
|
||||
# don't even use OpenCV
|
||||
if getattr(settings, 'WAGTAILIMAGES_FEATURE_DETECTION_ENABLED', False):
|
||||
try:
|
||||
import cv2.cv as cv
|
||||
import cv
|
||||
|
||||
opencv_available = True
|
||||
except ImportError:
|
||||
opencv_available = False
|
||||
try:
|
||||
import cv2.cv as cv
|
||||
|
||||
opencv_available = True
|
||||
except ImportError:
|
||||
opencv_available = False
|
||||
else:
|
||||
opencv_available = False
|
||||
|
||||
|
||||
from wagtail.wagtailimages.utils.focal_point import FocalPoint, combine_focal_points
|
||||
|
|
|
|||
Loading…
Reference in a new issue