Closed danmoebius closed 5 years ago
Could be closed. I found the issue on my own, regarding to wrong rectangle coordinates.
How did you solve this? Can you post your code, please?
Hi armin,
i solved this problem by pre calculation of the rectangle coordinates.
`getImageCroppingInformations = (imageWidth, imageHeight) => { let ratio = imageHeight / imageWidth; let calculatedWidth = width; let calculatedHeight = calculatedWidth * ratio;
let positionLeft =
calculatedWidth * DEFAULT_MARGIN_CROPPING_HANDLER_PERCENT;
let positionRight =
(calculatedWidth - doubleCroppingViewMargin) *
(1 - DEFAULT_MARGIN_CROPPING_HANDLER_PERCENT);
if (imageHeight > imageWidth) {
ratio = imageWidth / imageHeight;
calculatedWidth = height * ratio;
calculatedHeight = determineHeight(
DEFAULT_HEADER_HEIGHT + DEFAULT_BOTTOM_CONTROLS_HEIGHT
);
}
let positionTop =
calculatedHeight * DEFAULT_MARGIN_CROPPING_HANDLER_PERCENT;
let positionBottom =
(calculatedHeight - doubleCroppingViewMargin) *
(1 - DEFAULT_MARGIN_CROPPING_HANDLER_PERCENT);
return {
positionLeft: positionLeft,
positionRight: positionRight,
positionTop: positionTop,
positionBottom: positionBottom,
calculatedWidth: calculatedWidth,
calculatedHeight: calculatedHeight
};
};`
But in fact, we kicked this repository out of our project, because it does not fulfill our expectations. In my humble opinion, in general check your requirements and think about to build by your own for more stability, customizability and update capability. Best regards
@danmoebius was there an alternative library that you found to provide this perspective-cropping functionality? I'm currently stuck on a similar issue
@cdcharlebois i am sorry, I have no alternativ Library. I changed a lot of these library to make it useful for our case. But I think the best method will be a custom solution on your case with opencv. I know it is more work, but you are save in case of updates.
If you find another library. Let us know 😊 Best regards
please see my PR #64
Hi, i got to implement your package in my react native app. But i get trouble with the output image. If i use the full image size as rectangle coordinates, i will get only a part of the document, but not the full one. Second problem is, that the image will be on head. Have you any idea to solve these troubles? How decide opencv to get only part of the document? If there any properties to handle opencv?
Origin Document:![origin](https://user-images.githubusercontent.com/5362336/52132560-b308bc00-263f-11e9-9d12-d8ce7c23a0b0.png)
Cropped:![cropped](https://user-images.githubusercontent.com/5362336/52132602-c87de600-263f-11e9-9944-3b8c049ebe67.png)
Best regards