Ask Your Question
0

Convert PByte to Mat

asked 2015-09-24 17:09:46 -0600

Eisen gravatar image

Hi, I am using PS3 camera with opencv it works with PByte data type.Gives PByte as frame result.In SDK samples they use IplImage.I want use Mat instead IplImage.But i cant convert PByte to Mat.How can i convert PByte to Mat ? Example In SDK

    IplImage *pCapImage;
    PBYTE pCapBuffer = NULL;
    cvGetImageRawData(pCapImage, &pCapBuffer);
    while(_running)
        {
            cvGetImageRawData(pCapImage, &pCapBuffer);
            CLEyeCameraGetFrame(_cam, pCapBuffer, (i==0)?2000:0);
}

//Function from SDK

IMPORT(bool) CLEyeCameraGetFrame(CLEyeCameraInstance cam, PBYTE pData, int waitTimeout = 2000);

//MyCode //I use 2 camera.

    cv::Mat pCapImage[2];
    PBYTE pCapBuffer = NULL;
    while(_running){

        for (int i = 0; i < 2; i++)
                {
                                  //trying convert
                    pCapImage[i] = cv::Mat (cvSize(w, h), 4, &pCapBuffer,IPL_DEPTH_8U).clone();

                    CLEyeCameraGetFrame(_cam[i], pCapBuffer);
                }

                Mat pCapImageMatL = pCapImage[0];
                Mat pCapImageMatR = pCapImage[1];
                imshow(_windowNameL, pCapImageMatL);
                imshow(_windowNameR, pCapImageMatR);
}
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-09-24 17:58:23 -0600

updated 2015-09-25 02:58:46 -0600

thdrksdfthmn gravatar image

as mentioned here Take a look at the documentation

example usage:

void process_video_frame(const unsigned char* pixels,
                         int width, int height, int step)
{
    Mat img(height, width, CV_8UC3, pixels, step);
    GaussianBlur(img, img, Size(7,7), 1.5, 1.5);
}
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-09-24 17:09:46 -0600

Seen: 307 times

Last updated: Sep 25 '15