首页 > 代码库 > opencv png和jpg的叠加

opencv png和jpg的叠加

char *bgFile = "C:/C_Project/HandTraining/Debug/res/bg.jpg";    FILE *file = fopen(bgFile, "r");    if (file == NULL){        cout << "bg.jpg文件不存在..." << endl;        return -1;    }    char *handFile = "C:/C_Project/HandTraining/Debug/res/hand002.png";    file = fopen(handFile, "r");    if (file == NULL){        cout << "hand0001.png文件不存在..." << endl;        return -1;    }    Mat image = imread(bgFile);    Mat hand = imread(handFile);    Mat mask = imread(handFile,0);    Mat imageROI = image(Rect(30, 120, hand.cols, hand.rows));        hand.copyTo(imageROI,mask);            //addWeighted(imageROI, 1.0, hand, 0.3, 0, imageROI);    cv::imwrite("C:/C_Project/HandTraining/Debug/res/result.jpg", image);        imshow("result", image);    waitKey();    cv::destroyAllWindows();

 

opencv png和jpg的叠加