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
1890
votes
23 answers

Image Processing: Algorithm Improvement for 'Coca-Cola Can' Recognition

One of the most interesting projects I've worked on in the past couple of years was a project about image processing. The goal was to develop a system to be able to recognize Coca-Cola 'cans' (note that I'm stressing the word 'cans', you'll see why…
Charles Menguy
  • 40,830
  • 17
  • 95
  • 117
430
votes
25 answers

Cannot find module cv2 when using OpenCV

I have installed OpenCV on the Occidentalis operating system (a variant of Raspbian) on a Raspberry Pi, using this script by jayrambhia. It installed version 2.4.5. When I try import cv2 in a Python program, I get the following…
user2971844
  • 4,317
  • 2
  • 12
  • 3
426
votes
3 answers

Simple Digit Recognition OCR in OpenCV-Python

I am trying to implement a "Digit Recognition OCR" in OpenCV-Python (cv2). It is just for learning purposes. I would like to learn both KNearest and SVM features in OpenCV. I have 100 samples (i.e. images) of each digit. I would like to train with…
Abid Rahman K
  • 51,886
  • 31
  • 146
  • 157
403
votes
12 answers

How to crop an image in OpenCV using Python

How can I crop images, like I've done before in PIL, using OpenCV. Working example on PIL im = Image.open('0.png').convert('L') im = im.crop((1, 1, 98, 33)) im.save('_0.png') But how I can do it on OpenCV? This is what I tried: im =…
Nolik
  • 4,337
  • 5
  • 18
  • 14
394
votes
10 answers

How to detect a Christmas Tree?

Which image processing techniques could be used to implement an application that detects the Christmas trees displayed in the following images? I'm searching for solutions that are going to work on all these images. Therefore, approaches that…
karlphillip
  • 92,053
  • 36
  • 243
  • 426
308
votes
42 answers

How do I install Python OpenCV through Conda?

I'm trying to install OpenCV for Python through Anaconda, but I can't seem to figure this out. I tried conda install opencv conda install cv2 I also tried searching conda search cv No cigar. I ran across this which lists opencv as an included…
Chet
  • 18,421
  • 15
  • 69
  • 113
247
votes
14 answers

Python - Extracting and Saving Video Frames

So I've followed this tutorial but it doesn't seem to do anything. Simply nothing. It waits a few seconds and closes the program. What is wrong with this code? import cv2 vidcap = cv2.VideoCapture('Compton.mp4') success,image = vidcap.read() count…
Rontron
  • 3,963
  • 7
  • 26
  • 44
231
votes
9 answers

Simple and fast method to compare images for similarity

I need a simple and fast way to compare two images for similarity. I.e. I want to get a high value if they contain exactly the same thing but may have some slightly different background and may be moved / resized by a few pixel. (More concrete, if…
Albert
  • 65,406
  • 61
  • 242
  • 386
230
votes
35 answers

ImportError: numpy.core.multiarray failed to import

I'm trying to run this program import cv2 import time cv.NamedWindow("camera", 1) capture = cv.CaptureFromCAM(0) while True: img = cv.QueryFrame(capture) cv.ShowImage("camera", img) if cv.WaitKey(10) == 27: …
user3090952
229
votes
24 answers

How do I install opencv using pip?

I need to install cv2 for a script that has been written for me. I tried pip install cv2 and pip install open_cv and got the same problem - a warning message from dist.py and complains about zlib being not found. No cv2 installed. I also tried…
Ian Boag
  • 2,462
  • 2
  • 10
  • 6
227
votes
12 answers

Is there a way to detect if an image is blurry?

I was wondering if there is a way to determine if an image is blurry or not by analyzing the image data.
Sam
  • 4,727
  • 9
  • 23
  • 17
218
votes
5 answers

How to resize an image with OpenCV2.0 and Python2.6

I want to use OpenCV2.0 and Python2.6 to show resized images. I used and adopted this example but unfortunately, this code is for OpenCV2.1 and does not seem to be working on 2.0. Here my code: import os, glob import cv ulpath = "exampleshq/" for…
Bastian
  • 9,505
  • 6
  • 19
  • 8
216
votes
6 answers

How to remove convexity defects in a Sudoku square?

I was doing a fun project: Solving a Sudoku from an input image using OpenCV (as in Google goggles etc). And I have completed the task, but at the end I found a little problem for which I came here. I did the programming using Python API of OpenCV…
Abid Rahman K
  • 51,886
  • 31
  • 146
  • 157
196
votes
6 answers

Checking images for similarity with OpenCV

Does OpenCV support the comparison of two images, returning some value (maybe a percentage) that indicates how similar these images are? E.g. 100% would be returned if the same image was passed twice, 0% would be returned if the images were totally…
Boris
  • 8,551
  • 25
  • 67
  • 120
193
votes
6 answers

OpenCV C++/Obj-C: Detecting a sheet of paper / Square Detection

I successfully implemented the OpenCV square-detection example in my test application, but now need to filter the output, because it's quite messy - or is my code wrong? I'm interested in the four corner points of the paper for skew reduction (like…
dom
  • 11,894
  • 10
  • 51
  • 74
1
2 3
99 100