There is a IplImage and CvMat in OpenCV. What are the full names of them?
IPL in IplImage stands for Intel Processing Library, which is a remnant of when OpenCV was maintained by Intel.
CV in cvMat stands for Computer Vision Matrix, which is a data structure commonly used in graphics.
IplImage is an old structure, which I believe is internally converted into cv::Mat, or just Mat if you're in the cv namespace already. Likewise, cvMat is converted into Mat as well.
http://opencv.willowgarage.com/documentation/cpp/basic_structures.html?highlight=iplimage
Related
I'm brand new to rust. I have a vector of vectors (Vec<Vec<f32>>) containing values between 0 and 1, and I need to convert it to an openCV Mat so that I can use the algorithms in opencv::imgproc on it.
Could anyone give me some advice on how to do this?
I am using OpenCV and also want to add some of cool functions from mlpack, which is using Armadillo matrices.
Is there an easy way to convet between cv::Mat and arms::mat?
Thanks!
OpenCV's Mat has a pointer to its data. Armadillo has a constructor that is capable of reading from external data. It's easy to put them together. Remember that Armadillo stores in column-major order, whereas OpenCV uses row-major. I suppose you'll need to add another step for transformation, before or after.
cv::Mat opencv_mat; //opencv's mat, already transposed.
arma::mat arma_mat( reinterpret_cast<double*>opencv_mat.data, opencv_mat.rows, opencv_mat.cols )
The cv::Mat constructor has a form that accepts pointer to data, and arma::mat has a function for a double* pointer to its data called memptr().
So, if you'd like to convert from arma::mat to cv::Mat, this should work:
cv::Mat opencv_mat( rows, cols, CV_64FC1, arma_mat.memptr() )
Here is OpenCV types:
vector<Point> vectorPoint;
Mat mat;
What is equivalent types in EMGU of the types above?
Mat mat; changes to
Matrix<TDepth> mat;
which is in the Emgu.CV namespace. TDepth would be float, int, etc.
vector vectorPoint; changes to
VectorOfPoint vectorPoint;
which is in Emgu.CV.Util
I am not sure the earliest version of EMGU that VectorOfPoint is in, but it is not in as of 2.2.1. The latest as of this posting is 2.4.2, so it's likely in by now.
I am new to opencv and I have a data array for a binary image, like [1,0,0,1,1,0,0,1...]. My goal is to read it in opencv and manipulate it with opencv functions, so how to create a binary image from raw data array with opencv?
you can easily create a Mat from that data :
unsigned char bits[] = {1,0,0,1,1,0,0,1,1};
Mat m( 3,3, CV_8UC1, bits );
if your bits were an int[] you'd have to use CV_32SC1.
I have 3 matrices (R G B) in double precision format, so all I need is OpenCV version of matlab cat function to display image. If you have any sources or references please post, I would be grateful.
There is merge() for such tasks. I'm assuming that you're using C++ for the following example code, but this function is available for C and Python too (see docs).
// Suppose you have 3 matrices (instances of class cv::Mat)
// named channelR, channelG and channelB that hold your data
std::vector<cv::Mat> channels;
channels.push_back(channelR);
channels.push_back(channelG);
channels.push_back(channelB);
cv::Mat outputImage;
merge(channels, outputImage);