thumbor / opencv-engine

Thumbor engine for the openCV imaging library.
MIT License
26 stars 26 forks source link

Compatibility with thumbor 6.0 #20

Closed Bladrak closed 6 years ago

Bladrak commented 8 years ago

When running thumbor 6 with opencv, it seems there's an incompatibility when using smart detection:

2016-03-14 12:10:57 tornado.application:ERROR Future exception was never retrieved: Traceback (most recent call last):
  File "/home/thumbor/thumborenv/local/lib/python2.7/site-packages/tornado/gen.py", line 1017, in run
    yielded = self.gen.send(value)
  File "/home/thumbor/thumborenv/local/lib/python2.7/site-packages/thumbor/handlers/__init__.py", line 177, in get_image
    self.filters_runner.apply_filters(thumbor.filters.PHASE_AFTER_LOAD, transform)
  File "/home/thumbor/thumborenv/local/lib/python2.7/site-packages/thumbor/filters/__init__.py", line 81, in apply_filters
    callback()
  File "/home/thumbor/thumborenv/local/lib/python2.7/site-packages/thumbor/handlers/__init__.py", line 175, in transform
    self.context.transformer.transform(after_transform_cb)
  File "/home/thumbor/thumborenv/local/lib/python2.7/site-packages/thumbor/transformer.py", line 102, in transform
    self.smart_detect()
  File "/home/thumbor/thumborenv/local/lib/python2.7/site-packages/thumbor/transformer.py", line 151, in smart_detect
    self.do_smart_detection().result()
  File "/home/thumbor/thumborenv/local/lib/python2.7/site-packages/tornado/concurrent.py", line 232, in result
    raise_exc_info(self._exc_info)
  File "/home/thumbor/thumborenv/local/lib/python2.7/site-packages/tornado/gen.py", line 1017, in run
    yielded = self.gen.send(value)
  File "/home/thumbor/thumborenv/local/lib/python2.7/site-packages/thumbor/transformer.py", line 179, in do_smart_detection
    detectors[0](self.context, index=0, detectors=detectors).detect(self.after_smart_detect)
  File "/home/thumbor/thumborenv/local/lib/python2.7/site-packages/thumbor/detectors/face_detector/__init__.py", line 28, in detect
    features = self.get_features()
  File "/home/thumbor/thumborenv/local/lib/python2.7/site-packages/thumbor/detectors/local_detector.py", line 43, in get_features
    with_alpha=False
TypeError: convert_to_grayscale() got an unexpected keyword argument 'update_image'

Here's the version of the packages I'm using:

backports-abc==0.4
backports.ssl-match-hostname==3.5.0.1
botocore==1.2.0
certifi==2016.2.28
colour==0.1.2
derpconf==0.7.3
docutils==0.12
futures==3.0.5
jmespath==0.7.1
libthumbor==1.3.1
numpy==1.10.4
opencv-engine==1.0.1
pexif==0.15
Pillow==3.1.1
pycrypto==2.6.1
pycurl==7.19.5.3
python-dateutil==2.5.0
python-magic==0.4.10
pytz==2016.1
redis==2.10.5
shortuuid==0.4.3
singledispatch==3.4.0.3
six==1.10.0
statsd==3.2.1
tc-aws==6.0.0
tc-core==0.3.0
tc-redis==1.0.1
tc-shortener==0.2.2
thumbor==6.0.0
tornado==4.3
tornado-botocore==1.0.2

And the configuration for running thumbor:

################################################################################
#######                    FILE MANAGED BY PUPPET                        #######
################################################################################
COMMUNITY_EXTENSIONS = ["tc_shortener"]
DETECTORS = ["thumbor.detectors.face_detector", "thumbor.detectors.profile_detector", "thumbor.detectors.glasses_detector", "thumbor.detectors.feature_detector"]
ENGINE = "opencv_engine"
FACE_DETECTOR_CASCADE_FILE = "haarcascade_frontalface_default.xml"
FILTERS = ["thumbor.filters.brightness", "thumbor.filters.no_upscale", "thumbor.filters.colorize", "thumbor.filters.contrast", "thumbor.filters.equalize", "thumbor.filters.format", "thumbor.filters.rotate", "thumbor.filters.quality", "thumbor.filters.fill", "thumbor.filters.saturation", "thumbor.filters.rgb", "thumbor.filters.round_corner", "thumbor.filters.quality", "thumbor.filters.sharpen", "thumbor.filters.noise", "thumbor.filters.watermark", "thumbor.filters.blur", "thumbor.filters.grayscale", "thumbor.filters.strip_icc", "thumbor.filters.convolution", "thumbor.filters.extract_focal", "thumbor.filters.max_bytes"]
JPEGTRAN_PATH = "/usr/bin/jpegtran"
LOADER = "tc_aws.loaders.s3_loader"
METRICS = "thumbor.metrics.statsd_metrics"
MIXED_STORAGE_CRYPTO_STORAGE = "tc_redis.storages.redis_storage"
MIXED_STORAGE_DETECTOR_STORAGE = "tc_redis.storages.redis_storage"
MIXED_STORAGE_FILE_STORAGE = "tc_aws.storages.s3_storage"
OPTIMIZERS = ["thumbor.optimizers.jpegtran"]
REDIS_STORAGE_SERVER_DB = 0
REDIS_STORAGE_SERVER_HOST = "localhost"
REDIS_STORAGE_SERVER_PASSWORD = ""
REDIS_STORAGE_SERVER_PORT = 6379
RESULT_STORAGE = "tc_aws.result_storages.s3_storage"
RESULT_STORAGE_STORES_UNSAFE = True
SEND_IF_MODIFIED_LAST_MODIFIED_HEADERS = True
SHORTENER_REDIS_STORAGE_SERVER_DB = 0
SHORTENER_REDIS_STORAGE_SERVER_HOST = "localhost"
SHORTENER_REDIS_STORAGE_SERVER_PORT = 6379
STATSD_HOST = "localhost"
STATSD_PREFIX = "thumbor"
STORAGE = "thumbor.storages.mixed_storage"
TC_AWS_LOADER_BUCKET = "REDACTED"
TC_AWS_REGION = "eu-west-1"
TC_AWS_RESULT_STORAGE_BUCKET = "REDACTED"
TC_AWS_RESULT_STORAGE_ROOT_PATH = "/results"
TC_AWS_STORAGE_BUCKET = "REDACTED"
TC_AWS_STORAGE_ROOT_PATH = "/storage"
TC_AWS_STORAGE_RSS = False

@guilhermef maybe you did encounter this error?

guilhermef commented 8 years ago

@Bladrak It's really broken, the smart detection now uses cv2 interface, which works really well with Pillow but not cv.

Bladrak commented 8 years ago

@guilhermef ok, so we still need opencv for the smart cropping, but not as an image engine, is that right? If I switch the engine to pil, it should be ok then?

guilhermef commented 8 years ago

That's right. Em 14/03/2016 11:58, "Hugo Briand" notifications@github.com escreveu:

@guilhermef https://github.com/guilhermef ok, so we still need opencv for the smart cropping, but not as an image engine, is that right? If I switch the engine to pil, it should be ok then?

— Reply to this email directly or view it on GitHub https://github.com/thumbor/opencv-engine/issues/20#issuecomment-196351799 .

christianjgreen commented 7 years ago

This is fixed in my pr #27