Ask Your Question
0

Convert wiki tutorial from deprecated IplImage to Mat

asked 2017-08-14 08:52:33 -0600

danieltak gravatar image

updated 2017-08-14 15:14:15 -0600

Hello, this is the Opencv's wiki tutorial: How to Display more than one image in a single window. I tried to run the code on OpenCV 3.x and didn't work.

The tutorial uses IplImage that is the legacy Intel Image Processing Library for C language. The Detailed Description of the function states:

OpenCV handles ROIs differently. OpenCV functions require that the image size or ROI size of all source and destination images match exactly. On the other hand, the Intel Image Processing Library processes the area of intersection between the source and destination images (or ROIs), allowing them to vary independently.

So to display many images in one display, the images are transformed into Regions of Interest and then allocated to the display. Which is the best way to do it on OpenCV 3.x? Use the legacy IplImage or convert to Mat.

Conversion:I was trying to convert to Mat reading some SO and Q&A threads

Is it better to convert IplImage or maybe create a new program? Is it easy to convert this tutorial?

edit retag flag offensive close merge delete

Comments

1

a question asked before maybe helpful http://answers.opencv.org/question/82812

sturkmen gravatar imagesturkmen ( 2017-08-14 09:50:44 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-08-14 09:20:24 -0600

Ziri gravatar image

updated 2017-08-14 11:18:10 -0600

Its better to convert program because you'll end up converting all functions to C++ API.

to Achieve this in another way, you can create a background image :

Mat BackgroundImage = Mat(BackImg_height, BackImg_width, CV_8UC3, Scalar(1,1,1));

then copy images to "BackgroundImage" one by one using :

Image1.copyTo(BackgroundImage.rowRange(x, x+Image1.rows).colRange(y, y+Image1.cols ));

(x, y) are image1 top left corner coordinates in BackgroundImage .

Hope it helps.

edit flag offensive delete link more

Comments

I will try now, i saw this code googling, however, does it make the program heavier? To load and copy? or is it just fine?

danieltak gravatar imagedanieltak ( 2017-08-14 09:32:12 -0600 )edit

If you're trying to display images. I think it's fine. If you're trying to display stream from video source then it's better to use GUI framework and use multithreading.

Ziri gravatar imageZiri ( 2017-08-14 09:56:22 -0600 )edit

hi Ziri, you got BackImg_width, BackImg_height and also Image1.cols and rows in reverse could you correct it ?

berak gravatar imageberak ( 2017-08-14 11:04:46 -0600 )edit

Thank you! I edited the answer.

Ziri gravatar imageZiri ( 2017-08-14 11:18:52 -0600 )edit

I tried @Ziri program and @sturkmen. Both works! Thank You! I am now trying to modify for my needs and found sturkmen's DisplayManyImages more neat than the program i made with the copy functions, because i am a newbie programmer =P

danieltak gravatar imagedanieltak ( 2017-08-15 09:43:53 -0600 )edit

@danieltak you can open a new issue about updating need for wiki page

sturkmen gravatar imagesturkmen ( 2017-08-15 10:11:25 -0600 )edit

The Github Wiki issue was opened and now is closed. The code is updated: Wiki Page Update #9375

danieltak gravatar imagedanieltak ( 2017-08-16 12:52:08 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-08-14 08:52:33 -0600

Seen: 1,254 times

Last updated: Aug 14 '17