Editing
Jq stuff
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Using jq == [[Parsing]] Command to return the id number of the last scan: <code>cnt=$(jq '.lastVehicleRecord.scans | length' heartbeat)</code> Fancy way to find the scanId of a selected system via bash and jq <pre>if [ -z $1 ]; then whichIE="uvx"; else whichIE=$1; fi printf ".lastVehicleRecord.scans[] | select(.type | endswith(\""$whichIE"\"))\n" > parms.jq wget -qO heartbeat <nowiki>http://$ip/heartbeat</nowiki> cnt=$(jq '.lastVehicleRecord.scans | length' heartbeat) id=$(jq -f parms.jq heartbeat | jq '.id') if [ ! -z $id ]; then wget -qO $id.orig.tiff <nowiki>http://$ip/requestImage/?scanId=$id</nowiki> fi</pre>More interesting jq examples: <code>"plateCoordinates":[898, 210, 144, 44] "plateCoordinatesRelative":[898, 210, 144, 44],</code> <code>jq ".plateCoordinates | .[1]" upload_test/2023-05-12_12:08:07.txt</code> == Tiff info parsing == Parsing examples of .tiff files extracing meta data from the headers. <code>tiffinfo 2023-05-07\ 13_57_17_evx_left_3845.tiff | grep 65001 | sed 's/ Tag 65001: //' | sed 's/\\//'g | jq</code> <code>tiffinfo 2023-05-07\ 13_57_17_evx_left_3845.tiff | grep 65001 | sed 's/ Tag 65001: //' | sed 's/\\//'g | jq '.timestamp'</code> <code>tiffinfo 2023-05-07\ 13_57_17_evx_left_3845.tiff | grep 65001 | sed 's/ Tag 65001: //' | sed 's/\\//'g | jq '.renderData.type'</code> Remove stderr from stream <code>tiffinfo 189.tiff 2>/dev/null | grep 65001 | sed 's/ Tag 65001: //' | sed 's/\\//'g | jq '.renderData.type'</code> == LPR parsing (Axis P1455) == The camera should be set to "save full frame". Parsing the json from the axis camera: <code>jq ".ImageArray[0].BinaryImage" /home4/Events/upload_test/2023-06-15_15:27:01.txt > image.b64</code> Next remove the quotes in the image.b64 file, or: <code>jq --raw-output ".ImageArray[0].BinaryImage" /home4/Events/upload_test/2023-06-15_15:27:01.txt > image.b64</code> Then: <code>base64 -d image.b64 > image.jpg</code> Now to get the lpr image: <code>jq ".imagesURI[0]" /home4/Events/upload_test/2023-06-15_15:27:01.txt</code> then use that url to pull the license plate image. You may have to trim the returned url to just include "<code>getImage&name=3</code>", not the full url... Alternatively you could just grab the plate coordinates from the json and clip the image, presumably. <code>jq ".plateCoordinates" /home4/Events/upload_test/2023-06-15_15:27:01.txt</code> == Service Log parsing == As of July 25, 2023, the services logs have issues with quotes and backslashes. Basic parsing of the log is done like this: <code>jq ".[0].message" getServiceLogs.json</code> provides just the first message element. I edit the file and remove the quote around the contents of the "message" element. (in emacs macro search for message, space forward to the starting quote, now search for }" then search for dateLong and end macro. Next I am removing the /, both of these in emacs. A bunch of sed stuff to help with the parsing... <code>sed 's/\\\"\\\"/""""/g' getServiceLogs.json | sed 's/\\//g' | sed 's/\}"/\}/g' | sed 's/""/"/g' | sed 's/\"\[{/\[{/g' | sed 's/}\]\"/}\]/g' | sed 's/\"{/{/g' > getServiceLogs2.json</code>
Summary:
Please note that all contributions to SoftwareGuy may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
SoftwareGuy:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
Edit source
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information