使用sys给python运行程序传参
import sys
def main(argv1,argv2):img1 = cv2.imread(argv1)img2 = cv2.imread(argv2)final=Image_Stitching().blending(img1,img2)cv2.imwrite('panorama.jpg', final)
if __name__ == '__main__':try: main(sys.argv[1],sys.argv[2])except IndexError:print ("Please input two source images: ")print ("For example: python Image_Stitching.py '/Users/linrl3/Desktop/picture/p1.jpg' '/Users/linrl3/Desktop/picture/p2.jpg'")
cmd命令行,执行:
python Image_Stitching [/PATH/img1] [/PATH/img2]