4
// Generate output image
cv::Mat foreground(image.size(),CV_8UC3,
      cv::Scalar(255,255,255)); // all white image
image.copyTo(foreground,result); // bg pixels not copied

The above code is written in C++ using openCV, now i need to change this to python using opencv. I couldn't find the alternate for cv::Mat . Please help me..

rakesh
  • 71
  • 1
  • 5
  • I think the equivalent is `cv.CreateMat`. Also, I suggest you check out SimpleCV. It makes things like this much, much easier. – Blender Nov 01 '12 at 17:04
  • Please try to use new OpenCV Python module "cv2". cv is kind of outdated and difficult to use. try this link for some differences : http://stackoverflow.com/questions/10417108/what-is-different-between-all-these-opencv-python-interfaces/10425504#10425504 – Abid Rahman K Nov 02 '12 at 11:05

1 Answers1

3

Opencv on python, just "import cv" then pretty much the same function names. See http://opencv.willowgarage.com/documentation/python/cookbook.html

Alternately if you install numpy opencv will return numpy arrays

Martin Beckett
  • 94,801
  • 28
  • 188
  • 263