Relative path for OpenCV imread in python January 23, 2019 main_image = cv2.imread('data/image.jpg') img1 = os.path.join(os.path.dirname(__file__), 'images', 'main_image.jpg') main_image = cv2.imread(img1) References https://stackoverflow.com/questions/1270951/how-to-refer-to-relative-paths-of-resources-when-working-with-a-code-repository Related