added opencv code form opencv.org