我想将JSON文件转换回png图像或NumPy数组。 JSON文件由坐标和其他元数据的列表组成。举个例子。它看起来是这样的:
"firstEditDate": "2019-12-02T19:05:45.393Z",
"lastEditDate": "2020-06-30T13:21:33.371Z",
"folder": "/Pictures/poly",
"objects": [
{
"classIndex": 5,
"layer": 0,
"polygon": [
{
"x": 0,
"y": 0
},
{
"x": 1699.7291626931146,
"y": 0
},
{
"x": 1699.7291626931146,
"y": 1066.87392714095
},
{
"x": 0,
"y": 1066.87392714095
}
],
},
{
"classIndex": 2,
"layer": 0,
"polygon": [
{
"x": 844.2300556586271,
"y": 711.8243676199173
},
{
"x": 851.156462585034,
"y": 740.5194820293175
},
{
"x": 854.1249226963513,
"y": 744.477428844407
},
{
"x": 854.1249226963513,
"y": 747.4458889557243
},
(创建阵列或图像之前,应将坐标四舍五入到最近的坐标)
阵列/图片的尺寸应为1727 x 971
python中是否有函数可以将文件转换为ClassIndex
数组中包含值的数组?或者进入一张图片,其中每个ClassIndex
被指定为一种特定的颜色
以下是一个解决方案:
输出:
相关问题 更多 >
编程相关推荐