Giter Site home page Giter Site logo

opencv / opencv-python Goto Github PK

View Code? Open in Web Editor NEW
4.2K 86.0 795.0 1.88 MB

Automated CI toolchain to produce precompiled opencv-python, opencv-python-headless, opencv-contrib-python and opencv-contrib-python-headless packages.

Home Page: https://pypi.org/project/opencv-python/

License: MIT License

Python 50.23% Shell 49.77%
opencv python wheel python-3 opencv-python opencv-contrib-python precompiled pypi manylinux

opencv-python's Introduction

OpenCV: Open Source Computer Vision Library

Resources

Contributing

Please read the contribution guidelines before starting work on a pull request.

Summary of the guidelines:

  • One pull request per issue;
  • Choose the right base branch;
  • Include tests and documentation;
  • Clean up "oops" commits before submitting;
  • Follow the coding style guide.

Additional Resources

opencv-python's People

Contributors

abhitronix avatar asenyaev avatar asmorkalov avatar bertsky avatar c-martinez avatar cclauss avatar dkurt avatar dlech avatar engnadeau avatar glitchassassin avatar henryiii avatar illume avatar johnthagen avatar kianmeng avatar kvalev avatar mbdevpl avatar native-api avatar niyas-sait avatar pakal avatar peter-kovacs-aimotive avatar rockywhisper avatar scivision avatar sergregory avatar skvark avatar stweil avatar techdragon avatar techtonik avatar tomsweeting avatar vallentin avatar williamjacksn 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  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  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  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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opencv-python's Issues

DLL Dependencies fail in virtual environment

First of all, thanks a lot for the work on this distribution, it has been very helpful so far!

I have been running opencv-python on a win10/x64 device with python 2.7 and 3.6 successfully. Now, I wanted to use it on a new device, also win10/x64. I've installed it through the PyCharm-GUI, in a fresh virtualenv with python 3.6. Same simple process as my other device.

When I want to import cv2, I get the error "ImportError: DLL load failed (...)". Using find_module(), the correct path to the folder cv2 in site-packages is returned. But during interpretation of init.py, the "from . import cv2" line fails.

I have checked dependencies with dependencywalker, and I have scanned for broken dlls. I have all Redistributable packages since 2010 installed (2010, 2012, 2013, 2015). I also reinstalled all those once already.

I have tried copying around cv2.pyd. At one point, the error message changed: When I used a x86 file, I got the (expected) error message "Not a win32 ...". So the pyd is found by python, but for some reason, loading it fails.

A seemingly identical setup (at least concerning the virtualenv) works on one device and not on another. Do you have a clue what could be missing?

Problem when installing inside docker image ubuntu:14.04

Hi, I have problem when installing inside docker image

root@6296a40bde67:~/SDC2017Round1/src/object_awareness# pip3 install opencv-python
Downloading/unpacking opencv-python
  Could not find any downloads that satisfy the requirement opencv-python
Cleaning up...
No distributions at all found for opencv-python
Storing debug log for failure in /root/.pip/pip.log

is it the issue of manylinux or something?

Thanks

Relax numpy version requirements

Hi
Currently opencv-python requires numpy >=1.11.3 to be installed despite requirements.txt and .travis.yml specifying >= 1.11.1.

We want to use this with Anaconda 4.1.1, which installs numpy 1.11.1.
Would it be possible to relax these dependencies, and install/test/publish with version 1.11.1?

Inconsistent return type from CascadeClassifier.detectMultiScale

Expected behaviour

I expected the library to return an empty ndarray when there is no detection.

Actual behaviour

The library returns a single empty tuple when there is NO detection, and a numpy.ndarray when there are detections.

  • operating system : Windows 10
  • opencv-python version: 3.3.1

Is this a problem with the package or with the opencv library?

ARM support

ARM builds would be needed to support for example Raspberry Pi.

Package metadata

The package should contain some metadata. There are some things to consider:

  • authors/maintainers
    • probably only maintainers, since we are not the authors of OpenCV
  • license must be probably the same as in OpenCV
  • Readme in rst format, there's probably some conversion tool which can be run in setup.py

Error with setup.py install_requires?

Expected behaviour

I can pip install opencv-python without a hitch on my dev box, but am running into problems when setup.py's install_requires is trying to do it. I'm assuming the issue lies here, perhaps some of you are familiar with the error message?

Actual behaviour

