Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

read camera image incorrect

I using the function of videocapture to read camera data and the camera MT9P31 is Leopard products

VideoCapture cap(0);

int Key; Mat src;

if(cap.isOpened()) { while(1) {

    cap.read(src);
    namedWindow("capture", 0);
    imshow("capture",src);

    Key = waitKey(10);
    if(Key ==27)
            break;

}}

The output is likely bayer image with green visionimage description

And the image size is not correct(640X480), it should be 2592X1944.

I have tried setting

cap.set(CV_CAP_PROP_FRAME_WIDTH, 2592);

cap.set(CV_CAP_PROP_FRAME_HEIGHT, 1944);

before

cap.read(src);

but the read image size is still 640*480

the set function is really helpful?

I try another source code which is EmguCV that based on OpenCV

it can read the correct image in RGB channel with the same camera

Is some parameters for function videocapture need I set? or have anything I miss for opencv videocapture?

read camera image incorrect

I using the function of videocapture to read camera data and the camera MT9P31 is Leopard products

VideoCapture cap(0);

int Key; Mat src;

if(cap.isOpened()) { while(1) {

    cap.read(src);
    namedWindow("capture", 0);
    imshow("capture",src);

    Key = waitKey(10);
    if(Key ==27)
            break;

}}

The output is likely bayer image with green visionimage description

And the image size is not correct(640X480), it should be 2592X1944.

I have tried setting

cap.set(CV_CAP_PROP_FRAME_WIDTH, 2592);

cap.set(CV_CAP_PROP_FRAME_HEIGHT, 1944);

before

cap.read(src);

but the read image size is still 640*480

640*480 the set function is really helpful?

helpful? I try another source code which is EmguCV that based on OpenCV

OpenCV it can read the correct image in RGB channel with the same camera

camera. Is some parameters for function videocapture need I set? or have anything I miss for opencv videocapture?

---------------------------------------------------------------------------------------------------------------------

this camera output should be bayer pattern and the size is 2952*1944

the problem of size could be solving by

cap.set(CV_CAP_PROP_FRAME_WIDTH, 2592);

cap.set(CV_CAP_PROP_FRAME_HEIGHT, 1944);

in while loop

but the format problem is still exist.

I check the format the output src.channels = 3

It is puzzled that if the channel numbers is equal to three the format would be in RGB or others in 3 channel color space, but bayer pattern is 1 channel, that means the output format is change by OpenCV function cap.read(), and the change is unknown.

another tried

Mat bayer(1944, 2592, CV_16UC1, src.data);
cvtColor(bayer ,rgb, CV_BayerRG2BGR);

It can convert the format without assertion failed, but the output is still incorrect

I guess that using the function would losing information

Mat bayer(1944, 2592, CV_16UC1, src.data);

read camera image incorrect

I using the function of videocapture to read camera data and the camera MT9P31 is Leopard products

VideoCapture cap(0);

int Key; Mat src;

if(cap.isOpened()) { while(1) {

    cap.read(src);
    namedWindow("capture", 0);
    imshow("capture",src);

    Key = waitKey(10);
    if(Key ==27)
            break;

}}

The output is likely bayer image with green visionimage description And the image size is not correct(640X480), it should be 2592X1944.

I have tried setting

cap.set(CV_CAP_PROP_FRAME_WIDTH, 2592);

cap.set(CV_CAP_PROP_FRAME_HEIGHT, 1944);

before

cap.read(src);

but the read image size is still 640*480 the set function is really helpful? I try another source code which is EmguCV that based on OpenCV it can read the correct image in RGB channel with the same camera. Is some parameters for function videocapture need I set? or have anything I miss for opencv videocapture?

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

this camera output should be bayer pattern and the size is 2952*1944

the problem of size could be solving by

cap.set(CV_CAP_PROP_FRAME_WIDTH, 2592);

cap.set(CV_CAP_PROP_FRAME_HEIGHT, 1944);

in while loop

but the format problem is still exist.

I check the format the output src.channels = 3

It is puzzled that if the channel numbers is equal to three the format would be in RGB or others in 3 channel color space, but bayer pattern is 1 channel, that means the output format is change by OpenCV function cap.read(), and the change is unknown.

another tried

Mat bayer(1944, 2592, CV_16UC1, src.data);
cvtColor(bayer ,rgb, CV_BayerRG2BGR);

It can convert the format without assertion failed, but the output is still incorrect

I guess that using the function would losing information

Mat bayer(1944, 2592, CV_16UC1, src.data);

read camera image incorrect

I using the function of videocapture to read camera data and the camera MT9P31 is Leopard products

VideoCapture cap(0);

cap(0); int Key; Mat src;

src; if(cap.isOpened()) { while(1) {

{

        cap.read(src);
     namedWindow("capture", 0);
     imshow("capture",src);

     Key = waitKey(10);
     if(Key ==27)
             break;

}}

}}

The output is likely bayer image with green visionimage description And the image size is not correct(640X480), it should be 2592X1944.

I have tried setting

