scan environment code
Using heap allocation to avoid matrix copy problems with old Alvar C-sytle OpenCV code