2013-04-01 51 views
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??** 
} 

回答

2

只需使用Mat::copyTo()這樣的:

newPixelsMat.copyTo(roi); 
+0

哦,感謝它幫助! –

相關問題