OpenCV draw an image over another image

前端 未结 4 469
礼貌的吻别
礼貌的吻别 2020-12-07 21:06

Is there an OpenCV function to draw an image over another image? I have one big image of Mat type. And I have a small image of Mat type (5x7<

4条回答
  •  隐瞒了意图╮
    2020-12-07 21:35

    void zoomImage(Mat &src, Mat &dst, int scale_percent)
    {
    
        //# percent of original size
        int width = int(src.cols * scale_percent / 100);
        int height = int(src.rows * scale_percent / 100);
        Size dim = Size(width, height);
        //pyrUp(tmp, dst, Size(tmp.cols * 2, tmp.rows * 2));
        resize(src, dst, dim, 0.0, 0.0, INTER_CUBIC);
    
        if (scale_percent < 100)
        {
    
            Mat srcR =Mat::zeros(Size(640,480),src.type()) ;
            int rstart = (src.rows - height) / 2;
            int rend = height;
            int cstart = (src.cols - width) / 2;
            int cend = width;
            dst.copyTo(srcR.rowRange( rstart, dst.rows+ rstart).colRange(cstart,dst.cols+ cstart));
            dst = srcR.clone();
    
        }
        else
        {
            Mat  ROI(dst, Rect((width - src.cols) / 2, (height - src.rows) / 2, src.cols, src.rows));
              dst = ROI.clone();
        }
    
    }
    

提交回复
热议问题