rr: can be used for xs
parent
e00703d24d
commit
7324577fb3
|
|
@ -1,10 +1,6 @@
|
||||||
local rr = require("rerun_lua")
|
local rr = require("rerun_lua")
|
||||||
|
|
||||||
|
|
||||||
function bbox(ms_ocr_bbox)
|
|
||||||
return rr.text_object(ms_ocr_bbox)
|
|
||||||
end
|
|
||||||
|
|
||||||
function paragraphs(ms_form_result)
|
function paragraphs(ms_form_result)
|
||||||
local result = {}
|
local result = {}
|
||||||
for _, paragraph in ipairs(ms_form_result.analyzeResult.paragraphs) do
|
for _, paragraph in ipairs(ms_form_result.analyzeResult.paragraphs) do
|
||||||
|
|
@ -31,8 +27,6 @@ function lines(ms_form_result)
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function words(ms_form_result)
|
function words(ms_form_result)
|
||||||
local result = {}
|
local result = {}
|
||||||
for _, page in ipairs(ms_form_result.analyzeResult.pages) do
|
for _, page in ipairs(ms_form_result.analyzeResult.pages) do
|
||||||
|
|
@ -47,11 +41,53 @@ function words(ms_form_result)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local ms_form = rr.json("/Users/tbr/Desktop/ms_form.json")
|
function group_by_type(xs_result)
|
||||||
|
|
||||||
local record = rr.recording("example-2")
|
function geo_to_bbox(geo)
|
||||||
--record:image("54-1", "/Users/tbr/Desktop/00054-1.png")
|
return {geo.left, geo.top, geo.width, geo.height}
|
||||||
record:image("54-0", "/Users/tbr/Desktop/00054-0.png")
|
end
|
||||||
record:text_objects("54-0/ms-forms/paragraphs",paragraphs(ms_form))
|
|
||||||
record:text_objects("54-0/ms-forms/lines",lines(ms_form))
|
local result = {}
|
||||||
record:text_objects("54-0/ms-forms/words",words(ms_form))
|
for _, field in pairs(xs_result.proposedFields.fields) do
|
||||||
|
result[field.type] = result[field.type] or {}
|
||||||
|
result[field.type][field.name] = {}
|
||||||
|
for i, sub_field in ipairs(field.subfields) do
|
||||||
|
table.insert(result[field.type][field.name], {
|
||||||
|
--name = sub_field.name,
|
||||||
|
text = sub_field.type,
|
||||||
|
bbox = geo_to_bbox(sub_field.geo),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
function list_field_types(xs_result)
|
||||||
|
local result = {}
|
||||||
|
for _, field in pairs(xs_result.proposedFields.fields) do
|
||||||
|
result[field.type] = ""
|
||||||
|
end
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--local ms_form = rr.json("/Users/tbr/Desktop/ms_form.json")
|
||||||
|
local xs_result = rr.json("/Volumes/data/problematics/10138832-0ec5-4ea9-bf9e-2d863f714b6c-result.json")
|
||||||
|
local xs_fields = group_by_type(xs_result)
|
||||||
|
local record = rr.recording("fix")
|
||||||
|
record:image("steets_city_mixup", "/Volumes/data/problematics/street_city_mixup.png")
|
||||||
|
for field_type, fields in pairs(xs_fields) do
|
||||||
|
for field_name, sub_fields in pairs(fields) do
|
||||||
|
record:text_objects("steets_city_mixup/" .. field_type .. "/" .. field_name, sub_fields)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--local master_xs_result = rr.json("/Volumes/data/problematics/0636036f-6ade-41db-8fbe-1a97b2cdb6ca-result.json")
|
||||||
|
--local master_fields = group_by_type(master_xs_result)
|
||||||
|
--local master_record = rr.recording("master")
|
||||||
|
--master_record:image("steets_city_mixup", "/Volumes/data/problematics/street_city_mixup.png")
|
||||||
|
--for field_type, fields in pairs(master_fields) do
|
||||||
|
-- for field_name, sub_fields in pairs(fields) do
|
||||||
|
-- master_record:text_objects("steets_city_mixup/" .. field_type .. "/" .. field_name, sub_fields)
|
||||||
|
-- end
|
||||||
|
--end
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ use rerun::{Boxes2D, Image, RecordingStream, RecordingStreamBuilder};
|
||||||
use rerun::datatypes::{TensorData, Vec2D, Vec4D};
|
use rerun::datatypes::{TensorData, Vec2D, Vec4D};
|
||||||
|
|
||||||
|
|
||||||
type TextBox = [f32;8];
|
type TextBox = Vec<f32>;
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct TextObject {
|
pub struct TextObject {
|
||||||
pub text: String,
|
pub text: String,
|
||||||
|
|
@ -83,7 +83,13 @@ fn register_bindings(lua: &Lua) -> LuaResult<()> {
|
||||||
let sizes: Vec<Vec2D> = objects
|
let sizes: Vec<Vec2D> = objects
|
||||||
.iter()
|
.iter()
|
||||||
.map(|text_object| &text_object.bbox)
|
.map(|text_object| &text_object.bbox)
|
||||||
.map(|bbox| Vec2D([bbox[2] - bbox[0], bbox[7] - bbox[1]]) )
|
.map(|bbox| {
|
||||||
|
if bbox.len() == 8 {
|
||||||
|
Vec2D([bbox[2] - bbox[0], bbox[7] - bbox[1]])
|
||||||
|
} else {
|
||||||
|
Vec2D([bbox[2], bbox[3]])
|
||||||
|
}
|
||||||
|
} )
|
||||||
.collect();
|
.collect();
|
||||||
let labels: Vec<String> = objects
|
let labels: Vec<String> = objects
|
||||||
.iter()
|
.iter()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue