Camera and Image Gallery for iOS and Android

Monkey Programming Forums/User Modules/Camera and Image Gallery for iOS and Android

CopperCircle(Posted 2015) [#1]
This is based off the Android module by:
Dominik Kollon
https://github.com/Ironstorm/bbd

I have added iOS support:
https://github.com/CopperCircle/Camera


Arabia(Posted 2015) [#2]
I'm interested in playing around with the camera function on Android. I haven't touched Monkey-X in probably 12 months, can anyone post a quick example of how I use this module? Sorry I'm still very new to Monkey even though I've had it for a couple of years, and external modules scare me somewhat :)

I want to be able to take a picture, then let the user decide if the picture is suitable in which case keep it, if not then ditch the picture and allow them to take another one?


CopperCircle(Posted 2015) [#3]
Hi, download the whole repository from GitHub and put it in a folder called camera in your Monkey modules folder, examples are included.


Arabia(Posted 2015) [#4]
Thanks.

I could have probably worked it out, just had a quick look while working and didn't have time to explore too much. I'll hopefully give it a go in the next couple of days.
'


Arabia(Posted 2015) [#5]
Finally got around to downloading this to have a play.

I haven't used Monkey in ages, so hopefully I'm only doing someghinb simple that is making this not work.

Info: Running Monkey 84e
IDE: Jungle IDE

Downloaded the full repository, and put it in the modules/camera directory as advised

Updated the Monkey Modules Database in Jungle - the new module now appears in the help.

As soon as I try to run any of the examples, I get an error:
Type 'IOnImagePickComplete' not found

Any ideas what I'm doing wrong?


Arabia(Posted 2015) [#6]
*BUMP* Anyone?


CopperCircle(Posted 2015) [#7]
Are you building for a supported target ios/android?


Arabia(Posted 2015) [#8]
Yep, building for Android.

Just tried again, building using Monkey 84e, Android (Api 10), same error message whether I try to build or run in either debug or release mode.


Xaron(Posted 2015) [#9]
I will take a look.

edit: Android compiles without issues.

Have you copied it to the right place? Folder structure:

MonkeyPro/modules_ext/camera/native/camerapicker.android.java
MonkeyPro/modules_ext/camera/native/imagepicker.android.java
MonkeyPro/modules_ext/camera/native/camerapicker.ios.cpp
MonkeyPro/modules_ext/camera/native/imagepicker.ios.cpp
MonkeyPro/modules_ext/camera/camerapicker.monkey
MonkeyPro/modules_ext/camera/imagepicker.monkey

Can you post the complete build error log please? Is your Android SDK up to date?


Arabia(Posted 2015) [#10]
I had my stuff in monkey/modules/bdm-master/camera which was how it unzipped, didn't know it had to go in modules_ext folder. Have since moved it all, to reflect exactly what you have.

Yes, the Android SDK should be up to date - had to reconfigure Jungle IDE when I downloaded Monkey 84e and I just got it to redownload the SDK, Java etc.

format_code('C:\monkey84e\MonkeyXPro84e\Bin\transcc_winnt.exe -build -config=debug -target=Android_Game_(Api_10) "C:/monkey84e/MonkeyXPro84e/modules_ext/camera/examples/camerapicker_01.monkey"
TRANS monkey compiler V1.85
Parsing...
Semanting...
C:/monkey84e/MonkeyXPro84e/modules_ext/camera/examples/camerapicker_01.monkey<20> : Error : Type 'IOnCameraPickComplete' not found
Abnormal program termination.
Exit code: -1
')


Xaron(Posted 2015) [#11]
Can you share your example code please? It can't be the original, because there is no "IOnCameraPickComplete" in line 20.


Arabia(Posted 2015) [#12]
This is the exact code from the example that I unzipped, and it is in fact line 20:

format_code('
#Rem
Title: CameraPicker example 1 - Open camera and load it in monkey
Description: Open camera and load it into monkey.

Author: Dominik Kollon
Contact: hide_email('d.kollon@blackbird-design.de')

Repository: https://github.com/Ironstorm/bbd

License: MIT
#End

Import bbd.camerapicker
Import mojo

Function Main()
New MyApp
End

Class MyApp Extends App Implements IOnCameraPickComplete

Field camerapicker:CameraPicker
Field myimage:Image

Method OnCreate()
camerapicker = New CameraPicker
camerapicker.SetScaleType(2) ' Scale the image to fit in width and height
camerapicker.SetImageSize(DeviceWidth(), DeviceHeight()) ' Scale image to the devices resolution
SetUpdateRate(60)
End

Method OnUpdate()
UpdateAsyncEvents

If TouchDown() Then
If camerapicker.HasCamera() Then camerapicker.OpenCameraPickerAsync("test", Self) ' Check if device has camera, if so open the camera
EndIf
End

Method OnRender()

End

Method OnCameraPickComplete:Void(result:String)
If result <> "" Then
myimage = LoadImage(result)
EndIf
End

End
')

p.s. thanks for your help trying to get this issue sorted out.

Unless I've somehow managed to download something different, can you post the code you have and maybe it will clear up what is going wrong.


Xaron(Posted 2015) [#13]
Your problem is here:

format_code('
Import bbd.camerapicker
')

should be
format_code('
Import camera.camerapicker
')

(or whatever your folder structure is in the modules folder)
It simply can't find the module in the path you've given. Your path is set to:

Monkey/modules/bbd/
or
Monkey/modules_ext/bbd/

I guess in this folder there is no camerapicker.monkey. BTW: it makes no difference if you put it into the modules or modules_ext folder. It's just a convinient way to put it into the _ext folder.

BTW: I've used this repo: https://github.com/CopperCircle/Camera

Download it from there, it works out of the box.


Arabia(Posted 2015) [#14]
That fixed it - well it builds, don't have my Android Tablet with me atm to see what it does, but it builds successfully. You're a champ.

So actually your folder structure is NOT like the one I've posted above.


Sorry, I thought I made it clear that I moved everything to different directories that matched what you posted thinking that that may have somehow caused my issues.

I downloaded the first link which is where a lot/all of the trouble was.

Thanks again for helping me out. Will try and have a play tomorrow to see how it all works.