2 dim matrix, how can it be
Hello. I hope you all are fine.
Im new with this API and as every newbie I need a little help here. I'm using a banana pi m2 and a usb cam (a genius one). First of all I want to check the camera paramters, so:
#include <stdio.h>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui.hpp>
using namespace cv;
using namespace std;
int main(int argc,char ** argv)
{
VideoCapture cap(0);
if (!cap.isOpened()) {
cerr << "ERROR: Unable to open the camera" << endl;
return 0;
}
Mat frame1, frame;
cout << "Start grabbing, press a key on Live window to terminate" << endl;
cap >> frame1;
if (frame1.empty())
{
cerr << "ERROR: Unable to grab from the"<<endl;
}
int i, j, k,z;
i=frame1.dims;
j=frame1.cols;
k=frame1.rows;
z=frame1.type();
printf("%d dim\n %d col \n %d row\n %d type\n", i, j, k, z);
return 1;
}
And this is what a I got:
Start grabbing, press a key on Live window to terminate
2 dim
640 col
480 row
16 type
How can be a matrix 2 dimension??? So, thats means that it has just 2 colors? its a two channel?
Also, a 16 type means CV_8U. So there is 8 bits per color(R G or B)? because VGA use 6bits per color Thanks in advance.
the dimension you're missing is in
frame.channels()
(3) and it is BGR ordered(but it is not really a "dimension", since the pixels are interleaved)
Thanks.
But, what do you means when you said "the pixels are interleaved"? Thats ones question that I still have because there is 8bits per color (RGB) on CV_8U and every matrix element (pixel) has 32 bits?? and thats pixel with RGB color are consecutive?
again it is BGR, not RGB in opencv (and also numpy). like b g r b g r b g r .... (so yes, consecutive, not in seperate color planes (like it is in matlab)
also, that would make 24bits per pixel, not 32 (alpha has no real use in computer-vision)
Thanks a lot and the last one:
So if CV_8U has a deep pixel of 24bits that implies that CV_32F has 96 bits?
CV_8U == a single channel (grayscale, 8 bit image)
CV_8UC3 == 3 8bit channels (bgr, hsv, yuv, etc.)
CV_32F == a single channel 32bit float image
CV_32FC3 == 3 32bit float channels
CV_64FC2 == .... you'll get the picture, i hope ..
But
CV_32FC3 == 3 32bit float channels. There is 32 bits per color (B G R) and thats 96 bits deep pixel which gives 2^96 total color. For what I know the human can see 2^24 color and the alpha is just the transparency. Its not too much 96 bits? for what I know all camera works with 32 bits including alpha.
"There is 32 bits per color (B G R) and thats 96 bits deep pixel" -- exactly.
" For what I know the human can see 2^24 color " -- this is computer-vision , humans don't count ;)
also, there are a lot of Mat's that do not contain images per se, like transformations, neural network layers, distance tables, and whatnot.
" for what I know all camera works with 32 bits including alpha." -- no. cameras do not know anything about alpha. (and again, alpha is almost never used here)
Thank you very much.