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
75
votes
7 answers

sift = cv2.xfeatures2d.SIFT_create() not working even though have contrib installed

So I am trying to use: sift = cv2.xfeatures2d.SIFT_create() and it is coming up with this error: cv2.error: OpenCV(3.4.3) C:\projects\opencv-python\opencv_contrib\modules\xfeatures2d\src\sift.cpp:1207: error: (-213:The function/feature is not…
rhonda.rooster
  • 865
  • 1
  • 6
  • 8
74
votes
6 answers

Difference in output with waitKey(0) and waitKey(1)

I've just begun using the OpenCV library for Python and came across something I didn't understand. cap = cv2.VideoCapture(0) while True: ret, frame = cap.read() #returns ret and the frame cv2.imshow('frame',frame) if…
Omar Pervez Khan
  • 857
  • 1
  • 6
  • 8
73
votes
6 answers

How to crop a CvMat in OpenCV?

I have an image converted in a CvMat Matrix say CVMat source. Once I get a region of interest from source I want the rest of the algorithm to be applied to that region of interest only. For that I think I will have to somehow crop the source matrix…
Waqar
  • 957
  • 2
  • 8
  • 14
72
votes
15 answers

OpenCV TypeError: Expected cv::UMat for argument 'src' - What is this?

Disclaimer: huge openCV noob Traceback (most recent call last): File "lanes2.py", line 22, in canny = canny(lane_image) File "lanes2.py", line 5, in canny gray = cv2.cvtColor(imgUMat, cv2.COLOR_RGB2GRAY) TypeError: Expected cv::UMat for argument…
autonocat
  • 757
  • 1
  • 5
  • 7
72
votes
1 answer

Opencv - Grayscale mode Vs gray color conversion

I am working in opencv(2.4.11) python(2.7) and was playing around with gray images. I found an unusual behavior when loading image in gray scale mode and converting image from BGR to GRAY. Following is my experimental code: import cv2 path =…
Gagandeep Singh
  • 827
  • 1
  • 7
  • 11
72
votes
12 answers

How to use Opencv with Gradle?

I want to use Android Studio to develop an app using Gradle build tool. I can not insert the OpenCV repo and library on build.gradle. My .gradle file is like below: buildscript { repositories { mavenCentral() } dependencies { …
Omer Sonmez
  • 1,168
  • 2
  • 20
  • 31
71
votes
2 answers

What are the differences between CV_8U and CV_32F and what should I worry about when converting between them?

I have some code that is acting up and I suspect it's because I'm operating on the wrong types of data or converting between them poorly. It is mixing cv::Mat objects of types CV_8U (which is what is created when reading a jpg as grayscale with…
mic
  • 713
  • 1
  • 6
  • 4
71
votes
2 answers

"In-source builds are not allowed" in cmake

I'm new to cmake, and I'm only using it to install opencv on my ubuntu linux. Here's the command I ran: cmake -DCMAKE_BUILD_TYPE=Release DCMAKE_INSTALL_PREFIX=/home/jinha/OCV/source Then it returns the error: FATAL: In-source builds are not allowed.…
WannabeArchitect
  • 1,058
  • 2
  • 11
  • 22
71
votes
22 answers

Can't use SURF, SIFT in OpenCV

I'm trying a simple thing like detector = cv2.SIFT() and get this bad error detector = cv2.SIFT() AttributeError: 'module' object has no attribute 'SIFT' I do not understand that because cv2 is installed. cv2.__version__ is $Rev: 4557 $ My system…
Linda
  • 2,375
  • 4
  • 30
  • 33
71
votes
2 answers

What does cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC1);

What does the cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC1); do in OpenCV? I went through the documentation and was unable to understand what alpha, beta, NORM_MINMAX and CV_8UC1 actually do. I am aware alpha sets the lower and beta the…
user1179510
  • 1,003
  • 1
  • 14
  • 24
70
votes
5 answers

Print out the values of a (Mat) matrix in OpenCV C++

I want to dump the values of a matrix in OpenCV to the console using cout. I quickly learned that I do not understand OpenvCV's type system nor C++ templates well enough to accomplish this simple task. Would a reader please post (or point me to) a…
ahoffer
  • 6,347
  • 4
  • 39
  • 68
70
votes
4 answers

How do I find an image contained within an image?

I'm currently building what basically amounts to a cross between a search engine and a gallery for web comics that's focused on citing sources and giving authors credit. I'm trying to figure out a way to search an image to find characters within…
Adam
  • 1,407
  • 2
  • 14
  • 18
70
votes
6 answers

OpenCV/Python: read specific frame using VideoCapture

Is there a way to get a specific frame using VideoCapture() method? My current code is: import numpy as np import cv2 cap = cv2.VideoCapture('video.avi') This is my reference tutorial.
zinon
  • 4,427
  • 14
  • 70
  • 112
70
votes
3 answers

What does CV_8UC3 and the other types stand for in OpenCV?

I was surprised when I couldn't find anything in OpenCV documentation describing - with words - what the various types stand for, and Googling wasn't much help either. I know that CV_8UC1 is gray-scale, but what does CV_8UC3 stand for? Is it RGB? Or…
sashoalm
  • 75,001
  • 122
  • 434
  • 781
70
votes
8 answers

OpenCV v1/v2 error: the function is not implemented

I'm trying to get OpenCV working with Python on my Ubuntu machine. I've downloaded and installed OpenCV, but when I attempt to run the following python code (which should capture images from a webcam and push them to the screen) import…
Dan
  • 2,952
  • 4
  • 23
  • 29