Michaelvilleneuve / react-native-perspective-image-cropper

Perform custom crop, resizing and perspective correction 📐🖼
MIT License
306 stars 127 forks source link

Ditch OpenCV in favor of native iOS Core graphics code #2

Closed Michaelvilleneuve closed 5 years ago

Michaelvilleneuve commented 7 years ago

Some issues with native iOS library CoreGraphics forced me to use openCV. But the following code is very close to work, just need to figure out in which orientation the result image must be

 rectangleCoordinates[@"inputTopLeft"] = [CIVector vectorWithCGPoint:newLeft];
 rectangleCoordinates[@"inputTopRight"] = [CIVector vectorWithCGPoint:newRight];
 rectangleCoordinates[@"inputBottomLeft"] = [CIVector vectorWithCGPoint:newBottomLeft];
 rectangleCoordinates[@"inputBottomRight"] = [CIVector vectorWithCGPoint:newBottomRight];
 [image imageByApplyingFilter:@"CIPerspectiveCorrection" withInputParameters:rectangleCoordinates];
mikasjoman commented 7 years ago

Any progress on this? I am having major issues importing OpenCV to my project. It just wont build at all. Cheers

Michaelvilleneuve commented 7 years ago

Hi, I haven't been able to work on it for the last two weeks. I was even thinking of adding a pure JS solution but I wont be able to work on it before next week.

In the meantime could you please post an issue regarding your error. I'll try to help, it may help other people as well.

trymbill commented 6 years ago

I would love to see this in there. OpenCV is a pretty big library so having it replaced with something that we get natively with iOS would be a huge bonus. Thanks for a great package!

willelundborg commented 6 years ago

Hi @Michaelvilleneuve - Can I ask if you will still attempt to tackle this topic? Thanks!

Michaelvilleneuve commented 6 years ago

hi @willelundborg, no unfortunalty I'm not working actively on this anymore

willelundborg commented 6 years ago

Ok, I understand. What was the remaining issue about determining orientation you mentioned in the original issue? Do you think its worth if I try to get someone else to take a look?

Michaelvilleneuve commented 6 years ago

Sure that would be great. Try with the above code you will see :). I could not manage to get the orientation right. iOS core Image uses a specific orientation when computing image and I believe I was not providing coordinates in the right order. It worked sometimes but the image was reversed. Eventually I missed something and it could be easy to fix :).

Michaelvilleneuve commented 5 years ago

This has been fixed by 1832cb84a2ccd6369f098655788fd5d4093b6be4 :)