Skip to content

Commit 5416519

Browse files
committed
Use os path util to fetch example path to determine assets location
1 parent 7501eea commit 5416519

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

examples/computer_vision/fast.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from time import time
1313
import arrayfire as af
14+
import os
1415
import sys
1516

1617
def draw_corners(img, x, y, draw_len):
@@ -35,10 +36,13 @@ def draw_corners(img, x, y, draw_len):
3536

3637
def fast_demo(console):
3738

39+
root_path = os.path.dirname(os.path.abspath(__file__))
40+
file_path = root_path
3841
if console:
39-
img_color = af.load_image("../../assets/examples/images/square.png", True);
42+
file_path += "/../../assets/examples/images/square.png"
4043
else:
41-
img_color = af.load_image("../../assets/examples/images/man.jpg", True);
44+
file_path += "/../../assets/examples/images/man.jpg"
45+
img_color = af.load_image(file_path, True);
4246

4347
img = af.color_space(img_color, af.CSPACE.GRAY, af.CSPACE.RGB)
4448
img_color /= 255.0

examples/computer_vision/harris.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from time import time
1313
import arrayfire as af
14+
import os
1415
import sys
1516

1617
def draw_corners(img, x, y, draw_len):
@@ -35,10 +36,13 @@ def draw_corners(img, x, y, draw_len):
3536

3637
def harris_demo(console):
3738

39+
root_path = os.path.dirname(os.path.abspath(__file__))
40+
file_path = root_path
3841
if console:
39-
img_color = af.load_image("../../assets/examples/images/square.png", True);
42+
file_path += "/../../assets/examples/images/square.png"
4043
else:
41-
img_color = af.load_image("../../assets/examples/images/man.jpg", True);
44+
file_path += "/../../assets/examples/images/man.jpg"
45+
img_color = af.load_image(file_path, True);
4246

4347
img = af.color_space(img_color, af.CSPACE.GRAY, af.CSPACE.RGB)
4448
img_color /= 255.0

examples/computer_vision/matching.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from time import time
1313
import arrayfire as af
14+
import os
1415
import sys
1516

1617
def normalize(a):
@@ -45,10 +46,13 @@ def draw_rectangle(img, x, y, wx, wy):
4546

4647
def templateMatchingDemo(console):
4748

49+
root_path = os.path.dirname(os.path.abspath(__file__))
50+
file_path = root_path
4851
if console:
49-
img_color = af.load_image("../../assets/examples/images/square.png", True);
52+
file_path += "/../../assets/examples/images/square.png"
5053
else:
51-
img_color = af.load_image("../../assets/examples/images/man.jpg", True);
54+
file_path += "/../../assets/examples/images/man.jpg"
55+
img_color = af.load_image(file_path, True);
5256

5357
# Convert the image from RGB to gray-scale
5458
img = af.color_space(img_color, af.CSPACE.GRAY, af.CSPACE.RGB)

examples/computer_vision/susan.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from time import time
1313
import arrayfire as af
14+
import os
1415
import sys
1516

1617
def draw_corners(img, x, y, draw_len):
@@ -35,10 +36,13 @@ def draw_corners(img, x, y, draw_len):
3536

3637
def susan_demo(console):
3738

39+
root_path = os.path.dirname(os.path.abspath(__file__))
40+
file_path = root_path
3841
if console:
39-
img_color = af.load_image("../../assets/examples/images/square.png", True);
42+
file_path += "/../../assets/examples/images/square.png"
4043
else:
41-
img_color = af.load_image("../../assets/examples/images/man.jpg", True);
44+
file_path += "/../../assets/examples/images/man.jpg"
45+
img_color = af.load_image(file_path, True);
4246

4347
img = af.color_space(img_color, af.CSPACE.GRAY, af.CSPACE.RGB)
4448
img_color /= 255.0

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy