Do I need google-apis-explorer for Vision? - google-apis-explorer

I'm following the OCR Tutorial so of course calling GC's API, and I noticed bottom of OCR home page mentions API Explorer. What is this "Explorer", do I need it for Vision?

What the Explorer is is just a testbed for all the Google APIs so you can test the APIs in isolation or "Try Before You Buy" to see what functions are available. For instance, this page allows you to form a query for OCR and see what responses should look like. You don't need this tool, but it might be useful for debugging.
As an example, given this random source image, click this link to Google Explorer then press the Execute without OAuth button, and you get results that look like this:
{
"responses": [
{
"textAnnotations": [
{
"locale": "en",
"description": "How to\nInsert Text\nText Boxes in\nGoogle Docs\nBox\nControlAltAchieve.com #ericcurts\n",
"boundingPoly": {
"vertices": [
{
"x": 128,
"y": 20
},
{
"x": 909,
"y": 20
},
{
"x": 909,
"y": 502
},
{
"x": 128,
"y": 502
}
]
}
},
... And so on for many a page ...

Related

Vega-Lite Calculated Scale domainMax

I'm trying to calculate a value for domainMax on the Y-axis scale. I tried the following example where I want the Y-axis domainMax to be one greater than the maximum value in the dataset field named "value". The example produces the error 'Unrecognized signal name: "domMax"'. How can I get it to work?
{
"data": {
"values": [
{"date": "2021-03-01T00:00:00", "value": 1},
{"date": "2021-04-01T00:00:00", "value": 3},
{"date": "2021-05-01T00:00:00", "value": 2}
]
},
"transform": [
{ "calculate": "max(datum.value)+1","as": "domMax"}
],
"mark": "line",
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"y": {"field": "value", "type": "quantitative",
"scale": {"domainMax": {"expr": "domMax"}}
}
}
}
This transform
"transform": [
{ "calculate": "max(datum.value)+1","as": "domMax"}
]
adds a new column to your data set - it does not create a new signal. You can check that in the editor. Go to the DataViewer tab and select data_0 from the drop down. Can you see the new domMax column?
Signals are a different thing entirely - have a look here in the documentation. Note that the link points to Vega, not Vega-Lite. (Vega-Lite specifications are compiled to Vega.)
Vega-Lite does not let you declare signals; you declare parameters instead. Here is another example using the domMax parameter. Vega-Lite parameters are translated to Vega signals.
It looks like you are trying to derive the value of your parameter/signal from the data. I am not sure you can do that in Vega-Lite.
On the other hand it's very easy in Vega. For example you could use the extent transform:
https://vega.github.io/vega/docs/transforms/extent/
Side comment - while Vega specifications are more verbose you can sometimes find their primitives simpler and a good way to understand how the visualisation works. (You can see compiled Vega in the editor.)
I tried to get a custom domain based on the data but hit the same limitations as you did.
In my case, I update the data from the outside a bit like the streaming example. I compute the domain from the outside and modify them in the visualization with params. This is quite easy as vega-lite params are exposed as vega signals.
This is the gist of the layout:
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"params": [
{
"name": "lowBound",
"value": -10
},
{
"name": "highBound",
"value": 100
}
],
../..
"vconcat": [
{
"name": "detailed",
../..
"layer": [
{
../..
"mark": "line",
"encoding": {
"y": {
"field": "value",
"title": "Temperature",
"type": "quantitative",
"scale": {
"domainMin": {
"expr": "lowBound"
},
"domainMax": {
"expr": "highBound"
}
}
},
...
The lowBound and highBound are dynamically changed through vega signals. I change them with the regular JS API.
You can add a param to pan and zoom in case your hard coded values are less than ideal.
"params": [{"name": "grid", "select": "interval", "bind": "scales"}],
Open the Chart in the Vega Editor

Embed Vega-Lite Diagrams in Antora

I'm trying to embed this vega-lite diagram in my antora docs: https://vega.github.io/vega-lite/examples/line_overlay.html
My Asciidoc file looks like this:
... some text ...
== Attachments
[vegalite, rendered-vega-image, svg]
----
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"description": "Stock prices of 5 Tech Companies over Time.",
"data": {"url": "data/stocks.csv"},
"mark": {
"type": "line",
"point": true
},
"encoding": {
"x": {"timeUnit": "year", "field": "date"},
"y": {"aggregate":"mean", "field": "price", "type": "quantitative"},
"color": {"field": "symbol", "type": "nominal"}
}
}
----
... some more text ...
The problem is the CSV file containing my data is not found. I tried every path I imagined ... relative and absolute filesystem paths and relativ and absolute http urls. Still I always get this message:
[DONE] build ui bundle
Skipping vegalite block. No such file: http://localhost:8080/vegalite/svg/eNpVkEFywyAMRfc5BcN0mdibdpNtj9D0AAQrWA0gArKnnozvXoHbpl0Zv9F_X3DfKaWfih0hGH1UemRO5dj3MzjTOeRxOndI_TbQ6MEjQz8_dx-Fot7X_ADFZkyMAsTxxmSvKmW0UBRd1Is6gR3VK4VkIlY2Q1YnDNB95w3X8ruesq-Cu2E2dgwQuQyY1z5QRKaM0R08OVe_GRJlllNfal3pbJn12nTB5GvVyVn-eElQpR4jtDphiTCyQM4TCNliEC0NInxEP9tSLIu-S3-VLGCy3it9QfBDBbI6bLUyv7R541yWdxJ-1AFM_DffXqWSn7Vuk4mMbBjnh8iSp9xkv8GyhDP5v8lIAaPxeq032K1fIi6OZQ==
[DONE] build docs
The Skipping vegalite block should not appear.
I tried vega-lite with data which is defined directly in the json block. This snippet works. So Vega-Lite in general works (I'm using a Kroki Server for diagram generation).
[vegalite, rendered-vega-image, svg]
----
{
"description": "A simple bar chart with embedded data.",
"data": {
"values": [
{"a": "A","b": 28}, {"a": "B","b": 55}, {"a": "C","b": 43},
{"a": "D","b": 91}, {"a": "E","b": 81}, {"a": "F","b": 53},
{"a": "G","b": 19}, {"a": "H","b": 87}, {"a": "I","b": 52}
]
},
"mark": "bar",
"encoding": {
"x": {"field": "a", "type": "ordinal"},
"y": {"field": "b", "type": "quantitative"}
}
}
----
Defining my data directly inside the diagram definition is not a solution for me. Right now I'm just trying to make it work using the demo-CSV file. But afterwards I will switch to my own autogenerated, large CSV file. Both my real CSV and the Demo File are located in docs/modules/technical-docs/assets/attachments/monitoring-logging-reporting/stocks.csv.
My general setup consists of several projects.
Project containing the antora playbook und shell-script to generate my docs on my localhost
Project containing Asciidoc, the CSV files and a bunch of other docs and source code
Several other projects containing asciidoc docs which are not relevant for the problem at hand.
Anyone got any thougts? Thanks for yout help.
Kroki provides security levels that restrict access to files on the file system and on the network. Each level includes the restrictions enabled in the prior security level:
UNSAFE: disables any security features.
SAFE: Assume the diagram libraries secure mode request sanitization is sufficient.
SECURE: prevents attempts to read files from the file system or from the network.
By default, Kroki is running in SECURE mode.
As a result, "data": {"url": "data/stocks.csv"} will be removed/ignored.
If you are using Asciidoctor Kroki, the preprocessor should resolve the path, read the content and replace data.url with the actual values. See: https://github.com/Mogztter/asciidoctor-kroki
Alternatively, and since you are running a local instance of Kroki, you can use KROKI_SAFE_MODE=unsafe environment variable to configure the safe mode to unsafe.

How can I retrieve the perimeter and specific geometric properties using the Model Derivative API?

I have followed the Postman tutorial for the model derivative API, specifically for extracting metadata. I used a .dxf file, since I want to know if it is possible to retrieve perimeter, length/width properties based off the file.
I received a 200 response and it gave me a massive list of objects w/ their respective objectid's. Basically I got back a ton of these:
{
"objectid": 253,
"name": "Line [108]",
"externalId": "108",
"properties": {
"3D Visualization ": {
"Material": "ByLayer"
},
"General": {
"Color": "ByLayer",
"Handle": "108",
"Layer": "color#000000ff",
"Linetype": "BYLAYER",
"Linetype scale": "1.000",
"Lineweight": "ByLayer",
"Name ": "Line",
"Plot style": "ByColor",
"Thickness": "0.000 mm",
"Transparency": "ByLayer"
},
"Geometry": {
"Angle": "192.931 deg",
"Length": "0.088 mm"
}
}
}
The .dxf file I tested was as simple as possible and it looks like this image:
How can I retrieve the perimeter of this image? Is it possible to retrieve other specific geometric properties that I specify?
How can I know what part of the .dxf file each objectid is referring to?
Although it looks simple, the polyline (?) is probably being tessellated, resulting in a large number of small lines. Have you tried the original DWG file? Can you try that with viewer.autodesk.com?

Autodesk Forge - Extract geometry data from a 2D Cad Drawing using the modelderivative API

I am trying to extract data from a 2d Cad drawing. Essentially I would like to find the x/y coordinates of every element. However, the data does not show this information.
I am using the modelderivative/v2/designdata/{{urn}}/metadata/{{guid}}/properties endpoint to extract the data itself.
Here is an example of the output this gives
{
"objectid": 3308,
"name": "Text [67AC]",
"externalId": "67AC",
"properties": {
"AnnotationScaling": {
"Annotative": "No"
},
"General": {
"Color": "ByLayer",
"Handle": "67ac",
"Layer": "IMAGE-HYPERLINKS",
"Linetype": "ByLayer",
"Linetype scale": "1.000",
"Lineweight": "ByLayer",
"Name ": "Text",
"Plot style": "ByColor",
"Thickness": "0.000",
"Transparency": "ByLayer"
},
"Hyperlinks": {
"Description": ".\\R0010020.JPG",
"Name": ".\\R0010020.JPG"
},
"Misc": {
"Backward": "No",
"Upside down": "No"
},
"Text": {
"Contents": "R0010020.JPG",
"Height": "0.050",
"Justify": "Left",
"Obliquing": "0.000 deg",
"Rotation": "111.348 deg",
"Style": "Standard",
"Width factor": "1.000"
}
}
},
As you can see, there is no key 'Geometry'
Can anyone point me in the right direction on how I can extract the object positioning data for a 2d Cad drawing? Could it be that the drawing itself needs to implicitly set this information?
Here is an example of what I'm seeing in the Cad drawing itself.
Cad Output
There is no mention of the correct keys "Position X", "Position Y" in the modelderivative output above. Can anyone explain why this might be? Am I exporting it incorrectly? Or does Forge remove this information?
I am using PHP and getting the data server-side.
I exported another test model and found the following was generated
"Geometry": {
"Area": "1131855.821",
"Circumference": "3771.382 mm",
"Diameter": "1200.468 mm",
"Radius": "600.234 mm"
}
But there are no X/Y/Z coordinates in this data.
You can parse the individual primitives of your 2D drawing on the client side based on this blog post: https://forge.autodesk.com/blog/working-2d-and-3d-scenes-and-geometry-forge-viewer.
Parsing the drawing geometry on the server-side would be a bit more involved, since the file format used in Forge Viewer is not publicly documented. You could use tools like https://github.com/Autodesk-Forge/forge.commandline-nodejs, but I'm not sure if there are alternatives for PHP.

JSON to generate app dmg

I'm trying to find an automatic way to generate at dmg file with my app inside and a nice looking background and application icon. I have found a an app which generate this called appdmg
https://www.npmjs.com/package/appdmg
My issue is that the json file is not understand and still complaining about a syntax issue.
Any example I found matching my syntax..
{
"title": "myApp",
"icon": "icon.ico",
"background": "banner.png",
"icon-size": 80,
"contents": [
{ "x": 192, "y": 344, "type": "link", "path": "/Applications" },
{ "x": 448, "y": 344, "type": "file", "path": “connect.app” }
]
}
Any idea or other easy cli tool ? I need to plug the tool inside a build server which generate automatically the app.
Thanks
Curly quotes are your syntax error. "connect.app" vs. “connect.app”