Shape/Vertex detection and image perspective correction

Hi all,

I’m working on an app that needs to apply a perspective distortion correction to a photo taken with the phone’s camera. Once the photo is taken, the app have to detect the four corners or the shape of the document (eg: a page, a sheet of paper, etc.) and then apply the perspective correction upon this detection.

This is an example of what I’m looking for:

http://1.bp.blogspot.com/-ro9hniPj52E/TkoM0kTlEnI/AAAAAAAAAbQ/c2R5VrgmC_w/s640/s4.jpg

There is a way to do this with Corona SDK?

In case of yes, what functions I have to use?

Thanks in advance for any suggestions.

Ale 

Doing the actual correction probably isn’t such a big deal, but the detection is a non-trivial problem (and too expensive to do in Lua, generally).

However, since you’re listed as Enterprise…

Something like OpenCV might be what you’re after. The problem sounds like feature detection.

I have no idea how much work this would entail. If you did manage to put something together, though, it might be a good fit for the upcoming store, since questions like this come up a lot.

Hi StarCrunch,

thanks for your answer!

As I thought it can not be made in Corona without write a plugin.

I’m working on a business app that is completely developed with Corona SDK. The customer is asking (at the end… as usual!) a feature to capture the documents by photo camera.

During last days I have take a look to some projects that implement this feature,

https://github.com/shuhei/Rectify (Android with OpenCV library)

https://github.com/mmackh/IPDFCameraViewController (iOS without OpenCV library)

I think that look at these examples can be a good point to start.

Also, write a plugin to put in the Plugin Store can be a good idea, I had the same problem with the QR-Code detection for another app one year ago, and, at the end we had done the app in native Obj-C iOS!

So, the same is also true for a Bar/QR-Code reader or other kind of plugin.

Now, we have strong skills in iOS and Corona, but we have never worked with Android native before (it’s a choice!!), all our apps in Google Play Store are done with Corona SDK, while our iOS apps in Apple Appstore are both Obj-C and Corona.

Do you have skills in Android and advanced graphics?

Do you think you can develop this kind of feature?

And just in case, would you be interested to work with us on this feature, and what kind of effort may need to achieve a result?

I have an Enterprise license but honestly, due a lot of reasons I have never used until now!

I’m planning to spend more time in next weeks to look in deep the Enterprise version, and perform some tests.

Thank you very much for now.

Ale

You could do it in Corona. It would just be VERY , VERY slow. :D (Heavy per-pixel number-crunching, not to mention extracting those pixels in the first place.)

It looks like CoreImage on iOS has some support for this built in, as CIDetector. Relevant code seems to start around here: code

The interesting code in the Android project seems to be in RectFinder and PerspectiveTransformation.

I don’t see a license on the Rectify project, but the author seems to be reasonably active, so maybe you could just mail him.

I have done Android projects in the past, but completely forget the workflow whenever I’m done.  :P However, I don’t have Enterprise myself, and don’t think I could put in the necessary effort to learn (and use) it right now. But I’m sure there are others who could!

Hi StarCrunch,

thanks for the answer and the links on code.

I have take a litte bit of time before to reply because I have investigated more in deep looking for some solutions.

I had forced myself to download and install the Android Studio!! In 5 years on dev mobile app I never downloaded before!

I have build the Rectify project in Android after a lot of adjustments of project configuration.

