samples: use findFile() in "python"
This commit is contained in:
committed by
Alexander Alekhin
parent
9ea8c775f8
commit
c371df4aa2
@@ -11,10 +11,10 @@ def main(argv):
|
||||
* [ESC] -> Close program
|
||||
""")
|
||||
## [load]
|
||||
filename = argv[0] if len(argv) > 0 else "../data/chicky_512.png"
|
||||
filename = argv[0] if len(argv) > 0 else 'chicky_512.png'
|
||||
|
||||
# Load the image
|
||||
src = cv.imread(filename)
|
||||
src = cv.imread(cv.samples.findFile(filename))
|
||||
|
||||
# Check if image is loaded fine
|
||||
if src is None:
|
||||
|
||||
@@ -17,10 +17,10 @@ def main(argv):
|
||||
cv.namedWindow(window_name, cv.WINDOW_AUTOSIZE)
|
||||
|
||||
# Load the source image
|
||||
imageName = argv[0] if len(argv) > 0 else "../data/lena.jpg"
|
||||
imageName = argv[0] if len(argv) > 0 else 'lena.jpg'
|
||||
|
||||
global src
|
||||
src = cv.imread(imageName, 1)
|
||||
src = cv.imread(cv.samples.findFile(imageName))
|
||||
if src is None:
|
||||
print ('Error opening image')
|
||||
print ('Usage: smoothing.py [image_name -- default ../data/lena.jpg] \n')
|
||||
|
||||
+2
-2
@@ -7,10 +7,10 @@ import argparse
|
||||
# Read image given by user
|
||||
## [basic-linear-transform-load]
|
||||
parser = argparse.ArgumentParser(description='Code for Changing the contrast and brightness of an image! tutorial.')
|
||||
parser.add_argument('--input', help='Path to input image.', default='../data/lena.jpg')
|
||||
parser.add_argument('--input', help='Path to input image.', default='lena.jpg')
|
||||
args = parser.parse_args()
|
||||
|
||||
image = cv.imread(args.input)
|
||||
image = cv.imread(cv.samples.findFile(args.input))
|
||||
if image is None:
|
||||
print('Could not open or find the image: ', args.input)
|
||||
exit(0)
|
||||
|
||||
+2
-2
@@ -44,10 +44,10 @@ def on_gamma_correction_trackbar(val):
|
||||
gammaCorrection()
|
||||
|
||||
parser = argparse.ArgumentParser(description='Code for Changing the contrast and brightness of an image! tutorial.')
|
||||
parser.add_argument('--input', help='Path to input image.', default='../data/lena.jpg')
|
||||
parser.add_argument('--input', help='Path to input image.', default='lena.jpg')
|
||||
args = parser.parse_args()
|
||||
|
||||
img_original = cv.imread(args.input)
|
||||
img_original = cv.imread(cv.samples.findFile(args.input))
|
||||
if img_original is None:
|
||||
print('Could not open or find the image: ', args.input)
|
||||
exit(0)
|
||||
|
||||
@@ -42,10 +42,10 @@ def dilatation(val):
|
||||
cv.imshow(title_dilatation_window, dilatation_dst)
|
||||
|
||||
parser = argparse.ArgumentParser(description='Code for Eroding and Dilating tutorial.')
|
||||
parser.add_argument('--input', help='Path to input image.', default='../data/LinuxLogo.jpg')
|
||||
parser.add_argument('--input', help='Path to input image.', default='LinuxLogo.jpg')
|
||||
args = parser.parse_args()
|
||||
|
||||
src = cv.imread(args.input)
|
||||
src = cv.imread(cv.samples.findFile(args.input))
|
||||
if src is None:
|
||||
print('Could not open or find the image: ', args.input)
|
||||
exit(0)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import cv2 as cv
|
||||
import numpy as np
|
||||
|
||||
img = cv.imread('../data/sudoku.png')
|
||||
img = cv.imread(cv.samples.findFile('sudoku.png'))
|
||||
gray = cv.cvtColor(img,cv.COLOR_BGR2GRAY)
|
||||
edges = cv.Canny(gray,50,150,apertureSize = 3)
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import cv2 as cv
|
||||
import numpy as np
|
||||
|
||||
img = cv.imread('../data/sudoku.png')
|
||||
img = cv.imread(cv.samples.findFile('sudoku.png'))
|
||||
gray = cv.cvtColor(img,cv.COLOR_BGR2GRAY)
|
||||
edges = cv.Canny(gray,50,150,apertureSize = 3)
|
||||
lines = cv.HoughLinesP(edges,1,np.pi/180,100,minLineLength=100,maxLineGap=10)
|
||||
|
||||
@@ -31,10 +31,10 @@ def morphology_operations(val):
|
||||
cv.imshow(title_window, dst)
|
||||
|
||||
parser = argparse.ArgumentParser(description='Code for More Morphology Transformations tutorial.')
|
||||
parser.add_argument('--input', help='Path to input image.', default='../data/LinuxLogo.jpg')
|
||||
parser.add_argument('--input', help='Path to input image.', default='LinuxLogo.jpg')
|
||||
args = parser.parse_args()
|
||||
|
||||
src = cv.imread(args.input)
|
||||
src = cv.imread(cv.samples.findFile(args.input))
|
||||
if src is None:
|
||||
print('Could not open or find the image: ', args.input)
|
||||
exit(0)
|
||||
|
||||
@@ -23,12 +23,12 @@ def Threshold_Demo(val):
|
||||
## [Threshold_Demo]
|
||||
|
||||
parser = argparse.ArgumentParser(description='Code for Basic Thresholding Operations tutorial.')
|
||||
parser.add_argument('--input', help='Path to input image.', default='../data/stuff.jpg')
|
||||
parser.add_argument('--input', help='Path to input image.', default='stuff.jpg')
|
||||
args = parser.parse_args()
|
||||
|
||||
## [load]
|
||||
# Load an image
|
||||
src = cv.imread(args.input)
|
||||
src = cv.imread(cv.samples.findFile(args.input))
|
||||
if src is None:
|
||||
print('Could not open or find the image: ', args.input)
|
||||
exit(0)
|
||||
|
||||
Reference in New Issue
Block a user