๐ ๏ธ OpenAI Vision โ 2
3 min readNov 25, 2023
concat(
if(
"bicycle" = 0 OR "bicycle" IS NULL,
"",
concat("bicycle", ' bicycle(s)\n')
),
if(
"bus" = 0 OR "bus" IS NULL,
"",
concat("bus", ' bus(s)\n')
),
if(
"car" = 0 OR "car" IS NULL,
"",
concat("car", ' car(s)\n')
),
if(
"person" = 0 OR "person" IS NULL,
"", concat("person",
' person(s)\n')
),
if(
"truck" = 0 OR "truck" IS NULL,
"",
concat("truck", ' truck(s)')
)
)
use icons in the Label,
vanwatch_label(attributes($currentfeature))
{
"backpack": 0,
"bench": 0,
"bicycle": 0,
"boat": 0,
"bottle": 0,
"bowl": 0,
"bus": 0,
"cameras": "https://trafficcams.vancouver.ca/cameraimages/AlmaNorthW10th.jpg,https://trafficcams.vancouver.ca/cameraimages/W10thEastAlma.jpg,https://trafficcams.vancouver.ca/cameraimages/AlmaSouthW10th.jpg,https://trafficcams.vancouver.ca/cameraimages/W10thWestAlma.jpg",
"car": 60,
"chair": 0,
"clock": 0,
"fire hydrant": 0,
"geo_local_area": "West Point Grey",
"handbag": 0,
"label": '<a href="https://trafficcams.vancouver.ca/alma10.htm">Alma St and W 10th Av</a><br/> <img src="https://trafficcams.vancouver.ca/cameraimages/AlmaNorthW10th.jpg">',
"mapid": "TCM054",
"motorcycle": 0,
"name": "Alma St and W 10th Av",
"parking meter": 0,
"person": 0,
"potted plant": 0,
"skateboard": 0,
"stop sign": 0,
"suitcase": 0,
"surfboard": 0,
"traffic light": 0,
"train": 0,
"truck": 0,
"tv": 0,
"url": "https://trafficcams.vancouver.ca/alma10.htm",
}
vanwatch_label(
attributes($currentfeature),
webdings=True,
)
import math
from qgis.core import *
from qgis.gui import *
@qgsfunction(args='auto', group='Custom', referenced_columns=[])
def vanwatch_label(row, webdings, feature, parent):
"""
Produce label text for a vanwatch mapid.
vanwatch_label(row)
"""
row = {
keyword:value
for keyword, value in row.items()
if isinstance(value,int) and value != 0}
scale = {
"car": 10,
"people": 5
}
symbol = {
"bicycle": "๏ข",
"car": "๏",
"person": "๏",
}
if webdings:
return " ".join(
[
thing for thing in [
"".join(
math.ceil(row.get(thing,0) / scale.get(thing,1)) * [symbol.get(thing,"x")]
) for thing in symbol.keys()
] if thing])
return ", ".join(sorted(["{}:{}".format(keyword,value) for keyword,value in row.items()]))
QGIS expressions push push
openai vision \
"you are a police offier, what do you see in these images?" \
- Davie,Bute,.jpg \
$(vanwatch list area=vancouver,ingest,published \
--log 0 \
--count 1 \
--offset 0) \
--max_count 10 \
--verbose 1
โ