Refactor code to loadOpenCV