Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
DA-Platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
文档服务地址:
http://47.92.0.57:3000/
周报索引地址:
http://47.92.0.57:3000/s/NruNXRYmV
Open sidebar
Berlin
DA-Platform
Commits
416571ae
Commit
416571ae
authored
Jun 28, 2020
by
convivae
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
图像部分前后端交互修改bug
parent
536b6333
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
42 deletions
+50
-42
Image.py
DAPlatform/Dao/Image.py
+38
-30
imageAnnotation.py
DAPlatform/views/imageAnnotation.py
+12
-12
No files found.
DAPlatform/Dao/Image.py
View file @
416571ae
...
@@ -23,9 +23,9 @@ class Point(db.EmbeddedDocument):
...
@@ -23,9 +23,9 @@ class Point(db.EmbeddedDocument):
Y
=
db
.
FloatField
(
required
=
True
)
Y
=
db
.
FloatField
(
required
=
True
)
def
to_json
(
self
):
def
to_json
(
self
):
return
{
"pointId"
:
self
.
pointId
,
return
{
'pointId'
:
self
.
pointId
,
"X"
:
self
.
X
,
'X'
:
self
.
X
,
"Y"
:
self
.
Y
}
'Y'
:
self
.
Y
}
# 标签
# 标签
...
@@ -35,9 +35,9 @@ class Label(db.EmbeddedDocument):
...
@@ -35,9 +35,9 @@ class Label(db.EmbeddedDocument):
pointList
=
db
.
ListField
(
db
.
EmbeddedDocumentField
(
Point
))
pointList
=
db
.
ListField
(
db
.
EmbeddedDocumentField
(
Point
))
def
to_json
(
self
):
def
to_json
(
self
):
return
{
"labelId"
:
self
.
labelId
,
return
{
'labelId'
:
self
.
labelId
,
"labelName"
:
self
.
labelName
,
'labelName'
:
self
.
labelName
,
"pointList"
:
[
i
.
to_json
()
for
i
in
self
.
pointList
]
'pointList'
:
[
i
.
to_json
()
for
i
in
self
.
pointList
]
}
}
...
@@ -49,9 +49,9 @@ class Image(db.Document):
...
@@ -49,9 +49,9 @@ class Image(db.Document):
labelList
=
db
.
ListField
(
db
.
EmbeddedDocumentField
(
Label
))
labelList
=
db
.
ListField
(
db
.
EmbeddedDocumentField
(
Label
))
def
to_json
(
self
):
def
to_json
(
self
):
return
{
"relationId"
:
self
.
relationId
,
return
{
'relationId'
:
self
.
relationId
,
"imageUrl"
:
self
.
imageUrl
,
'imageUrl'
:
self
.
imageUrl
,
"labelList"
:
[
i
.
to_json
()
for
i
in
self
.
labelList
]
'labelList'
:
[
i
.
to_json
()
for
i
in
self
.
labelList
]
}
}
...
@@ -85,6 +85,10 @@ def create_labels(label_list):
...
@@ -85,6 +85,10 @@ def create_labels(label_list):
def
create_images
(
image_list
):
def
create_images
(
image_list
):
res
=
[]
res
=
[]
for
i
in
image_list
:
for
i
in
image_list
:
rid
=
i
[
'relationId'
]
obj
=
Image
.
objects
(
relationId
=
rid
)
if
obj
:
obj
.
delete
()
image
=
Image
(
image
=
Image
(
relationId
=
i
[
'relationId'
],
relationId
=
i
[
'relationId'
],
imageUrl
=
i
[
'imageUrl'
],
imageUrl
=
i
[
'imageUrl'
],
...
@@ -102,9 +106,9 @@ class LayerEntity(db.EmbeddedDocument):
...
@@ -102,9 +106,9 @@ class LayerEntity(db.EmbeddedDocument):
layerUrl
=
db
.
StringField
(
required
=
True
)
layerUrl
=
db
.
StringField
(
required
=
True
)
def
to_json
(
self
):
def
to_json
(
self
):
return
{
"layerId"
:
self
.
layerId
,
return
{
'layerId'
:
self
.
layerId
,
"layerName"
:
self
.
layerName
,
'layerName'
:
self
.
layerName
,
"layerUrl"
:
self
.
layerUrl
}
'layerUrl'
:
self
.
layerUrl
}
# 图层标注的数据库
# 图层标注的数据库
...
@@ -114,9 +118,9 @@ class Layer(db.Document):
...
@@ -114,9 +118,9 @@ class Layer(db.Document):
labelList
=
db
.
ListField
(
db
.
EmbeddedDocumentField
(
Label
))
labelList
=
db
.
ListField
(
db
.
EmbeddedDocumentField
(
Label
))
def
to_json
(
self
):
def
to_json
(
self
):
return
{
"relationId"
:
self
.
relationId
,
return
{
'relationId'
:
self
.
relationId
,
"layerEntityList"
:
[
i
.
to_json
()
for
i
in
self
.
layerEntityList
],
'layerEntityList'
:
[
i
.
to_json
()
for
i
in
self
.
layerEntityList
],
"labelList"
:
[
i
.
to_json
()
for
i
in
self
.
labelList
]
'labelList'
:
[
i
.
to_json
()
for
i
in
self
.
labelList
]
}
}
...
@@ -137,6 +141,10 @@ def create_layer_entities(layer_entity_list):
...
@@ -137,6 +141,10 @@ def create_layer_entities(layer_entity_list):
def
create_layers
(
layer_list
):
def
create_layers
(
layer_list
):
res
=
[]
res
=
[]
for
i
in
layer_list
:
for
i
in
layer_list
:
rid
=
i
[
'relationId'
]
obj
=
Layer
.
objects
(
relationId
=
rid
)
if
obj
:
obj
.
delete
()
layer
=
Layer
(
layer
=
Layer
(
relationId
=
i
[
'relationId'
],
relationId
=
i
[
'relationId'
],
layerEntityList
=
create_layer_entities
(
i
[
'layerEntityList'
]),
layerEntityList
=
create_layer_entities
(
i
[
'layerEntityList'
]),
...
@@ -155,10 +163,10 @@ class LandmarkEntity(db.EmbeddedDocument):
...
@@ -155,10 +163,10 @@ class LandmarkEntity(db.EmbeddedDocument):
Y
=
db
.
FloatField
(
required
=
True
)
Y
=
db
.
FloatField
(
required
=
True
)
def
to_json
(
self
):
def
to_json
(
self
):
return
{
"landmarkId"
:
self
.
landmarkId
,
return
{
'landmarkId'
:
self
.
landmarkId
,
"landmarkName"
:
self
.
landmarkName
,
'landmarkName'
:
self
.
landmarkName
,
"X"
:
self
.
X
,
'X'
:
self
.
X
,
"Y"
:
self
.
Y
}
'Y'
:
self
.
Y
}
# 地标存储表
# 地标存储表
...
@@ -168,9 +176,9 @@ class Landmark(db.Document):
...
@@ -168,9 +176,9 @@ class Landmark(db.Document):
landmarkEntityList
=
db
.
ListField
(
db
.
EmbeddedDocumentField
(
LandmarkEntity
))
landmarkEntityList
=
db
.
ListField
(
db
.
EmbeddedDocumentField
(
LandmarkEntity
))
def
to_json
(
self
):
def
to_json
(
self
):
return
{
"relationId"
:
self
.
relationId
,
return
{
'relationId'
:
self
.
relationId
,
"layerEntityList"
:
[
i
.
to_json
()
for
i
in
self
.
layerEntityList
],
'layerEntityList'
:
[
i
.
to_json
()
for
i
in
self
.
layerEntityList
],
"landmarkEntityList"
:
[
i
.
to_json
()
for
i
in
self
.
landmarkEntityList
]
'landmarkEntityList'
:
[
i
.
to_json
()
for
i
in
self
.
landmarkEntityList
]
}
}
...
@@ -206,8 +214,8 @@ def create_landmarks(landmark_list):
...
@@ -206,8 +214,8 @@ def create_landmarks(landmark_list):
def
getImage
(
relation_list
):
def
getImage
(
relation_list
):
try
:
try
:
image_list
=
Image
.
objects
(
relationId__in
=
relation_list
)
image_list
=
Image
.
objects
(
relationId__in
=
relation_list
)
data
=
[
json
.
dumps
(
image
.
to_json
(),
ensure_ascii
=
False
)
for
image
in
image_list
]
data
=
[
image
.
to_json
(
)
for
image
in
image_list
]
return
Result
(
1
,
len
(
image_list
),
{
"imageList"
:
data
})
return
Result
(
1
,
{
'image num'
:
len
(
image_list
)},
{
'imageList'
:
data
})
except
Exception
as
e
:
except
Exception
as
e
:
traceback
.
print_exc
()
traceback
.
print_exc
()
return
Result
(
0
,
repr
(
e
),
{})
return
Result
(
0
,
repr
(
e
),
{})
...
@@ -217,7 +225,7 @@ def getImage(relation_list):
...
@@ -217,7 +225,7 @@ def getImage(relation_list):
def
saveImage
(
image_list
):
def
saveImage
(
image_list
):
try
:
try
:
images
=
create_images
(
image_list
)
images
=
create_images
(
image_list
)
return
Result
(
1
,
len
(
images
)
,
{})
return
Result
(
1
,
{
'image num'
:
len
(
images
)}
,
{})
except
Exception
as
e
:
except
Exception
as
e
:
traceback
.
print_exc
()
traceback
.
print_exc
()
return
Result
(
0
,
repr
(
e
),
{})
return
Result
(
0
,
repr
(
e
),
{})
...
@@ -228,10 +236,10 @@ def getLayer(relation_list):
...
@@ -228,10 +236,10 @@ def getLayer(relation_list):
try
:
try
:
layer_list
=
Layer
.
objects
(
relationId__in
=
relation_list
)
layer_list
=
Layer
.
objects
(
relationId__in
=
relation_list
)
landmark_list
=
Landmark
.
objects
(
relationId__in
=
relation_list
)
landmark_list
=
Landmark
.
objects
(
relationId__in
=
relation_list
)
layer_data
=
[
json
.
dumps
(
layer
.
to_json
(),
ensure_ascii
=
False
)
for
layer
in
layer_list
]
layer_data
=
[
layer
.
to_json
(
)
for
layer
in
layer_list
]
landmark_data
=
[
json
.
dumps
(
landmark
.
to_json
(),
ensure_ascii
=
False
)
for
landmark
in
landmark_list
]
landmark_data
=
[
landmark
.
to_json
(
)
for
landmark
in
landmark_list
]
return
Result
(
1
,
[
"layers:"
,
len
(
layer_data
),
"landmarks:"
,
len
(
landmark_data
)
],
return
Result
(
1
,
[
{
'layer num'
:
len
(
layer_data
),
'landmark num'
:
len
(
landmark_data
)}
],
{
"layerList"
:
layer_data
,
"landmarkList"
:
landmark_data
})
{
'layerList'
:
layer_data
,
'landmarkList'
:
landmark_data
})
except
Exception
as
e
:
except
Exception
as
e
:
traceback
.
print_exc
()
traceback
.
print_exc
()
return
Result
(
0
,
repr
(
e
),
{})
return
Result
(
0
,
repr
(
e
),
{})
...
@@ -242,7 +250,7 @@ def saveLayer(layer_list, landmark_list):
...
@@ -242,7 +250,7 @@ def saveLayer(layer_list, landmark_list):
try
:
try
:
layers
=
create_layers
(
layer_list
)
layers
=
create_layers
(
layer_list
)
landmarks
=
create_landmarks
(
landmark_list
)
landmarks
=
create_landmarks
(
landmark_list
)
return
Result
(
1
,
[
"layers:"
,
len
(
layers
),
"landmarks:"
,
len
(
landmarks
)
],
{})
return
Result
(
1
,
[
{
'layer num'
:
len
(
layers
),
'landmark num'
:
len
(
landmarks
)}
],
{})
except
Exception
as
e
:
except
Exception
as
e
:
traceback
.
print_exc
()
traceback
.
print_exc
()
return
Result
(
0
,
repr
(
e
),
{})
return
Result
(
0
,
repr
(
e
),
{})
DAPlatform/views/imageAnnotation.py
View file @
416571ae
...
@@ -3,25 +3,26 @@ from flask import Blueprint, jsonify, request
...
@@ -3,25 +3,26 @@ from flask import Blueprint, jsonify, request
from
dao
import
Image
from
dao
import
Image
image
=
Blueprint
(
"image"
,
__name__
,
url_prefix
=
""
)
image
=
Blueprint
(
"image"
,
__name__
,
url_prefix
=
"
/api/image
"
)
# 获取图片
# 获取图片
@image.route
(
"/
image"
,
methods
=
[
"GE
T"
])
@image.route
(
"/
getImage"
,
methods
=
[
"POS
T"
])
def
get_image
():
def
get_image
():
data
=
json
.
loads
(
request
.
data
)
data
=
json
.
loads
(
request
.
data
)
relation_list
=
data
[
'relationList'
]
relation_list
=
data
[
'relationList'
]
# relation_list = request.args['relationList']
image
=
Image
.
getImage
(
relation_list
)
image
=
Image
.
getImage
(
relation_list
)
res
=
{
res
=
{
'code'
:
image
.
code
,
'code'
:
image
.
code
,
'message'
:
image
.
message
,
'message'
:
image
.
message
,
'data'
:
image
.
data
'data'
:
image
.
data
}
}
return
json
.
dumps
(
res
)
return
json
.
dumps
(
res
,
ensure_ascii
=
False
)
# 保存图片标注结果
# 保存图片标注结果
@image.route
(
"/
i
mage"
,
methods
=
[
"POST"
])
@image.route
(
"/
saveI
mage"
,
methods
=
[
"POST"
])
def
save_image
():
def
save_image
():
data
=
json
.
loads
(
request
.
data
)
data
=
json
.
loads
(
request
.
data
)
image_list
=
data
[
'imageList'
]
image_list
=
data
[
'imageList'
]
...
@@ -31,11 +32,11 @@ def save_image():
...
@@ -31,11 +32,11 @@ def save_image():
'message'
:
ret
.
message
,
'message'
:
ret
.
message
,
'data'
:
ret
.
data
'data'
:
ret
.
data
}
}
return
json
.
dumps
(
res
)
return
json
.
dumps
(
res
,
ensure_ascii
=
False
)
# 获取图层
# 获取图层
@image.route
(
"/
layer"
,
methods
=
[
"GE
T"
])
@image.route
(
"/
getLayer"
,
methods
=
[
"POS
T"
])
def
get_layer
():
def
get_layer
():
data
=
json
.
loads
(
request
.
data
)
data
=
json
.
loads
(
request
.
data
)
relation_list
=
data
[
'relationList'
]
relation_list
=
data
[
'relationList'
]
...
@@ -45,11 +46,11 @@ def get_layer():
...
@@ -45,11 +46,11 @@ def get_layer():
'message'
:
layer
.
message
,
'message'
:
layer
.
message
,
'data'
:
layer
.
data
'data'
:
layer
.
data
}
}
return
json
.
dumps
(
res
)
return
json
.
dumps
(
res
,
ensure_ascii
=
False
)
# 保存图层标注结果
# 保存图层标注结果
@image.route
(
"/
l
ayer"
,
methods
=
[
"POST"
])
@image.route
(
"/
saveL
ayer"
,
methods
=
[
"POST"
])
def
save_layer
():
def
save_layer
():
data
=
json
.
loads
(
request
.
data
)
data
=
json
.
loads
(
request
.
data
)
layer_list
=
data
[
'layerList'
]
layer_list
=
data
[
'layerList'
]
...
@@ -60,11 +61,10 @@ def save_layer():
...
@@ -60,11 +61,10 @@ def save_layer():
'message'
:
ret
.
message
,
'message'
:
ret
.
message
,
'data'
:
ret
.
data
'data'
:
ret
.
data
}
}
return
json
.
dumps
(
res
)
return
json
.
dumps
(
res
,
ensure_ascii
=
False
)
# 保存图片标注结果的测试数据
# 保存图片标注结果的测试数据
#
meta =
{
# {
# "imageList": [
# "imageList": [
# {
# {
# "relationId": 123,
# "relationId": 123,
...
@@ -104,7 +104,7 @@ def save_layer():
...
@@ -104,7 +104,7 @@ def save_layer():
# }
# }
# 保存图层标注结果的测试数据
# 保存图层标注结果的测试数据
#
meta =
{
# {
# "layerList": [
# "layerList": [
# {
# {
# "relationId": 8,
# "relationId": 8,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment