Show multiple (2,3,4,…) images in the same window in OpenCV

后端 未结 6 1870
臣服心动
臣服心动 2020-12-13 07:11

I want to show 2, 3 or more images in the same window.

My problem is how to put the second, third image just on the right side (above, left or upper) the main image.

6条回答
  •  渐次进展
    2020-12-13 07:54

    The answer depends on which interface you are using (C or C++). General workflow is

    • Create an image (cv::Mat for C++, IplImage* for C) big enough to accomodate your composed image
    • Copy your images into the big image
      • C++: Use the Mat::Mat(const Mat& m, const Range& rowRange, const Range& colRange) constructor to get a cv::Mat pointing to a subimage of your original window, then use the copyTo method to copy your small image into the big one
      • C: set a ROI in the big image and copy your small image into it
    • Display your big image

提交回复
热议问题