converting library to use OpenCV