cap.set(CV_CAP_PROP_FRAME_WIDTH, 2592);

2592); cap.set(CV_CAP_PROP_FRAME_HEIGHT, 1944);

1944);

before

cap.read(src);

cap.read(src);

but the read image size is still 640*480 the set function is really helpful? I try another source code which is EmguCV that based on OpenCV it can read the correct image in RGB channel with the same camera. Is some parameters for function videocapture need I set? or have anything I miss for opencv videocapture?

----------------------------------------------------------------------------------------------------------------

this camera output should be bayer pattern and the size is 2952*1944

the problem of size could be solving by

cap.set(CV_CAP_PROP_FRAME_WIDTH, 2592);

2592); cap.set(CV_CAP_PROP_FRAME_HEIGHT, 1944);

1944);

in while loop

but the format problem is still exist.

I check the format the output src.channels = 3

It is puzzled that if the channel numbers is equal to three the format would be in RGB or others in 3 channel color space, but bayer pattern is 1 channel, that means the output format is change by OpenCV function cap.read(), and the change is unknown.

another tried

Mat bayer(1944, 2592, CV_16UC1, src.data); 
cvtColor(bayer ,rgb, CV_BayerRG2BGR);

CV_BayerRG2BGR);

It can convert the format without assertion failed, but the output is still incorrect

I guess that using the function would losing information

Mat bayer(1944, 2592, CV_16UC1, src.data);             

src.data);

read camera image incorrect

I using the function of videocapture to read camera data and the camera MT9P31 is Leopard products

VideoCapture cap(0);

int Key;
Mat src;

if(cap.isOpened())
{
    while(1)
{

        cap.read(src);
        namedWindow("capture", 0);
        imshow("capture",src);

        Key = waitKey(10);
        if(Key ==27)
                break;
}}

The output is likely bayer image with green visionimage description And the image size is not correct(640X480), it should be 2592X1944.

I have tried setting

cap.set(CV_CAP_PROP_FRAME_WIDTH, 2592);

cap.set(CV_CAP_PROP_FRAME_HEIGHT, 1944);

before

cap.read(src);

but the read image size is still 640*480 the set function is really helpful? I try another source code which is EmguCV that based on OpenCV it can read the correct image in RGB channel with the same camera. Is some parameters for function videocapture need I set? or have anything I miss for opencv videocapture?

----------------------------------------------------------------------------------------------------------------

this camera output should be bayer pattern and the size is 2952*1944

the problem of size could be solving by

cap.set(CV_CAP_PROP_FRAME_WIDTH, 2592);

cap.set(CV_CAP_PROP_FRAME_HEIGHT, 1944);

in while loop

but the format problem is still exist.

I check the format the output src.channels = 3

It is puzzled that if the channel numbers is equal to three the format would be in RGB or others in 3 channel color space, but bayer pattern is 1 channel, that means the output format is change by OpenCV function cap.read(), and the change is unknown.

another tried

Mat bayer(1944, 2592, CV_16UC1, src.data);              
cvtColor(bayer ,rgb, CV_BayerRG2BGR);

It can convert the format without assertion failed, but the output is still incorrect

(All type of bayer pattern I have tried)

image description

I guess that using the function would losing information

Mat bayer(1944, 2592, CV_16UC1, src.data);

read camera image incorrect

I using the function of videocapture to read camera data and the camera MT9P31 is Leopard products

VideoCapture cap(0);

int Key;
Mat src;

if(cap.isOpened())
{
    while(1)
{

        cap.read(src);
        namedWindow("capture", 0);
        imshow("capture",src);

        Key = waitKey(10);
        if(Key ==27)
                break;
}}

The output is likely bayer image with green visionimage description And the image size is not correct(640X480), it should be 2592X1944.

I have tried setting

cap.set(CV_CAP_PROP_FRAME_WIDTH, 2592);

cap.set(CV_CAP_PROP_FRAME_HEIGHT, 1944);

before

cap.read(src);

but the read image size is still 640*480 the set function is really helpful? I try another source code which is EmguCV that based on OpenCV it can read the correct image in RGB channel with the same camera. Is some parameters for function videocapture need I set? or have anything I miss for opencv videocapture?

----------------------------------------------------------------------------------------------------------------

this camera output should be bayer pattern and the size is 2952*1944

the problem of size could be solving by

cap.set(CV_CAP_PROP_FRAME_WIDTH, 2592);

cap.set(CV_CAP_PROP_FRAME_HEIGHT, 1944);

in while loop

but the format problem is still exist.

I check the format the output src.channels = 3

It is puzzled that if the channel numbers is equal to three the format would be in RGB or others in 3 channel color space, but bayer pattern is 1 channel, that means the output input format is change by OpenCV function cap.read(), and the change is unknown.

another tried

Mat bayer(1944, 2592, CV_16UC1, src.data);              
cvtColor(bayer ,rgb, CV_BayerRG2BGR);

It can convert the format without assertion failed, but the output is still incorrect

(All type of bayer pattern I have tried)

image description

I guess that using the function would losing information

