I access GPU memory directly to accelerate data reading
void EGLImageWrapper::CopyToCpuUnpack(cv::Mat1b &dst) { static EGLint attribs_rgba[] = { MALI_EGL_IMAGE_PLANE, MALI_EGL_IMAGE_PLANE_Y, MALI_EGL_IMAGE_ACCESS_MODE, MALI_EGL_IMAGE_ACCESS_READ_WRITE, EGL_NONE }; { void *mali_elg_img = mali_egl_image_lock_ptr(gl_img_); unsigned char *p_buf = (unsigned char*)mali_egl_image_map_buffer(mali_elg_img, attribs_rgba); unsigned char *p_tmp = tmp_buf_.ptr(); for (int i = 0; i < roi_height_adj_; i+= 16, p_tmp += roi_block_size_, p_buf += block_size_) { memcpy(p_tmp, p_buf, roi_block_size_); } mali_egl_image_unmap_buffer(mali_elg_img, attribs_rgba); mali_egl_image_unlock_ptr(gl_img_); } dst.create(cv::Size(roi_width_, roi_height_*4)); // Repack data here }