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": {}}}},
|
||||
|
||||
Reference in New Issue
Block a user