Hi all,
Just trying to write a simple app that on the press of a button waits 3 seconds and takes a photo via rear camera (selfie) and store the image on the device photo album.
So far I attempted examples from the forum and from the LiveCode manuals I purchased (pages 750 - 754 which do not work at all as indicated). I have set permissions for the camera.
Depending on the attempt the most I can get is the android camera app to come up with the front camera not the rear and once the camera takes the picture it does not store it on the device.
Any help from the forum would be great.
Thanks,
Patrick
Android Camera access and save
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Android Camera access and save
Hi Patrick,
Firstly, are you using mobilepickphoto function?
Secondly, when the camera lauches, is there a button for you to switch it to rear camera?
Lastly, did you set the filepath of the image?
Firstly, are you using mobilepickphoto function?
Secondly, when the camera lauches, is there a button for you to switch it to rear camera?
Lastly, did you set the filepath of the image?
Eddie
-
- Posts: 4
- Joined: Wed May 08, 2013 12:21 pm
Re: Android Camera access and save
Thank you for your reply,
Here are some examples I have tried:
on mouseUp
-- set the virtual camera
cameraControlCreate"myFirstCamera"
cameraControlSet "MyFirstCamera", "rect", "0,0,0,0" -- it seems necessary on Android, on iPhone doesn't
cameraControlSet "myFirstCamera", "device", "front"
-- give time for the camera to settle
wait for 3 seconds
-- take the picture
cameraControlDo "myFirstCamera", "takePicture"
--answer the result
put the result into img "Img1"
set the visible of img "Img1" to true
end mouseUp
Example 2:
mobilePickPhoto "camera"
set the defaultFolder to "/mnt/sdcard/DCIM/"
put last image into url("binfile:" & milliseconds() & ".jpg")
Example 3:
on mouseUp
cameraControlDo "myFirstCamera", "takePicture"
put the result into image 1
put the long ID of the last image into tImageID
mobileExportImageToAlbum tImageID
end mouseUp
It appears direct control of the cameras on an android device is not possible. The camera app will come up in it's default mode and seems to take a picture but does not save. Plus I can not force which camera to use.
A good code sample that works and saves to the device photoAlbum would be great!
Patrick
Here are some examples I have tried:
on mouseUp
-- set the virtual camera
cameraControlCreate"myFirstCamera"
cameraControlSet "MyFirstCamera", "rect", "0,0,0,0" -- it seems necessary on Android, on iPhone doesn't
cameraControlSet "myFirstCamera", "device", "front"
-- give time for the camera to settle
wait for 3 seconds
-- take the picture
cameraControlDo "myFirstCamera", "takePicture"
--answer the result
put the result into img "Img1"
set the visible of img "Img1" to true
end mouseUp
Example 2:
mobilePickPhoto "camera"
set the defaultFolder to "/mnt/sdcard/DCIM/"
put last image into url("binfile:" & milliseconds() & ".jpg")
Example 3:
on mouseUp
cameraControlDo "myFirstCamera", "takePicture"
put the result into image 1
put the long ID of the last image into tImageID
mobileExportImageToAlbum tImageID
end mouseUp
It appears direct control of the cameras on an android device is not possible. The camera app will come up in it's default mode and seems to take a picture but does not save. Plus I can not force which camera to use.
A good code sample that works and saves to the device photoAlbum would be great!
Patrick
-
- VIP Livecode Opensource Backer
- Posts: 7237
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Android Camera access and save
In your first example, what do you get in the result after executing cameraControlDo? After taking the picture, do you get a visible image on the card? Also, did you check the "write external storage" permission in the Android standalone settings? You can't write to disk without that.
I'd use your third example to export the image. The dictionary says that an exported image goes into the default picture folder; on Android I'd assume that's DCIM but it also may be a folder named Pictures. See if it's there. Don't use your second example, the file path will vary among different devices, and mobilePickPhoto isn't what you want anyway. I'd use the third example and let the LC engine figure out where the default folder is.
It looks like you need a combination of the first example to set up the camera control and take the photo, and the third example to export the image. I haven't actually used the camera control, but theoretically the above should work.
I'd use your third example to export the image. The dictionary says that an exported image goes into the default picture folder; on Android I'd assume that's DCIM but it also may be a folder named Pictures. See if it's there. Don't use your second example, the file path will vary among different devices, and mobilePickPhoto isn't what you want anyway. I'd use the third example and let the LC engine figure out where the default folder is.
It looks like you need a combination of the first example to set up the camera control and take the photo, and the third example to export the image. I haven't actually used the camera control, but theoretically the above should work.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com