Questions tagged [mat]

Use this tag for questions dealing with opencv cv::Mat (or cvMat) data structure. Use [mat-file] tag for Matlab binary file format. Use [matrix] tag for other types of 2D numeric data structures.

cv::Mat (or cvMat) is a basic data structure defined by to handle tabular (2D or 3D) numeric data.

DO NOT CONFUSE THIS TAG WITH
for general data structures for tabular numeric data.
for Matlab's binary file format.

941 questions
69
votes
4 answers

Pandas: Creating DataFrame from Series

My current code is shown below - I'm importing a MAT file and trying to create a DataFrame from variables within it: mat = loadmat(file_path) # load mat-file Variables = mat.keys() # identify variable names df = pd.DataFrame #…
BMichell
  • 3,581
  • 5
  • 23
  • 31
54
votes
3 answers

c++ and opencv get and set pixel color to Mat

I'm trying to set a new color value to some pixel into a cv::Mat image my code is below: Mat image = img; for(int y=0;y(Point(x,y)); …
grll
  • 1,047
  • 2
  • 10
  • 18
37
votes
1 answer

What is the difference between UMat and Mat in OpenCV?

I have been through the documentation and didn't get a clear detailed description about UMat; however I think it has something to relate with GPU and CPU. Please help me out. Thank you.
Aniket Sharma
  • 471
  • 1
  • 4
  • 8
37
votes
4 answers

convert Bitmap to Mat after capture image using android camera

Mat b = new Mat(); Bitmap bmp = getIntent().getExtras().getParcelable("image_send"); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_display_image); Mat…
John
  • 445
  • 2
  • 6
  • 10
37
votes
1 answer

Change type of Mat object from CV_32F to CV_8U

I tried to display an image of CV_32F type using imshow function but it showed a WHITE image. In the Documentation its given that floating point images will be mapped to 0-255 and displayed but it just showed a white image.I tried to convert it to…
Karthik Murugan
  • 1,595
  • 4
  • 19
  • 26
36
votes
6 answers

How to write a Float Mat to a file in OpenCV

I have a matrix, Mat B(480,640,CV_32FC1); containing floating-point values. I want to write this matrix to a file which could be opened in Notepad or Microsoft Word or Excel to see the values inside and for storage, but the imwrite function can save…
Karthik Murugan
  • 1,595
  • 4
  • 19
  • 26
35
votes
9 answers

Converting `BufferedImage` to `Mat` in OpenCV

How can I convert a BufferedImage to a Mat in OpenCV? I'm using the JAVA wrapper for OpenCV(not JavaCV). As I am new to OpenCV I have some problems understanding how Mat works. I want to do something like this. (Based on Ted W.…
Jompa234
  • 1,228
  • 2
  • 14
  • 24
32
votes
2 answers

Can I determine the number of channels in cv::Mat Opencv

This maybe rudimentary, but is it possible to know how many channels a cv::Mat has? For eg, we load an RGB image, I know there are 3 channels. I do the following operations, just to get the laplacian of the image, which is straight from the Opencv…
Lakshmi Narayanan
  • 5,220
  • 13
  • 50
  • 92
27
votes
2 answers

How to capture the desktop in OpenCV (ie. turn a bitmap into a Mat)?

I want to use OpenCV to process my desktop as if it were a video stream. I am familiar with OpenCV. I am not familiar with the Windows API. I realize there are other ways to capture the screen, but for the purposes of my question, I need it to be…
john k
  • 6,268
  • 4
  • 55
  • 59
25
votes
5 answers

Conversion from IplImage* to cv::MAT

I searched to convert an IplImage* to Mat, but all answers were about the conversion to cvMat. How, can I do it? and what is the difference between Mat and cvMat? Thanks in advance
user1807367
21
votes
3 answers

How do i get the size of a multi-dimensional cv::Mat? (Mat, or MatND)

I am creating a multi-dimensional MAT object, and would like to get the size of the object - e.g., const int sz[] = {10,10,9}; Mat temp(3,sz,CV_64F); std::cout << "temp.dims = " << temp.dims << " temp.size = " << temp.size() << " temp.channels = "…
Pete
  • 2,336
  • 2
  • 16
  • 23
20
votes
2 answers

Compress Mat into Jpeg And save the result into memory

I know that the function cv::imwrite can compress a cv::Mat into Jpeg and save it to a file. But now I want to save it into memory, like a array of uchar. So, I can send the array to another one ,and it can write the data into a jpeg file. Is there…
charlie
  • 267
  • 1
  • 3
  • 15
19
votes
1 answer

Efficiently load a large Mat into memory in OpenCV

Is there a more efficient way to load a large Mat object into memory than the FileStorage method in OpenCV? I have a large Mat with 192 columns and 1 million rows I want to store locally in a file and load into memory then my application starts.…
user622194
19
votes
6 answers

Copy Mat in opencv

I try to copy a image to other image using opencv, but I got a problem. Two image is not the same, like this: This is the code I used: #include #include #include…
Robotic Vn
  • 437
  • 2
  • 7
  • 20
18
votes
6 answers

How to read a v7.3 mat file via h5py?

I have a struct array created by matlab and stored in v7.3 format mat file: struArray = struct('name', {'one', 'two', 'three'}, 'id', {1,2,3}, 'data', {[1:10], [3:9], [0]}) save('test.mat', 'struArray',…
Eastsun
  • 18,526
  • 6
  • 57
  • 81
1
2 3
62 63