1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

py_tutorials: add print() braces for python3

This commit is contained in:
berak
2017-05-28 11:07:15 +02:00
parent 17b89b2a35
commit 0f51155e79
18 changed files with 41 additions and 41 deletions
@@ -69,8 +69,8 @@ kp = star.detect(img,None)
# compute the descriptors with BRIEF
kp, des = brief.compute(img, kp)
print brief.descriptorSize()
print des.shape
print( brief.descriptorSize() )
print( des.shape )
@endcode
The function brief.getDescriptorSize() gives the \f$n_d\f$ size used in bytes. By default it is 32. Next one
is matching, which will be done in another chapter.
@@ -108,10 +108,10 @@ kp = fast.detect(img,None)
img2 = cv2.drawKeypoints(img, kp, None, color=(255,0,0))
# Print all default params
print "Threshold: ", fast.getThreshold()
print "nonmaxSuppression: ", fast.getNonmaxSuppression()
print "neighborhood: ", fast.getType()
print "Total Keypoints with nonmaxSuppression: ", len(kp)
print( "Threshold: {}".format(fast.getThreshold()) )
print( "nonmaxSuppression:{}".format(fast.getNonmaxSuppression()) )
print( "neighborhood: {}".format(fast.getType()) )
print( "Total Keypoints with nonmaxSuppression: {}".format(len(kp)) )
cv2.imwrite('fast_true.png',img2)
@@ -119,7 +119,7 @@ cv2.imwrite('fast_true.png',img2)
fast.setNonmaxSuppression(0)
kp = fast.detect(img,None)
print "Total Keypoints without nonmaxSuppression: ", len(kp)
print( "Total Keypoints without nonmaxSuppression: {}".format(len(kp)) )
img3 = cv2.drawKeypoints(img, kp, None, color=(255,0,0))
@@ -85,7 +85,7 @@ if len(good)>MIN_MATCH_COUNT:
img2 = cv2.polylines(img2,[np.int32(dst)],True,255,3, cv2.LINE_AA)
else:
print "Not enough matches are found - %d/%d" % (len(good),MIN_MATCH_COUNT)
print( "Not enough matches are found - {}/{}".format(len(good), MIN_MATCH_COUNT) )
matchesMask = None
@endcode
Finally we draw our inliers (if successfully found the object) or matching keypoints (if failed).
@@ -92,7 +92,7 @@ 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.getHessianThreshold()
>>> print( surf.getHessianThreshold() )
400.0
# We set it to some 50000. Remember, it is just for representing in picture.
@@ -102,7 +102,7 @@ While matching, we may need all those features, but not now. So we increase the
# Again compute keypoints and check its number.
>>> kp, des = surf.detectAndCompute(img,None)
>>> print len(kp)
>>> print( len(kp) )
47
@endcode
It is less than 50. Let's draw it on the image.
@@ -119,7 +119,7 @@ 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.getUpright()
>>> print( surf.getUpright() )
False
>>> surf.setUpright(True)
@@ -139,7 +139,7 @@ etc, this is better.
Finally we check the descriptor size and change it to 128 if it is only 64-dim.
@code{.py}
# Find size of descriptor
>>> print surf.descriptorSize()
>>> print( surf.descriptorSize() )
64
# That means flag, "extended" is False.
@@ -149,9 +149,9 @@ Finally we check the descriptor size and change it to 128 if it is only 64-dim.
# So we make it to True to get 128-dim descriptors.
>>> surf.extended = True
>>> kp, des = surf.detectAndCompute(img,None)
>>> print surf.descriptorSize()
>>> print( surf.descriptorSize() )
128
>>> print des.shape
>>> print( des.shape )
(47, 128)
@endcode
Remaining part is matching which we will do in another chapter.