opencv-mat

OpenCv create 3 channel Mat from continuous data array

老子叫甜甜 提交于 2020-07-06 11:27:10
问题 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, CV_8UC3, rawData); // This works only if rawData interleaves channel data like an OpenCv Mat Is there a way to create an OpenCV Mat without having to resort to the below solution of splitting channels from a temporary Mat and copying the right channel

Access elements of multidimentional cv::Mat array

陌路散爱 提交于 2020-01-25 08:07:52
问题 I cannot figure out how to properly access elements of a 3D cv::Mat array. The following code runs in Vivado HLS and fails with a non-descriptive error. Is this a problem with the Vivado HLS, or I am not properly reading values? cv::Mat img = cv::Mat(cv::Size(100,100),CV_MAKETYPE(CV_8U,5)); // should create a 100x100x5 array uchar x; x = img.at<uchar>(0,0,0); // works fine when reading from third dimension at 0 x = img.at<uchar>(0,0,1); // fails when reading from third dimension at 1 Error:

Size of Matrix OpenCV

[亡魂溺海] 提交于 2019-12-17 17:26:22
问题 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 and columns. And is there a way to directly obtain the maximum value of a 2D matrix? 回答1: cv:Mat mat; int rows = mat.rows; int cols = mat.cols; cv::Size s = mat.size(); rows = s.height; cols = s.width; Also note that stride >= cols; this means that

Multidimensional cv::Mat initialization and display

梦想与她 提交于 2019-12-12 06:14:03
问题 Being a Matlab/Python guy and a novice in C++, I'm having major frustration moving to OpenCV in C++ for image processing purposes. I'm working with Kinect v2 so there is only one Windows example I found online which I'm modifying. This example gives the depthMap as a cv::Mat and I've calculated surface normals on this depth image taken from a kinect v2. This surface normal image contains the i,j,k vector components (3 channels) per row,col element and I'm trying to visualize this surface

Size of Matrix OpenCV

喜你入骨 提交于 2019-11-28 03:21:43
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 and columns. And is there a way to directly obtain the maximum value of a 2D matrix? Michael O cv:Mat mat; int rows = mat.rows; int cols = mat.cols; cv::Size s = mat.size(); rows = s.height; cols = s.width; Also note that stride >= cols; this means that actual size of the row can be greater than element size x cols. This is different from the issue

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

社会主义新天地 提交于 2019-11-26 14:07:50
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 or in a couple of books in vain. Here is a handy function you can use to help with identifying your opencv matrices at runtime. I find it useful for debugging, at least. string type2str(int type) { string r; uchar depth = type & CV_MAT_DEPTH_MASK; uchar chans = 1 + (type >> CV_CN_SHIFT); switch ( depth ) { case CV_8U: r = "8U"; break; case CV_8S: r

How to crop a CvMat in OpenCV?

孤人 提交于 2019-11-26 09:29:53
问题 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 which I am unable to do so. Is there a method or a function that could crop a CvMat Matrix and return another cropped CvMat matrix? thanks. 回答1: OpenCV has region of interest functions which you may find useful. If you are using the cv::Mat then

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

核能气质少年 提交于 2019-11-26 03:47:57
问题 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 or in a couple of books in vain. 回答1: Here is a handy function you can use to help with identifying your opencv matrices at runtime. I find it useful for debugging, at least. string type2str(int type) { string r; uchar depth = type & CV_MAT