Hi.
I am trying to extract a region of interest from an opencv 2 Mat
I first generate a new Mat from my kinect depth pixels.
Then i am defining a cv::rect from one of the found contours.
define a ROI-image and try to drawMat.
But the image is jumbled.
Am I doing something wrong in connections to width and height being flipped when working with Mat?
thx.
myGlobal->grayImageMat = Mat(myGlobal->kinect.height, myGlobal->kinect.width, CV_8UC1, myGlobal->kinect.getDepthPixels(), 0);
if(myGlobal->contourFinder.size() > 0){
cv::Rect boundRect = myGlobal->contourFinder.getBoundingRect(0);
Mat matROI = myGlobal->grayImageMat(cv::Rect(boundRect.x,boundRect.y,boundRect.width,boundRect.height));
drawMat(matROI, boundRect.x,boundRect.y);
}
ok got it finally.
if(bNewFrame) {
background.update(vidPlayer, thresholded);
thresholded.update();
convertColor(vidPlayer, sourceMat, CV_RGB2GRAY);
contourFinder.setThreshold(126);
contourFinder.findContours(sourceMat);
for(int i = 0; i < contourFinder.size(); i++) {
cv::Rect boundRect = contourFinder.getBoundingRect(i);
sourceMat(boundRect).copyTo(matROI);
}
}
here i copy a part of one video and past it into an other.
for(int i = 0; i < contourFinder.size(); i++) {
cv::Rect boundRect = contourFinder.getBoundingRect(i);
//define which part of the live video we are interested in
sourceMat(boundRect).copyTo(matROI);
//make a solid white image
whiteImg = Mat(vidPlayer.height,vidPlayer.width,CV_8UC1,cv::Scalar(255));
//define in to which part we want to add things
Mat whiteImg_TargetROI = whiteImg(boundRect);
//combine two source imaged in to a third, the third can be one of the source images
addWeighted(whiteImg_TargetROI, 0, matROI, 1, 0, whiteImg_TargetROI);
drawMat(whiteImg, 0,0);
drawMat(matROI, mouseX, mouseY);
}
but a problem i am noticing is, when i now do any sort of calculations on the combined image, it still only considers the ROI and resulting points are also just within the ROI.
not sure how to reset ROI of the image.