Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You should use the same name of the window in imshow function. Something like:

for (std::size_t i = 0, i < imgsPaths.size(); i++) // if you have a vector of images' paths
{
  cv::Mat img = cv::imread(imgsPaths[i]);
  cv::imshow("same window", img);
  cv::waitKey(); // for seeing the displayed image until key pressed
}

You should use the same name of the window in imshow function. Something like:

for (std::size_t i = 0, i < imgsPaths.size(); i++) // if you have a vector of images' paths
{
  cv::Mat img = cv::imread(imgsPaths[i]);
  cv::imshow("same window", img);
  cv::waitKey(); // for seeing the displayed image until key pressed
}

I am not sure what you want, so I am adding also another thing: If you want to display two images in the same window, you can do something like:

cv::Mat img1 = cv::imread("../img1.png");
cv::Mat img2 = cv::imread("../img2.png");
cv::Mat img3;
img3.push_back(img1);
img3.push_back(img2);
cv::imshow("img3", img3);
cv::waitKey();

Or if you want to display them one next to each other, then you'll need to play a little more (like create a zero Mat of Size(width1 + width2, max(height1, height2)) and just copy the images in the specific places)