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
89
votes
12 answers

opencv.imshow will cause jupyter notebook crash

I check other question on google or stackoverflow, they are talking about run cv2.imshow in script, but my code run in jupyter notebook. Here is my configuration: ubuntu 16.4x64 python 3.5 opencv 3.1.0 I start a jupyter notebook: here is the code…
scott huang
  • 2,478
  • 4
  • 21
  • 36
89
votes
9 answers

How to fill OpenCV image with one solid color?

How to fill OpenCV image with one solid color?
Rella
  • 65,003
  • 109
  • 363
  • 636
89
votes
23 answers

Installing OpenCV for Python on Ubuntu, getting ImportError: No module named cv2.cv

I have an Ubuntu 14.04 system, on which I want to install OpenCV and use it with Python 2.x. I installed OpenCV using the instructions here: https://help.ubuntu.com/community/OpenCV The install seemed to run properly, no errors, the script ended…
robm
  • 1,051
  • 2
  • 8
  • 15
88
votes
4 answers

Convert opencv image format to PIL image format?

I want to convert an image loaded TestPicture = cv2.imread("flowers.jpg") I would like to run a PIL filter like on the example with the variable TestPicture but I'm unable to convert it back and forth between these types. Is there a way to do…
88
votes
18 answers

openCV video saving in python

I am trying to save the video but it's not working. I followed the instructions from the openCV documentation. import numpy as np import cv2 cap = cv2.VideoCapture(0) fourcc = cv2.VideoWriter_fourcc(*'XVID') out = cv2.VideoWriter('output.avi',…
user4594264
88
votes
9 answers

OpenCV Python: cv2.findContours - ValueError: too many values to unpack

I'm writing an opencv program and I found a script on another stackoverflow question: Computer Vision: Masking a human hand When I run the scripted answer, I get the following error: Traceback (most recent call last): File "skinimagecontour.py",…
ahmadux
  • 2,667
  • 3
  • 17
  • 15
86
votes
9 answers

overlay a smaller image on a larger image python OpenCv

Hi I am creating a program that replaces a face in a image with someone else's face. However, I am stuck on trying to insert the new face into the original, larger image. I have researched ROI and addWeight(needs the images to be the same size) but…
kaboomfox
  • 901
  • 1
  • 7
  • 7
85
votes
14 answers

How can I upgrade NumPy?

When I installed OpenCV using Homebrew (brew), I got this problem whenever I run this command to test python -c "import cv2": RuntimeError: module compiled against API version 9 but this version of numpy is 6 Traceback (most recent call last): …
user3378649
  • 5,154
  • 14
  • 52
  • 76
83
votes
6 answers

Accessing certain pixel RGB value in openCV

I have searched internet and stackoverflow thoroughly, but I haven't found answer to my question: How can I get/set (both) RGB value of certain (given by x,y coordinates) pixel in OpenCV? What's important-I'm writing in C++, the image is stored in…
Wookie88
  • 33,079
  • 4
  • 27
  • 32
83
votes
11 answers

Why is Visual Studio 2010 not able to find/open PDB files?

I am trying to use OpenCV in VS 2010. I am an amateur, and I am learning first steps from the OpenCV wiki. However, when trying to debug my project, I get the following errors: 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file …
83
votes
11 answers

Resize an image without distortion OpenCV

I am using python 3 and latest version of openCV. I am trying to resize an image using the resize function provided but after resizing the image is very distorted. Code : import cv2 file = "/home/tanmay/Desktop/test_image.png" img = cv2.imread(file…
Tanmay Bhatnagar
  • 2,330
  • 4
  • 30
  • 50
83
votes
2 answers

How to get image width and height in OpenCV?

I want to get image width and height, how can I do that in OpenCV? For example: Mat src = imread("path_to_image"); cout << src.width; Is that right?
sarmad m
  • 879
  • 1
  • 7
  • 5
83
votes
12 answers

Using other keys for the waitKey() function of opencv

I'm working on a program (python ,opencv) in which I use the spacebar to go to the next frame, and Esc to exit the program. These are the only two keys i've got working. I tried to find out about more keys , tried various codes for them but didnt…
md1hunox
  • 3,815
  • 10
  • 45
  • 67
83
votes
2 answers

Create a new RGB OpenCV image using Python?

Using OpenCV in Python, how can I create a new RGB image? I don't want to load the image from a file, just create an empty image ready to work with.
Phil
  • 46,436
  • 33
  • 110
  • 175
81
votes
14 answers

Could not find module FindOpenCV.cmake ( Error in configuration process)

I wrote a CMakeLists.txt for a project in C++, which uses OpenCV libraries. When I try to create the project using cmake, I get the next configuration problem: CMake Error at CMakeLists.txt:15 (find_package): Could not find module FindOpenCV.cmake…
Jav_Rock
  • 22,059
  • 20
  • 123
  • 164