Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

[Android]How to directly process ROI of preview data and display the processed data on screen?

I am processing the frame data in onPreviewFrame() function. I would like to change the left-top 1/4 part of the preview data to gray while keep the other part as colorful image. Because I am a beginner of OpenCV I don't know what is the best method. So I use a workaround: 1. change the data parameter of onPreviewFrame from yuv to rgb, then use matToBitmap() function to convert it to a bitmap. 2. change the ROI data to a gray bitmap (COLOR_GRAY2RGBA, and then matToBitmap()). 3. draw the gray bitmap onto the first bitmap I get 4. draw the bitmap on canvas. Although this method works, I still want to know whether there is a better method: can I directly process the ROI of original data and convert new whole data to a bitmap, and draw the bitmap on canvas. Is there any way I can do it?

click to hide/show revision 2
No.2 Revision

[Android]How How to directly process ROI of preview data and display the processed data on screen?

I am processing the frame data in onPreviewFrame() onPreviewFrame() function. I would like to change the left-top 1/4 part of the preview data to gray while keep the other part as colorful image. Because I am a beginner of OpenCV I don't know what is the best method. So I use a workaround: 1.

  1. change the data parameter of onPreviewFrame onPreviewFrame from yuv to rgb, then use matToBitmap() matToBitmap() function to convert it to a bitmap. 2.
  2. change the ROI data to a gray bitmap (COLOR_GRAY2RGBA, (COLOR_GRAY2RGBA, and then matToBitmap()). 3. matToBitmap()).
  3. draw the gray bitmap onto the first bitmap I get 4.
  4. draw the bitmap on canvas.

Although this method works, I still want to know whether there is a better method: can I directly process the ROI of original data and convert new whole data to a bitmap, and draw the bitmap on canvas. Is there any way I can do it?