0

私はOpenCVがまったく初めてで、OpenCVを使用してピクセルバッファを画面の一部にコピーしようとしています。

私は次のようにします:

//In the beginning I allocate the screen buffer and create a Mat for it
void initScreen(int screenWidth, int screenHeight) {

      pixels = new uint8_t[screenWidth*screenHeight*BITS_PER_PIXEL];
      screenMat = new Map(Size(screenWidth, screenHeight), PIXEL_FORMAT);
      screenMat->data = pixels
}

// Here I'm getting the pixel data to display on screen and coords where they should be displayed
void onDisplayPixels(int l, int t, int w, int h, void* newPixels) 
{
      // So I set a ROI at my screen Map
      Mat roi(screenMat, cv::Rect(l, t, w, h));

      // And I create a new Mat for the new pixels 
      Mat newPixelsMat(Size(w, h), newPixels, PIXELS_FMT);


      // Now I need to copy newPixelsMat to roi 
      **But how do I do that??**
}
4

1 に答える 1

2

Mat::copyTo()を次のように使用します。

newPixelsMat.copyTo(roi);
于 2013-04-01T15:13:55.187 に答える