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
|
pycocotools
|
||||||
numpy
|
numpy
|
||||||
mahotas
|
mahotas
|
||||||
|
svgwrite
|
46
tools.py
46
tools.py
|
@ -57,6 +57,16 @@ argParser.add_argument(
|
||||||
metavar="SVG_FILENAME",
|
metavar="SVG_FILENAME",
|
||||||
help="""
|
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\")
|
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()
|
args = argParser.parse_args()
|
||||||
|
@ -200,7 +210,8 @@ if args.stickers:
|
||||||
size = (105, 148) # in mm
|
size = (105, 148) # in mm
|
||||||
sizeFactor = 5 # influences the size of the patterns
|
sizeFactor = 5 # influences the size of the patterns
|
||||||
viewBoxSize = (size[0] * sizeFactor, size[1] * sizeFactor)
|
viewBoxSize = (size[0] * sizeFactor, size[1] * sizeFactor)
|
||||||
margin = 5
|
margin = 10
|
||||||
|
textMargin = 5
|
||||||
gridSize = (
|
gridSize = (
|
||||||
int((viewBoxSize[0]-((grid[0]+1)*margin))/grid[0]),
|
int((viewBoxSize[0]-((grid[0]+1)*margin))/grid[0]),
|
||||||
int((viewBoxSize[1]-((grid[1]+1)*margin))/grid[1])
|
int((viewBoxSize[1]-((grid[1]+1)*margin))/grid[1])
|
||||||
|
@ -211,6 +222,7 @@ if args.stickers:
|
||||||
|
|
||||||
nr = 0
|
nr = 0
|
||||||
total_nr = len(coco.cats)
|
total_nr = len(coco.cats)
|
||||||
|
max_cat_id = max([cid for cid, _ in coco.cats.items()])
|
||||||
for category_id, cat in coco.cats.items():
|
for category_id, cat in coco.cats.items():
|
||||||
nr+=1
|
nr+=1
|
||||||
filename = os.path.join(
|
filename = os.path.join(
|
||||||
|
@ -228,6 +240,7 @@ if args.stickers:
|
||||||
)
|
)
|
||||||
|
|
||||||
inkscape = Inkscape(dwg)
|
inkscape = Inkscape(dwg)
|
||||||
|
# Layers/groups to cut stickers at 123stickers.nl
|
||||||
contourG = inkscape.layer(label='Snijlijnen')
|
contourG = inkscape.layer(label='Snijlijnen')
|
||||||
drawingG = inkscape.layer(label='Shapes')
|
drawingG = inkscape.layer(label='Shapes')
|
||||||
|
|
||||||
|
@ -237,27 +250,29 @@ if args.stickers:
|
||||||
|
|
||||||
|
|
||||||
font_size = 10
|
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(
|
text = dwg.text(
|
||||||
f"{nr:02d}/{total_nr}",
|
f"{category_id:02d}/{max_cat_id}",
|
||||||
insert=(margin, margin+font_size), font_size=font_size, fill='black'
|
insert=(textMargin, textMargin+font_size), font_size=font_size, fill='black', font_family='Arial',
|
||||||
)
|
)
|
||||||
drawingG.add(text)
|
drawingG.add(text)
|
||||||
|
|
||||||
text = dwg.text(
|
text = dwg.text(
|
||||||
f"{category_id}. {cat['supercategory']} - {cat['name']}",
|
f"{cat['supercategory']} - {cat['name']}",
|
||||||
insert=(viewBoxSize[0]-margin, margin+font_size), font_size=font_size, fill='black',
|
insert=(viewBoxSize[0]-textMargin, textMargin+font_size), font_size=font_size, fill='black', font_family='Arial',
|
||||||
style='text-anchor:end;')
|
style='text-anchor:end;')
|
||||||
drawingG.add(text)
|
drawingG.add(text)
|
||||||
|
|
||||||
text = dwg.text(
|
text = dwg.text(
|
||||||
f"Common Objects In Context",
|
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)
|
drawingG.add(text)
|
||||||
|
|
||||||
text = dwg.text(
|
text = dwg.text(
|
||||||
f"Plotting Data",
|
f"http://plottingd.at/a",
|
||||||
insert=(viewBoxSize[0]-margin, viewBoxSize[1]-margin), font_size=font_size, fill='black',
|
insert=(viewBoxSize[0]-textMargin, viewBoxSize[1]-textMargin), font_size=font_size, fill='black', font_family='Arial',
|
||||||
style='text-anchor:end;')
|
style='text-anchor:end;')
|
||||||
drawingG.add(text)
|
drawingG.add(text)
|
||||||
|
|
||||||
|
@ -283,14 +298,17 @@ if args.stickers:
|
||||||
drawingG.add(position2G)
|
drawingG.add(position2G)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
xml = dwg.get_xml()
|
xml = dwg.get_xml()
|
||||||
with open('textures.xml', 'r') as fp:
|
|
||||||
textureTree = ElementTree.fromstring(fp.read())
|
if not args.no_texture:
|
||||||
defsTree = xml.find('defs')
|
with open('textures.xml', 'r') as fp:
|
||||||
for pattern in textureTree:
|
textureTree = ElementTree.fromstring(fp.read())
|
||||||
defsTree.append(pattern)
|
defsTree = xml.find('defs')
|
||||||
|
for pattern in textureTree:
|
||||||
|
defsTree.append(pattern)
|
||||||
|
|
||||||
xmlString = ElementTree.tostring(xml)
|
xmlString = ElementTree.tostring(xml)
|
||||||
|
|
||||||
with open(filename, 'wb') as fp:
|
with open(filename, 'wb') as fp:
|
||||||
# print(xmlString)
|
# print(xmlString)
|
||||||
fp.write(xmlString)
|
fp.write(xmlString)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
<title>The COCO dataset : Plotting Data</title>
|
||||||
<meta charset='utf-8'>
|
<meta charset='utf-8'>
|
||||||
<!-- Publication CSS: -->
|
<!-- Publication CSS: -->
|
||||||
<link rel="stylesheet" type="text/css" href="/a/css/main.css">
|
<link rel="stylesheet" type="text/css" href="/a/css/main.css">
|
||||||
|
@ -8,7 +9,7 @@
|
||||||
</head>
|
</head>
|
||||||
<body class='drawspace'>
|
<body class='drawspace'>
|
||||||
|
|
||||||
<nav id='publication'>
|
<nav id='publication' class='dataset'>
|
||||||
<a href="/a/introduction.html">
|
<a href="/a/introduction.html">
|
||||||
Introduction
|
Introduction
|
||||||
</a>
|
</a>
|
||||||
|
@ -26,7 +27,7 @@
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<div id='sub'>
|
<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>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Plotting Data: COCO drawings</title>
|
<title>Saved images : the COCO dataset : Plotting Data</title>
|
||||||
<!-- Plotting Data publication -->
|
<!-- Plotting Data publication -->
|
||||||
<link rel="stylesheet" type="text/css" href="/a/css/main.css">
|
<link rel="stylesheet" type="text/css" href="/a/css/main.css">
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
Interviews
|
Interviews
|
||||||
</a>
|
</a>
|
||||||
<div id='sub'>
|
<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>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue