Update: improving relation with opencv

some bug fixes and merging with Shleime's code