B4A Library Onyx

this is a wrap for this Github Project.

An android library that uses technologies like artificial Intelligence, machine learning, and deep learning to make developers understand the content that they are displaying in their app.

Please note that this lib used service from Clarifai which is not totally free (https://clarifai.com/pricing)


Onyx
Author:
DonManfred (wrapper)
Version: 1
  • OnyxTags
    Events:
    • onComplete (tags As List)
    Methods:
    • Initialize (EventName As String)
    • IsInitialized As Boolean
    • TagsandProbability
    • TagsfromApi
    • fromURL (urls As String) As Tags
    • fromVideoArray (videoArray() As Byte) As Tags
    Permissions:
    • android.permission.ACCESS_NETWORK_STATE
    • android.permission.INTERNET
    Properties:
    • Instance As Tags [write only]

In this example the following image is scanned...


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 onyx As OnyxTags
End Sub
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    onyx.Initialize("Onyx")
    onyx.fromURL("http://www.europa-entdecken.net/fileadmin/eu-entdecken/images/frankreich/eiffelturm.jpg")
    onyx.TagsandProbability
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Onyx_onComplete(tags As List)
    For i = 0 To tags.Size -1
        Log("Tag: "&tags.Get(i))
    Next
End Sub

 

Attachments

  • OnyxEx.zip
    6.7 KB · Views: 354
  • OnyxV1.0.zip
    215.3 KB · Views: 358
Last edited:

petr4ppc

Well-Known Member
Licensed User
Longtime User
DonManfred, thank you very much

because of your advice I am trying to add in manifest editor this:
B4X:
CreateResource(values,strings.xml,
<resources>
    <string name="app_name">XXX</string>
    <string name="app_id">YYYY</string>
    <string name="app_secret">ZZZZ</string>
</resources>
)

I see in Clarifai only:
API

What I must write to
app_name
app_id = API?
app_secret?

Do you have experience?
Best regards
p4ppc
 

yiankos1

Well-Known Member
Licensed User
Longtime User

I think this lib is for API v1. As Clarifai mentions "All API access is over HTTPS, and accessed via the https://api.clarifai.com domain. The relative path prefix /v2/ indicates that we are currently using version 2 of the API.". So i think this lib is not usable.
 

petr4ppc

Well-Known Member
Licensed User
Longtime User
Yiankos - thank you for your tips. Where you see v2 prefix, please?
DonManfred-Do you know if this lib is usable, please?
 

DonManfred

Expert
Licensed User
Longtime User

hookshy

Well-Known Member
Licensed User
Longtime User
I have problems runing this lib can you advise please

B4X:
Logger connected to:  HUAWEI PRA-LX1
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
java.lang.RuntimeException: An error occurred while executing doInBackground()
    at android.os.AsyncTask$3.done(AsyncTask.java:330)
    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
    at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
    at java.util.concurrent.FutureTask.run(FutureTask.java:242)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:255)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
    at java.lang.Thread.run(Thread.java:776)
Caused by: com.hanuor.onyx.exceptionhandler.ClarifaiBadRequestException:  Path /v1/multiop not found
    at com.hanuor.onyx.helper.ResponseUtil.throwExceptionForErrorResponse(ResponseUtil.java:54)
    at com.hanuor.onyx.helper.ClarifaiRequester.executeOnce(ClarifaiRequester.java:91)
    at com.hanuor.onyx.helper.ClarifaiRequester.execute(ClarifaiRequester.java:40)
    at com.hanuor.onyx.helper.ClarifaiClient.recognize(ClarifaiClient.java:87)
    at com.hanuor.onyx.hub.Tags$3.doInBackground(Tags.java:122)
    at com.hanuor.onyx.hub.Tags$3.doInBackground(Tags.java:117)
    at android.os.AsyncTask$2.call(AsyncTask.java:316)
    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
    ... 4 more
 

DonManfred

Expert
Licensed User
Longtime User
I do not have the source anymore. Like all other old libs i lost the source last year due to a HDD crash.

The lib uses clarify. Clarify does provide a HTTP Api. It is most probably better to directly use their HTTP Api. No need for a library at all.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…