submited opencv patch by ponyma