Questions tagged [opencv]

OpenCV (Open Source Computer Vision) is a library for real time computer vision. When using this tag, please add a language specific tag (python, c++, ...), if relevant.

OpenCV is a code library for Computer Vision related applications, spanning from many very basic tasks (capture and pre-processing of image data) to high-level algorithms (feature extraction, motion tracking, machine learning).

It is free software. Versions from 4.5.0 are licensed under the Apache 2 license, versions before that under the BSD 3-clause license. OpenCV provides a rich API in C++, Python, and Java. Third party wrappers are available. The library is platform-independent and often used for real-time image processing and computer vision (e.g. tracking in videos). It supports Windows, Linux, and OS X as well as Android (native and Java) and iOS.

OpenCV was officially launched by Intel in 1999. Version 2.0 (2009) was an important landmark as it introduced the new, comprehensive C++ interface, which since then is also to be used internally in the library. Since this release, OpenCV saw a strong acceleration of development in improving the library and adding new features. Version 3.0, released in 2015, deprecated the C API and emphasized object-oriented design for increased modularity and intuitive interface. More information may be found in Wikipedia.

Latest stable versions:

Homepage: https://opencv.org

Documentation: https://docs.opencv.org

Tutorials including source code:


Books

Note that this list is likely outdated and not vetted for quality. A book or course on computer vision in general, along with the official documentation of OpenCV, will give a better understanding of the matter and the library.

72729 questions
192
votes
11 answers

How to display an image

I tried to use IPython.display with the following code: from IPython.display import display, Image display(Image(filename='MyImage.png')) I also tried to use matplotlib with the following code: import matplotlib.pyplot as plt import…
FiReTiTi
  • 5,597
  • 12
  • 30
  • 58
181
votes
2 answers

OpenCV – Depth map from Uncalibrated Stereo System

I'm trying to get a depth map with an uncalibrated method. I can obtain the fundamental matrix by finding correspondent points with SIFT and then using cv2.findFundamentalMat. I then use cv2.stereoRectifyUncalibrated to get the homography matrices…
user3601754
  • 3,792
  • 11
  • 43
  • 77
171
votes
20 answers

cv2.imshow command doesn't work properly in opencv-python

I'm using opencv 2.4.2, python 2.7 The following simple code created a window of the correct name, but its content is just blank and doesn't show the image: import cv2 img=cv2.imread('C:/Python27/03323_HD.jpg') cv2.imshow('ImageWindow',img) does…
top.eng
  • 1,828
  • 2
  • 13
  • 21
167
votes
10 answers

Extracting text OpenCV

I am trying to find the bounding boxes of text in an image and am currently using this approach: // calculate the local variances of the grayscale image Mat t_mean, t_mean_2; Mat grayF; outImg_gray.convertTo(grayF, CV_32F); int winSize =…
Clip
  • 3,018
  • 8
  • 42
  • 77
165
votes
5 answers

Convert image from PIL to openCV format

I'm trying to convert image from PIL to OpenCV format. I'm using OpenCV 2.4.3. here is what I've attempted till now. >>> from PIL import Image >>> import cv2 as cv >>> pimg = Image.open('D:\\traffic.jpg') #PIL Image >>>…
md1hunox
  • 3,815
  • 10
  • 45
  • 67
163
votes
14 answers

OpenCV in Android Studio

I want to use OpenCV library in my app with Android Studio. I followed instructions found here but I get error Configuration with name 'default' not found What can be wrong? I use Android Studio 1.0 with gradle 2.2.1.
Bartosz Bialecki
  • 4,391
  • 10
  • 42
  • 64
159
votes
15 answers

how to convert an RGB image to numpy array?

I have an RGB image. I want to convert it to numpy array. I did the following im = cv.LoadImage("abc.tiff") a = numpy.asarray(im) It creates an array with no shape. I assume it is a iplimage object.
Shan
  • 18,563
  • 39
  • 97
  • 132
157
votes
9 answers

How can I sharpen an image in OpenCV?

How can I sharpen an image using OpenCV? There are many ways of smoothing or blurring but none that I could see of sharpening.
AruniRC
  • 5,070
  • 7
  • 43
  • 73
156
votes
5 answers

Size of Matrix OpenCV

I know this might be very rudimentary, but I am new to OpenCV. Could you please tell me how to obtain the size of a matrix in OpenCV?. I googled and I am still searching, but if any of you know the answer, please help me. Size as in number of rows…
Lakshmi Narayanan
  • 5,220
  • 13
  • 50
  • 92
155
votes
26 answers

error: (-215) !empty() in function detectMultiScale

I'm trying to learn cv2 in python 2.7, but when I run my code, in the specific part of it: face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml') eye_cascade = cv2.CascadeClassifier('haarcascade_eye.xml') img =…
arthurckl
  • 5,281
  • 6
  • 17
  • 16
152
votes
6 answers

How to find out what type of a Mat object is with Mat::type() in OpenCV?

I am kind of confused with type() method of Mat object in OpenCV.If I have following lines: mat = imread("C:\someimage.jpg"); type = mat.type(); and type = 16, how do I find out what type of mat matrix is?.I tried to find the answer in its manual…
Tae-Sung Shin
  • 20,215
  • 33
  • 138
  • 240
148
votes
9 answers

ImportError: libSM.so.6: cannot open shared object file: No such file or directory

When trying to import OpenCV, using import cv2 I get the following error: /usr/local/lib/python2.7/dist-packages/cv2/__init__.py in () 7 8 # make IDE's (PyCharm) autocompletion happy ----> 9 from .cv2 import * 10 11 #…
Dmitry Rastorguev
  • 3,473
  • 4
  • 13
  • 14
140
votes
21 answers

Pycharm/Python OpenCV and CV2 install error

I've been trying to install both OpenCV and cv2 from both Pycharm and from the terminal as suggested using: pip install --user opencv pip install --user cv2 but I'm getting the following error for them: Collecting opencv Could not find a version…
Sibi
  • 2,221
  • 6
  • 24
  • 37
140
votes
3 answers

Python OpenCV2 (cv2) wrapper to get image size?

How to get the size of an image in cv2 wrapper in Python OpenCV (numpy). Is there a correct way to do that other than numpy.shape(). How can I get it in these format dimensions: (width, height) list?
xercool
  • 4,179
  • 6
  • 27
  • 33
130
votes
24 answers

ImportError: DLL load failed: %1 is not a valid Win32 application. But the DLL's are there

I have a situation very much like the one at Error "ImportError: DLL load failed: %1 is not a valid Win32 application", but the answer there isn't working for me. My Python code says: import cv2 But that line throws the error shown in the title of…
LarsH
  • 27,481
  • 8
  • 94
  • 152