Coder Social home page Coder Social logo

opencv-engine's Introduction

Join thumbor-bootcamp for a learning and contribution experience with โค๏ธ and ๐Ÿค— from the thumbor team

thumbor

Crop, resize, transform and much more, all on-demand and AI Powered


thumbor is trusted by hundreds of companies worldwide

Wikipedia trusts thumborย  Globo.com trusts thumborย  Vox Media trusts thumborย  Forbes trusts thumborย  Square trusts thumborย  Deliveroo trusts thumborย  Canal+ trusts thumborย  Terra trusts thumborย  nrc trusts thumborย  web.dev indicates thumbor for high-performance web sitesย  aws indicates thumbor for serverless image handling
and many more!

thumbor is a smart imaging service that enables on-demand cropping, resizing, applying filters and optimizing images.

Cropping photos automatically can be a frustrating experience with severed heads involved. thumbor uses AI for smart detection.

thumbor is an HTTP server and you can create as many different images as you want just by varying path parameters:

http://<thumbor-server>/300x200/smart/thumbor.readthedocs.io/en/latest/_images/logo-thumbor.png

You should see an image of the thumbor logo in 300x200.

Learn more about all you can do in thumbor's documentation.

โš™๏ธ Installation

Decide which installation option you want to use.

Option 1: pip

# thumbor with main dependencies only
pip install thumbor

# thumbor with OpenCV dependency
pip install thumbor[opencv]

# thumbor with all dependencies
pip install thumbor[all]

Option 2: Binary

sudo add-apt-repository ppa:thumbor/ppa
sudo aptitude update
sudo aptitude install thumbor

For more ways, please check out Installation.

Run

Running it is as easy as hit:

thumbor

After this, you can reach it on https://localhost:8888/unsafe/https://raw.githubusercontent.com/thumbor/thumbor/master/example.jpg

Troubles?

If you experience any troubles, try running:

thumbor-doctor

If you have a thumbor.conf file, you can use that to help thumbor-doctor:

thumbor-doctor -c thumbor.conf

If you still need help, please raise an issue. Remember to send your thumbor-doctor output in the issue:

thumbor-doctor --nocolor -c thumbor.conf

๐ŸŽฏ Features

  • supports all common images formats out of the box
  • intelligent cropping and resizing
  • blazing fast using caching
  • supports many storages (local storage, AWS S3, Rackspace, Ceph, ...)
  • AI-powered cropping based on face and feature detection (glasses, interesting points, ...)
  • integrated with many programming languages and frameworks and many more...
  • highly extensible

๐ŸŒŸ Awesome Goodies

awesome-thumbor is a curated list of all things thumbor. There you can find filters, storages, engines, loaders, docker images, extensions in your favorite language and framework, and much more.

All of it with a clear indication of each project's quality. Have fun!

๐Ÿ‘ Contribute

thumbor is an open-source project with many contributors. Join them contributing code or contributing documentation.

If you use thumbor, please take 1 minute and answer this survey? Only 2 questions!

Join the chat at https://gitter.im/thumbor/thumbor

๐Ÿ‘€ Demo

You can see thumbor in action at http://thumborize.me/

opencv-engine's People

Contributors

cezarsa avatar dannyeuu avatar fgnass avatar gockxml avatar heynemann avatar scorphus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opencv-engine's Issues

filters:fill w/ opencv fails: TypeError: gen_image() takes exactly 1 argument (3 given)

FAILED (unsafe/filters:fill(ff0000)/s.glbimg.com/en/ho/f/original/2012/10/29/dilmahaddad.jpg) - ERR(500)
FAILED (unsafe/filters:fill(ff0000)/g1.globo.com/platb/files/2135/2012/05/logo-FV.png-menor.png) - ERR(500)

FAILED (unsafe/filters:fill(auto)/s.glbimg.com/en/ho/f/original/2012/10/29/dilmahaddad.jpg) - ERR(500)
FAILED (unsafe/filters:fill(auto)/g1.globo.com/platb/files/2135/2012/05/logo-FV.png-menor.png) - ERR(500)

FAILED (unsafe/filters:fill(ff0000,true)/s.glbimg.com/en/ho/f/original/2012/10/29/dilmahaddad.jpg) - ERR(500)
FAILED (unsafe/filters:fill(ff0000,true)/g1.globo.com/platb/files/2135/2012/05/logo-FV.png-menor.png) - ERR(500)

thumbor:ERROR ERROR: Traceback (most recent call last):
  File "lib/python2.7/site-packages/tornado/web.py", line 1115, in _stack_context_handle_exception
    raise_exc_info((type, value, traceback))
  File "lib/python2.7/site-packages/tornado/web.py", line 1298, in wrapper
    result = method(self, *args, **kwargs)
  File "thumbor/handlers/imaging.py", line 85, in get
    return self.execute_image_operations()
  File "thumbor/handlers/__init__.py", line 67, in execute_image_operations
    self.get_image()
  File "thumbor/handlers/__init__.py", line 89, in get_image
    self._fetch(self.context.request.image_url, self.context.request.extension, callback)
  File "thumbor/handlers/__init__.py", line 283, in _fetch
    callback(False, buffer=buffer)
  File "thumbor/handlers/__init__.py", line 87, in callback
    Transformer(self.context).transform(after_transform_cb)
  File "thumbor/transformer.py", line 88, in transform
    self.smart_detect()
  File "thumbor/transformer.py", line 120, in smart_detect
    self.do_image_operations()
  File "thumbor/transformer.py", line 196, in do_image_operations
    self.done_callback()
  File "thumbor/handlers/__init__.py", line 128, in after_transform
    self.apply_filters(context.filters_factory.create_instances(context, context.request.filters), finish_callback)
  File "thumbor/handlers/__init__.py", line 144, in apply_filters
    exec_one_filter()
  File "thumbor/handlers/__init__.py", line 143, in exec_one_filter
    f.run(exec_one_filter)
  File "thumbor/filters/__init__.py", line 171, in run
    results.append(self.runnable_method(*self.params))
  File "thumbor/filters/__init__.py", line 19, in wrapper
    return fn(self, *args2)
  File "thumbor/filters/fill.py", line 35, in fill
    self.fill_engine.image = self.fill_engine.gen_image((bx, by), color)
