mirror of
https://github.com/leaders-of-digital-9-task/backend.git
synced 2024-11-22 01:16:33 +03:00
add point cloud and patology generation
This commit is contained in:
parent
13ab4ea2c2
commit
50c52dcdf5
|
@ -15,6 +15,8 @@ from dicom.api.views import (
|
|||
RetrieveUpdateDeleteRoiApi,
|
||||
RetrieveUpdateDeleteRulerApi,
|
||||
SmartFileUploadApi,
|
||||
GeneratePatology,
|
||||
GeneratePointCloud
|
||||
)
|
||||
from django.urls import include, path
|
||||
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView
|
||||
|
@ -120,4 +122,13 @@ urlpatterns = [
|
|||
]
|
||||
),
|
||||
),
|
||||
path(
|
||||
'generate/',
|
||||
include(
|
||||
[
|
||||
path('patology', GeneratePatology.as_view(), name='generate_patology'),
|
||||
path('point_cloud', GeneratePointCloud.as_view(), name='generate_patology')
|
||||
]
|
||||
),
|
||||
)
|
||||
]
|
||||
|
|
|
@ -299,7 +299,7 @@ SPECTACULAR_SETTINGS = {
|
|||
"SERVE_PERMISSIONS": ["rest_framework.permissions.AllowAny"],
|
||||
"SERVERS": [
|
||||
{"url": "https://dev.akarpov.ru", "description": "Development server"},
|
||||
{"url": "https//127.0.0.1:8000", "description": "Development server"},
|
||||
{"url": "http://127.0.0.1:8000", "description": "Development server"},
|
||||
],
|
||||
}
|
||||
|
||||
|
|
|
@ -177,3 +177,22 @@ class ProjectSerializer(serializers.ModelSerializer):
|
|||
class Meta:
|
||||
model = Project
|
||||
fields = ["files", "slug", "created"]
|
||||
|
||||
|
||||
|
||||
class PatologyGenerateSerializer(serializers.Serializer):
|
||||
project_slug = serializers.CharField()
|
||||
points = serializers.ListField(child=CoordinateSerializer())
|
||||
depth = serializers.ListField(child=serializers.IntegerField())
|
||||
|
||||
|
||||
class VoxelSerializer(serializers.Serializer):
|
||||
x = serializers.IntegerField()
|
||||
y = serializers.IntegerField()
|
||||
z = serializers.IntegerField()
|
||||
value = serializers.IntegerField()
|
||||
|
||||
|
||||
class PointCloudSerializer(serializers.Serializer):
|
||||
voxels = serializers.ListField(child=serializers.IntegerField(), read_only=True)
|
||||
project_slug = serializers.CharField(write_only=True)
|
||||
|
|
|
@ -6,7 +6,7 @@ from rest_framework.parsers import FormParser, MultiPartParser
|
|||
from rest_framework.response import Response
|
||||
|
||||
from ..models import Circle, Dicom, Project, Roi
|
||||
from ..services import process_files
|
||||
from ..services import generate_3d_point_cloud, get_bbox, process_files
|
||||
from .serializers import (
|
||||
BaseShapeLayerSerializer,
|
||||
BaseShapeSerializer,
|
||||
|
@ -15,11 +15,13 @@ from .serializers import (
|
|||
FreeHandSerializer,
|
||||
ListDicomSerializer,
|
||||
ListProjectSerializer,
|
||||
PointCloudSerializer,
|
||||
ProjectSerializer,
|
||||
RoiSerializer,
|
||||
RulerSerializer,
|
||||
SmartFileUploadSerializer,
|
||||
create_coordinate,
|
||||
PatologyGenerateSerializer
|
||||
)
|
||||
|
||||
|
||||
|
@ -216,3 +218,23 @@ class RetrieveUpdateDeleteProjectApi(generics.RetrieveUpdateDestroyAPIView):
|
|||
queryset = Project.objects.all()
|
||||
|
||||
lookup_field = "slug"
|
||||
|
||||
|
||||
class GeneratePatology(generics.CreateAPIView):
|
||||
serializer_class = PatologyGenerateSerializer
|
||||
|
||||
def create(self, request, *args, **kwargs):
|
||||
data = self.get_serializer(request.data).data
|
||||
bbox = get_bbox(data['project_slug'], data['points'], data['depth'])
|
||||
return Response(data={}, status=200)
|
||||
|
||||
|
||||
class GeneratePointCloud(generics.CreateAPIView):
|
||||
serializer_class = PointCloudSerializer
|
||||
|
||||
def create(self, request, *args, **kwargs):
|
||||
print(request.data)
|
||||
data = request.data
|
||||
point_cloud = generate_3d_point_cloud(data['project_slug'])
|
||||
print(point_cloud[0:5])
|
||||
return Response(data={'voxels': point_cloud}, status=200)
|
|
@ -25,3 +25,5 @@ django-cors-headers==3.13.0 # https://github.com/adamchainz/django-cors-headers
|
|||
djangorestframework-simplejwt==5.2.2
|
||||
# DRF-spectacular for api documentation
|
||||
drf-spectacular==0.24.2 # https://github.com/tfranzel/drf-spectacular
|
||||
numpy==1.23.4
|
||||
pydicom==2.3.0
|
Loading…
Reference in New Issue
Block a user