Mat bayer(1944, 2592, CV_16UC1, src.data);

read camera image incorrect

I using the function of videocapture to read camera data and the camera MT9P31 is Leopard products

VideoCapture cap(0);

int Key;
Mat src;

if(cap.isOpened())
{
    while(1)
{

        cap.read(src);
        namedWindow("capture", 0);
        imshow("capture",src);

        Key = waitKey(10);
        if(Key ==27)
                break;
}}

The output is likely bayer image with green visionimage description And the image size is not correct(640X480), it should be 2592X1944.

I have tried setting

cap.set(CV_CAP_PROP_FRAME_WIDTH, 2592);

cap.set(CV_CAP_PROP_FRAME_HEIGHT, 1944);

before

cap.read(src);

but the read image size is still 640*480 the set function is really helpful? I try another source code which is EmguCV that based on OpenCV it can read the correct image in RGB channel with the same camera. Is some parameters for function videocapture need I set? or have anything I miss for opencv videocapture?

----------------------------------------------------------------------------------------------------------------

I got it!

The problem is causing by a function which is translating raw data to bayer pattern.

The camera input is raw in 12 bits format, as reading the camera data that one element is separated to two bytes (low byte and high byte)

We need to merge this camera output should be two byte to a int format(0~2^8 -> 0~2^16).

OpenCV has a mistake in the data merging, so I got the wrong image first.

I coding that translating raw data to bayer pattern and the size is 2952*1944

the problem of size could be solving by

cap.set(CV_CAP_PROP_FRAME_WIDTH, 2592);

cap.set(CV_CAP_PROP_FRAME_HEIGHT, 1944);

in while loop

but the format problem is still exist.

I check the format the output src.channels = 3

It is puzzled that if the channel numbers is equal to three the format would be in RGB or others in 3 channel color space, but bayer pattern is 1 channel, that means the input format is change by OpenCV function cap.read(), and the change is unknown.

another tried

Mat bayer(1944, 2592, CV_16UC1, src.data);              
cvtColor(bayer ,rgb, CV_BayerRG2BGR);

It can convert the format getting the correct result without assertion failed, but the output is still incorrect

(All type of bayer pattern I have tried)

image description

I guess that using the function would losing information

Mat bayer(1944, 2592, CV_16UC1, src.data);
white balance.

image description

read camera image incorrect

I using the function of videocapture to read camera data and the camera MT9P31 is Leopard productsdata

VideoCapture cap(0);

int Key;
Mat src;

if(cap.isOpened())
{
    while(1)
{

        cap.read(src);
        namedWindow("capture", 0);
        imshow("capture",src);

        Key = waitKey(10);
        if(Key ==27)
                break;
}}

The output is likely bayer image with green visionimage description And the image size is not correct(640X480), it should be 2592X1944.2592X1944 in raw 12 bits.

I have tried setting

cap.set(CV_CAP_PROP_FRAME_WIDTH, 2592);

cap.set(CV_CAP_PROP_FRAME_HEIGHT, 1944);

before

cap.read(src);

but the read image size is still 640*480 the set function is really helpful? I try another source code which is EmguCV that based on OpenCV it can read the correct image in RGB channel with the same camera. Is some parameters for function videocapture need I set? or have anything I miss for opencv videocapture?

----------------------------------------------------------------------------------------------------------------

I got it!

The problem is causing by a function which is translating raw data to bayer pattern.

The camera input is raw in 12 bits format, as reading the camera data that one element is separated to two bytes (low byte and high byte)

We need to merge this two byte to a int format(0~2^8 -> 0~2^16).

OpenCV has a mistake in the data merging, so I got the wrong image first.

I coding that translating raw data to bayer pattern and getting the correct result without white balance.

image description

read camera image incorrect

I using the function of videocapture to read camera data

VideoCapture cap(0);

int Key;
Mat src;

if(cap.isOpened())
{
    while(1)
{

        cap.read(src);
        namedWindow("capture", 0);
        imshow("capture",src);

        Key = waitKey(10);
        if(Key ==27)
                break;
}}

The output is likely bayer image with green visionimage description And the image size is not correct(640X480), it should be 2592X1944 in raw 12 bits.

I have tried setting

cap.set(CV_CAP_PROP_FRAME_WIDTH, 2592);

cap.set(CV_CAP_PROP_FRAME_HEIGHT, 1944);

before

cap.read(src);

but the read image size is still 640*480 the set function is really helpful? I try another source code which is EmguCV that based on OpenCV it can read the correct image in RGB channel with the same camera. Is some parameters for function videocapture need I set? or have anything I miss for opencv videocapture?

----------------------------------------------------------------------------------------------------------------

I got it!

The problem is causing by a function which is translating raw data to bayer pattern.

The camera input is raw in 12 bits format, as reading the camera data that one element is separated to two bytes (low byte and high byte)

We need to merge this two byte to a int format(0~2^8 -> 0~2^16).

OpenCV has a mistake in the data merging, so I got the wrong image first.

I coding that translating raw data to bayer pattern and getting the correct result without white balance.

image description