Questions tagged [opencv-mat]

A part of OpenCV API

An OpenCV API part: http://docs.opencv.org/modules/core/doc/basic_structures.html

65 questions
156
votes
5 answers

Size of Matrix OpenCV

I know this might be very rudimentary, but I am new to OpenCV. Could you please tell me how to obtain the size of a matrix in OpenCV?. I googled and I am still searching, but if any of you know the answer, please help me. Size as in number of rows…
Lakshmi Narayanan
  • 5,220
  • 13
  • 50
  • 92
152
votes
6 answers

How to find out what type of a Mat object is with Mat::type() in OpenCV?

I am kind of confused with type() method of Mat object in OpenCV.If I have following lines: mat = imread("C:\someimage.jpg"); type = mat.type(); and type = 16, how do I find out what type of mat matrix is?.I tried to find the answer in its manual…
Tae-Sung Shin
  • 20,215
  • 33
  • 138
  • 240
73
votes
6 answers

How to crop a CvMat in OpenCV?

I have an image converted in a CvMat Matrix say CVMat source. Once I get a region of interest from source I want the rest of the algorithm to be applied to that region of interest only. For that I think I will have to somehow crop the source matrix…
Waqar
  • 957
  • 2
  • 8
  • 14
9
votes
1 answer

OpenCv create 3 channel Mat from continuous data array

I'd like to create an OpenCV 3-channel Mat using data allocated elsewhere where the pixels of each channel are together, unlike the data for an OpenCV Mat where the data from different channels is interleaved. Mat outputMat = Mat(dimY, dimX,…
locke14
  • 1,335
  • 3
  • 15
  • 36
9
votes
3 answers

Concatenate Mat in OpenCV

I have a couple of images in Mat objects all with same dimensions I'd like to create one bix cv::Mat object to hold them all So the dimension of the new matrix is: widthNew = widthOld x number of matrices, height remains unchanged. I found that such…
Moataz Elmasry
  • 2,509
  • 4
  • 27
  • 37
7
votes
1 answer

How is the comma-separated initializer of OpenCV Mat implemented with C++?

#include #include using namespace std; using namespace cv; int main() { Mat a = (Mat_(3, 3) << 0, 1, 2, 3, 4, 5, 6, 7, 8); cout << a << endl; return 0; } How is the comma-separated initializer…
chaosink
  • 1,329
  • 13
  • 27
6
votes
2 answers

How to completely free memory of cv::Mat in C++

when I try to create a cv::Mat and release it afterwards (code below), I still have (according to valgrind) a memory leak by about 1 Byte per Pixel. Does anyone know how to free the memory of an cv::Mat properly? Thanks for ansers :) Code: int…
cagcoach
  • 625
  • 7
  • 24
4
votes
2 answers

how to use opencv Mat reserve? with push_back

I want to use the opencv cv::Mat function push_back to add new rows to a matrix, but I want to precache the size of the matrix so that the data doesn't need to be constantly reallocated. The cv::mat::reserve function has a number of rows parameter,…
Geronimo
  • 430
  • 4
  • 10
4
votes
1 answer

OpenCV 3.0 - How can I create a cv::Mat from CSV string?

I'm trying to create a cv::Mat from a CSV string that I pipe from a python-script. I'm currently using python 2.7, C++ and OpenCV 3.0, and all I can find is how to do it in OpenCV 2.4, but the problem is that it differs a lot from 3.0 where the…
CrowStudio
  • 75
  • 1
  • 9
3
votes
0 answers

OpenCV - Python's Numpy.transpose by axes equivalent for cv::Mat?

I'm trying to translate the below Python code that uses numpy arrays into C++ and use cv::Mat instead of numpy: def get_face_mask(im, landmarks): im = numpy.zeros(im.shape[:2], dtype=numpy.float64) for group in OVERLAY_POINTS: …
hmt
  • 69
  • 7
3
votes
1 answer

from cvMat to QImage

i want to convert an image from cvMat type to Qimage , with my actual code the application does not work; i have did it the other way (Qimage to Mat it work fine) please tell me what is going on wrong with my code here is my code for Qimage to Mat :…
ner
  • 711
  • 3
  • 13
  • 30
3
votes
1 answer

shift image content in OpenCV

My task is to periodically update a cv::Mat m of r rows and c cols, in this way: shift by 1 column the whole m to the right, dropping away the last column at position c-1 randomly generate the new column at position 0 refresh the plot of m This…
Patrizio Bertoni
  • 2,582
  • 31
  • 43
3
votes
1 answer

C++ OpenCV not drawing circles on mat image

I've got images that are displayed using cv::Mat and I'm trying to highlight certain points with circles as so cv::namedWindow("image_window"); cv::Mat image = cv::imread(fileLoc); cv::imshow("image_window", image); /*for (unsigned int b = 0; b <…
rfho_bdss
  • 170
  • 1
  • 18
2
votes
2 answers

converting xtensor xarray to opencv mat back and forth in cpp

I am looking for a fast and reliable way to convert xt::xarray <-> cv::mat / cv::mat1f. In my specific case, I what it for 2 dimensions and datatype float, but more general answers are welcome, of course! At the moment, I have an elementwise…
Markus Dutschke
  • 9,341
  • 4
  • 63
  • 58
2
votes
1 answer

C++ openCV mat initialization

I am completely new to OpenCV and I'm trying to initialize two cv::Mat matrices from two different type of data. One is simple one-channel array of uint16_t gray values, second should hold RGB values from array of uint8_t values holding RGB 565…
kochy
  • 51
  • 9
1
2 3 4 5