码迷,mamicode.com
首页 > 其他好文 > 详细

opencv png和jpg的叠加

时间:2016-09-06 13:39:09      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:

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的叠加

标签:

原文地址:http://www.cnblogs.com/mypsq/p/5845216.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!