๋ฐ˜์‘ํ˜•

OpenCV๋Š” ์ด๋ฏธ์ง€ ๋ฐ์ดํ„ฐ ๊ด€๋ฆฌ๋ฅผ ์œ„ํ•œ ๊ตฌ์กฐ์ฒด๋กœ IplImage์™€ Mat์„ ์ œ๊ณตํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

๋‘˜ ๋‹ค ์ œ๊ณตํ•œ๋‹ค๋ฉด, ์–ด๋–ค ๊ฒƒ์„ ๊ณจ๋ผ ์‚ฌ์šฉํ•ด์•ผ ํ• ๊นŒ์š”?


IplImage ๊ตฌ์กฐ์ฒด๋Š” OpenCV 1.x ๋ฒ„์ „, C์—์„œ ์ด๋ฏธ์ง€ ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•˜๊ธฐ ์œ„ํ•œ ์˜ค๋ฆฌ์ง€๋„ ํฌ๋งท์ž…๋‹ˆ๋‹ค.

์ƒ๋‹นํžˆ ์˜ค๋ž˜์ „๋ถ€ํ„ฐ ์‚ฌ์šฉํ•ด์˜จ ํฌ๋งท์ด์ง€์š”.

์ด ๊ตฌ์กฐ์ฒด๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ํ• ๋‹น(allocate)๊ณผ ํ•ด์ œ(deallocate)๋ฅผ ๋ฐ˜๋“œ์‹œ ํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค.

cvReleaseImage()์™€ ๊ฐ™์€ API๋ฅผ ์‚ฌ์šฉํ•ด์„œ ๋ง์ด์ฃ .


IplImage๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฐ„๋‹จํ•œ ์ฝ”๋“œ ์˜ˆ์ œ๋ฅผ ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

IplImage *pImage = cvLoadImage("lena.jpg");
// ... ์ž‘์—… ...
cvReleaseImage(&pImage);


Mat ๊ตฌ์กฐ์ฒด๋Š” C++์—์„œ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด ์ƒˆ๋กœ ๊ณ ์•ˆ๋œ ๋ฐ์ดํ„ฐํ˜•์ž…๋‹ˆ๋‹ค.

OpenCV 2.x ๋ฒ„์ „ ์ด์ƒ์—์„œ ์‚ฌ์šฉ์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

๊ฐ€์žฅ ํฐ ํŠน์ง•์œผ๋กœ๋Š” ๋ฉ”๋ชจ๋ฆฌ ํ•ด์ œ๊ฐ€ ์ž๋™์œผ๋กœ ํ˜ธ์ถœ๋˜๊ธฐ ๋•Œ๋ฌธ์—, ์‚ฌ์šฉ์ž๊ฐ€ ํฌ์ธํ„ฐ๋ฅผ ๊ด€๋ฆฌ ์•ˆ ํ•ด๋„ ๋œ๋‹ค๋Š” ์ ์ž…๋‹ˆ๋‹ค.


Mat๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฐ„๋‹จํ•œ ์ฝ”๋“œ ์˜ˆ์ œ๋ฅผ ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

Mat image = imread("lena.jpg");
// ... ์ž‘์—… ...

์˜ˆ์ œ๋Š” ๊ฐ„๋‹จํ•˜์ฃ ?


OpenCV 4.0-alpha Release note์—์„œ ์˜ค๋ž˜๋œ C API (OpenCV 1.x ๋ฒ„์ „๋ถ€ํ„ฐ ์‚ฌ์šฉ๋œ CvMat, IplImage, etc)๋Š” 

๋ถ€๋ถ„์ ์œผ๋กœ ์ œ์™ธ๋œ๋‹ค๊ณ  ๊ธฐ์žฌ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. (์ฐธ์กฐ ๋งํฌ)

์ด์ œ OpenCV ๋ฒ„์ „์ด ์—…๋ฐ์ดํŠธ ๋จ์— ๋”ฐ๋ผ IplImage๋Š” ์‚ฌ์šฉํ•˜์ง€ ๋ชปํ•˜๋ฉฐ, ์•ž์œผ๋กœ Mat ํ™œ์šฉ๋„๊ฐ€ ๋†’์•„์งˆ ๊ฒƒ์œผ๋กœ ์ƒ๊ฐ๋ฉ๋‹ˆ๋‹ค.


์ฐธ๊ณ  :

Stack Overflow : ๋งํฌ

OpenCV : ๋งํฌ

๋ฐ˜์‘ํ˜•