B4A Library Advanced Camera Library V1.00

UPDATE! - Zoom, Current & Supported - Advanced Camera Library V2.00

Hello everyone!

B4X:
Sub Globals
Dim camera1 As AdvancedCamera ' New lib
End Sub


I'm glad to announce my fourth library!
This library is a modification of the existing camera library with more options.
So the standard procedures of the camera still apply.
Basic4android - Camera

You can find the Advanced Camera Library in the attachements.
To use: Extract and Copy the Advanced Camera.xml and Advanced Camera.jar to the library folder in "Anywhere Software\Basic4android\Libraries".

.:!BIG UPDATE!:.
Advanced Camera Library has been updated to version 2.0 with tons of new features!
See post #19
http://www.b4x.com/forum/52479-post19.html


.:Index:.


[1] Flashlight
[2] Camera's
[3] Orientation
[4] Pictures
[5] Antibanding
[6] Colour Effects
[7] Focus Mode
[8] Scene Mode
[9] White Balance


So, let's start

1) Flashlight

a.
"FlashAuto": Enables the flashlight to turn on automatically.
B4X:
Camera1.FlashAuto()

b.
"FlashOn": Turns the flashlight on.
B4X:
Camera1.FlashOn()

c.
"FlashOff": Turns the flashlight off.
B4X:
Camera1.FlashOff()

2) Camera's

a.
"CameraBack": Sets the back camera as primary camera.
B4X:
Camera1.CameraBack()

b.
"CameraFront": Sets the front camera as primary camera.
B4X:
Camera1.CameraPortrait()

3) Orientation

a.
"OriLandscape": Sets the orientation to landscape mode.
B4X:
Camera1.OriLandscape()

b.
"OriPortrait": Sets the orientation to portrait mode.
B4X:
Camera1.OriPortrait()

4) Pictures

a.
b.
5) Antibanding


6) Colour Effects

a.
7) Focus Mode


8) Scene Mode


9) White Balance



If there are any bugs, questions or features you want to add to the library, please post them on this forum.

Credits and feedback are really much appreciated!

Thank you very much!

XverhelstX

Full example:

B4X:
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   
End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   
   Dim camera1 As AdvancedCamera
   Dim Panel1 As Panel
   
End Sub

Sub Activity_Create(FirstTime As Boolean)
    
   Activity.LoadLayout("Menu")
   activity.AddMenuItem("Take Picture","mnuTakePicture")
   activity.AddMenuItem("Set Effect","mnuSetEffect")
   activity.AddMenuItem("Flash On","mnuFlashOn")
   activity.AddMenuItem("Focus Mode","mnuFocusMode")
   
End Sub

Sub Activity_Resume
   
   camera1.Initialize(panel1, "Camera1")
   
End Sub

Sub Activity_Pause (UserClosed As Boolean)
   camera1.StopPreview
   camera1.Release
End Sub

Sub mnuFlashOn_Click

camera1.FlashOn()
End Sub

Sub mnuSetEffect_Click

Camera1.setEffect = "SEPIA"

End Sub

Sub Camera1_Ready (Success As Boolean)
   If success Then
      Camera1.StartPreview
      
   Else
      ToastMessageShow("Cannot open camera.", True)
   End If
End Sub

Sub Camera1_PictureTaken (Data() As Byte)
   camera1.StartPreview
   Dim out As OutputStream
   out = File.OpenOutput(File.DirRootExternal, "Image.jpg", False)
   out.WriteBytes(data, 0, data.Length)
   out.Close
   ToastMessageShow("Image saved: " & File.Combine(File.DirRootExternal, "Image.jpg"), True)

   
End Sub

Sub mnuTakePicture_Click
   
   camera1.TakePicture
   
End Sub

Sub mnuFocusMode_Click
   
   camera1.setFocusMode = "MACRO"
   
End Sub
 

Attachments

  • ACL4.4.zip
    364.7 KB · Views: 1,953
  • ACL4.5.zip
    33.5 KB · Views: 1,396
  • ACL4.6.zip
    359.4 KB · Views: 4,880
Last edited:

NJDude

Expert
Licensed User
Longtime User

Steini1980

Active Member
Licensed User
Longtime User
The're many Methods implemented, but I can't find an interface which allows to work with AutoExposureLock.

ExposureCompensation is implemented, but in dependency with android device it's just possible to correct the ExposureCompansation +/-2.
The requirements of my customer is always to take photos with back light (e.g. doors and windows from inside), so it's necessary to have a greater scope to adjust camera settings such as the Exposure.
 

Andrey Lopatin

New Member
Licensed User
Longtime User
Hello.
Did anyone try to create flashlignt app for Nexus 5? I tried cam.FlashTorch, then cam.toggleFlashLight functions. Both with no success. Flashlight simply does not turn on, nothing happens. cam.SupportedFlashMode shows "off, auto, on, torch" are avalaible.
 

tmf

Member
Licensed User
Longtime User
I would like to take a 256x256 pixel image and save it as JPG, can this be done, I have read through this and it seems it will save it at the max resolution of the camera?? any examples for this??

Thanks!
 

dataware

Member
Licensed User
Hi, i hope someone should help me with this, when i implement this on another program code, throw me an error message like this:

sub.main_some_function(B4a line:"some_line")
camera.initialize(some_panel, "some_name")
java.lang.ClassCastException:android.widget.Button
cannot be cast to android.view.SurfaceView

and am doing some like this

B4X:
Sub capture_Click
    Try
        LoadLayoutIntoActivity("camera")
        Dim camera As AdvancedCamera
        camera.initilize(panel1,"camera_event")
        camera.StartPreview
       Catch
        ToastMessageShow("Error", True)
    End Try
End Sub

i dont wonna put "camera.initilize(panel1,"camera_event")" on "resume" activity because it send me another error when i dont call the activity at start

for your comments, thanks
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…