|
cv::Mat pix8ToMat(PIX *pix8) |
|
{ |
|
cv::Mat mat(cv::Size(pix8->w, pix8->h), CV_8UC1); |
|
uint32_t *line = pix8->data; |
|
for (uint32_t y = 0; y < pix8->h; ++y) { |
|
for (uint32_t x = 0; x < pix8->w; ++x) { |
|
mat.at<uchar>(y, x) = GET_DATA_BYTE(line, x); |
|
} |
|
line += pix8->wpl; |
|
} |
|
return mat; |
|
} |
I know this code can convert the pix into Mat
Pix *p = pixRead("mytif.tif");
Mat mat1 = pix8ToMat(p);
But this code will fail to convert the Pix into Mat
Mat image = imread("danger_module.png", 0);
cvtColor(image, image, CV_GRAY2BGR);
api->SetImage(image.data, image.cols, image.rows, 3, 3 * image.cols);
Pix* page_pix = api->GetThresholdedImage();
Mat mat2 = pix8ToMat(page_pix);
I just can view the page_pix by pixWrite("tessinput.png", page_pix, IFF_PNG); now. I think the question is derive from your pix8ToMat. Help please.
node-dv/src/image.cc
Lines 164 to 175 in 3b0c526
I know this code can convert the pix into Mat
But this code will fail to convert the Pix into Mat
I just can view the
page_pixbypixWrite("tessinput.png", page_pix, IFF_PNG);now. I think the question is derive from yourpix8ToMat. Help please.