Skip to content

Instantly share code, notes, and snippets.

@z4none
Created December 28, 2018 02:06
Show Gist options
  • Select an option

  • Save z4none/2d4975edd7271dc0dedeed3531bb07f0 to your computer and use it in GitHub Desktop.

Select an option

Save z4none/2d4975edd7271dc0dedeed3531bb07f0 to your computer and use it in GitHub Desktop.
int width = m_view_size.width();
int height = m_view_size.height();
uint8_t * data = new uint8_t[width * height * 4];
m_gles2->ReadPixels(m_context->pp_resource(), 0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
cv::Mat rgbFrame, outputFrame;
cv::Mat glFrame = cv::Mat(height, width, CV_8UC4, data);
cv::cvtColor(glFrame, rgbFrame, CV_BGRA2RGB);
cv::flip(rgbFrame, outputFrame, 0);
cv::imwrite("d:\\1.bmp", outputFrame);
delete[] data;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment