publication changes
This commit is contained in:
parent
c8581982c1
commit
d59a682c04
4 changed files with 38 additions and 18 deletions
|
@ -3,3 +3,4 @@ coloredlogs
|
|||
pycocotools
|
||||
numpy
|
||||
mahotas
|
||||
svgwrite
|
46
tools.py
46
tools.py
|
@ -57,6 +57,16 @@ argParser.add_argument(
|
|||
metavar="SVG_FILENAME",
|
||||
help="""
|
||||
Create an SVG with sticker pages (afterwards convert to EPS: \"for f in *; do echo $f; inkscape -f $f --export-eps $f.eps; done\")
|
||||
To PDF:
|
||||
for f in stickers-v1/*.svg; do echo $f; inkscape $f -o pdf/$f.pdf; done
|
||||
pdfunite stickers-v1/*.pdf stickers-v1.pdf
|
||||
"""
|
||||
)
|
||||
argParser.add_argument(
|
||||
'--no-texture',
|
||||
action='store_true',
|
||||
help="""
|
||||
Don't fill with texture, but only print cut lines
|
||||
"""
|
||||
)
|
||||
args = argParser.parse_args()
|
||||
|
@ -200,7 +210,8 @@ if args.stickers:
|
|||
size = (105, 148) # in mm
|
||||
sizeFactor = 5 # influences the size of the patterns
|
||||
viewBoxSize = (size[0] * sizeFactor, size[1] * sizeFactor)
|
||||
margin = 5
|
||||
margin = 10
|
||||
textMargin = 5
|
||||
gridSize = (
|
||||
int((viewBoxSize[0]-((grid[0]+1)*margin))/grid[0]),
|
||||
int((viewBoxSize[1]-((grid[1]+1)*margin))/grid[1])
|
||||
|
@ -211,6 +222,7 @@ if args.stickers:
|
|||
|
||||
nr = 0
|
||||
total_nr = len(coco.cats)
|
||||
max_cat_id = max([cid for cid, _ in coco.cats.items()])
|
||||
for category_id, cat in coco.cats.items():
|
||||
nr+=1
|
||||
filename = os.path.join(
|
||||
|
@ -228,6 +240,7 @@ if args.stickers:
|
|||
)
|
||||
|
||||
inkscape = Inkscape(dwg)
|
||||
# Layers/groups to cut stickers at 123stickers.nl
|
||||
contourG = inkscape.layer(label='Snijlijnen')
|
||||
drawingG = inkscape.layer(label='Shapes')
|
||||
|
||||
|
@ -237,27 +250,29 @@ if args.stickers:
|
|||
|
||||
|
||||
font_size = 10
|
||||
# COCO cat id's go until 90, whereas there's only 80 categories.
|
||||
# for consistency, we stick with id instead of the nr.
|
||||
text = dwg.text(
|
||||
f"{nr:02d}/{total_nr}",
|
||||
insert=(margin, margin+font_size), font_size=font_size, fill='black'
|
||||
f"{category_id:02d}/{max_cat_id}",
|
||||
insert=(textMargin, textMargin+font_size), font_size=font_size, fill='black', font_family='Arial',
|
||||
)
|
||||
drawingG.add(text)
|
||||
|
||||
text = dwg.text(
|
||||
f"{category_id}. {cat['supercategory']} - {cat['name']}",
|
||||
insert=(viewBoxSize[0]-margin, margin+font_size), font_size=font_size, fill='black',
|
||||
f"{cat['supercategory']} - {cat['name']}",
|
||||
insert=(viewBoxSize[0]-textMargin, textMargin+font_size), font_size=font_size, fill='black', font_family='Arial',
|
||||
style='text-anchor:end;')
|
||||
drawingG.add(text)
|
||||
|
||||
text = dwg.text(
|
||||
f"Common Objects In Context",
|
||||
insert=(margin, viewBoxSize[1]-margin), font_size=font_size, fill='black',
|
||||
insert=(textMargin, viewBoxSize[1]-textMargin), font_size=font_size, fill='black', font_family='Arial',
|
||||
)
|
||||
drawingG.add(text)
|
||||
|
||||
text = dwg.text(
|
||||
f"Plotting Data",
|
||||
insert=(viewBoxSize[0]-margin, viewBoxSize[1]-margin), font_size=font_size, fill='black',
|
||||
f"http://plottingd.at/a",
|
||||
insert=(viewBoxSize[0]-textMargin, viewBoxSize[1]-textMargin), font_size=font_size, fill='black', font_family='Arial',
|
||||
style='text-anchor:end;')
|
||||
drawingG.add(text)
|
||||
|
||||
|
@ -283,14 +298,17 @@ if args.stickers:
|
|||
drawingG.add(position2G)
|
||||
|
||||
|
||||
|
||||
xml = dwg.get_xml()
|
||||
with open('textures.xml', 'r') as fp:
|
||||
textureTree = ElementTree.fromstring(fp.read())
|
||||
defsTree = xml.find('defs')
|
||||
for pattern in textureTree:
|
||||
defsTree.append(pattern)
|
||||
|
||||
if not args.no_texture:
|
||||
with open('textures.xml', 'r') as fp:
|
||||
textureTree = ElementTree.fromstring(fp.read())
|
||||
defsTree = xml.find('defs')
|
||||
for pattern in textureTree:
|
||||
defsTree.append(pattern)
|
||||
|
||||
xmlString = ElementTree.tostring(xml)
|
||||
|
||||
with open(filename, 'wb') as fp:
|
||||
# print(xmlString)
|
||||
fp.write(xmlString)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>The COCO dataset : Plotting Data</title>
|
||||
<meta charset='utf-8'>
|
||||
<!-- Publication CSS: -->
|
||||
<link rel="stylesheet" type="text/css" href="/a/css/main.css">
|
||||
|
@ -8,7 +9,7 @@
|
|||
</head>
|
||||
<body class='drawspace'>
|
||||
|
||||
<nav id='publication'>
|
||||
<nav id='publication' class='dataset'>
|
||||
<a href="/a/introduction.html">
|
||||
Introduction
|
||||
</a>
|
||||
|
@ -26,7 +27,7 @@
|
|||
</a>
|
||||
|
||||
<div id='sub'>
|
||||
<a href="/a/introduction.html#dataset-for-4-year-olds-coco">Dataset for 4 year olds</a>
|
||||
<a href="/a/introduction.html#dataset-for-4-year-olds-coco">More about this interface</a>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Plotting Data: COCO drawings</title>
|
||||
<title>Saved images : the COCO dataset : Plotting Data</title>
|
||||
<!-- Plotting Data publication -->
|
||||
<link rel="stylesheet" type="text/css" href="/a/css/main.css">
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
|||
Interviews
|
||||
</a>
|
||||
<div id='sub'>
|
||||
<a href="/a/introduction.html#dataset-for-4-year-olds-coco">Dataset for 4 year olds</a>
|
||||
<a href="/a/introduction.html#dataset-for-4-year-olds-coco">More about this interface</a>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
|
|
Loading…
Reference in a new issue