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... eiffelturm.jpg


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

** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
lib:Raising.. onyx_oncomplete()
Tag: architecture-0.9931149482727051
Tag: travel-0.9882233142852783
Tag: no person-0.9877809882164001
Tag: tower-0.9698358774185181
Tag: outdoors-0.9656822681427002
Tag: sky-0.9615469574928284
Tag: landmark-0.9527928829193115
Tag: monument-0.9508309364318848
Tag: city-0.9461989402770996
Tag: tourism-0.9448901414871216
Tag: building-0.9446797370910645
Tag: old-0.9224209785461426
Tag: tallest-0.903542160987854
Tag: famous-0.8974774479866028
Tag: capital-0.8950203657150269
Tag: ancient-0.8797848224639893
Tag: sightseeing-0.8765351176261902
Tag: tourist-0.8734467625617981
Tag: traditional-0.8710891008377075
Tag: historic-0.8630752563476563
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
 

Attachments

  • OnyxEx.zip
    6.7 KB · Views: 350
  • OnyxV1.0.zip
    215.3 KB · Views: 351
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
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

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.
 
Top