This is my first time using media.capturePhoto() api. I want to make a scene in my app where the user touches a button in the app menu and open the camera to take a photo of some surface. Then I wanted to reduce and multiply it in 9 images organized as the attached photo. Below those images would have 15 buttons that would change the color of the background square where the images will be multiplied. As I am a new programmer I do not have any type of experience with the use of the camera. I read the “Corona SDK > Sample Code> Media> Camera” but I do not really understand it yet.
Doubts:
* Can I use that same “Camera” example in my app and just change some things? How?
* Can I use only the example code in the api page of media.capturePhoto() as a part of my scene?
* In which part of the scene (create>show>hide>destroy) I must use the function correctly to avoid memory
leaks?
* It is better not to reduce or multiply the image just send it back and put my other objects in front to simulate
it’s reduce/multiply?
I would like to know how to manipulate the captured photo as one more object in my scene.
Attachment info:
--Light gray is my backgroung
–square Is what changes color when I touch one of the buttons
–9 white tiles is the reduce/multiply same captured image
–rectangle is the color change buttons background
@roaminggamer: Thanks for the fast answer. I would like to try to write it by myself. I want to develop the ability to gradually learn more about programming. If you can guide me where to start reading I would appreciate it.
@roaminggamer – Thanks for your quick response. Looks very good material, I will study it carefully. I have 80% of my App already made. I have tested it on 26 different Android devices including a ‘Live Wire’ Android device from the government program with no problems. I did everything by adjusting for my needs what I learned from the Getting Started guide. Now, to have my App 100% I only need to learn how to handle objects that are the result of media.capturePhoto. I searched all over google, youtube, the Corona forum, look up under my bed too but did not find anything that could clarify my doubt about the handling of those objects. So I decided to create this topic to see if someone clarified my mind and to be able to go ahead with this project and others that I have already planned. I really want to learn because I would like to do business with this and be a client of Corona Enterprise in the not too distant future.
-- cam button function local function camButtonTouch( event ) if ( event.phase == "began" ) then if media.hasSource( media.Camera ) then media.capturePhoto( { listener=onComplete } ) else native.showAlert( "Corona", "This device does not have a camera.", { "OK" } ) end elseif ( event.phase == "ended" ) then print( "camera is ready to take a photo" ) end return true end -- camera function local function onComplete( event ) local photo = event.target print( "photo w,h = " .. photo.width .. "," .. photo.height ) end
The scene opens, when I touch the camera widget button (Corona simulator) I get the alert that says “Corona”, “This device does not have a camera.” But after clicking ok I can not leave the scene, neither the return button works, anywhere I touch the alert returns again and again. The only way to return for menu is relaunching the app.
I am working hard, reading a lot, practicing a lot. Step by step I clarify my doubts. If I can not solve my problem I will prepare the project to upload it with the information you ask me.
Hi. You keep writing posts saying " I have some doubts". My guess is English is not your first language and you’re translating your questions. That is cool, but let me give you a small correction.
The phrase you are seeking is, " I have some questions".
Cheers,
Ed
I’m not picking on you here, just thought you might want to know. :)
You are correct that English is not my first language. I’m learning, and sometimes struggle with grammar, especially when trying to compose a message. I want to thank you for all of the help you provide for me, and all others like me, who come to forum in search of the knowledge that professionals such as yourself are able to provide.
@roaminggamer: Thanks for the fast answer. I would like to try to write it by myself. I want to develop the ability to gradually learn more about programming. If you can guide me where to start reading I would appreciate it.
@roaminggamer – Thanks for your quick response. Looks very good material, I will study it carefully. I have 80% of my App already made. I have tested it on 26 different Android devices including a ‘Live Wire’ Android device from the government program with no problems. I did everything by adjusting for my needs what I learned from the Getting Started guide. Now, to have my App 100% I only need to learn how to handle objects that are the result of media.capturePhoto. I searched all over google, youtube, the Corona forum, look up under my bed too but did not find anything that could clarify my doubt about the handling of those objects. So I decided to create this topic to see if someone clarified my mind and to be able to go ahead with this project and others that I have already planned. I really want to learn because I would like to do business with this and be a client of Corona Enterprise in the not too distant future.
-- cam button function local function camButtonTouch( event ) if ( event.phase == "began" ) then if media.hasSource( media.Camera ) then media.capturePhoto( { listener=onComplete } ) else native.showAlert( "Corona", "This device does not have a camera.", { "OK" } ) end elseif ( event.phase == "ended" ) then print( "camera is ready to take a photo" ) end return true end -- camera function local function onComplete( event ) local photo = event.target print( "photo w,h = " .. photo.width .. "," .. photo.height ) end
The scene opens, when I touch the camera widget button (Corona simulator) I get the alert that says “Corona”, “This device does not have a camera.” But after clicking ok I can not leave the scene, neither the return button works, anywhere I touch the alert returns again and again. The only way to return for menu is relaunching the app.