Processing dependencies for autocrop==0.1                                      
Searching for opencv-python            
Reading https://pypi.python.org/simple/opencv-python/                          
No local packages or working download links found for opencv-python            
error: Could not find suitable distribution for Requirement.parse('opencv-python')                                                                             

Steps to reproduce

  • example code
setup(install_requires='opencv-python')

in my package's setup.py, when running python setup.py install

  • operating system

    • Manjaro Linux
  • architecture (e.g. x86)

    • x86
  • opencv-python version

    • Latest (any)

DLL load fails on Anaconda/Windows install (python3.dll)

After doing a simple pip install opencv-python or pip install opencv-contrib-python and trying to import the library, I ran into this issue:

λ python
Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul  5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Anaconda3\lib\site-packages\cv2\__init__.py", line 7, in <module>
    from . import cv2
ImportError: DLL load failed: The specified module could not be found.

The readme suggests installing the Visual C++ Redistributable for Visual Studio 2015
but I already had it installed (actually had Visual Studio itself installed as well).

Checking the dependencies of the pyd binary in this package (using dumpbin which comes with Visual Studio):

λ dumpbin.exe C:\Anaconda3\Lib\site-packages\cv2\cv2.cp35-win_amd64.pyd /IMPORTS | grep dll
    python3.dll
    python35.dll
    MSVFW32.dll
    AVIFIL32.dll
    AVICAP32.dll
    KERNEL32.dll
    USER32.dll
    GDI32.dll
    ole32.dll
    OLEAUT32.dll
    COMDLG32.dll
    ADVAPI32.dll

After checking if these were in the PATH I was surprised to find that python3.dll was the only one that wasn't!

Although python3.dll comes with the standard CPython install, it's not packaged with Anaconda for some reason. ContinuumIO/anaconda-issues#1394 references this and it seems like it's just not supported(?).

As a workaround suggested in that thread, I solved this by just copying python3.dll from the official CPython 3.5.2 binaries (specifically from the Windows x86-64 embeddable zip file) into C:\Anaconda3, although I imagine it would work being anywhere in your PATH.

I thought I'd share this bit of troubleshooting since Anaconda is a popular distribution among academics and so is OpenCV, so I figure I might not be the only one running into this issue. Maybe a note in the readme might help others until Anaconda resolves this?

Alternatively, the menpo/opencv3 Anaconda package would also work but I don't think it supports ffmpeg nor opencv-contrib.

For reference, I'm running on Python 3.5.2 which came with Anaconda 4.2.0 (official installer), although conda info reports a slightly newer version:

λ conda info
Current conda install:

               platform : win-64
          conda version : 4.3.16
       conda is private : False
      conda-env version : 4.3.16
    conda-build version : 2.0.2
         python version : 3.5.2.final.0
       requests version : 2.12.4
       root environment : C:\Anaconda3  (writable)
    default environment : C:\Anaconda3
       envs directories : C:\Anaconda3\envs
                          C:\Users\Talmo\AppData\Local\conda\conda\envs
                          C:\Users\Talmo\.conda\envs
          package cache : C:\Anaconda3\pkgs
                          C:\Users\Talmo\AppData\Local\conda\conda\pkgs
           channel URLs : https://repo.continuum.io/pkgs/free/win-64
                          https://repo.continuum.io/pkgs/free/noarch
                          https://repo.continuum.io/pkgs/r/win-64
                          https://repo.continuum.io/pkgs/r/noarch
                          https://repo.continuum.io/pkgs/pro/win-64
                          https://repo.continuum.io/pkgs/pro/noarch
                          https://repo.continuum.io/pkgs/msys2/win-64
                          https://repo.continuum.io/pkgs/msys2/noarch
            config file : None
           offline mode : False
             user-agent : conda/4.3.16 requests/2.12.4 CPython/3.5.2 Windows/10 Windows/10.0.15063

Cheers and thanks for all the work you put into this repo!

Add GUI support (Qt)

Hi, I am having trouble with the library, I installed it and tried to use it on:

https://github.com/gliese581gg/YOLO_tensorflow

But the error I get when trying to run it is:

OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvShowImage, file /io/opencv/modules/highgui/src/window.cpp, line 545
Traceback (most recent call last):
  File "YOLO_small_tf.py", line 250, in <module>
    main(sys.argv)
  File "YOLO_small_tf.py", line 245, in main
    yolo = YOLO_TF(argvs)
  File "YOLO_small_tf.py", line 30, in __init__
    if self.fromfile is not None: self.detect_from_file(self.fromfile)
  File "YOLO_small_tf.py", line 137, in detect_from_file
    self.detect_from_cvmat(img)
  File "YOLO_small_tf.py", line 129, in detect_from_cvmat
    self.show_results(img,self.result)
  File "YOLO_small_tf.py", line 225, in show_results
    cv2.imshow('YOLO_small detection',img_cp)
cv2.error: /io/opencv/modules/highgui/src/window.cpp:545: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvShowImage

Build using FFMPEG

Hi

I need to use cv2 for video files on my cloud foundry python app. Could you guide me on how to build this package with ffmpeg compatibility for ubuntu trusty?

Thanks

[Question] Complete opencv installation using pip

Hello Olli-Pekka,

First of all I must say thank you for starting this repository. I am very new to both Python and OpenCV.
I'm trying to start a new project that will intensively use OpenCV. Could you please clarify whether it is possible or not to have a complete OpenCV installation entirely based on pip or easy_install packages? If yes, than what are the steps I should follow.

Drawing a parallel with .NET/Java, I'd like to introduce a single dependency on NuGet/Maven package of OpenCV. In my scenario, development is going to be all in Python, though.

I understand, this question does not really belong here but I can't find a better place and more knowledgeable person to get it answered.

Thanks!

Cannot `pip install opencv-python` in ubuntu 14.04

Logs:


/usr/bin/pip run on Mon Jun 26 17:25:27 2017
Downloading/unpacking opencv-python
Getting page https://pypi.python.org/simple/opencv-python/
URLs to search for versions for opencv-python:

The travis building failed in Linux/OSX, is it the reason?

https://travis-ci.org/skvark/opencv-python

My environment: Ubuntu 14.04, Python 2.7.6

Alpine linux

It's possible install this package for alpine linux?

Python 3.4 doesn't install through pip

C:\Users\drebbe>c:\python34\scripts\pip.exe install opencv_python
Collecting opencv-python
  Could not find a version that satisfies the requirement opencv-python (from versions: )
No matching distribution found for opencv-python
Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

Inspecting the cv2.pyd inside opencv_python-3.4.0.12-cp34-cp34m-win32.whl (Used PEiD) looks like it was built with Visual Studio's 2015 compiler/linker whereas Python 3.4 requires Visual Studio 2010.

Install Fails on OS X

On OS X 10.11 with python 2.7.12:

$ pip install opencv-python
Collecting opencv-python
  Could not find a version that satisfies the requirement opencv-python (from versions: )
No matching distribution found for opencv-python

If I try to explicitly install the wheel, I get:

opencv_python-3.1.0.3-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl is not a supported wheel on this platform.

Problem caused by the change from libjpeg to libjpeg-turbo

Expected behaviour

cv2.imread in different versions should return same values for the same JPG file.

Actual behaviour

001
For this image(w=153, h=209), pixel[0, 207] will get different value between 3.3 and 3.4
screenshot from 2018-01-19 18-41-01
In 3.3, pixel[0, 207] = [115, 52, 226]
screenshot from 2018-01-19 18-42-01
In 3.4, pixel[0, 207] = [111, 52, 223]

Steps to reproduce

  • example code
    import cv2
    print(cv2.__version__)
    img = cv2.imread('001.jpg')
    print(img[0, 207])
  • operating system
    linux
  • architecture (e.g. x86)
    x64
  • opencv-python version
    3.4

I have tested the libjpeg and libjpeg-turbo, and this difference is caused by these two libs. (Test code in https://github.com/Marco-LIU/libjpeg-test)

Though the libjpeg-turbo has better performance than libjpeg, this difference will make a TRAP, and cause some machine learning models give DIFFERENT results for same input file. We've trained a model in v3.3, but got a wrong test result in v3.4 for that beauty pic.

opencv GUI does not work

cv2.namedWindow('test', cv2.WINDOW_AUTOSIZE) results in an error:

QObject::moveToThread: Current thread (0xca9110) is not the object's thread (0x1256140).
Cannot move to target thread (0xca9110)

here is the version:

cv2.__version__
Out[3]: '3.3.0'
QtCore.QT_VERSION_STR
Out[7]: '5.6.2'

JPEG decoding and encoding is significant slower than from Ubuntu package

First of all thanks for your work!

OpenCV version in Ubuntu 16.04 is still 2.4.9.1, so most users have to install OpenCV from this wheels.

Surprisingly, these wheels have much lower JPEG decoding and encoding speed than shipped with Ubuntu.

Cv2 load 2560×1600 RGB image
    Jpeg load           0.05430 s    75.43 Mpx/s
    Jpeg save           0.10867 s    37.69 Mpx/s
Cv2 load 2560×1600 RGB image
    Jpeg load           0.03277 s   124.99 Mpx/s
    Jpeg save           0.03084 s   132.82 Mpx/s

Here is perf report for both cases:

screen shot 2017-10-16 at 1 39 58

screen shot 2017-10-16 at 1 17 12

It's clear that these wheels don't use system-provided libjpeg library (which is libjpeg-turbo for some systems). Instead, they are decoding and encoding using some build-in libjpeg library which is much slower.

I see two solutions: use libjpeg-turbo for wheels or use system libraries.

Please publish source distribution

I would love to try opencv-python, but running into issues pip-installing it (via pygradle, https://github.com/linkedin/pygradle)

Could you by any chance also publish an sdist with your pypi package?
Wheels is great, but having an sdist (as usual) would be awesome too for things that don't quite use wheels yet (and also if one wants to rebuild the complete package on target machine)

Missing haarcascades xml files

First thanks for putting this package together!

I'm trying to perform face detection by following this tutorial: http://docs.opencv.org/trunk/d7/d8b/tutorial_py_face_detection.html, however this leads to an error as the haarcascade xml files appear to be missing from the wheel:

import cv2
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
print(face_cascade.empty())
img = cv2.imread(<path/to/an/image/file>)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, 1.3, 5)

This should print False and then perform face detection. However, it prints True and then leads to an error:

opencv-python/opencv/modules/objdetect/src/cascadedetect.cpp:1698: error: (-215) !empty() in function detectMultiScale

It looks as though the files under https://github.com/opencv/opencv/tree/master/data are missing from the wheels so I guess that adding them should fix this.

(This works as expected using the conda package).

  • macOS Sierra 10.12.6
  • x86-64
  • opencv-python v3.3.0.10

Thanks!

cv2.imshow()

is there any way to show the image in this instead of cv2.imshow() ? you said it has limits for it

3.3.0.10 breaks on ubuntu server without X11

We're running an opencv python application in docker (with GPU support via nvidia-docker but no GUI). The most recent release has added a dependency on Qt, but it is also linking against X11, which is not typically installed in such environments. Would it be possible to provide a headless version, or include X11 and other libs in the build (which would make the resulting package a fair bit larger I'd imagine).

In version opencv_python-3.3.0.9-cp35-cp35m-manylinux1_x86_64.whl (8.8MB), ldd shows the following.

root@3b68495a9aa8:/usr/local/lib/python3.5/dist-packages/cv2# ldd cv2.cpython-35m-x86_64-linux-gnu.so
linux-vdso.so.1 => (0x00007ffc9d7aa000)
libz-a147dcb0.so.1.2.3 => /usr/local/lib/python3.5/dist-packages/cv2/./.libs/libz-a147dcb0.so.1.2.3 (0x00007fe2c6f04000)
libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007fe2c6cfb000)
libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007fe2c69ea000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fe2c6668000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fe2c6463000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fe2c6246000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fe2c603e000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fe2c5d34000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fe2c5b1e000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe2c5754000)
/lib64/ld-linux-x86-64.so.2 (0x00005569d85ea000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fe2c54e3000)

In version opencv_python-3.3.0.10-cp35-cp35m-manylinux1_x86_64.whl (15.4MB) ldd shows the following:

