Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

What type shoukd be used cv::Mat.forEach on 16bit Greyscale (CV_16UC1)

I am trying to convert from big endian to little endian using cv::Mat.forEach however im getting this error

opencv/modules/core/include/opencv2/core/utility.hpp:609:18: error: no match for call to ‘(const cv::CvCaptureCAM_V4L::convertToRgb(const cv::Buffer&)::Operator) (short unsigned int&, int*)’

609 | operation(*reinterpret_cast<_Tp*>(0), reinterpret_cast<int*>(0));

what type should be used to get for each to work?

my currebt code is typedef ushort Pixel; cv::Mat temp(imageSize, CV_8UC1, buffers[MAX_V4L_BUFFERS].start); cv::Mat temp2(imageSize, CV_16UC1, currentBuffer.start);

    struct Operator {
        void operator ()(Pixel &pixel, const int * position) {
        ushort ptemp = pixel;
           ptemp = ptemp << 8;
           pixel = pixel >> 8;
           pixel = pixel | ptemp;
        }
    };
    temp2.forEach<Pixel>(Operator());

    temp2.convertTo(temp, CV_8U, 1.0 / 256);
    cv::cvtColor(temp, destination, COLOR_GRAY2BGR);
    return;

if anyone gas a more efficient way of doing this that would also be welcome

What type shoukd be used cv::Mat.forEach on 16bit Greyscale (CV_16UC1)

I am trying to convert from big endian to little endian using cv::Mat.forEach however im getting this error

opencv/modules/core/include/opencv2/core/utility.hpp:609:18: error: no match for call to ‘(const cv::CvCaptureCAM_V4L::convertToRgb(const cv::Buffer&)::Operator) (short unsigned int&, int*)’
int*)’   609 |         operation(*reinterpret_cast<_Tp*>(0), reinterpret_cast<int*>(0));

609 | operation(*reinterpret_cast<_Tp*>(0), reinterpret_cast<int*>(0));

what type should be used to get for each to work?

my currebt code is typedef ushort Pixel; cv::Mat temp(imageSize, CV_8UC1, buffers[MAX_V4L_BUFFERS].start); cv::Mat temp2(imageSize, CV_16UC1, currentBuffer.start);

    struct Operator {
        void operator ()(Pixel &pixel, const int * position) {
        ushort ptemp = pixel;
           ptemp = ptemp << 8;
           pixel = pixel >> 8;
           pixel = pixel | ptemp;
        }
    };
    temp2.forEach<Pixel>(Operator());

    temp2.convertTo(temp, CV_8U, 1.0 / 256);
    cv::cvtColor(temp, destination, COLOR_GRAY2BGR);
    return;

if anyone gas a more efficient way of doing this that would also be welcome

What type shoukd be used cv::Mat.forEach on 16bit Greyscale (CV_16UC1)

I am trying to convert from big endian to little endian using cv::Mat.forEach however im getting this error

opencv/modules/core/include/opencv2/core/utility.hpp:609:18: error: no match for call to ‘(const cv::CvCaptureCAM_V4L::convertToRgb(const cv::Buffer&)::Operator) (short unsigned int&, int*)’   609 |         operation(*reinterpret_cast<_Tp*>(0), reinterpret_cast<int*>(0));

what type should be used to get for each to work?

my currebt code is is

    typedef ushort Pixel;
     cv::Mat temp(imageSize, CV_8UC1, buffers[MAX_V4L_BUFFERS].start);
     cv::Mat temp2(imageSize, CV_16UC1, currentBuffer.start);

currentBuffer.start);

    struct Operator {
        void operator ()(Pixel &pixel, const int * position) {
        ushort ptemp = pixel;
           ptemp = ptemp << 8;
           pixel = pixel >> 8;
           pixel = pixel | ptemp;
        }
    };
    temp2.forEach<Pixel>(Operator());

    temp2.convertTo(temp, CV_8U, 1.0 / 256);
    cv::cvtColor(temp, destination, COLOR_GRAY2BGR);
    return;

if anyone gas a more efficient way of doing this that would also be welcome