After, I have installed the app on my Android tablet because the Android Simulator has a bug on Mac with Intel Core 2 Duo processor (my Mac :((  ), and I had a big surprise!

The app need the OpenCV library to run and the OpenCV Manager app MUST be installed on Android device in order to work Rectify properly!

https://play.google.com/store/apps/details?id=org.opencv.engine

I did not know before that in Android you could release apps that do absolutely nothing and act as libraries, I believe this is not allowed in iOS!

This means that even in the case I could to create a Corona Plugin with the Rectify feature (I think this not so easy to do! ) there would always be two apps working together!

At this point I might as well use the app the customer has asked me as feature, MS Office Lens, in order to capture and save the captured docs. 

https://play.google.com/store/apps/details?id=com.microsoft.office.officelens

With Office Lens the user can capture the docs and my app can use the captured files stored in the phone image gallery.

At this time I’m trying to launch Office Lens from within my Corona app but this is not working with Office Lens.

I can run other apps from within the Corona App but Office Lens.

I know this issue is out if topic and I will open another post in the proper forum.

Anyway… ideas on how to launch apps within corona are appreciated :slight_smile:

Thanks in any case for you help.

Ale

Doing the actual correction probably isn’t such a big deal, but the detection is a non-trivial problem (and too expensive to do in Lua, generally).

However, since you’re listed as Enterprise…

Something like OpenCV might be what you’re after. The problem sounds like feature detection.

I have no idea how much work this would entail. If you did manage to put something together, though, it might be a good fit for the upcoming store, since questions like this come up a lot.

Hi StarCrunch,

thanks for your answer!

As I thought it can not be made in Corona without write a plugin.

I’m working on a business app that is completely developed with Corona SDK. The customer is asking (at the end… as usual!) a feature to capture the documents by photo camera.

During last days I have take a look to some projects that implement this feature,

https://github.com/shuhei/Rectify (Android with OpenCV library)

https://github.com/mmackh/IPDFCameraViewController (iOS without OpenCV library)

I think that look at these examples can be a good point to start.

Also, write a plugin to put in the Plugin Store can be a good idea, I had the same problem with the QR-Code detection for another app one year ago, and, at the end we had done the app in native Obj-C iOS!

So, the same is also true for a Bar/QR-Code reader or other kind of plugin.

Now, we have strong skills in iOS and Corona, but we have never worked with Android native before (it’s a choice!!), all our apps in Google Play Store are done with Corona SDK, while our iOS apps in Apple Appstore are both Obj-C and Corona.

Do you have skills in Android and advanced graphics?

Do you think you can develop this kind of feature?

And just in case, would you be interested to work with us on this feature, and what kind of effort may need to achieve a result?

I have an Enterprise license but honestly, due a lot of reasons I have never used until now!

I’m planning to spend more time in next weeks to look in deep the Enterprise version, and perform some tests.

Thank you very much for now.

Ale

You could do it in Corona. It would just be VERY , VERY slow. :D (Heavy per-pixel number-crunching, not to mention extracting those pixels in the first place.)

It looks like CoreImage on iOS has some support for this built in, as CIDetector. Relevant code seems to start around here: code

The interesting code in the Android project seems to be in RectFinder and PerspectiveTransformation.

I don’t see a license on the Rectify project, but the author seems to be reasonably active, so maybe you could just mail him.

I have done Android projects in the past, but completely forget the workflow whenever I’m done.  :P However, I don’t have Enterprise myself, and don’t think I could put in the necessary effort to learn (and use) it right now. But I’m sure there are others who could!

Hi StarCrunch,

thanks for the answer and the links on code.

I have take a litte bit of time before to reply because I have investigated more in deep looking for some solutions.

I had forced myself to download and install the Android Studio!! In 5 years on dev mobile app I never downloaded before!

I have build the Rectify project in Android after a lot of adjustments of project configuration.

After, I have installed the app on my Android tablet because the Android Simulator has a bug on Mac with Intel Core 2 Duo processor (my Mac :((  ), and I had a big surprise!

The app need the OpenCV library to run and the OpenCV Manager app MUST be installed on Android device in order to work Rectify properly!

https://play.google.com/store/apps/details?id=org.opencv.engine

I did not know before that in Android you could release apps that do absolutely nothing and act as libraries, I believe this is not allowed in iOS!

This means that even in the case I could to create a Corona Plugin with the Rectify feature (I think this not so easy to do! ) there would always be two apps working together!

At this point I might as well use the app the customer has asked me as feature, MS Office Lens, in order to capture and save the captured docs. 

https://play.google.com/store/apps/details?id=com.microsoft.office.officelens

With Office Lens the user can capture the docs and my app can use the captured files stored in the phone image gallery.

At this time I’m trying to launch Office Lens from within my Corona app but this is not working with Office Lens.

I can run other apps from within the Corona App but Office Lens.

I know this issue is out if topic and I will open another post in the proper forum.

Anyway… ideas on how to launch apps within corona are appreciated :slight_smile:

Thanks in any case for you help.

Ale