TypeError: gen_image() takes exactly 1 argument (3 given)

Upgrade to thumbor 7

Hey @scorphus do you think we can work together to upgrade this to thumbor 7 and python 3?

Adding it to awesome thumbor anyway.

Compatibility with thumbor 6.0

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?

filters:watermark w/ opencv fails: NotImplementedError

FAILED (unsafe/filters:watermark(http://s.glbimg.com/es/ge/f/original/2012/08/15/brasil_45.png,10,10,50)/s.glbimg.com/en/ho/f/original/2012/10/29/dilmahaddad.jpg) - ERR(500)
FAILED (unsafe/filters:watermark(http://s.glbimg.com/es/ge/f/original/2012/08/15/brasil_45.png,10,10,50)/g1.globo.com/platb/files/2135/2012/05/logo-FV.png-menor.png) - ERR(500)

thumbor:ERROR ERROR: Traceback (most recent call last):
  File "lib/python2.7/site-packages/tornado/web.py", line 1115, in _stack_context_handle_exception
    raise_exc_info((type, value, traceback))
  File "lib/python2.7/site-packages/tornado/web.py", line 1298, in wrapper
    result = method(self, *args, **kwargs)
  File "thumbor/handlers/imaging.py", line 85, in get
    return self.execute_image_operations()
  File "thumbor/handlers/__init__.py", line 67, in execute_image_operations
    self.get_image()
  File "thumbor/handlers/__init__.py", line 89, in get_image
    self._fetch(self.context.request.image_url, self.context.request.extension, callback)
  File "thumbor/handlers/__init__.py", line 283, in _fetch
    callback(False, buffer=buffer)
  File "thumbor/handlers/__init__.py", line 87, in callback
    Transformer(self.context).transform(after_transform_cb)
  File "thumbor/transformer.py", line 88, in transform
    self.smart_detect()
  File "thumbor/transformer.py", line 120, in smart_detect
    self.do_image_operations()
  File "thumbor/transformer.py", line 196, in do_image_operations
    self.done_callback()
  File "thumbor/handlers/__init__.py", line 128, in after_transform
    self.apply_filters(context.filters_factory.create_instances(context, context.request.filters), finish_callback)
  File "thumbor/handlers/__init__.py", line 144, in apply_filters
    exec_one_filter()
  File "thumbor/handlers/__init__.py", line 143, in exec_one_filter
    f.run(exec_one_filter)
  File "thumbor/filters/__init__.py", line 169, in run
    self.runnable_method(callback, *self.params)
  File "thumbor/filters/__init__.py", line 19, in wrapper
    return fn(self, *args2)
  File "thumbor/filters/watermark.py", line 63, in watermark
    self.on_image_ready(buffer)
  File "thumbor/filters/watermark.py", line 21, in on_image_ready
    self.watermark_engine.enable_alpha()
  File "thumbor/engines/__init__.py", line 216, in enable_alpha
    raise NotImplementedError()
NotImplementedError

Intermittent segfaults on Ubuntu 14.04

Not sure if this is the right place to raise this, but I've been unable to get the opencv_engine running reliably due to intermittent segfaults in the cv module taking down the whole thumbor process. It's nothing related to a specific file because I can retry and it works fine. I noticed this during load testing so it may be exacerbated during high load.

It took me a while to find the issue, there was nothing relevant in the thumbor logs, but I noticed 502s and dropped/prematurely closed connections in Nginx. Here's the relevant snippet from syslog:

Feb 12 21:48:30 ip-172-17-0-246 kernel: [  775.849915] init: thumbor_worker (1) main process (20820) killed by SEGV signal
Feb 12 21:48:30 ip-172-17-0-246 kernel: [  775.849930] init: thumbor_worker (1) main process ended, respawning
Feb 12 21:48:33 ip-172-17-0-246 kernel: [  779.087115] thumbor[20891]: segfault at 8 ip 00007faf3f436609 sp 00007fff1054b4e0 error 4 in cv2.so[7faf3f3ff000+14e000]

I tried with both the python-opencv package and building 2.4.10 from source, but saw the same results. Relevant Python packages:

opencv-engine==1.0.0
thumbor==4.8.6

install error

when I install it with $ pip install opencv-engine
there is an error

Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;file='/tmp/pip_build_xsm/opencv-engine/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /tmp/pip-VUmNze-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_xsm/opencv-engine
Storing debug log for failure in /home/xsm/.pip/pip.log

what can I do for it ?

Support for OpenCV 3.0?

Hello,

OpenCV 3.0 being out and relatively stable, is opencv-engine compatible with this version?

I've tried it on a VM, but ran into some errors. One of them was the import, that I fixed with the following code:

try:
    import cv
except ImportError:
    import cv2.cv as cv
except ImportError:
    import cv2 as cv

But when trying to request an image, I now get the following:

2015-08-12 10:02:39 tornado.application:ERROR Future exception was never retrieved: Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 879, in run
    yielded = self.gen.send(value)
  File "/usr/local/lib/python2.7/dist-packages/thumbor/handlers/__init__.py", line 97, in get_image
    engine.load(buffer, self.context.request.extension)
  File "/usr/local/lib/python2.7/dist-packages/thumbor/engines/__init__.py", line 96, in load
    image_or_frames = self.create_image(buffer)
  File "/usr/local/lib/python2.7/dist-packages/opencv_engine/engine.py", line 78, in create_image
    imagefiledata = cv.CreateMatHeader(1, len(buffer), cv.CV_8UC1)
AttributeError: 'module' object has no attribute 'CreateMatHeader'

I'm guessing the engine is not compatible with OpenCV 3.0 at the moment, but is there any plan to make it so? Do you need help in this?

I'm using opencv-engine 1.0.1.

Thanks for any information!

filters:grayscale w/ opencv fails: AttributeError: 'Engine' object has no attribute 'convert_to_grayscale'

FAILED (unsafe/filters:grayscale()/s.glbimg.com/en/ho/f/original/2012/10/29/dilmahaddad.jpg) - ERR(500)
FAILED (unsafe/filters:grayscale()/g1.globo.com/platb/files/2135/2012/05/logo-FV.png-menor.png) - ERR(500)

  File "lib/python2.7/site-packages/tornado/web.py", line 1115, in _stack_context_handle_exception
    raise_exc_info((type, value, traceback))
  File "lib/python2.7/site-packages/tornado/web.py", line 1298, in wrapper
    result = method(self, *args, **kwargs)
  File "thumbor/handlers/imaging.py", line 85, in get
    return self.execute_image_operations()
  File "thumbor/handlers/__init__.py", line 67, in execute_image_operations
    self.get_image()
  File "thumbor/handlers/__init__.py", line 89, in get_image
    self._fetch(self.context.request.image_url, self.context.request.extension, callback)
  File "thumbor/handlers/__init__.py", line 283, in _fetch
    callback(False, buffer=buffer)
  File "thumbor/handlers/__init__.py", line 87, in callback
    Transformer(self.context).transform(after_transform_cb)
  File "thumbor/transformer.py", line 88, in transform
    self.smart_detect()
  File "thumbor/transformer.py", line 120, in smart_detect
    self.do_image_operations()
  File "thumbor/transformer.py", line 196, in do_image_operations
    self.done_callback()
  File "thumbor/handlers/__init__.py", line 128, in after_transform
    self.apply_filters(context.filters_factory.create_instances(context, context.request.filters), finish_callback)
  File "thumbor/handlers/__init__.py", line 144, in apply_filters
    exec_one_filter()
  File "thumbor/handlers/__init__.py", line 143, in exec_one_filter
    f.run(exec_one_filter)
  File "thumbor/filters/__init__.py", line 171, in run
    results.append(self.runnable_method(*self.params))
  File "thumbor/filters/__init__.py", line 19, in wrapper
    return fn(self, *args2)
  File "thumbor/filters/grayscale.py", line 19, in grayscale
    engine.convert_to_grayscale()
AttributeError: 'Engine' object has no attribute 'convert_to_grayscale'

Problematic examples:

  • unsafe/filters:grayscale()/g1.globo.com/platb/files/2135/2012/05/logo-FV.png-menor.png
  • unsafe/60x/entropymine.com/jason/testbed/pngtrans/gray8a_bk.png
  • unsafe/filters:grayscale()/entropymine.com/jason/testbed/pngtrans/gray8a_bk.png

Alpha layer transformed to black on grayscaled images with feature detection

Hi everybody,

We're using thumbor with feature detection but we have problems when we use grayscaled PNGs having an alpha layer. On these images, the whole alpha layer is transformed into black color.

It seems somehow related to this FIXME:
https://github.com/thumbor/opencv-engine/blob/master/opencv_engine/engine.py#L193

Called by:
https://github.com/thumbor/thumbor/blob/bc52ab6bb8934c08d24c89ef5e52f20744468e58/thumbor/detectors/feature_detector/__init__.py#L23

Did anyone also encountered this problem and have clues to fix it?
Thanks by advance.

Edit New issue OpenCV crash with some PNG Files

Hello,

We are using Thumbor for some resizing on Overblog (https://www.over-blog.com/) and it works very well, but we encounter problems with some PNG files.

We are using OpenCV engine because of its speed and smart detection, and we fallback on PIL when OpenCV crash.

Here is the version we use:
Pillow==2.3.2
opencv-engine==1.0.0
pgmagick==0.5.8
thumbor==4.8.2
thumbor-pexif==0.14.1
tornado==3.2.2

Works on Debian 7 with bundled OpenCV 2.4.10.

Here is an example of a PNG: http://img.over-blog-kiwi.com/0/88/72/24/20150107/ob_f75a17_jescharlie.png

We resize with this command:
/unsafe/568x568/http://img.over-blog-kiwi.com/0/88/72/24/20150107/ob_f75a17_jescharlie.png
(I know it's an upscale)

It's the same with downscale: /unsafe/100x50/http://img.over-blog-kiwi.com/0/88/72/24/20150107/ob_f75a17_jescharlie.png

thumbor_opencv OpenCV Error: Assertion failed (src.depth() == dst.depth() && src.size == dst.size) in cvCopy, file /tmp/opencv-2.4.10/modules/core/src/copy.cpp, line 556
thumbor_opencv 2015-01-14 09:57:34 thumbor:ERROR ERROR: Traceback (most recent call last):
thumbor_opencv   File "/usr/local/lib/python2.7/dist-packages/tornado/web.py", line 1320, in _stack_context_handle_exception
thumbor_opencv     raise_exc_info((type, value, traceback))
thumbor_opencv   File "/usr/local/lib/python2.7/dist-packages/tornado/stack_context.py", line 302, in wrapped
thumbor_opencv     ret = fn(*args, **kwargs)
thumbor_opencv   File "/usr/local/lib/python2.7/dist-packages/thumbor/loaders/http_loader.py", line 54, in return_contents
thumbor_opencv     callback(response.body)
thumbor_opencv   File "/usr/local/lib/python2.7/dist-packages/thumbor/handlers/__init__.py", line 373, in handle_loader_loaded
thumbor_opencv     callback(normalized, engine=self.context.request.engine)
thumbor_opencv   File "/usr/local/lib/python2.7/dist-packages/thumbor/handlers/__init__.py", line 110, in callback
thumbor_opencv     self.filters_runner.apply_filters(thumbor.filters.PHASE_AFTER_LOAD, transform)
thumbor_opencv   File "/usr/local/lib/python2.7/dist-packages/thumbor/filters/__init__.py", line 81, in apply_filters
thumbor_opencv     callback()
thumbor_opencv   File "/usr/local/lib/python2.7/dist-packages/thumbor/handlers/__init__.py", line 108, in transform
thumbor_opencv     Transformer(self.context).transform(after_transform_cb)
thumbor_opencv   File "/usr/local/lib/python2.7/dist-packages/thumbor/transformer.py", line 88, in transform
thumbor_opencv     self.smart_detect()
thumbor_opencv   File "/usr/local/lib/python2.7/dist-packages/thumbor/transformer.py", line 123, in smart_detect
thumbor_opencv     self.do_image_operations()
thumbor_opencv   File "/usr/local/lib/python2.7/dist-packages/thumbor/transformer.py", line 195, in do_image_operations
thumbor_opencv     self.auto_crop()
thumbor_opencv   File "/usr/local/lib/python2.7/dist-packages/thumbor/transformer.py", line 247, in auto_crop
thumbor_opencv     self.engine.crop(crop_left, crop_top, crop_right, crop_bottom)
thumbor_opencv   File "/usr/local/lib/python2.7/dist-packages/opencv_engine/engine.py", line 95, in crop
thumbor_opencv     cv.Copy(src_region, cropped)
thumbor_opencv error: src.depth() == dst.depth() && src.size == dst.size

Works very well with PIL.

Thanks for your work and your help.

filters:frame w/ opencv fails: NotImplementedError

FAILED (unsafe/filters:frame(publicobject.com/ninepatch/frame.9.png)/s.glbimg.com/en/ho/f/original/2012/10/29/dilmahaddad.jpg) - ERR(500)
FAILED (unsafe/filters:frame(publicobject.com/ninepatch/frame.9.png)/g1.globo.com/platb/files/2135/2012/05/logo-FV.png-menor.png) - ERR(500)

thumbor:ERROR ERROR: Traceback (most recent call last):
  File "lib/python2.7/site-packages/tornado/web.py", line 1115, in _stack_context_handle_exception
    raise_exc_info((type, value, traceback))
  File "lib/python2.7/site-packages/tornado/web.py", line 1298, in wrapper
    result = method(self, *args, **kwargs)
  File "thumbor/handlers/imaging.py", line 85, in get
    return self.execute_image_operations()
  File "thumbor/handlers/__init__.py", line 67, in execute_image_operations
    self.get_image()
  File "thumbor/handlers/__init__.py", line 89, in get_image
    self._fetch(self.context.request.image_url, self.context.request.extension, callback)
  File "thumbor/handlers/__init__.py", line 283, in _fetch
    callback(False, buffer=buffer)
  File "thumbor/handlers/__init__.py", line 87, in callback
    Transformer(self.context).transform(after_transform_cb)
  File "thumbor/transformer.py", line 88, in transform
    self.smart_detect()
  File "thumbor/transformer.py", line 120, in smart_detect
    self.do_image_operations()
  File "thumbor/transformer.py", line 196, in do_image_operations
    self.done_callback()
  File "thumbor/handlers/__init__.py", line 128, in after_transform
    self.apply_filters(context.filters_factory.create_instances(context, context.request.filters), finish_callback)
  File "thumbor/handlers/__init__.py", line 144, in apply_filters
    exec_one_filter()
  File "thumbor/handlers/__init__.py", line 143, in exec_one_filter
    f.run(exec_one_filter)
  File "thumbor/filters/__init__.py", line 169, in run
    self.runnable_method(callback, *self.params)
  File "thumbor/filters/__init__.py", line 19, in wrapper
    return fn(self, *args2)
  File "thumbor/filters/frame.py", line 90, in frame
    self.on_image_ready(buffer)
  File "thumbor/filters/frame.py", line 21, in on_image_ready
    self.nine_patch_engine.enable_alpha()
  File "thumbor/engines/__init__.py", line 216, in enable_alpha
    raise NotImplementedError()
NotImplementedError

AttributeError: 'cv2.cv.iplimage' object has no attribute 'tobytes'

Please see: thumbor/thumbor#817

I was not sure where to open the issue, I encounter this error:

2016-10-13 04:09:42 tornado.application:ERROR Future exception was never retrieved: Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/tornado/gen.py", line 270, in wrapper
    result = func(*args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/thumbor/handlers/__init__.py", line 362, in finish_request
    callback=inner,
  File "/usr/lib64/python2.7/site-packages/thumbor/context.py", line 284, in queue
    self._execute_in_foreground(operation, callback)
  File "/usr/lib64/python2.7/site-packages/thumbor/context.py", line 272, in _execute_in_foreground
    callback(result)
  File "/usr/lib64/python2.7/site-packages/thumbor/handlers/__init__.py", line 355, in inner
    self._write_results_to_client(context, results, content_type)
  File "/usr/lib64/python2.7/site-packages/thumbor/handlers/__init__.py", line 394, in _write_results_to_client
    self.finish()
  File "/usr/lib64/python2.7/site-packages/tornado/web.py", line 955, in finish
    self.on_finish()
  File "/usr/lib64/python2.7/site-packages/thumbor/handlers/__init__.py", line 78, in on_finish
    len(self.context.request.engine.image.tobytes())
AttributeError: 'cv2.cv.iplimage' object has no attribute 'tobytes'

Using non-image url for image in watermark filter crashes the server instead of giving 400

I am using https://github.com/APSL/docker-thumbor to run thumbor.

Request to thumbor

pbagrecha-mpb15-1490:~ pbagrecha$ curl -v "http://localhost:8000/unsafe/filters:watermark(https://google.com,-10,-10,50)/images/gracenote/assets/p10492765_e_h9_ab.jpg"
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8000 (#0)
> GET /unsafe/filters:watermark(https://google.com,-10,-10,50)/images/gracenote/assets/p10492765_e_h9_ab.jpg HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/7.58.0
> Accept: */*
>
* Empty reply from server
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server
pbagrecha-mpb15-1490:~ pbagrecha$

Command for how I am running thumbor and debug logs

pbagrecha-mpb15-1490:docker-thumbor pbagrecha$ docker run -e AWS_ACCESS_KEY_ID='<access_key>' -e AWS_SECRET_ACCESS_KEY='<secret_key>' -e TC_AWS_LOADER_BUCKET='<s3_bucket>' -e LOADER='tc_aws.loaders.presigning_loader' -e TC_AWS_REGION='us-east-1' -e TC_AWS_ENABLE_HTTP_LOADER='True' -e RESULT_STORAGE_STORES_UNSAFE='False' -e STORES_CRYPTO_KEY_FOR_EACH_IMAGE='False' -e TC_AWS_STORE_METADATA='False' -e OPTIMIZERS="['thumbor.optimizers.jpegtran']" -e ENGINE='opencv_engine' -e MAX_AGE='604800' -e QUALITY='100' -e LOG_LEVEL=debug -p 8000:8000 apsl/thumbor
2018-03-06 21:27:05 root:DEBUG thumbor running at 0.0.0.0:8000
2018-03-06 21:27:09 thumbor:DEBUG METRICS: inc: response.count:1
2018-03-06 21:27:09 thumbor:DEBUG METRICS: inc: storage.miss:1
2018-03-06 21:27:09 botocore.credentials:DEBUG Looking for credentials via: env
2018-03-06 21:27:09 botocore.credentials:INFO Found credentials in environment variables.
2018-03-06 21:27:09 botocore.client:DEBUG Registering retry handlers for service: s3
2018-03-06 21:27:09 botocore.hooks:DEBUG Event creating-client-class.s3: calling handler <function add_generate_presigned_post at 0x7fca09603578>
2018-03-06 21:27:09 botocore.hooks:DEBUG Event creating-client-class.s3: calling handler <function add_generate_presigned_url at 0x7fca095ed500>
2018-03-06 21:27:09 botocore.endpoint:DEBUG Setting s3 timeout as (60, 60)
2018-03-06 21:27:09 thumbor:DEBUG Cleaning key: images/gracenote/assets/p10492765_e_h9_ab.jpg
2018-03-06 21:27:09 thumbor:DEBUG Cleansed key: images/gracenote/assets/p10492765_e_h9_ab.jpg
2018-03-06 21:27:09 botocore.utils:DEBUG Checking for DNS compatible bucket for: https://s3.amazonaws.com/<s3_bucket>/images/gracenote/assets/p10492765_e_h9_ab.jpg
2018-03-06 21:27:09 botocore.utils:DEBUG Not changing URI, bucket is not DNS compatible: <s3_bucket>
2018-03-06 21:27:09 botocore.auth:DEBUG Calculating signature using hmacv1 auth.
2018-03-06 21:27:09 botocore.auth:DEBUG HTTP request method: GET
2018-03-06 21:27:09 botocore.auth:DEBUG StringToSign:
GET


1520375229
/<s3_bucket>/images/gracenote/assets/p10492765_e_h9_ab.jpg
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG GET https://s3.amazonaws.com/<s3_bucket>/images/gracenote/assets/p10492765_e_h9_ab.jpg?AWSAccessKeyId=AKIAIQ6ASSOSDZVWHLBA&Expires=1520375229&Signature=R23hZCHtlFRdYNAqQlcnU%2BTztNI%3D
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG Hostname was NOT found in DNS cache
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG Trying 54.231.82.92...
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG Connected to s3.amazonaws.com (54.231.82.92) port 443 (#0)
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG successfully set certificate verify locations:
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG CAfile: none
  CApath: /etc/ssl/certs
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG SSLv3, TLS handshake, Client hello (1):
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG SSLv3, TLS handshake, Server hello (2):
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG SSLv3, TLS handshake, CERT (11):
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG SSLv3, TLS handshake, Server key exchange (12):
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG SSLv3, TLS handshake, Server finished (14):
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG SSLv3, TLS handshake, Client key exchange (16):
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG SSLv3, TLS change cipher, Client hello (1):
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG SSLv3, TLS handshake, Finished (20):
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG SSLv3, TLS change cipher, Client hello (1):
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG SSLv3, TLS handshake, Finished (20):
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG Server certificate:
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG subject: C=US; ST=Washington; L=Seattle; O=Amazon.com Inc.; CN=s3.amazonaws.com
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG start date: 2017-09-26 00:00:00 GMT
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG expire date: 2018-09-20 12:00:00 GMT
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG subjectAltName: s3.amazonaws.com matched
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert Baltimore CA-2 G2
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG SSL certificate verify ok.
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG > GET /<s3_bucket>/images/gracenote/assets/p10492765_e_h9_ab.jpg?AWSAccessKeyId=AKIAIQ6ASSOSDZVWHLBA&Expires=1520375229&Signature=R23hZCHtlFRdYNAqQlcnU%2BTztNI%3D HTTP/1.1
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG > User-Agent: Thumbor/6.3.0
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG > Host: s3.amazonaws.com
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG > Accept: */*
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG > Accept-Encoding: gzip,deflate
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG >
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG < HTTP/1.1 200 OK
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG < x-amz-id-2: m8v0TDRZfjCU0q4WJBDStgy6yivJ14PxfcUBDhP6TDHIEXHjVpWzi2gm3ZF2p+0VoVOXlt4onRg=
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG < x-amz-request-id: 2BBDD3B5740DEB55
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG < Date: Tue, 06 Mar 2018 21:27:10 GMT
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG < Last-Modified: Fri, 02 Mar 2018 20:19:14 GMT
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG < ETag: "8e2fc13a6a32fa15ab5927b51246d4a9"
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG < Cache-Control: max-age=604800
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG < x-amz-meta-etag: "8e2fc13a6a32fa15ab5927b51246d4a9"
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG < x-amz-version-id: null
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG < x-amz-meta-lastmodified: Sat, 28 Jan 2017 12:40:44 GMT
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG < Accept-Ranges: bytes
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG < Content-Type: image/jpeg
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG < Content-Length: 230154
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG Server AmazonS3 is not blacklisted
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG < Server: AmazonS3
2018-03-06 21:27:09 tornado.curl_httpclient:DEBUG <
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG Connection #0 to host s3.amazonaws.com left intact
2018-03-06 21:27:10 thumbor:DEBUG METRICS: timing: original_image.fetch.200.s3.amazonaws.com:811
2018-03-06 21:27:10 thumbor:DEBUG METRICS: inc: original_image.status.200:1
2018-03-06 21:27:10 thumbor:DEBUG METRICS: timing: original_image.time_info.redirect:0
2018-03-06 21:27:10 thumbor:DEBUG METRICS: timing: original_image.time_info.queue:0
2018-03-06 21:27:10 thumbor:DEBUG METRICS: timing: original_image.time_info.pretransfer:238
2018-03-06 21:27:10 thumbor:DEBUG METRICS: timing: original_image.time_info.starttransfer:525
2018-03-06 21:27:10 thumbor:DEBUG METRICS: timing: original_image.time_info.total:809
2018-03-06 21:27:10 thumbor:DEBUG METRICS: timing: original_image.time_info.connect:81
2018-03-06 21:27:10 thumbor:DEBUG METRICS: timing: original_image.time_info.namelookup:7
2018-03-06 21:27:10 thumbor:DEBUG METRICS: timing: original_image.time_info.bytes_per_second:284405
2018-03-06 21:27:10 thumbor:DEBUG METRICS: inc: original_image.response_bytes:230154
2018-03-06 21:27:10 thumbor:DEBUG creating tempfile for images/gracenote/assets/p10492765_e_h9_ab.jpg in /data/storage/70/2d55d55b39c5c6d330da45da49eb7dc38de72f.edf3b4e06c9e4e9cb1e5dc3f9bc27794...
2018-03-06 21:27:10 thumbor:DEBUG moving tempfile /data/storage/70/2d55d55b39c5c6d330da45da49eb7dc38de72f.edf3b4e06c9e4e9cb1e5dc3f9bc27794 to /data/storage/70/2d55d55b39c5c6d330da45da49eb7dc38de72f...
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG GET https://google.com
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG Rebuilt URL to: https://google.com/
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG Hostname was NOT found in DNS cache
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG Trying 216.58.217.78...
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG Connected to google.com (216.58.217.78) port 443 (#1)
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG successfully set certificate verify locations:
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG CAfile: none
  CApath: /etc/ssl/certs
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG SSLv3, TLS handshake, Client hello (1):
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG SSLv3, TLS handshake, Server hello (2):
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG SSLv3, TLS handshake, CERT (11):
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG SSLv3, TLS handshake, Server key exchange (12):
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG SSLv3, TLS handshake, Server finished (14):
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG SSLv3, TLS handshake, Client key exchange (16):
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG SSLv3, TLS change cipher, Client hello (1):
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG SSLv3, TLS handshake, Finished (20):
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG SSLv3, TLS change cipher, Client hello (1):
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG SSLv3, TLS handshake, Finished (20):
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG SSL connection using TLSv1.2 / ECDHE-ECDSA-AES128-GCM-SHA256
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG Server certificate:
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG subject: C=US; ST=California; L=Mountain View; O=Google Inc; CN=*.google.com
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG start date: 2018-02-20 14:33:16 GMT
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG expire date: 2018-05-15 14:08:00 GMT
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG subjectAltName: google.com matched
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG issuer: C=US; O=Google Inc; CN=Google Internet Authority G2
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG SSL certificate verify ok.
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG > GET / HTTP/1.1
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG > User-Agent: Thumbor/6.3.0
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG > Host: google.com
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG > Accept: */*
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG > Accept-Encoding: gzip,deflate
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG >
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG < HTTP/1.1 301 Moved Permanently
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG < Location: https://www.google.com/
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG < Content-Type: text/html; charset=UTF-8
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG < Date: Tue, 06 Mar 2018 21:27:10 GMT
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG < Expires: Thu, 05 Apr 2018 21:27:10 GMT
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG < Cache-Control: public, max-age=2592000
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG Server gws is not blacklisted
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG < Server: gws
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG < Content-Length: 220
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG < X-XSS-Protection: 1; mode=block
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG < X-Frame-Options: SAMEORIGIN
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG < Alt-Svc: hq=":443"; ma=2592000; quic=51303431; quic=51303339; quic=51303335,quic=":443"; ma=2592000; v="41,39,35"
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG <
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG Ignoring the response-body
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG Connection #1 to host google.com left intact
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG Issue another request to this URL: 'https://www.google.com/'
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG Hostname was NOT found in DNS cache
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG Trying 172.217.13.68...
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG Connected to www.google.com (172.217.13.68) port 443 (#2)
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG successfully set certificate verify locations:
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG CAfile: none
  CApath: /etc/ssl/certs
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG SSLv3, TLS handshake, Client hello (1):
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG SSLv3, TLS handshake, Server hello (2):
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG SSLv3, TLS handshake, CERT (11):
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG SSLv3, TLS handshake, Server key exchange (12):
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG SSLv3, TLS handshake, Server finished (14):
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG SSLv3, TLS handshake, Client key exchange (16):
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG SSLv3, TLS change cipher, Client hello (1):
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG SSLv3, TLS handshake, Finished (20):
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG SSLv3, TLS change cipher, Client hello (1):
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG SSLv3, TLS handshake, Finished (20):
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG SSL connection using TLSv1.2 / ECDHE-ECDSA-AES128-GCM-SHA256
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG Server certificate:
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG subject: C=US; ST=California; L=Mountain View; O=Google Inc; CN=www.google.com
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG start date: 2018-02-20 14:08:00 GMT
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG expire date: 2018-05-15 14:08:00 GMT
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG subjectAltName: www.google.com matched
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG issuer: C=US; O=Google Inc; CN=Google Internet Authority G2
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG SSL certificate verify ok.
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG > GET / HTTP/1.1
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG > User-Agent: Thumbor/6.3.0
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG > Host: www.google.com
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG > Accept: */*
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG > Accept-Encoding: gzip,deflate
2018-03-06 21:27:10 tornado.curl_httpclient:DEBUG >
2018-03-06 21:27:11 tornado.curl_httpclient:DEBUG < HTTP/1.1 200 OK
2018-03-06 21:27:11 tornado.curl_httpclient:DEBUG < Date: Tue, 06 Mar 2018 21:27:11 GMT
2018-03-06 21:27:11 tornado.curl_httpclient:DEBUG < Expires: -1
2018-03-06 21:27:11 tornado.curl_httpclient:DEBUG < Cache-Control: private, max-age=0
2018-03-06 21:27:11 tornado.curl_httpclient:DEBUG < Content-Type: text/html; charset=ISO-8859-1
2018-03-06 21:27:11 tornado.curl_httpclient:DEBUG < P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
2018-03-06 21:27:11 tornado.curl_httpclient:DEBUG < Content-Encoding: gzip
2018-03-06 21:27:11 tornado.curl_httpclient:DEBUG Server gws is not blacklisted
2018-03-06 21:27:11 tornado.curl_httpclient:DEBUG < Server: gws
2018-03-06 21:27:11 tornado.curl_httpclient:DEBUG < X-XSS-Protection: 1; mode=block
2018-03-06 21:27:11 tornado.curl_httpclient:DEBUG < X-Frame-Options: SAMEORIGIN
2018-03-06 21:27:11 tornado.curl_httpclient:DEBUG < Set-Cookie: 1P_JAR=2018-03-06-21; expires=Thu, 05-Apr-2018 21:27:11 GMT; path=/; domain=.google.com
2018-03-06 21:27:11 tornado.curl_httpclient:DEBUG < Set-Cookie: NID=125=YXwimxjfmQRS3Ov_4b5cRpOdH1VNb0w9Agwog_-8jthHdd-kHK7oTF4znSZBPUPpEy3ehnc50IwjV3Cs8kZRdz_eScVD2yZdaRfl40VqheKJ9OYfBtisRDmGlP_d2qhd; expires=Wed, 05-Sep-2018 21:27:11 GMT; path=/; domain=.google.com; HttpOnly
2018-03-06 21:27:11 tornado.curl_httpclient:DEBUG < Alt-Svc: hq=":443"; ma=2592000; quic=51303431; quic=51303339; quic=51303335,quic=":443"; ma=2592000; v="41,39,35"
2018-03-06 21:27:11 tornado.curl_httpclient:DEBUG < Transfer-Encoding: chunked
2018-03-06 21:27:11 tornado.curl_httpclient:DEBUG <
2018-03-06 21:27:11 tornado.curl_httpclient:DEBUG Connection #2 to host www.google.com left intact
2018-03-06 21:27:11 thumbor:DEBUG METRICS: timing: original_image.fetch.200.google.com:825
2018-03-06 21:27:11 thumbor:DEBUG METRICS: inc: original_image.status.200:1
2018-03-06 21:27:11 thumbor:DEBUG METRICS: timing: original_image.time_info.redirect:385
2018-03-06 21:27:11 thumbor:DEBUG METRICS: timing: original_image.time_info.queue:0
2018-03-06 21:27:11 thumbor:DEBUG METRICS: timing: original_image.time_info.pretransfer:321
2018-03-06 21:27:11 thumbor:DEBUG METRICS: timing: original_image.time_info.starttransfer:432
2018-03-06 21:27:11 thumbor:DEBUG METRICS: timing: original_image.time_info.total:823
2018-03-06 21:27:11 thumbor:DEBUG METRICS: timing: original_image.time_info.connect:96
2018-03-06 21:27:11 thumbor:DEBUG METRICS: timing: original_image.time_info.namelookup:3
2018-03-06 21:27:11 thumbor:DEBUG METRICS: timing: original_image.time_info.bytes_per_second:15263
2018-03-06 21:27:11 thumbor:DEBUG METRICS: inc: original_image.response_bytes:12572
pbagrecha-mpb15-1490:docker-thumbor pbagrecha$

If you notice the process just died after trying to handle the request.

so, opencv engine crashes trying to open html file as image https://github.com/thumbor/opencv-engine/blob/master/opencv_engine/engine.py#L80

import cv
f = open('index.html', 'rb')
buf = f.read()
print(buf[0:32])
# <!doctype html><html itemscope="

imagefiledata = cv.CreateMatHeader(1, len(buf), cv.CV_8UC1)
cv.SetData(imagefiledata, buf, len(buf))
img0 = cv.DecodeImageM(imagefiledata, cv.CV_LOAD_IMAGE_UNCHANGED)

# Segmentation fault (core dumped)
# python[11900]: segfault at 8 ip 00007f0e56a346c9 sp 00007ffd741c4e30 error 4 in cv2.so[7f0e569fc000+151000]

When do I need this?

As a new user, I am missing a little documentation when I should use this.

  • Which minimum Thumbor version is required to use this engine?
  • Up to wich version was this engine included in Thumbor?
  • Which Thumbor features require this engine to be installed?

ENGINE = opencv_engine with detectors logs "error during face detection"

OS:
Ubuntu 16.04

List python packages:
ackports-abc (0.5)
boto (2.38.0)
certifi (2017.11.5)
chardet (2.3.0)
colour (0.1.5)
crcmod (1.7)
derpconf (0.8.1)
futures (3.2.0)
google-compute-engine (2.7.2)
libthumbor (1.3.2)
numpy (1.11.0)
olefile (0.44)
opencv-engine (1.0.1)
pexif (0.15)
Pillow-SIMD (4.3.0.post0)
pip (9.0.1)
pycrypto (2.6.1)
pycurl (7.43.0.1)
Pyste (0.9.10)
pytz (2017.3)
requests (2.9.1)
setuptools (20.7.0)
singledispatch (3.4.0.3)
six (1.11.0)
statsd (3.2.2)
thumbor (6.3.2)
tornado (4.5.2)
urllib3 (1.13.1)
wheel (0.29.0)

In thumbor.conf, I have setup the following detectors:
DETECTORS = [
'thumbor.detectors.face_detector',
'thumbor.detectors.feature_detector',
]

When I use the PIL engine (in this case I use Pillow-SIMD but with PIL the same result), everything works fine:
ENGINE = 'thumbor.engines.pil'

http://<thumbor_server>/unsafe/100x200/smart/https://www.dzoom.org.es/wp-content/uploads/2013/04/retratos-fotograficos-1-734x489.jpg
image

But when I change to use OPENCV engine, the detectors don't work

http://<thumbor_server>/unsafe/100x200/smart/https://www.dzoom.org.es/wp-content/uploads/2013/04/retratos-fotograficos-1-734x489.jpg
image

and I see the following in the console output:
2018-01-05 09:41:22 thumbor:WARNING Error during face detection; skipping to next detector
2018-01-05 09:41:22 thumbor:WARNING Error during feature detection; skipping to next detector

Support for GPU acceleration?

Hi, is there support for GPU acceleration in the OpenCV engine?

I tried the OpenCV engine on a GPU instance on AWS EC2, with CUDA drivers installed, but saw an actual drop in performance as compared to the default pil engine when doing simple resizes.

AttributeError: 'module' object has no attribute 'DecodeImageM'

I get the following error (I use CentOS 6.4):

File "/usr/lib/python2.6/site-packages/opencv_engine/engine.py", line 61, in create_image
img0 = cv.DecodeImageM(imagefiledata, cv.CV_LOAD_IMAGE_UNCHANGED)
AttributeError: 'module' object has no attribute 'DecodeImageM'

how can I solve it?

Install success but has errors

Went ahead to try, I am using amazon ec2 ubuntu 13.10. I have the same version at home and it works. But now this is the error.

Downloading/unpacking opencv-engine
  Downloading opencv_engine-0.1.0.tar.gz
  Running setup.py egg_info for package opencv-engine
    libdc1394 error: Failed to initialize libdc1394

Requirement already satisfied (use --upgrade to upgrade): thumbor in /usr/local/lib/python2.7/dist-packages/thumbor-4.0.0-py2.7-linux-x86_64.egg (from opencv-engine)
Requirement already satisfied (use --upgrade to upgrade): tornado>=2.1.1,<3.2.0 in /usr/local/lib/python2.7/dist-packages (from thumbor->opencv-engine)
Requirement already satisfied (use --upgrade to upgrade): pyCrypto>=2.1.0 in /usr/local/lib/python2.7/dist-packages (from thumbor->opencv-engine)
Requirement already satisfied (use --upgrade to upgrade): pycurl>=7.19.0,<7.20.0 in /usr/lib/python2.7/dist-packages (from thumbor->opencv-engine)
Requirement already satisfied (use --upgrade to upgrade): Pillow>=2.1.0,<2.4.0 in /usr/local/lib/python2.7/dist-packages (from thumbor->opencv-engine)
Requirement already satisfied (use --upgrade to upgrade): derpconf>=0.2.0 in /usr/local/lib/python2.7/dist-packages (from thumbor->opencv-engine)
Requirement already satisfied (use --upgrade to upgrade): python-magic>=0.4.3 in /usr/local/lib/python2.7/dist-packages (from thumbor->opencv-engine)
Requirement already satisfied (use --upgrade to upgrade): pexif==0.13 in /usr/local/lib/python2.7/dist-packages/pexif-0.13-py2.7.egg (from thumbor->opencv-engine)
Requirement already satisfied (use --upgrade to upgrade): six in /usr/lib/python2.7/dist-packages (from derpconf>=0.2.0->thumbor->opencv-engine)
Installing collected packages: opencv-engine
  Running setup.py install for opencv-engine
    libdc1394 error: Failed to initialize libdc1394

Successfully installed opencv-engine
Cleaning up...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.