SciPy/NumPy import guideline

前端 未结 3 507
猫巷女王i
猫巷女王i 2021-02-08 09:10

Notice: I checked for duplicate and nothing clearly answers my question. I trust you\'ll let me know if I missed something!

In an effort to clean up my code, I have been

3条回答
  •  情话喂你
    2021-02-08 09:57

    What about making classes and use just what you will need, fx: class one:

    import cv2
    from SIGBWindows import SIGBWindows
    from SIGBAssg import *
    

    class two:

    import cv2
    import numpy as np
    
    from pylab import *
    from scipy.cluster.vq import *
    from scipy.misc import imresize
    

    class three:

    import cv2
    import numpy as np
    

    and Finally where we call the object:

    import cv2
    from SIGBWindows import SIGBWindows
    from SIGBAssg import *
    
    windows = SIGBWindows(mode="video")
    windows.openVideo("somevideo.avi")
    kmeans(windows)
    

    I don't know if it is what you are looking for, but this approach it makes the code really clean and easy to add more features to it.

提交回复
热议问题