Hello,
I have a problem and i need your help, when i read a video, i want to apply a mask in each frame (make pixels black in a ROI (Rectangle),
i used :
imv.copyTo(ImvMasked, im2MasqueRectangle);
imv : is the frame of the video.
im2MasqueRectangle : is the mask, for me it's a rectangle, that change dimension for every frame, i don't add code how i get the rectangle because it's very long.
ImvMasked : is the result of applying the mask in the image imv.
My problem is the result is not an image masked, but the mask is deformed, it's like instead of showing black pixels it's shows the preview frame.
//read the video
VideoCapture cap("box.mp4");
for (;;)
{
cap >> im; // get a new frame from camera
if (!im.data)
{
//std::cout << "Image not loaded";
return -1;
}
//Creation of the mask
Mat im2MasqueRectangle(im.rows, im.cols, CV_8UC1, Scalar(255, 255, 255));
//bounding_rect is the ROI i want to mask i don't add how i get it because the code is very long.
rectangle(im2MasqueRectangle, bounding_rect, cv::Scalar(0, 0, 0),-1);
//Here i add the mask to the image
imv.copyTo(fondEnCours, im2MasqueRectangle);
imshow("fond en cours", fondEnCours);
}
I can't figure out why i am having this problem, i need your help and thank you.