Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

It is usefull to deal with OpenCV's documentation before asking such basic questions. What you need is cv::Mat::convertTo with CV_32S and CV_8U as rtype and if you want to convert 2D matrix to 1D array use cv::reshape

It is usefull useful to deal with OpenCV's documentation before asking such basic questions. What you need is cv::Mat::convertTo with CV_32S and CV_8U as rtype and if you want to convert 2D matrix to 1D array use cv::reshape

It is useful to deal with OpenCV's documentation before asking such basic questions. What you need is cv::Mat::convertTo with CV_32S and CV_8U as rtype and if you want to convert 2D matrix to 1D array use cv::reshape

It is useful to deal with OpenCV's documentation before asking such basic questions. What you need is cv::Mat::convertTo with CV_32S and CV_8U as rtype and if you want to convert 2D matrix to 1D array use cv::reshape

It is useful to deal with OpenCV's documentation before asking such basic questions. What you need is cv::Mat::convertTo with CV_32S and CV_8U as rtype and if you want to convert 2D matrix to 1D array use cv::reshape

It is useful to deal with OpenCV's documentation before asking such basic questions. What you need is cv::Mat::convertTo with CV_32S and CV_8U as rtype and if you want to convert 2D matrix to 1D array use cv::reshape. You can use Mat as C++ array using

cv::Mat img, imgconv;
img.convertTo(imgconv, CV_32S);

for(int i = 0; i < imgconv.rows; ++i) {
    int *ptrarray = imgconv.ptr<int>(i);
    for(int ii = 0; ii < imgconv.cols; ++ii) {
         int x = ptrarray[i];
    }
}

It is useful to deal with OpenCV's documentation before asking such basic questions. What you need is cv::Mat::convertTo with CV_32S and CV_8U as rtype and if you want to convert 2D matrix to 1D array use cv::reshape. You can use Mat as C++ C array using

cv::Mat img, imgconv;
img.convertTo(imgconv, CV_32S);

for(int i = 0; i < imgconv.rows; ++i) {
    int *ptrarray = imgconv.ptr<int>(i);
    for(int ii = 0; ii < imgconv.cols; ++ii) {
         int x = ptrarray[i];
    }
}

It is useful to deal with OpenCV's documentation before asking such basic questions. What you need is cv::Mat::convertTo with CV_32S and CV_8U as rtype and if you want to convert 2D matrix to 1D array use cv::reshape. You can use 1 channel Mat as C array using

cv::Mat img, imgconv;
img.convertTo(imgconv, CV_32S);

if(imgconv.isContinuous() {
    imgconv = imgconv.reshape(1, 1);
}

for(int i = 0; i < imgconv.rows; ++i) {
    int *ptrarray = imgconv.ptr<int>(i);
    for(int ii = 0; ii < imgconv.cols; ++ii) {
         int x = ptrarray[i];
    }
}

It is useful to deal with OpenCV's documentation before asking such basic questions. What you need is cv::Mat::convertTo with CV_32S and CV_8U as rtype and if you want to convert 2D matrix to 1D array use cv::reshapecv::Mat::reshape. You can use 1 channel Mat as C array using

cv::Mat img, imgconv;
img.convertTo(imgconv, CV_32S);

if(imgconv.isContinuous() {
    imgconv = imgconv.reshape(1, 1);
}

for(int i = 0; i < imgconv.rows; ++i) {
    int *ptrarray = imgconv.ptr<int>(i);
    for(int ii = 0; ii < imgconv.cols; ++ii) {
         int x = ptrarray[i];
    }
}

It is useful to deal with OpenCV's documentation before asking such basic questions. What you need is cv::Mat::convertTo with CV_32S and CV_8U as rtype and if you want to convert 2D matrix to 1D array use cv::Mat::reshape. You can use 1 channel Mat as C array using

cv::Mat img, imgconv;
img.convertTo(imgconv, CV_32S);

if(imgconv.isContinuous() {
    imgconv = imgconv.reshape(1, 1);
}

for(int i = 0; i < imgconv.rows; ++i) {
    int *ptrarray = imgconv.ptr<int>(i);
    for(int ii = 0; ii < imgconv.cols; ++ii) {
         int x = ptrarray[i];
    }
}

It is useful to deal with OpenCV's documentation before asking such basic questions. What you need is cv::Mat::convertTo with CV_32S and CV_8U as rtype and if you want to convert 2D matrix to 1D array use cv::Mat::reshape. You can use 1 channel Mat as C array using

cv::Mat img, imgconv;
img.convertTo(imgconv, CV_32S);

if(imgconv.isContinuous() {
    imgconv = imgconv.reshape(1, 1);
}

for(int i = 0; i < imgconv.rows; ++i) {
    int *ptrarray = imgconv.ptr<int>(i);
    for(int ii = 0; ii < imgconv.cols; ++ii) {
         int x = ptrarray[i];
ptrarray[ii];
    }
}

It is useful to deal with OpenCV's documentation before asking such basic questions. What you need is cv::Mat::convertTo with CV_32S and CV_8U as rtype and if you want to convert 2D matrix to 1D array use cv::Mat::reshape. You can use handle 1 channel Mat as C array usingwith

cv::Mat img, imgconv;
img.convertTo(imgconv, CV_32S);

if(imgconv.isContinuous() {
    imgconv = imgconv.reshape(1, 1);
}

for(int i = 0; i < imgconv.rows; ++i) {
    int *ptrarray = imgconv.ptr<int>(i);
    for(int ii = 0; ii < imgconv.cols; ++ii) {
         int x = ptrarray[ii];
    }
}

It is useful to deal with OpenCV's documentation before asking such basic questions. What you need is cv::Mat::convertTo with CV_32S and CV_8U as rtype and if you want to convert 2D matrix to 1D array use cv::Mat::reshape. You can handle 1 channel Mat as C array withwith cv::Mat::ptr

cv::Mat img, imgconv;
img.convertTo(imgconv, CV_32S);

if(imgconv.isContinuous() {
    imgconv = imgconv.reshape(1, 1);
}

for(int i = 0; i < imgconv.rows; ++i) {
    int *ptrarray = imgconv.ptr<int>(i);
    for(int ii = 0; ii < imgconv.cols; ++ii) {
         int x = ptrarray[ii];
    }
}

It is useful to deal with OpenCV's documentation before asking such basic questions. What you need is cv::Mat::convertTo with CV_32S and CV_8U as rtype and if you want to convert 2D matrix to 1D array use cv::Mat::reshape. You can handle 1 channel Mat as C array with cv::Mat::ptr

// example for 1 channel Mat
cv::Mat img, imgconv;
img.convertTo(imgconv, CV_32S);

if(imgconv.isContinuous() {
    imgconv = imgconv.reshape(1, 1);
}

for(int i = 0; i < imgconv.rows; ++i) {
    int *ptrarray = imgconv.ptr<int>(i);
    for(int ii = 0; ii < imgconv.cols; ++ii) {
         int x = ptrarray[ii];
    }
}