1 | initial version |
So the Question is How to copy one Image to a part of another image?
int _tmain(int argc, _TCHAR* argv[])
{
String FileName1="\\opencv-master\\samples\\data\\lena.jpg",
FileName2="\\opencv-master\\samples\\data\\opencv-logo.png";
Mat mSrc,mSrc_Crop,mSubImage;
Rect rtFaceROI(200,170,160,230);
mSrc= imread(FileName1,1);
mSubImage= imread(FileName2,1);
if(mSrc.empty()||mSubImage.empty())
{
cout<<"[Error]! Invalid Input Image\n";
return 0;
}
imshow("mSrc",mSrc);
imshow("Sub Image",mSubImage);
resize(mSubImage,mSubImage,Size(rtFaceROI.width,rtFaceROI.height));
mSrc_Crop= mSrc(rtFaceROI);//To Set an ROI
mSubImage.copyTo(mSrc_Crop);
imshow("Sub Image",mSrc);
waitKey();
}
Input Image
Output Image