Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
781931a6
Commit
781931a6
authored
Oct 20, 2015
by
berak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update python features2d tutorials
parent
1648e929
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
17 deletions
+19
-17
py_brief.markdown
doc/py_tutorials/py_feature2d/py_brief/py_brief.markdown
+5
-3
py_fast.markdown
doc/py_tutorials/py_feature2d/py_fast/py_fast.markdown
+1
-1
py_feature_homography.markdown
...re2d/py_feature_homography/py_feature_homography.markdown
+2
-2
py_orb.markdown
doc/py_tutorials/py_feature2d/py_orb/py_orb.markdown
+2
-2
py_sift_intro.markdown
...torials/py_feature2d/py_sift_intro/py_sift_intro.markdown
+3
-3
py_surf_intro.markdown
...torials/py_feature2d/py_surf_intro/py_surf_intro.markdown
+6
-6
No files found.
doc/py_tutorials/py_feature2d/py_brief/py_brief.markdown
View file @
781931a6
...
...
@@ -48,6 +48,8 @@ BRIEF in OpenCV
Below code shows the computation of BRIEF descriptors with the help of CenSurE detector. (CenSurE
detector is called STAR detector in OpenCV)
note, that you need
[
opencv contrib
](
https://github.com/Itseez/opencv_contrib
)
) to use this.
@code{.py}
import numpy as np
import cv2
...
...
@@ -55,11 +57,11 @@ from matplotlib import pyplot as plt
img = cv2.imread('simple.jpg',0)
# Initiate
STAR
detector
star = cv2.
FeatureDetector_create("STAR"
)
# Initiate
FAST
detector
star = cv2.
xfeatures2d.StarDetector_create(
)
# Initiate BRIEF extractor
brief = cv2.
DescriptorExtractor_create("BRIEF"
)
brief = cv2.
BriefDescriptorExtractor_create(
)
# find the keypoints with STAR
kp = star.detect(img,None)
...
...
doc/py_tutorials/py_feature2d/py_fast/py_fast.markdown
View file @
781931a6
...
...
@@ -101,7 +101,7 @@ from matplotlib import pyplot as plt
img = cv2.imread('simple.jpg',0)
# Initiate FAST object with default values
fast = cv2.FastFeatureDetector()
fast = cv2.FastFeatureDetector
_create
()
# find and draw the keypoints
kp = fast.detect(img,None)
...
...
doc/py_tutorials/py_feature2d/py_feature_homography/py_feature_homography.markdown
View file @
781931a6
...
...
@@ -44,7 +44,7 @@ img1 = cv2.imread('box.png',0) # queryImage
img2 = cv2.imread('box_in_scene.png',0) # trainImage
# Initiate SIFT detector
sift = cv2.
SIFT
()
sift = cv2.
xfeatures2d.SIFT_create
()
# find the keypoints and descriptors with SIFT
kp1, des1 = sift.detectAndCompute(img1,None)
...
...
@@ -78,7 +78,7 @@ if len(good)>MIN_MATCH_COUNT:
M, mask = cv2.findHomography(src_pts, dst_pts, cv2.RANSAC,5.0)
matchesMask = mask.ravel().tolist()
h,w = img1.shape
h,w
,d
= img1.shape
pts = np.float32([ [0,0],[0,h-1],[w-1,h-1],[w-1,0] ]).reshape(-1,1,2)
dst = cv2.perspectiveTransform(pts,M)
...
...
doc/py_tutorials/py_feature2d/py_orb/py_orb.markdown
View file @
781931a6
...
...
@@ -69,8 +69,8 @@ from matplotlib import pyplot as plt
img = cv2.imread('simple.jpg',0)
# Initiate
STAR
detector
orb = cv2.ORB()
# Initiate
ORB
detector
orb = cv2.ORB
_create
()
# find the keypoints with ORB
kp = orb.detect(img,None)
...
...
doc/py_tutorials/py_feature2d/py_sift_intro/py_sift_intro.markdown
View file @
781931a6
...
...
@@ -104,7 +104,7 @@ greater than 0.8, they are rejected. It eliminaters around 90% of false matches
So this is a summary of SIFT algorithm. For more details and understanding, reading the original
paper is highly recommended. Remember one thing, this algorithm is patented. So this algorithm is
included in
Non-free module in OpenCV.
included in
[
the opencv contrib repo
](
https://github.com/Itseez/opencv_contrib
)
SIFT in OpenCV
--------------
...
...
@@ -119,7 +119,7 @@ import numpy as np
img = cv2.imread('home.jpg')
gray= cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
sift = cv2.
SIFT
()
sift = cv2.
xfeatures2d.SIFT_create
()
kp = sift.detect(gray,None)
img=cv2.drawKeypoints(gray,kp)
...
...
@@ -151,7 +151,7 @@ Now to calculate the descriptor, OpenCV provides two methods.
We will see the second method:
@code{.py}
sift = cv2.
SIFT
()
sift = cv2.
xfeatures2d.SIFT_create
()
kp, des = sift.detectAndCompute(gray,None)
@endcode
Here kp will be a list of keypoints and des is a numpy array of shape
...
...
doc/py_tutorials/py_feature2d/py_surf_intro/py_surf_intro.markdown
View file @
781931a6
...
...
@@ -80,7 +80,7 @@ examples are shown in Python terminal since it is just same as SIFT only.
# Create SURF object. You can specify params here or later.
# Here I set Hessian Threshold to 400
>>> surf = cv2.
SURF
(400)
>>> surf = cv2.
xfeatures2d.SURF_create
(400)
# Find keypoints and descriptors directly
>>> kp, des = surf.detectAndCompute(img,None)
...
...
@@ -92,12 +92,12 @@ examples are shown in Python terminal since it is just same as SIFT only.
While matching, we may need all those features, but not now. So we increase the Hessian Threshold.
@code{.py}
# Check present Hessian threshold
>>> print surf.
hessianThreshold
>>> print surf.
getHessianThreshold()
400.
0
# We set it to some 50000. Remember, it is just for representing in picture.
# In actual cases, it is better to have a value 300-500
>>> surf.
hessianThreshold = 50000
>>> surf.
setHessianThreshold(50000)
# Again compute keypoints and check its number.
>>> kp, des = surf.detectAndCompute(img,None)
...
...
@@ -119,10 +119,10 @@ on wings of butterfly. You can test it with other images.
Now I want to apply U-SURF, so that it won't find the orientation.
@code{.py}
# Check upright flag, if it False, set it to True
>>> print surf.
upright
>>> print surf.
getUpright()
False
>>> surf.
upright = True
>>> surf.
setUpright(True)
# Recompute the feature points and draw it
>>> kp = surf.detect(img,None)
...
...
@@ -143,7 +143,7 @@ Finally we check the descriptor size and change it to 128 if it is only 64-dim.
64
# That means flag, "extended" is False.
>>> surf.
extended
>>> surf.
getExtended()
False
# So we make it to True to get 128-dim descriptors.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment