changed code to opencv2