Skip to content

Commit 0f51155

Browse files
committed
py_tutorials: add print() braces for python3
1 parent 17b89b2 commit 0f51155

File tree

18 files changed

+41
-41
lines changed

18 files changed

+41
-41
lines changed

doc/py_tutorials/py_calib3d/py_calibration/py_calibration.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ for i in xrange(len(objpoints)):
218218
error = cv2.norm(imgpoints[i], imgpoints2, cv2.NORM_L2)/len(imgpoints2)
219219
mean_error += error
220220

221-
print "total error: ", mean_error/len(objpoints)
221+
print( "total error: {}".format(mean_error/len(objpoints)) )
222222
@endcode
223223
Additional Resources
224224
--------------------

doc/py_tutorials/py_core/py_basic_ops/py_basic_ops.markdown

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,18 @@ You can access a pixel value by its row and column coordinates. For BGR image, i
3030
of Blue, Green, Red values. For grayscale image, just corresponding intensity is returned.
3131
@code{.py}
3232
>>> px = img[100,100]
33-
>>> print px
33+
>>> print( px )
3434
[157 166 200]
3535

3636
# accessing only blue pixel
3737
>>> blue = img[100,100,0]
38-
>>> print blue
38+
>>> print( blue )
3939
157
4040
@endcode
4141
You can modify the pixel values the same way.
4242
@code{.py}
4343
>>> img[100,100] = [255,255,255]
44-
>>> print img[100,100]
44+
>>> print( img[100,100] )
4545
[255 255 255]
4646
@endcode
4747

@@ -76,7 +76,7 @@ etc.
7676
Shape of image is accessed by img.shape. It returns a tuple of number of rows, columns and channels
7777
(if image is color):
7878
@code{.py}
79-
>>> print img.shape
79+
>>> print( img.shape )
8080
(342, 548, 3)
8181
@endcode
8282

@@ -85,12 +85,12 @@ good method to check if loaded image is grayscale or color image.
8585

