B4A Library Camera library v2.20

The camera library was updated.
It now also supports the front camera.

There were several internal improvements required for the CameraEx class.

Installation instructions:
- Unzip the attached file and copy both files to the internal libraries folder.

Edit:
V2.20 is attached. Adds Camera.AutoFocus and Camera.CancelAutoFocus methods. CameraEx class was also updated and it includes a new FocusAndTakePicture method.
V2.10 is attached. The camera management code was rewritten to fix stability issues.
 

Attachments

  • Camera.zip
    11.9 KB · Views: 4,369

canalrun

Well-Known Member
Licensed User
Longtime User
Erel,

My eyes are getting bad and I have an idea to use my phone when I forget my glasses. Can I use the zoom in preview mode?

I want to create a small app. that increases the size of the stuff that I need to read, my phone would be perfect for that.

Cheers,

Zoom does work in preview.

I beat you to this app. :)
There is a restaurant near me that is so dark you need a flashlight to see the menu. I use my phone in preview mode, LED light, zoom capability, special effects are helpful.

On Google Play, search for "CanalRun MagnifEye". It's free.

Barry.
 

bluedude

Well-Known Member
Licensed User
Longtime User
Should I do this by using Setparameter or do I need to use reflection to do this?

Cheers,
 

canalrun

Well-Known Member
Licensed User
Longtime User
Should I do this by using Setparameter or do I need to use reflection to do this?

Cheers,

I noticed a few minutes ago that Erel answered a question today in the "Basic4android Updates and Questions" forum about using the reflection library for Camera functions like "Is Zoom Supported".

Erel Posted his Camera Library code a long time ago. I used this to create my own camera library that included a few more functions.There are a couple of Enhanced and Extended Camera libraries available in these newsgroups on B4A.

In MagnifEye I attempt to find the highest supported preview resolution. I try to do a camera focus. I also try to detect focus modes supported. There is a button on the right to cycle between focus modes supported – Auto, Infinity, Macro…

You mention a Nexus. Is this the phone or tablet? I have a Nexus 7 "7 inch tablet" as one of my testing devices, but that does not have a rear camera.

Barry.
 

bluedude

Well-Known Member
Licensed User
Longtime User
Done my own small app. with the new library and added Autofocus and zoom, now it works fine to use.

Also added shake to torch on or off.

Great library Erel and it helps me to read tiny letters on supermarket products.

Cheers,
 

Eduard

Active Member
Licensed User
Longtime User
V2.10 uploaded to the first post. Fixes several stability issues.

Thanks

I have a question. v2.01 lib is included in b4a v2.5. If I now download v2.1 and put it into the additional lib folder, will it automatically be updated in for example b4a v3.0 (if that would contain camera lib v3.0)?

It would by handy by the way if the IDE could check for library updates!


update

How can I use this library version? After installing it into additional library folder and restarting, refreshing, reloading the camera version is stil 2.01. Not 2.1

I use BvA v2.5
 
Last edited:

Eduard

Active Member
Licensed User
Longtime User
Thanks,

never thought that would be a different location.

Copied the files to:
C:\Program Files (x86)\Anywhere Software\Basic4android\Libraries

and it works of course.:sign0188:
 

ednt

Member
Licensed User
Longtime User
is there a good example for the new camera library which show all possible features ?
 

enrico

Active Member
Licensed User
Longtime User
Is there a way to take a picture from camera and compare it with some images I could have stored, to detect in which most resembles ?
 

ComposerB4A

Member
Licensed User
Longtime User
Hi, one question please i used the code and work,
but with if launched "external app" and retunred, the app of frezeer in line:
Camera1.StartPreview
¿any persona know the solution?
 

ComposerB4A

Member
Licensed User
Longtime User
In log not exist message.
My app uses the same code as the example code.
The situación appear when the steps:
1) The "My app" work good in general using the cam
2) Exist one incoming call
3) The cam is release in "pause section"
3) Appear (change) to "app of call" screen (predeterminated in device)
4) with one service (of "my app") return to screen of "My app" (using "StarActivity(main)")
5) The cam is initialized in "resume section"
6) but in the line "Camera1.StartPreview" is frozen (panel show white color)
7) S.O. Android after the seconds show "force close app"

¿Maybe that "incoming call" affect the "cam object"?

is curious but, after (of the situation of error/frozen),the cam app (cam app predeterminated in device) not work (is necesary reboot the device), show "not is possible access to the cam"
 

ComposerB4A

Member
Licensed User
Longtime User
i run one test with this code (and library)(in debug mode):
B4X:
Sub Globals
  'These global variables will be redeclared each time the activity is created.
  'These variables can only be accessed from this module.
  Dim Button1 As Button
  Dim camera1 As Camera
  Dim Panel1 As Panel
End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("2")
End Sub

Sub Activity_Resume
camera1.Initialize(Panel1 ,"camera1")
End Sub

Sub Activity_Pause (UserClosed As Boolean)
StartServiceAt(retorna1,DateTime.Now+(5*2000),False )
End Sub

Sub Button2_Click 'sacar foto
camera1.TakePicture
End Sub

Sub Camera1_Ready (Success As Boolean)
    If Success Then
        camera1.StartPreview
    Else
        Log("camara ready -> Cannot open camera")
    End If
End Sub

step of test:
1) execute code, work
2) incomign call
3) return to all
and exist this log of error of "startpreview":
PackageAdded: package:ejm.fotosb4a
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
main_camera1_ready (B4A line: 75)
camera1.StartPreview
java.io.IOException: setPreviewDisplay failed
at android.hardware.Camera.setPreviewDisplay(Native Method)
at android.hardware.Camera.setPreviewDisplay(Camera.java:399)
at anywheresoftware.b4a.objects.CameraW.StartPreview(CameraW.java:176)
at ejm.fotosb4a.main._camera1_ready(main.java:454)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:538)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:158)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:154)
at anywheresoftware.b4a.objects.CameraW$2$1.run(CameraW.java:139)
at android.os.Handler.handleCallback(Handler.java:618)
at android.os.Handler.dispatchMessage(Handler.java:123)
at android.os.Looper.loop(SourceFile:351)
at android.app.ActivityThread.main(ActivityThread.java:3814)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:538)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:659)
at dalvik.system.NativeStart.main(Native Method)
 
Top