root@a867b910c313:/usr/local/lib/python3.5/dist-packages/cv2# ldd cv2.cpython-35m-x86_64-linux-gnu.so
linux-vdso.so.1 => (0x00007fffbed3e000)
libz-a147dcb0.so.1.2.3 => /usr/local/lib/python3.5/dist-packages/cv2/./.libs/libz-a147dcb0.so.1.2.3 (0x00007f2862370000)
libQtGui-6d0f14dd.so.4.8.7 => /usr/local/lib/python3.5/dist-packages/cv2/./.libs/libQtGui-6d0f14dd.so.4.8.7 (0x00007f28614de000)
libQtTest-1183da5d.so.4.8.7 => /usr/local/lib/python3.5/dist-packages/cv2/./.libs/libQtTest-1183da5d.so.4.8.7 (0x00007f28612b1000)
libQtCore-ba1dc80c.so.4.8.7 => /usr/local/lib/python3.5/dist-packages/cv2/./.libs/libQtCore-ba1dc80c.so.4.8.7 (0x00007f2860da5000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f2860a1c000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f2860818000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f28605fb000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f28603f2000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f28600e9000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f285fed3000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f285fb08000)
/lib64/ld-linux-x86-64.so.2 (0x000055aedf75a000)
libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f285f906000)
libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f285f5f5000)
libSM.so.6 => not found
libICE.so.6 => not found
libXrender.so.1 => not found
libXext.so.6 => not found
libX11.so.6 => not found
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f285f382000)

Running the application results in the following error:

File "/usr/local/lib/python3.5/dist-packages/cv2/init.py", line 9, in
from .cv2 import *
ImportError: libSM.so.6: cannot open shared object file: No such file or directory

"cv2.img_hash_PHash()"

I have problem to calculate the opencv-contrib "phash()"

import cv2
image = cv2.imread( '/tmp/test.jpg' )
hashcode = cv2.img_hash_PHash( image )
print hashcode

Result -> phash-object:

<img_hash_PHash 0x7fbc4761d330>

Are there any docs?
Thanks a lot!

cv2.imshow "The function is not implemented. Rebuild the library"

OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvShowImage, file /io/opencv/modules/highgui/src/window.cpp, line 545

please, OpenCV version :3.1.0
Python version: 2.7.12
OS: Elementary OS Loki.

Thanks!

Fail to open capture device (Linux and macOS builds are not compiled with FFmpeg)

My system is

Ubuntu 14.04.5 LTS
Python 3.5

I have a virtual environment with

$ pip freeze
numpy==1.11.1
opencv-python==3.1.0.2

Any try on opening a VideoCapture fails... Any of the following always return False when I test with cap.isOpened()

cap = cv2.VideoCapture(full_path_to_video_file)
cap = cv2.VideoCapture(0)
cap = cv2.VideoCapture(-1)

I have ffmpeg installed and other OpenCV installations from source on my system work fine.
I was now giving a try with your package but it is not working. What am I missing? Do I need to link ffmpeg in some way?

MacOS builds with FFMPEG shared libraries

I've just taken my first attempt to get the homebrew formula for FFMPEG to support compiling an LGPL version -> Homebrew/homebrew-core#18909

If I've read your FAQ answer correctly... Assuming I can get those changes into HomeBrew, or I include an appropriately customised homebrew formula in this repo, it should be possible to build a version of FFMPEG suitable for use in a MacOS wheel. Is this correct?

OSX and sudo install requirements

When trying to install opencv-python on OS X (python3 installed via Homebrew), installing as an unprivileged user failed with the following message:

Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
File "/usr/local/lib/python3.6/site-packages/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
File "/usr/local/lib/python3.6/site-packages/pip/req/req_set.py", line 784, in install
    **kwargs
File "/usr/local/lib/python3.6/site-packages/pip/req/req_install.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/usr/local/lib/python3.6/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,
File "/usr/local/lib/python3.6/site-packages/pip/wheel.py", line 377, in move_wheel_files
    clobber(source, dest, False, fixer=fixer, filter=filter)
File "/usr/local/lib/python3.6/site-packages/pip/wheel.py", line 323, in clobber
    shutil.copyfile(srcfile, destfile)
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/shutil.py", line 121, in copyfile
    with open(dst, 'wb') as fdst:
PermissionError: [Errno 13] Permission denied: '/usr/local/LICENSE-3RD-PARTY.txt'

After installing with sudo -H pip3 install opencv-python, the package worked.

Can the sudo requirement be eliminated by not writing the license to /usr/local/?

Include headers to support binary linking?

First off, thanks for this project, it saves a ton of time and I'm really happy that it exists. It makes it a lot easier to get OpenCV installed for the high school students I work with.

I'd like to take a C++ library that uses OpenCV, wrap it with cython, and link it to the OpenCV bits in the binary provided by the installed wheel. This would allow users to just install the wheel of the other library + the opencv-python wheel, as opposed to having to compile their own version.

