Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

nice, that you found that !

i think, you should read the pixels directly into a cv::Mat (and skip that buf variable):

Mat getPixels() {

    // allocate 8bit pixel data, 1 or 3 channels:

Mat img( pxd_imageYdim(), pxd_imageXdim(), pxd_imageCdim() == 1 ? CV_8UC1 : CV_8UC3);

    pxd_readuchar(0x1, 1, 0, 0, -1, -1, (void*)img.data,  // <-- here we pass allocated mem.
            pxd_imageXdim() * pxd_imageYdim() * pxd_imageCdim(),
            pxd_imageCdim() == 1 ? "Grey" : "RGB");
    return img;

}

then, you might have to convert RGB to BGR (or not, just be aware...)

nice, that you found that !

i think, you should read the pixels directly into a cv::Mat (and skip that buf variable):

Mat getPixels() {

    // allocate 8bit pixel data, 1 or 3 channels:

Mat img( pxd_imageYdim(), pxd_imageXdim(), pxd_imageCdim() == 1 ? CV_8UC1 : CV_8UC3);

CV_8UC3);
    pxd_readuchar(0x1, 1, 0, 0, -1, -1, (void*)img.data,  // <-- here we pass allocated mem.
            pxd_imageXdim() * pxd_imageYdim() * pxd_imageCdim(),
            pxd_imageCdim() == 1 ? "Grey" : "RGB");
    return img;

}

then, you might have to convert RGB to BGR (or not, just be aware...)

nice, that you found that !

i think, you should read the pixels directly into a cv::Mat (and skip that buf variable):

Mat getPixels() {

    // allocate 8bit pixel data, 1 or 3 channels:
    Mat img( pxd_imageYdim(), pxd_imageXdim(), pxd_imageCdim() == 1 ? CV_8UC1 : CV_8UC3);

    pxd_readuchar(0x1, 1, 0, 0, -1, -1, (void*)img.data,  // <-- here we pass allocated mem.
            pxd_imageXdim() * pxd_imageYdim() * pxd_imageCdim(),
            pxd_imageCdim() == 1 ? "Grey" : "RGB");
     return img;

}

then, you might have to convert RGB to BGR (or not, just be aware...)