8686
Total number of pixels is accessed by `img.size`:
8787
@code{.py}
88-
>>> print img.size
88+
>>> print( img.size )
8989
562248
9090
@endcode
9191
Image datatype is obtained by \`img.dtype\`:
9292
@code{.py}
93-
>>> print img.dtype
93+
>>> print( img.dtype )
9494
uint8
9595
@endcode
9696

doc/py_tutorials/py_core/py_image_arithmetics/py_image_arithmetics.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ For example, consider below sample:
2323
>>> x = np.uint8([250])
2424
>>> y = np.uint8([10])
2525
26-
>>> print cv2.add(x,y) # 250+10 = 260 => 255
26+
>>> print( cv2.add(x,y) ) # 250+10 = 260 => 255
2727
[[255]]
2828

29-
>>> print x+y # 250+10 = 260 % 256 = 4
29+
>>> print( x+y ) # 250+10 = 260 % 256 = 4
3030
[4]
3131
@endcode
3232
It will be more visible when you add two images. OpenCV function will provide a better result. So

doc/py_tutorials/py_core/py_optimization/py_optimization.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ for i in xrange(5,49,2):
4444
img1 = cv2.medianBlur(img1,i)
4545
e2 = cv2.getTickCount()
4646
t = (e2 - e1)/cv2.getTickFrequency()
47-
print t
47+
print( t )
4848

4949
# Result I got is 0.521107655 seconds
5050
@endcode

doc/py_tutorials/py_feature2d/py_brief/py_brief.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ kp = star.detect(img,None)
6969
# compute the descriptors with BRIEF
7070
kp, des = brief.compute(img, kp)
7171

72-
print brief.descriptorSize()
73-
print des.shape
72+
print( brief.descriptorSize() )
73+
print( des.shape )
7474
@endcode
7575
The function brief.getDescriptorSize() gives the \f$n_d\f$ size used in bytes. By default it is 32. Next one
7676
is matching, which will be done in another chapter.

doc/py_tutorials/py_feature2d/py_fast/py_fast.markdown

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,18 @@ kp = fast.detect(img,None)
108108
img2 = cv2.drawKeypoints(img, kp, None, color=(255,0,0))
109109

110110
# Print all default params
111-
print "Threshold: ", fast.getThreshold()
112-
print "nonmaxSuppression: ", fast.getNonmaxSuppression()
113-
print "neighborhood: ", fast.getType()
114-
print "Total Keypoints with nonmaxSuppression: ", len(kp)
111+
print( "Threshold: {}".format(fast.getThreshold()) )
112+
print( "nonmaxSuppression:{}".format(fast.getNonmaxSuppression()) )
113+
print( "neighborhood: {}".format(fast.getType()) )
114+
print( "Total Keypoints with nonmaxSuppression: {}".format(len(kp)) )
115115

116116
cv2.imwrite('fast_true.png',img2)
117117

118118
# Disable nonmaxSuppression
119119
fast.setNonmaxSuppression(0)
120120
kp = fast.detect(img,None)
121121

122-
print "Total Keypoints without nonmaxSuppression: ", len(kp)
122+
print( "Total Keypoints without nonmaxSuppression: {}".format(len(kp)) )
123123

124124
img3 = cv2.drawKeypoints(img, kp, None, color=(255,0,0))
125125

doc/py_tutorials/py_feature2d/py_feature_homography/py_feature_homography.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ if len(good)>MIN_MATCH_COUNT:
8585
img2 = cv2.polylines(img2,[np.int32(dst)],True,255,3, cv2.LINE_AA)
8686

8787
else:
88-
print "Not enough matches are found - %d/%d" % (len(good),MIN_MATCH_COUNT)
88+
print( "Not enough matches are found - {}/{}".format(len(good), MIN_MATCH_COUNT) )
8989
matchesMask = None
9090
@endcode
9191
Finally we draw our inliers (if successfully found the object) or matching keypoints (if failed).

doc/py_tutorials/py_feature2d/py_surf_intro/py_surf_intro.markdown

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ examples are shown in Python terminal since it is just same as SIFT only.
9292
While matching, we may need all those features, but not now. So we increase the Hessian Threshold.
9393
@code{.py}
9494
# Check present Hessian threshold
95-
>>> print surf.getHessianThreshold()
95+
>>> print( surf.getHessianThreshold() )
9696
400.0
9797

9898
# 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
102102
# Again compute keypoints and check its number.
103103
>>> kp, des = surf.detectAndCompute(img,None)
104104
105-
>>> print len(kp)
105+
>>> print( len(kp) )
106106
47
107107
@endcode
108108
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.
119119
Now I want to apply U-SURF, so that it won't find the orientation.
120120
@code{.py}
121121
# Check upright flag, if it False, set it to True
122-
>>> print surf.getUpright()
122+
>>> print( surf.getUpright() )
123123
False
124124

125125
>>> surf.setUpright(True)
@@ -139,7 +139,7 @@ etc, this is better.
139139
Finally we check the descriptor size and change it to 128 if it is only 64-dim.
140140
@code{.py}
141141
# Find size of descriptor
142-
>>> print surf.descriptorSize()
142+
>>> print( surf.descriptorSize() )
143143
64
144144

145145
# 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.
149149
# So we make it to True to get 128-dim descriptors.
150150
>>> surf.extended = True
151151
>>> kp, des = surf.detectAndCompute(img,None)
152-
>>> print surf.descriptorSize()
152+
>>> print( surf.descriptorSize() )
153153
128
154-
>>> print des.shape
154+
>>> print( des.shape )
155155
(47, 128)
156156
@endcode
157157
Remaining part is matching which we will do in another chapter.

doc/py_tutorials/py_gui/py_mouse_handling/py_mouse_handling.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ in Python terminal:
2121
@code{.py}
2222
import cv2
2323
events = [i for i in dir(cv2) if 'EVENT' in i]
24-
print events
24+
print( events )
2525
@endcode
2626
Creating mouse callback function has a specific format which is same everywhere. It differs only in
2727
what the function does. So our mouse callback function does one thing, it draws a circle where we

doc/py_tutorials/py_imgproc/py_colorspaces/py_colorspaces.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ commands in your Python terminal :
2424
@code{.py}
2525
>>> import cv2
2626
>>> flags = [i for i in dir(cv2) if i.startswith('COLOR_')]
27-
>>> print flags
27+
>>> print( flags )
2828
@endcode
2929
@note For HSV, Hue range is [0,179], Saturation range is [0,255] and Value range is [0,255].
3030
Different softwares use different scales. So if you are comparing OpenCV values with them, you need
@@ -96,7 +96,7 @@ terminal:
9696
@code{.py}
9797
>>> green = np.uint8([[[0,255,0 ]]])
9898
>>> hsv_green = cv2.cvtColor(green,cv2.COLOR_BGR2HSV)
99-
>>> print hsv_green
99+
>>> print( hsv_green )
100100
[[[ 60 255 255]]]
101101
@endcode
102102
Now you take [H-10, 100,100] and [H+10, 255, 255] as lower bound and upper bound respectively. Apart

0 commit comments

Comments
 (0)