1- '''opencvlib'''
2- from opencvlib .common import getimg , show , checkwaitkey , getwaitkey , showarray , play
3- from opencvlib .common import ImageInfo , Info , mosaic , eImgType , CVColors
1+ '''main init file for package opencvlib'''
2+ import os .path as _path
3+
4+ import cv2 as _cv2
5+
46
57
68IMAGE_EXTENSIONS = ('.bmp' ,
2426 '*.ppm' )
2527
2628__all__ = ['classifiers' , 'common' ,
27- 'decs' , 'distance' ,
29+ 'color' , ' decs' , 'distance' ,
2830 'edges' , 'errors' ,
2931 'faces' , 'features' ,
3032 'hogview' , 'keypoints' ,
3941#<package>.debug("debug message")
4042#<package>.critical("informational message")
4143try :
42- import os .path as _path
4344 import funclib .log as _log
4445 _logfile = _path .join (_log .RootLogger .USER_TEMP_FOLDER , 'opencvlib.log' )
4546 _rootlogger = _log .RootLogger (_logfile )
@@ -55,3 +56,17 @@ def loginfo():
5556 print (_rootlogger )
5657 except Exception as e :
5758 print ('Failed to get log info for file %s.\n Error: %s' % (_logfile , str (e )))
59+
60+
61+
62+ def getimg (img , outflag = _cv2 .IMREAD_UNCHANGED ):
63+ '''(ndarray|str)->ndarray
64+ tries to load the image if its a path and returns the loaded ndarray
65+ otherwise returns input img if it is an ndarray
66+
67+ Also consider using @decs._decs.decgetimg decorator
68+ '''
69+ if isinstance (img , str ):
70+ return _cv2 .imread (_path .normpath (img ), outflag )
71+
72+ return img
0 commit comments