I installed opencv in my mac using mac ports by the following command
sudo port install opencv
It took around 2 hours and it installed properly. But the problem is that the python bindings are not enabled.
So please let me know how to install opencv in mac using ports and also enable the python bindings. Thanks
PS: I tried to manually compile opencv from source but I am getting lot of errors and I am not able to do it.
be sure to have py26-numpy installed to have support for basic functions such as cv.fromarray :
sudo port install py26-numpy
opencv will compile silently without numpy (it's not strictly a dependency).
sudo port install -v opencv +python26
there you can check that the binding to numpy is effective.
It's possible to compile opencv using cmake on macos (I'm actually doing this) but there is a problem with the videoWriter ...
Have a look there http://www.tsd.net.au/blog/opencv-python-bindings-macports
should be helpful.
I am still not able to compile opencv properly. At last, I found some pre-compiled dmg files from http://vislab.cs.vt.edu/~vislab/wiki/index.php?title=Vision which is working pretty decently.
Related
So I have tried to install python when my terminal showed that I didn't have python, which was weird because I thought I did. When I tried to find it I couldn't find it, I used commands like:
which python
When I tried to remove python (I was trying random things):
sudo apt remove python
Then this error would show:
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
When I tried installing it with
apt install python
It would then throw the same Java error.
UPDATE: Apologies, I am on macOS Monterrey! 12.4
The python is by default install in linux you can check with which python3 or which python2.
Uninstalling python from your device is not a good idea, Your OS is depends on python, If you uninstall default python from your device then your system will be corrupted, Your terminal , Firefox and etc system software are using resources from default python.
If your JRE is not configure then you can configure with https://ubuntu.com/tutorials/install-jre#2-installing-openjdk-jre officials.
If you need to run multiple python versions on your device then must go with pyenv it's safe and easy.
https://github.com/pyenv/pyenv/wiki
https://github.com/pyenv/pyenv
I have a program that processes videos using foreground detection in OpenCV 2.4.9/python/on windows and packaged for a windows executable using py2exe. I recently updated opencv to opencv3 and repackaged my program. When i run on my computer (with opencv3 installed locally) everything goes fine.
However, when a user goes and downloads the program and runs it on another computer, they get the warning
Failed to load OpenCL runtime
This just seems to be just a warning, and i can detect no performance issues.
I have a couple options. I can just suppress this specific warning in a try statement, or i can somehow turn off the OpenCL on my computer for packaging the program. Suggestions on either strategy would be appreciated. Anything i am overlooking? To my understanding the OpenCL library is for acceleration using GPU.
Thanks,
the solution will be compiling the OpenCV libs without OpenCL and then link them to your application
I had encounter the same problem, here's my solution:
go to the Intel website and download the OpenCL library, then unzip it
run the install.sh file
If your install fails because of update-alternatives errors, maybe it's because you are using Ubuntu/Debian distro and the Intel install package has a wrong setting with it.
To solve this, xfanzone did a very good job on this. Take a look here.
download the patch zip file and patch your OpenCL package
install it again, now it should work fine
If you just don't need to use OpenCL, you can set the environment var as below:
export OPENCV_OPENCL_RUNTIME=999
Sometimes, if you want to turn on the opencl:
export OPENCV_OPENCL_RUNTIME=
I was trying to install matplotlib in Mac OSX Lion. Tried to used the binary that is in the sourcefourge site, but I got this error: "matplotlib requires System Python 2.7 to install".
I went to the Terminal and typed python --version and its check the requirements.
After this I tried to used the pip, and while doing so é got the following error:
"src/_image.cpp:908: error: invalid use of incomplete type ‘struct png_info_def’"
Can you give me clues in how to install it?
Many thanks.
EDIT: I found a way, without having to install a new version of python:
http://the.taoofmac.com/space/blog/2011/07/24/2222
This is because of a change in the API for libpng v1.5 (which is included with Mac OSX Lion). The changes has already been pushed upstream, so you will need to compile from the upstream repository until the next release.
You can follow the instructions on http://jholewinski.wordpress.com/2011/07/21/installing-matplotlib-on-os-x-10-7-with-homebrew/
I followed this page's instructions. I got stuck at
pip install -e git+https://github.com/matplotlib/matplotlib#egg=matplotlib-dev
Then I did:
git clone https://github.com/matplotlib/matplotlib.git
cd matplotlib
python setup.py build
python setup.py install
Checked my installation by typing in terminal:
python
import matplotlib
print matplotlib.__version__
print matplotlib.__file__
I got version 0.10.0 dev (as of this writing) and path /usr/local/Cellar/...
You can try with an "official" python distribution, apple might have tweaked the supplied one. You can find the 2.7 here: http://www.python.org/download/
You might have to re-install numpy as well afterwords: http://sourceforge.net/projects/numpy/files/NumPy/1.6.1/
I would suggest to install scipy as well
Let me know if it works ;)
I would recommend using macports, it should take care of dependencies and would be indepedent of the system python version.
EDIT: Just a few clarifications, taking into account comments to this answer.
Why use macports (or another installer)? Because they take care of dependencies, provide functionality to uninstall and switch between versions (I've used the latter successfully for gcc and python). And because the default installation location is not the system executable location. Overriding the system python can break applications that rely on it (this is certainly true in many Linux distributions, maybe less so on mac OS X).
When is it particularly useful? When you want to install on top of a version of python that is different to system python, and when you have non-python extensions (C, C++, Fortran...).
What's the down side? As #Trond has mentioned in the comments, it is good if you're OK with default compilations of packages. You don't have a handle over configuration or compiler flags as you would if you built from source.
A good alternative to macports is fink, which seems to give you more control (build from source). I am not sure it is completely ready for mac OS X Lion yet.
I know it will take a lot more time, but I would reccomend installing python, numpy, and matplotlib from source to ensure that you have consistency in your system. From the error it could look like you have a problem with libPNG support. I have a written a "How to install python dev tools on Mac OSX" that you may find useful. It contains directions for how to install python, numpy, matplotlib and all necessary dependencies. I understand you are working with Python 2.7 and the directions I am listing is for Python 2.6.5, but it would be the same approach. Hope you get it to work.
You could just install the Python 2.6 version of Matplotlib, assuming that Python2.6 is included with Lion (py2.5 & 2.6 are included with Mac OS 10.6 "Snow Leopard" - try typing python2.6 to find out if that version is installed.).
On MacPorts you do this via something like:
sudo port install py26-matplotlib
where py26-... (or py25-..., py27-... etc.) indicates which python version it is meant for. (check the Pallet/ports list to get the correct package name, in case I guessed wrong)
I've been trying to connect opencv and python in both Ubuntu and Windows XP. I've failed on both.
I've read many webpages and threads about "how to install" it but none has worked (the worst part is that they all say kind of the same).
Steps (windows xp):
Installed Python 2.7 by default (works perfectly)
Installed PIL and cx_Freeze (may they
create a conflict? I don't think so
:s)
Installed Opencv 2.2 by default
(OpenCV-2.2.0-win32-vs2010.exe) and
it isn't recognized inside a py nor
as import opencv.cv nor using the
cookbook way, import cv (I skipped
the visual studio steps since I'll
use it with python)
Checked path (it's ok, it has the
Opencv2.2\bin thing)
Rechecked webpages and stuff
Steps (ubuntu):
Had python working
sudo apt-get install, cmake, make,
sudo make install, etcetc (from the
tutorials)
same thing... module not recognized
Please can you help?
Update:
I managed to install it and have it recognized by the system (I used http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv and it worked perfectly after that).
The problem now is that it crashes when I try to use CaptureFromFile. Someone else has reported it 3 days ago so now I wait.
I'll check the other wrappers, maybe one of them will work.
For windows see my web page: http://www.modernmind.org/wiki/OpenCV
For Ubuntu you should just need to apt-get install python-dev then generate the make files with Cmake, build it and then make install. In order to build the python bindings you need to have the python header files on your system and you probably don't. When you run configure in Cmake make sure that you don't see any messages at the top about PYTHON_INCLUDE not being defined.
To access a library it needs a Python library installed in the Python version you are using. From what you write above it seems to me that you install OpenCV in general, but that you don't specifically install the Python library. This is why it doesn't work.
I'm not sure how to install the Python wrappers, and the OpenCV documentation is a bit sparse on that info. But if you did build them (and that needs to be turned on explicitly, says the docs) they seem to end up in opencv/release/lib .
Look at "Testing Python wrappers" on http://opencv.willowgarage.com/wiki/InstallGuide
If there is still no luck, there is a bunch of alternative Python wrappers available: http://pypi.python.org/pypi?%3Aaction=search&term=opencv&submit=search
Maybe they are better documented.
I'm running OS X Leopard. I followed this site to install it. Trying to run any demo script, I now get "No module named opencv.cv", which is obviously stopping me from doing any programming. I am running python 2.5.1 (yes, I know it's kind of old).
Why would this be, and how can I solve it?
Thanks
You need to compile openCV unfortunately. It's not that hard to do though at least.
A nice route is to use MacPorts: First, be sure to have py26-numpy installed to have support for basic functions such as cv.fromarray :
sudo port install py26-numpy
Then, opencv will compile (with no problem on my side):
sudo port install opencv +python26
Your link tells to install OpenCV with MacPorts, which currently installs version 2.2.0. The API was changed for 2.2, so that might be the reason opencv.cv doesn't exist (also your link is written for the ancient 1.0). OpenCV changelog explains it:
http://opencv.willowgarage.com/wiki/OpenCV%20Change%20Logs
It isn't clear to me how up-to-date the OpenCV documentation is nowadays but I recommend looking at it:
http://opencv.willowgarage.com/documentation/python/index.html
(Python examples there begin with import cv)