B4A Library [Class] CameraEx - Extends the camera library functionality

Discussion in 'Additional libraries, classes and official updates' started by Erel, Nov 28, 2012.

Thread Status:
Not open for further replies.
  1. moster67

    moster67 Expert Licensed User

    MarcoRome and Erel like this.
  2. Douglas Farias

    Douglas Farias Expert Licensed User

    @Erel i tested this example in 3 diferents devices, and when u take a picture using front camera in portrait, this flip on horizontal the image.
    only in front camera, back camera is normal.

    this bug dont happens on the preview, only on the final photo, on the saved image
    file.

    how can i fix this? tested in a moto g4 , samsung j2 and sony e4 (front camera + portrait = fliped horizontal picture)

    i know this is not right place to post this, but this bug is on the example too :)

    thx
     
    Last edited: Dec 22, 2016
  3. Erel

    Erel Administrator Staff Member Licensed User

    This is not a bug. For further discussion please start a new thread in the questions forum.
     
  4. Rusty

    Rusty Well-Known Member Licensed User

    CameraEx - If the device is set to automatically store GPS location, can CameraEx also automatically store the GPS location in the Exif data?
    Or do you have to update the Exif data yourself?
    Thanks,
    Rusty
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    You will need to add it yourself. It is a feature of the camera app.
     
  6. padvou

    padvou Active Member Licensed User

    Hi!
    Here's some Subs I added to the Class and I use in a project of mine:

    Code:
    Public Sub GetSupportedWhiteBalance As List
        r.target = parameters
        
    Return r.RunMethod("getSupportedWhiteBalance")
    End Sub

    Public Sub GetWhiteBalance As String
        r.target = parameters
        
    Return r.RunMethod("getWhiteBalance")
    End Sub

    Public Sub SetWhiteBalance(Mode As String)
        r.target = parameters
        r.RunMethod2(
    "setWhiteBalance", Mode, "java.lang.String")
    End Sub
    I also added this code in the Activity Module to test:

    Code:
    Sub Button1_Click
       
        
    For i=0 To L.Size-1
           
            
    Dim testval As String=L.Get(i)
            
    If testval=CurMode Then
                
    If i <L.Size-1 Then CurMode=L.Get(i+1Else CurMode=L.Get(0)
               
                camEx.SetWhiteBalance(CurMode)
               
                
    ToastMessageShow(camEx.GetWhiteBalance,False)
                camEx.StopPreview
                camEx.CommitParameters
                camEx.StartPreview
                
    Exit
            
    End If
           
        
    Next
    End Sub
    I have a question though.
    A device I'm using gives "manual" as one of the white balance modes.
    Does anyone know how to use it in code and send a manual value?
     
  7. biometrics

    biometrics Active Member Licensed User

    Has anyone used this with a Samsung J1 entry level phone?

    I have reports that it's failing to take a picture with .TakePicture.

    Unfortunately I don't have such a phone to test so that makes it difficult to sort out.
     
  8. cxdzbl

    cxdzbl Active Member Licensed User

    For a long time did not solve the problem of the direction of the photo, and finally solved today, thank you
     
  9. hayderOICO

    hayderOICO Member Licensed User

    hi erel

    I just upgraded from the 1.21 to the 1.3 library. added javaobjects. but the commit parameter fails.

    the "demo" camera app you bundled does work fine though. here's some of my code.

    using b4A v 5.02

    Code:
    #Region  Project Attributes
        
    #ApplicationLabel: Cam
        
    #VersionCode: 5
        
    #VersionName:
        
    'SupportedOrientations possible values: unspecified, landscape or portrait.
        #SupportedOrientations: portrait
        
    #CanInstallToExternalStorage: False
    #End Region

    #Region  Activity Attributes
        
    #FullScreen: True
        
    #IncludeTitle: False
    #End Region

    Sub Process_Globals
        
    Private frontCamera As Boolean = False
        
    Private usbserial As felUsbSerial
        
    Private manager As UsbManager
        
    Dim DisableCameraTimer As Timer
        
    Dim TakePicTimer As Timer
    End Sub

    Sub Globals
        
    Private Panel1 As Panel
        
    Private Panel2 As Panel
        
    Private camEx As CameraExClass
        
    Private btnTakePicture As Button
        
    Dim awake As PhoneWakeState
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
        
    Activity.LoadLayout("allinone")

           
    If FirstTime Then
        manager.Initialize
          
    End If

        DisableCameraTimer.Initialize(
    "DisableCameraTimer1",300)
        TakePicTimer.Initialize(
    "pictimer",300)
        awake.KeepAlive(
    True)
    End Sub


    Sub Activity_Resume
        InitializeCamera
        manager.Initialize
        awake.KeepAlive(
    True)
    End Sub

    Private Sub InitializeCamera
        camEx.Initialize(Panel2, frontCamera, Me, 
    "Camera1")
        DisableCameraTimer.Enabled=
    True
        frontCamera = camEx.Front
    End Sub

    Sub Activity_Pause (UserClosed As Boolean)
        camEx.Release
        awake.ReleaseKeepAlive
    End Sub

    Sub Camera1_Ready (Success As Boolean)
        
    If Success Then
            camEx.SetColorEffect(
    "none")
            camEx.SetFlashMode(
    "Off")
            camEx.SetPictureSize(
    40323024)
            camEx.ExposureCompensation=-
    6
            camEx.CommitParameters
            camEx.StartPreview
        
    Else
            
    ToastMessageShow("Cannot open camera."True)
        
    End If
    End Sub

    Sub btnTakePicture_Click
        
    If mode_select = "I" Then
            camEx.TakePicture
        
    Else
            camEx.SetFlashMode(
    "torch")
            camEx.CommitParameters
            camEx.TakePicture
        
    End If
        btnTakePicture.Enabled = 
    False
    End Sub

    Sub DisableCameraTimer1_Tick
        DisableCameraTimer.Enabled=
    False
        
    ProgressDialogHide
    End Sub

    Sub pictimer_Tick
        TakePicTimer.Enabled=
    False
        PicTake
    End Sub

    Sub PicTake
        camEx.TakePicture
        btnTakePicture.Enabled = 
    False
    End Sub

    Sub Camera1_PictureTaken (Data() As Byte)
        camEx.SetFlashMode(
    "off")
        camEx.CommitParameters
            
    Else  
        
    End If
    End Sub
     
    Last edited: May 25, 2017
  10. Erel

    Erel Administrator Staff Member Licensed User

    1. Please don't limit your questions to a single member.

    2. Please start a new thread for this question and make sure to post:
    a. Whether the example as is worked for you.
    b. The error message.
     
  11. Rusty

    Rusty Well-Known Member Licensed User

    Is there a way to find a "new thread" as suggested above?
    It would be nice if a URL was posted in the "final" thread pointing to the new thread so we/I could easily find the "new thread" with a simple click...
    Just sayin'... :)
    Rusty
     
  12. Erel

    Erel Administrator Staff Member Licensed User

    Rusty likes this.
  13. NeoTechni

    NeoTechni Well-Known Member Licensed User

    I'm having trouble restarting the camera after it shuts down. Is there certain subs I should be calling to properly shut it down besides camEx.Release, and camEx.Initialize to turn it on? Or would you prefer this in a new thread?

    EDIT: I think I found the issue. The panel needed to be visible.
     
    Last edited: Jul 9, 2017
  14. Croïd

    Croïd Active Member Licensed User

    Hello
    Do you know, how I can add a precision circle for focus mode? ( as Google camera)
    Thanks

    focus.jpg
     
  15. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread in the questions forum.
     
  16. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread in the questions forum.
     
  17. Croïd

    Croïd Active Member Licensed User

  18. JUAN CARLOSORDOÑEZ

    JUAN CARLOSORDOÑEZ Member Licensed User

    Hello. When I run your example its shows "
    B4A Versión: 7.30
    Parseando código. (0.02s)
    Compilando código (0.07s)
    Compilado código de diseños (0.01s)
    Organizando librerías. (0.00s)
    Generando el fichero R. (0.05s)
    Compilando el código Java generado. (1.38s)
    Convirtiendo byte code a dex optimizado. Error
    java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
    Exception in thread "main"

    Please help me. thanks!!
     
  19. Erel

    Erel Administrator Staff Member Licensed User

  20. hears

    hears Active Member Licensed User

    can you share this library JAVA code? i try to make a same library now.
     
Thread Status:
Not open for further replies.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice