Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically install dependencies when package is installed #276

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ For more information, along with a detailed code review check out the following
- [http://www.pyimagesearch.com/2015/08/10/checking-your-opencv-version-using-python/](http://www.pyimagesearch.com/2015/08/10/checking-your-opencv-version-using-python/)

## Installation
Provided you already have NumPy, SciPy, Matplotlib, and OpenCV already installed, the `imutils` package is completely `pip`-installable:

<pre>$ pip install imutils</pre>

## Finding function OpenCV functions by name
Expand Down Expand Up @@ -127,17 +125,19 @@ cv2.waitKey(0)</pre>
<img src="docs/images/url_to_image.png?raw=true" alt="Matplotlib example" style="max-width: 500px;">

## Checking OpenCV Versions
OpenCV 3 has finally been released! But with the major release becomes backward compatibility issues (such as with the `cv2.findContours` and `cv2.normalize` functions). If you want your OpenCV 3 code to be backwards compatible with OpenCV 2.4.X, you'll need to take special care to check which version of OpenCV is currently being used and then take appropriate action. The `is_cv2()` and `is_cv3()` are simple functions that can be used to automatically determine the OpenCV version of the current environment.
OpenCV 3 has finally been released! But with the major release becomes backward compatibility issues (such as with the `cv2.findContours` and `cv2.normalize` functions). If you want your OpenCV 3 code to be backwards compatible with OpenCV 2.4.X, you'll need to take special care to check which version of OpenCV is currently being used and then take appropriate action. The `is_cv2()`, `is_cv3()` and `is_cv4()` are simple functions that can be used to automatically determine the OpenCV version of the current environment.

#### Example:
<pre>print("Your OpenCV version: {}".format(cv2.__version__))
print("Are you using OpenCV 2.X? {}".format(imutils.is_cv2()))
print("Are you using OpenCV 3.X? {}".format(imutils.is_cv3()))</pre>
print("Are you using OpenCV 3.X? {}".format(imutils.is_cv3()))
print("Are you using OpenCV 4.X? {}".format(imutils.is_cv4()))</pre>

#### Output:
<pre>Your OpenCV version: 3.0.0
Are you using OpenCV 2.X? False
Are you using OpenCV 3.X? True</pre>
Are you using OpenCV 3.X? True
Are you using OpenCV 4.X? False</pre>

## Automatic Canny Edge Detection
The Canny edge detector requires two parameters when performing hysteresis. However, tuning these two parameters to obtain an optimal edge map is non-trivial, especially when working with a dataset of images. Instead, we can use the `auto_canny` function which uses the median of the grayscale pixel intensities to derive the upper and lower thresholds. You can read more about the `auto_canny` function [here](http://www.pyimagesearch.com/2015/04/06/zero-parameter-automatic-canny-edge-detection-with-python-and-opencv/).
Expand Down
14 changes: 13 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
from distutils.core import setup
from setuptools import setup
import sys

if sys.version_info.major == 2:
open_cv = 'opencv-python==4.2.0.32' # Last supported version for Python 2.7
else:
open_cv = 'opencv-python' # Latest available version

setup(
name='imutils',
Expand All @@ -12,4 +18,10 @@
keywords=['computer vision', 'image processing', 'opencv', 'matplotlib'],
classifiers=[],
scripts=['bin/range-detector'],
install_requires=[
'numpy',
'scipy',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have raised a PR to remove scipy dependency. If that gets approved then you might have one less dependency to install.

#277 (comment)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@farqis When your PR is merged, please update that here and resolve this conversation.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@farqis Was your PR merged (for removing scipy dependency)?

'matplotlib',
open_cv
]
)