creatale / node-dv

A node.js library for processing and understanding scanned documents
Other
340 stars 72 forks source link

Question about your pix8ToMat #45

Open Juddd opened 6 years ago

Juddd commented 6 years ago

https://github.com/creatale/node-dv/blob/3b0c5265d74bfb0f4b811fde525d76aad7126169/src/image.cc#L164-L175

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.