Changed where the conversion from cv::Mat to float* happens, plus found possible problem with memory allocation