Has anyone tried this yet? A cursory look at the linux .so files indicate that it exports all of the normal OpenCV symbols, so in theory if you just include the right headers and link to it then it should just work (though maybe not for Windows)... I think that one would add an additional cv2 module (cv2.distutils?) that could provide a list of includes/libraries, similar to how numpy works.

If there's no opposition to this, I might try this out in a week or three to see how it goes.

Unwanted Horizontal Lines Appears when using cv2.putText()

System information (version)
  • OpenCV => opencv-python==3.2.0.7
  • Operating System / Platform => Windows 10 64 Bit
  • Python 3.5.3 and installed with PIP with a virtualenv
Detailed description

I use the following dummy_code:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys, cv2, time
import numpy as np

video_capture = cv2.VideoCapture(0)

h_offset  = 150
font      = cv2.FONT_HERSHEY_SIMPLEX
fontScale = 0.5
fontColor = (0, 255, 0)
thickness = 2

while True:
    
    start    = time.time()
    v_offset = 50 
    
    # Capture frame-by-frame
    ret, frame = video_capture.read()
    
    print("\n####################\n")
    
    for _ in range(5):
    
        printed_txt = "DOG" + " => " +str(round(25.3 ,1))+"%"
        cv2.putText(frame, printed_txt, (h_offset, v_offset), font, fontScale, fontColor, thickness)
        
        v_offset += 50
        
        print(printed_txt)

    cv2.imshow('Video', frame)

    key = cv2.waitKey(1)
    if key & 0xFF == ord('q'):
        break
    elif key & 0xFF == ord(' '):
        #raw_input("Press any key to stop pause")
        cv2.waitKey(0)       

    print("\nframe_rate: %2.2f images/sec" % (1 / (time.time() - start)))

# When everything is done, release the capture
video_capture.release()
cv2.destroyAllWindows()

Which leads to this screen :
image

Could anyone tell me why am I having these horizontal lines and how to remove them ?

Firstly posted here : opencv/opencv#8824

Thanks a lot dear friends

Assertion failed (scn == 3 || scn == 4)

I am currently experiencing this on a Mi 13.3 laptop when trying to run a basic example like:

import numpy as np
import cv2

cap = cv2.VideoCapture(0)

while(True):
    # Capture frame-by-frame
    ret, frame = cap.read()

    # Our operations on the frame come here
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    # Display the resulting frame
    cv2.imshow('frame',gray)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()

Complete output:

OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /io/opencv/modules/imgproc/src/color.cpp, line 10638
Traceback (most recent call last):
  File "main.py", line 11, in <module>
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.error: /io/opencv/modules/imgproc/src/color.cpp:10638: error: (-215) scn == 3 || scn == 4 in function cvtColor

I have checked this from two distributions: a Ubuntu 17.04 and a Kali from a Live USB.

Non-free opencv_contrib modules are not available

I try to use opencv-contrib-python wheel package from PyPI

Expected behaviour

import cv2
out_img = cv2.xphoto.bm3dDenoising(inp_img)
# No any errors

Actual behaviour

I get the following error

cv2.error: C:\projects\opencv-python\opencv_contrib\modules\xphoto\src\bm3d_image_denoising.cpp:341: error: (-213) This algorithm is patented and is excluded in this configuration;Set OPENCV_ENABLE_NONFREE CMake option and rebuild the library in function cv::xphoto::bm3dDenoising

A hand-greyscaled image is not "showed" but "written well"

Expected behaviour

A hand-greyscaled image should be imshow() on a screen.

Actual behaviour

It could be imwrite() into a file well but be not imshow() on a screen.
Am I missing something?

Steps to reproduce

  • example code
import cv2

def rgb_to_gray(src):
     r, g, b = src[:,:,0], src[:,:,1], src[:,:,2]
     gray = 0.2989 * r + 0.5870 * g + 0.1140 * b   
     return gray   
    
def main():
    img = cv2.imread("input.jpg")
    gray1 = rgb_to_gray(img)
    cv2.imwrite("gray1.jpg", gray1) # works well :-)
    cv2.imshow("gray1.jpg", gray1) # does not work :-(
    cv2.waitKey(0)
    cv2.destroyAllWindows()

if __name__ == "__main__":
    main()

  • operating system
    Windows 10

  • architecture (e.g. x86)
    x86 64bit

  • opencv-python version

numpy (1.13.3)
opencv-python (3.4.0.12)

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.