Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dewarping issue #694

Open
kraw-ios opened this issue May 17, 2023 · 1 comment
Open

Dewarping issue #694

kraw-ios opened this issue May 17, 2023 · 1 comment

Comments

@kraw-ios
Copy link

Screenshot 2023-05-16 at 16 35 38 Screenshot 2023-05-16 at 16 35 38

Hey, I have an issue with dewarping this image example. I get the following logs:

Info in dewarpGetTextlineCenters: finding text line centers
Warning in dewarpBuildPageModel: linecount 2 < min req'd number of lines (10) for model
Info in dewarpaSetValidModels: page 35: no model successfully built
Info in dewarpaApplyInit: no valid dew model for page 35
Error in dewarpaApplyDisparity: no model available
Error in getFilenamesInDirectory: pdir not opened
Error in getSortedPathnamesInDirectory: sa not made
Error in convertFilesToPdf: sa not made

I tried to deskew but without any success. Do you think it might be because it's to curved? Because I'm able to get the lines drawn on the document.
Here's my code, do you have any suggestions?

var pixn = pixBackgroundNormSimple(pixs, nil, nil);
        var pixg = pixConvertRGBToGray(pixn, 0.5, 0.3, 0.2);
        var pixb = pixThresholdToBinary(pixg, 130);
        let dewa = dewarpaCreate(2, 30, 1, 10, 90);
       dewarpaUseBothArrays(dewa, 1);
let dew1 = dewarpCreate(pixb, 35);
        dewarpaInsertDewarp(dewa, dew1);
        dewarpBuildPageModel(dew1, modelPath.relativePath);
        dewarpaApplyDisparity(dewa, 35, pixg, 200, 0, 0, &pixd, disparityPath.relativePath);

Maybe it's worth mentioning that it also fails for the "1555-3.jpg" example and I tried using versions 1.72 and 1.79.

@kraw-ios
Copy link
Author

kraw-ios commented May 30, 2023

I was able to fix it by changing the input image and also the curvature values allowed. Now I'm facing another issue that I can't really find any documentation or solution for it. The dewarped results become way worse than the original ones as you can see in the following examples.
I get the following debug info:

Info in dewarpFindVertDisparity: Pass 1: Curvature: medval = 0.000075, meddev = 0.000023
Info in dewarpFindVertDisparity: Pass 2: Min/max curvature = (13, 123)
Info in dewarpFindHorizDisparity: Left quad LSF median error = 0.73
Info in dewarpFindHorizDisparity: Left edge slope = 10
Info in dewarpFindHorizDisparity: Left edge curvature = -3
Info in dewarpFindHorizDisparity: Right quad LSF median error = 11.27
Info in dewarpFindHorizDisparity: Right edge slope = 4
Info in dewarpFindHorizDisparity: Right edge curvature = 3
Info in dewarpBuildPageModel: hsuccess = 1

Is it possible to somehow only apply the disparity to one side of the image without reducing the curvature line curv maximum value?

Original
original

Dewarped
dewarped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant