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

Status
Not open for further replies.
Example based on B4XPages: https://www.b4x.com/android/forum/threads/b4x-b4xpages-barcode-reader.120417/#content

CameraEx class wraps the Camera object and using reflection and other code it extends its functionality.

CameraEx class requires Android 2.3+ and depends on Camera library v2.20+
CameraEx features:
  • Easily open the back or front camera
  • Preview images and saved images orientation will match the device orientation (all orientations are supported)
  • Gives access to Camera.Parameters native class (flashmode, picture size, effects and other settings)
  • Includes methods to convert preview images to JPEG and to save the taken pictures.
  • It should be simple to add more methods to this class

SS-2012-11-28_12.18.31.png


See this page for the constant values and other possible methods:
https://developer.android.com/reference/android/hardware/Camera.Parameters.html

Note that you should call CommitParameters after changing one or more parameters.

CameraExClass module is included in the attached example.

V1.30 is attached - Includes various new methods.

v1.20 - Includes all the various posts in this thread as well as AutoFocusAndTakePicture method which first calls AutoFocus and then takes a picture (if AutoFocus was successful).

Edit (06/2018): A new version was uploaded with targetSdkVersion set to 26.
 

Attachments

  • CameraEx.zip
    13.2 KB · Views: 4,274
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User

Shadow&Max

Active Member
Licensed User
Longtime User
Erel... All I was saying is that in his image, you can see just the top of the picture size button at the bottom of his image...

This is because his "view" is long and short... the button for picture size in your example is too low to show on his device... Your example, while fine for most rectangular formats in portrait or landscape, has too many buttons vertically to show on his shorter screen.
 
Last edited:

GMan

Well-Known Member
Licensed User
Longtime User
i think, the Glass res & ratio is equal to a 16:9 format - and that cant be handled by the "normal" classes and libs 'cause they are developed for another ratio (for smartphones).
MAYBE some time there will be 16:9 smartphones (thinking about how that should look like) :rolleyes:
 

Erel

B4X founder
Staff member
Licensed User
Longtime User

Alberto Iglesias

Well-Known Member
Licensed User
Longtime User

Attachments

  • GlassColor.zip
    71 KB · Views: 285

victormedranop

Well-Known Member
Licensed User
Longtime User
One Question. How can i reduce the size of the view of the área i am trying to shoot?

thanks,
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Try to change the zoom level:
B4X:
Public Sub IsZoomSupported As Boolean
  r.target = parameters
  Return r.RunMethod("isZoomSupported")
End Sub
Public Sub GetMaxZoom As Int
  r.target = parameters
  Return r.RunMethod("getMaxZoom")
End Sub

Public Sub getZoom() As Int
  r.target = parameters
  Return r.RunMethod("getZoom")
End Sub
Public Sub setZoom(ZoomValue As Int)
  r.target = parameters
  r.RunMethod2("setZoom", ZoomValue, "java.lang.int")
End Sub

http://www.b4x.com/android/forum/th...ex-class-zoom-function-to-work.35829/#content
 

RAJAN MBA

Member
Licensed User
Longtime User
Yes...

I share with everybody this project....

Works very well with Google Glass, my Samsung Galaxy Tab 7, my Smartwach.

The APP is in Google Play in https://play.google.com/store/apps/details?id=com.visualnet.glasscolor

This may give inaccurate colors in low light. Is there a way to check if light is low and warn the user? How many colors database are you using (may be 500?)? I was wondering if the colors database could be stored locally in SQlite and used without sacrificing retrieval speed.
 

Alberto Iglesias

Well-Known Member
Licensed User
Longtime User
Yes, I work in a new version to put the database inside a project, not in internet.

and the check if light is low, yes, can be, look the google glass sensors:
The following sensors are supported on Glass:

The following sensors are not supported:


  • And the quantity of colors is 751, look the attachment
 

Attachments

  • GlassColor.zip
    29.6 KB · Views: 241

RAJAN MBA

Member
Licensed User
Longtime User
Yes, I work in a new version to put the database inside a project, not in internet.

and the check if light is low, yes, can be, look the google glass sensors:
The following sensors are supported on Glass:

The following sensors are not supported:


  • And the quantity of colors is 751, look the attachment
Thank you for the links. :)I will study them
 

Shadow&Max

Active Member
Licensed User
Longtime User
Hi Erel...

I'm using this class, but I've got an issue... the flash and the switch camera work fine in Release mode, but don't work at all in Release (Obfuscated).

Any idea why?
 
Status
Not open for further replies.
Top