Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Data types in OpenCV

Tags:

python

opencv

I'm working with OpenCV for the first time and I'm a little bit confused with data types. I am working with Python.

I see that I can store an image as:

  • Numpy array
  • CvMat
  • Iplimage

The problem I'm having is that different parts of OpenCV seem to require different types and I keep having to try and convert back and forth- it's very confusing, and I'm certain it can't have been designed this way on purpose. I'm also a bit confused about when something should be in the cv module vs cv2.cv:

import cv
import cv2.cv

Can someone explain the logic? It would really help.

Thanks!

like image 261
cjm2671 Avatar asked Jan 26 '26 14:01

cjm2671


1 Answers

  • cv (or, cv2.cv)

    is the old opencv python api, using IplImage and CvMat.

    you should not use that anymore. it's being phased out, and won't be available in the next version.

  • cv2 is the new python api, using numpy arrays for almost anything instead,

    so easy to combine with scipy, matplotlib and what not. (and , btw, much closer the the current c++ api)

like image 157
berak Avatar answered Jan 28 '26 03:01

berak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!