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
69
votes
5 answers

linux/videodev.h : no such file or directory - OpenCV on ubuntu 11.04

I tried to install OpenCV2.2 on Ubuntu 11.04. But OpenCV compilation fails stating an error related to linux/videodev.h file. File available in /user/includes/linux is named…
Niroshan
  • 2,064
  • 6
  • 35
  • 60
69
votes
5 answers

How to detect lines in OpenCV?

I am trying to detect lines in parking as shown below. What I hope to get is the clear lines and (x,y) position in the crossed line. However, the result is not very promising. I guess it is due to two main reasons: Some lines are very broken or…
user824624
  • 7,077
  • 27
  • 106
  • 183
69
votes
2 answers

Recommended values for OpenCV detectMultiScale() parameters

What are the recommended parameters for CascadeClassifier::detectMultiScale() and depending on which factors I should change default parameters? void CascadeClassifier::detectMultiScale( const Mat& image, vector& objects, double…
torayeff
  • 9,296
  • 19
  • 69
  • 103
69
votes
4 answers

Using make with -j4 or -j8

I have 4 processors and am compiling a processor-hungry application. I read that using make with the -j4 switch was recommended for OpenCV; should I instead use -j8? What is the advantage of making for multiple processors?
user784435
69
votes
2 answers

How to verify the correctness of calibration of a webcam?

I am totally new to camera calibration techniques... I am using OpenCV chessboard technique... I am using a webcam from Quantum... Here are my observations and steps.. I have kept each chess square side = 3.5 cm. It is a 7 x 5 chessboard with 6 x 4…
rotating_image
  • 3,046
  • 4
  • 28
  • 46
68
votes
7 answers

cv::imwrite could not find a writer for the specified extension

The following command causes an exception. cv::imwrite("test.jpg", diffImg); I also tried numerous variations on this, including absolute paths and PNG export. Here's the error: Exception at 0x75abd36f, code: 0xe06d7363: C++ exception, flags=0x1 …
Pieter
  • 31,619
  • 76
  • 167
  • 242
68
votes
10 answers

Using openCV to overlay transparent image onto another image

How can I overlay a transparent PNG onto another image without losing it's transparency using openCV in python? import cv2 background = cv2.imread('field.jpg') overlay = cv2.imread('dice.png') # Help please cv2.imwrite('combined.png',…
Anthony Budd
  • 982
  • 2
  • 8
  • 11
68
votes
3 answers

How to add noise (Gaussian/salt and pepper etc) to image in Python with OpenCV

I am wondering if there exists some functions in Python with OpenCV or any other python image processing library that adds Gaussian or salt and pepper noise to an image? For example, in MATLAB there exists straight-forward functions that do the same…
Sanchit
  • 3,180
  • 8
  • 37
  • 53
68
votes
7 answers

Easiest way to rotate by 90 degrees an image using OpenCV?

What is the best way (in c/c++) to rotate an IplImage/cv::Mat by 90 degrees? I would assume that there must be something better than transforming it using a matrix, but I can't seem to find anything other than that in the API and online.
Ben H
  • 3,136
  • 3
  • 25
  • 34
68
votes
5 answers

OpenCV - Apply mask to a color image

How can I apply mask to a color image in latest python binding (cv2)? In previous python binding the simplest way was to use cv.Copy e.g. cv.Copy(dst, src, mask) But this function is not available in cv2 binding. Is there any workaround without…
pzo
  • 2,087
  • 3
  • 24
  • 42
67
votes
1 answer

Tensorflow vs OpenCV

I'm new into the AI world, I've start doing some stuff using Python & OpenCV for face detection and so on. I know that with the implementation of some algorithms I can develop AI system using Python & OpenCV. So my question is : What is the position…
binmosa
  • 967
  • 1
  • 7
  • 9
67
votes
9 answers

Get video dimension in python-opencv

I can get size of image, like this: import cv2 img = cv2.imread('my_image.jpg',0) height, width = img.shape[:2] How about video?
karavanjo
  • 1,626
  • 4
  • 18
  • 31
67
votes
6 answers

How can one display an image using cv2 in Python

I've been working with code to display frames from a movie. The bare bones of the code is as follows: import cv2 import matplotlib.pyplot as plt # Read single frame avi cap = cv2.VideoCapture('singleFrame.avi') rval, frame = cap.read() # Attempt…
user1245262
  • 6,968
  • 8
  • 50
  • 77
67
votes
13 answers

Rotate an image without cropping in OpenCV in C++

I'd like to rotate an image, but I can't obtain the rotated image without cropping My original image: Now I use this code: #include #include #include // Compile…
67
votes
5 answers

Convert RGB to Black & White in OpenCV

I would like to know how to convert an RGB image into a black & white (binary) image. After conversion, how can I save the modified image to disk?
mohammed
  • 867
  • 1
  • 9
  • 9