thread lock opencv functions