JFJochReceiver: No access to preview frame via gRPC
This commit is contained in:
@@ -245,26 +245,6 @@ async def put_detector_selection(request: Request):
|
||||
raise HTTPException(status_code=400, detail=e.details())
|
||||
|
||||
|
||||
# https://stackoverflow.com/questions/55873174/how-do-i-return-an-image-in-fastapi
|
||||
@app.get(
|
||||
"/image/preview.tiff",
|
||||
responses={200: {"content": {"image/tiff": {}}}},
|
||||
response_class=Response,
|
||||
)
|
||||
async def get_preview():
|
||||
try:
|
||||
stub = jfjoch_pb2_grpc.gRPC_JFJochBrokerStub(channel)
|
||||
pbuf = stub.GetPreview(jfjoch_pb2.Empty())
|
||||
image_array = numpy.frombuffer(pbuf.data, numpy.int16)
|
||||
image_array = numpy.where(image_array < 0, -1, image_array)
|
||||
image_array = numpy.reshape(image_array, (pbuf.height, pbuf.width))
|
||||
b = BytesIO()
|
||||
imwrite(b, image_array)
|
||||
return Response(content=b.getvalue(), media_type="image/tiff")
|
||||
except grpc.RpcError as e:
|
||||
raise HTTPException(status_code=400, detail=e.details())
|
||||
|
||||
|
||||
def calib_to_tiff(im: jfjoch_pb2.Image) -> bytes:
|
||||
if im.pixel_depth == 2:
|
||||
image_array = numpy.frombuffer(im.data, numpy.uint16)
|
||||
@@ -276,29 +256,6 @@ def calib_to_tiff(im: jfjoch_pb2.Image) -> bytes:
|
||||
return bytes(b.getvalue())
|
||||
|
||||
|
||||
@app.get(
|
||||
"/image/preview_dioptas.tiff",
|
||||
responses={200: {"content": {"image/tiff": {}}}},
|
||||
response_class=Response,
|
||||
)
|
||||
async def get_preview_dioptas():
|
||||
try:
|
||||
stub = jfjoch_pb2_grpc.gRPC_JFJochBrokerStub(channel)
|
||||
pbuf = stub.GetPreview(jfjoch_pb2.Empty())
|
||||
if pbuf.pixel_depth == 2:
|
||||
image_array = numpy.frombuffer(pbuf.data, numpy.int16)
|
||||
else:
|
||||
image_array = numpy.frombuffer(pbuf.data, numpy.int32)
|
||||
image_array = numpy.where(image_array < 0, 32767, image_array)
|
||||
image_array = numpy.reshape(image_array, (pbuf.height, pbuf.width))
|
||||
image_array = numpy.flipud(image_array)
|
||||
b = BytesIO()
|
||||
imwrite(b, image_array)
|
||||
return Response(content=b.getvalue(), media_type="image/tiff")
|
||||
except grpc.RpcError as e:
|
||||
raise HTTPException(status_code=400, detail=e.details())
|
||||
|
||||
|
||||
@app.get(
|
||||
"/image/pedestalG0.tiff",
|
||||
responses={200: {"content": {"image/tiff": {}}}},
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -54,11 +54,6 @@ class gRPC_JFJochReceiverStub(object):
|
||||
request_serializer=jfjoch__pb2.Empty.SerializeToString,
|
||||
response_deserializer=jfjoch__pb2.RadialIntegrationProfiles.FromString,
|
||||
)
|
||||
self.GetPreviewFrame = channel.unary_unary(
|
||||
'/JFJochProtoBuf.gRPC_JFJochReceiver/GetPreviewFrame',
|
||||
request_serializer=jfjoch__pb2.Empty.SerializeToString,
|
||||
response_deserializer=jfjoch__pb2.PreviewFrame.FromString,
|
||||
)
|
||||
self.GetNetworkConfig = channel.unary_unary(
|
||||
'/JFJochProtoBuf.gRPC_JFJochReceiver/GetNetworkConfig',
|
||||
request_serializer=jfjoch__pb2.Empty.SerializeToString,
|
||||
@@ -117,12 +112,6 @@ class gRPC_JFJochReceiverServicer(object):
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def GetPreviewFrame(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def GetNetworkConfig(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
@@ -172,11 +161,6 @@ def add_gRPC_JFJochReceiverServicer_to_server(servicer, server):
|
||||
request_deserializer=jfjoch__pb2.Empty.FromString,
|
||||
response_serializer=jfjoch__pb2.RadialIntegrationProfiles.SerializeToString,
|
||||
),
|
||||
'GetPreviewFrame': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.GetPreviewFrame,
|
||||
request_deserializer=jfjoch__pb2.Empty.FromString,
|
||||
response_serializer=jfjoch__pb2.PreviewFrame.SerializeToString,
|
||||
),
|
||||
'GetNetworkConfig': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.GetNetworkConfig,
|
||||
request_deserializer=jfjoch__pb2.Empty.FromString,
|
||||
@@ -328,23 +312,6 @@ class gRPC_JFJochReceiver(object):
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def GetPreviewFrame(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
call_credentials=None,
|
||||
insecure=False,
|
||||
compression=None,
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(request, target, '/JFJochProtoBuf.gRPC_JFJochReceiver/GetPreviewFrame',
|
||||
jfjoch__pb2.Empty.SerializeToString,
|
||||
jfjoch__pb2.PreviewFrame.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def GetNetworkConfig(request,
|
||||
target,
|
||||
@@ -805,11 +772,6 @@ class gRPC_JFJochBrokerStub(object):
|
||||
request_serializer=jfjoch__pb2.Empty.SerializeToString,
|
||||
response_deserializer=jfjoch__pb2.RadialIntegrationProfiles.FromString,
|
||||
)
|
||||
self.GetPreview = channel.unary_unary(
|
||||
'/JFJochProtoBuf.gRPC_JFJochBroker/GetPreview',
|
||||
request_serializer=jfjoch__pb2.Empty.SerializeToString,
|
||||
response_deserializer=jfjoch__pb2.PreviewFrame.FromString,
|
||||
)
|
||||
self.GetPedestalG0 = channel.unary_unary(
|
||||
'/JFJochProtoBuf.gRPC_JFJochBroker/GetPedestalG0',
|
||||
request_serializer=jfjoch__pb2.Empty.SerializeToString,
|
||||
@@ -941,12 +903,6 @@ class gRPC_JFJochBrokerServicer(object):
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def GetPreview(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def GetPedestalG0(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
@@ -1066,11 +1022,6 @@ def add_gRPC_JFJochBrokerServicer_to_server(servicer, server):
|
||||
request_deserializer=jfjoch__pb2.Empty.FromString,
|
||||
response_serializer=jfjoch__pb2.RadialIntegrationProfiles.SerializeToString,
|
||||
),
|
||||
'GetPreview': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.GetPreview,
|
||||
request_deserializer=jfjoch__pb2.Empty.FromString,
|
||||
response_serializer=jfjoch__pb2.PreviewFrame.SerializeToString,
|
||||
),
|
||||
'GetPedestalG0': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.GetPedestalG0,
|
||||
request_deserializer=jfjoch__pb2.Empty.FromString,
|
||||
@@ -1383,23 +1334,6 @@ class gRPC_JFJochBroker(object):
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def GetPreview(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
call_credentials=None,
|
||||
insecure=False,
|
||||
compression=None,
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(request, target, '/JFJochProtoBuf.gRPC_JFJochBroker/GetPreview',
|
||||
jfjoch__pb2.Empty.SerializeToString,
|
||||
jfjoch__pb2.PreviewFrame.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def GetPedestalG0(request,
|
||||
target,
|
||||
|
||||
Reference in New Issue
Block a user