OpenCV is one of the most popular and most used Computer vision libraries. It contains tools to carry out image and video processing.
When OpenCV 3..4.1 is an improved version of OpenCV 2.4 as it introduced new algorithms and features. Although some of the existing modules were rewritten and moved to sub-modules. In this articles, I will focus on the changes made in the existing modules of OpenCV 2.4 and how they can be implemented in OpenCV 3.4.1.
Feature Detection
Some of the feature detection algorithms (FREAK, BRIEF, SIFT and SURF) have been moved to opencv_contrib repository and xfeatures2d module. SIFT and SURF algorithms are patented by their creators and are non-free. Although they can be used for educational and research purposes.
SIFT : Create SIFT feature detector object.
sift = cv2.SIFT()
sift = cv2.xfeatures2d.SIFT_create()
|
SURF : Create SURF feature detector object
surf = cv2.SURF()
surf = cv2.xfeatures2d.SURF_create()
|
FAST : Create FAST detector object
fast = cv2.FastFeatureDetector()
fast = cv2.FastFeatureDetector_create()
|
ORB : Create ORB detector object
orb = cv2.ORB()
orb = cv2.ORB_create()
|
Simple Blob Detector
detector = cv2.SimpleBlobDetector()
detector = cv2.SimpleBlobDetector_create()
|
CIRCLE DETECTION
OpenCV uses Hough Gradient Method to detect circles that uses gradient information of the edges.
circles = cv2.HoughCircles(img, cv2.HOUGH_GRADIENT, 4 , 10 )
|
The name of the method has been changed from CV_HOUGH_GRADIENT
in 2.4 version to HOUGH_GRADIENT
in 3.4 version.
CONTOURS
Initially the findContours()
function returned only two parameters in OpenCV 2.4 . In OpenCV 3.2 onwards, the function was modified to return three parameters i.e. the modified image, contours and hierarchy.
contours, hierarchy = cv2.findContours(img, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
im, contours, hierarchy = cv2.findContours(img, cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_NONE)
|
These were a few important changes that could be useful while migrating the code from OpenCV 2 .4 to OpenCV 3.x .
Last Updated :
03 Jan, 2023
Like Article
Save Article
Vote for difficulty
Current difficulty :
Basic