Change the script to use opencv2 functions, Tested working