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
4
votes
3 answers

How to convert mat to array2d?

I created dll for the dlib face landmark code there used array2d to get the image, but i like to read an image using Mat and to convert to array2d because dlib supports only array2d. Can any one say how to convert mat to array2d ??
Jayabalaji V
  • 79
  • 1
  • 1
  • 8
4
votes
0 answers

How to use MatVector in JavaCV

Hi I'm trying to write some camera calibration code and I'm having a hard time using MatVectors in JavaCV that should be the equivalents of std::vec in C++. This is how i generate my image and object points: Mat objectPoints = new…
Marc
  • 767
  • 1
  • 10
  • 23
4
votes
3 answers

Display image using Mat in OpenCV Java

I am writing my first program in OpenCV in Java and I'd like to ask, is it possible to load and display image from file only using Mat? I found solution on this website…
pupilx
  • 75
  • 1
  • 2
  • 10
4
votes
2 answers

opencv split vs mixChannels

To separate hue channel from HSV image, here is the code using the mixChannels function: /// Transform it to HSV cvtColor( src, hsv, CV_BGR2HSV ); /// Use only the Hue value hue.create( hsv.size(), hsv.depth() ); int ch[] = { 0, 0 }; mixChannels(…
tidy
  • 4,747
  • 9
  • 49
  • 89
4
votes
1 answer

Error in findnonzero() while storing the coordinates of non zero elements in vector

I was trying to store the non-zero elements indices of a Mat img1 into vector vp1 but it shows an cv::Exception at memory location error. This happens when the mat does not contain any non-zero element. Example code is below. where finding non-zero…
sAm
  • 193
  • 1
  • 1
  • 10
4
votes
5 answers

OpenCV How to initialize Mat with 2D array in JAVA

Suppose, I have a 2D array initialized with values, how do I put this value in a Mat object in OpenCV?
Rabbir
  • 47
  • 1
  • 2
  • 6
4
votes
2 answers

Check if Mat is a black image

Maybe an easy question but since I am a noob I dont know how to do it in an elegant way. I am analyzing video. For that I am taking differences between the frames. If nothing has changed the resulting frame will be empty or black if I display it…
user2175762
  • 271
  • 1
  • 6
  • 13
4
votes
2 answers

Get the mean of sequence of frames

I want to calculate the mean of the sequence of frames by adding them and then divide by the total number of frames. The problem is that i can't access the pixels in the image. I used this code. for(i = 1; i <= N; i++){ image =…
Fadwa
  • 1,717
  • 5
  • 26
  • 43
4
votes
1 answer

Template Matching in Android using openCV

I'm trying to match an image with the camera input in Android using template matching. When i try this with static 2 images like in here: OpenCV Template Matching example in Android, everything works just fine. But when I try to use the captured…
TharakaNirmana
  • 10,237
  • 8
  • 50
  • 69
4
votes
4 answers

How to read the text file and create Mat object in C++

Hi i have being able to write a Mat object in to a text file. As follows, std::fstream outputFile; outputFile.open( "myFile.txt", std::ios::out ) ; outputFile << des_object.rows << std::endl; outputFile << des_object.cols <<…
posha
  • 881
  • 4
  • 16
  • 28
4
votes
5 answers

How to Access rows and columns of Vector Images on Open cv for Android?

I was going through some code on open cv using Android.Can any one show me how I am gonna access the rows and columns of a vector Mat of image?Its declared and the columns and rows are accessed as given below but i am having errors like and…
Sisay
  • 681
  • 7
  • 16
  • 31
4
votes
1 answer

Does a const Mat reference in OpenCV make sense?

In the following function foo(const Mat& img) img can be changed in the function without even a warning by the compiler. Why? Does it mean const Mat reference don't make any sense?
beaver
  • 550
  • 1
  • 9
  • 23
4
votes
1 answer

Removing selected rows from opencv::Mat?

For some reasons I need to filter out rows of a Mat. (I need to filter out some descriptors of ORB) Which way do you suggest me? I haven't find any method to remove a single row from a Mat. So I was thinking I could iteratively inserting the good…
anon
4
votes
2 answers

cv::mat to UIImage conversion not recovering exact image

I am using this function to convert cv::mat to UIImage. -(UIImage *)UIImageFromCVMat:(cv::Mat)cvMat { NSData *data = [NSData dataWithBytes:cvMat.data length:cvMat.elemSize()*cvMat.total()]; CGColorSpaceRef colorSpace; if…
Nik
  • 682
  • 1
  • 8
  • 27
4
votes
1 answer

How to access findNonZero coordinates stored in Mat C++

I am a beginner with OpenCV and I have read some tutorials and manuals but I couldn't quite make sense of some things. Currently, I am trying to crop a binary image into two sections. I want to know which row has the most number of white pixels and…
user2253922
  • 125
  • 1
  • 4
  • 10