Exemplo n.º 1
0
class OnlineSFMClient:
    def __init__(self, server_addr):
        self._channel = grpc.insecure_channel(server_addr)
        self._client = ReconstructionServiceStub(self._channel)

    def get_reconstruction(self, id):
        return OnlineSFMReconstruction(self._client, self._channel, id)

    def make_reconstruction(self):
        reconstruction_id = self._client.NewReconstruction(
            NewReconstructionRequest()).reconstruction_id
        return OnlineSFMReconstruction(self._client, self._channel, reconstruction_id)

    def make_session(self, reconstruction_id):
        return OnlineSFMSession(self._client, reconstruction_id)
Exemplo n.º 2
0
import grpc
from server_pb2 import ImageData, ImageMetaData, NewReconstructionRequest
from server_pb2_grpc import ReconstructionServiceStub

if __name__ == "__main__":
    channel = grpc.insecure_channel('localhost:9999')
    client = ReconstructionServiceStub(channel)
    req = NewReconstructionRequest()
    print(client.NewReconstruction(req))
Exemplo n.º 3
0
import grpc
from server_pb2 import ImageData, ImageMetaData, ReconstructionUploadImageBatchRequest
from server_pb2_grpc import ReconstructionServiceStub
import sys
import random
import string
from glob import glob
import os

CHUNK_SIZE = 100 * 1000

if __name__ == "__main__":
    channel = grpc.insecure_channel('localhost:9999')
    client = ReconstructionServiceStub(channel)

    reconstruction_id = str(sys.argv[1])
    dir_path = sys.argv[2]

    files = glob(dir_path + "/*")
    img_idx = 0
    chunked = []
    for image_path in files:
        with open(image_path, "rb") as image:
            meta = ImageMetaData(reconstruction=reconstruction_id,
                                 format=os.path.splitext(image_path)[1][1:])
            image_bytes = image.read()
            for i in range(0, len(image_bytes), CHUNK_SIZE):
                chunked.append(
                    ReconstructionUploadImageBatchRequest(
                        idx=int(img_idx),
                        data=ImageData(metadata=meta,
import grpc
from server_pb2 import DeleteReconstructionRequest
from server_pb2_grpc import ReconstructionServiceStub
import sys

if __name__ == "__main__":
    channel = grpc.insecure_channel('localhost:9999')
    client = ReconstructionServiceStub(channel)
    req = DeleteReconstructionRequest(id=sys.argv[1])
    client.DeleteReconstruction(req)
Exemplo n.º 5
0
import grpc
from server_pb2 import ReconstructRequest
from server_pb2_grpc import ReconstructionServiceStub
import sys

if __name__ == "__main__":
    channel = grpc.insecure_channel('localhost:9999')
    client = ReconstructionServiceStub(channel)
    req = ReconstructRequest(reconstruction_id=sys.argv[1])
    client.Reconstruct(req)
Exemplo n.º 6
0
 def __init__(self, server_addr):
     self._channel = grpc.insecure_channel(server_addr)
     self._client = ReconstructionServiceStub(self._channel)
Exemplo n.º 7
0
import grpc
from server_pb2 import ImageData, ImageMetaData, UploadImageRequest, ReconstructRequest, GetOBJRequest, NewReconstructionRequest
from server_pb2_grpc import ReconstructionServiceStub
import sys
import random
import string
from glob import glob
import os

CHUNK_SIZE = 100 * 1000

if __name__ == "__main__":
    dir_path = sys.argv[1]
    channel = grpc.insecure_channel('localhost:9999')
    client = ReconstructionServiceStub(channel)

    print("Requesting new reconstruction...")
    new_reconstruction_resp = client.NewReconstruction(
        NewReconstructionRequest())
    reconstruction_id = new_reconstruction_resp.reconstruction_id
    print(f"Created new reconstruction {reconstruction_id}")

    files = glob(dir_path + "/*")

    print(f"Uploading dataset from {dir_path}")
    for image_path in files:
        with open(image_path, "rb") as image:
            meta = ImageMetaData(reconstruction=reconstruction_id,
                                 format=os.path.splitext(image_path)[1][1:])
            image_bytes = image.read()
            chunked = []
Exemplo n.º 8
0
        with open(image_path, "rb") as image:
            meta = ImageMetaData(reconstruction=reconstruction_id, format=os.path.splitext(image_path)[1][1:])
            image_bytes = image.read()
            print(len(image_bytes))
            chunked = []
            for i in range(0, len(image_bytes), CHUNK_SIZE):
                chunked.append(SessionUploadImageRequest(session_id= session_id, 
                                                            upload_image=UploadImageRequest(reconstruction_id=reconstruction_id, 
                                                                                            image = ImageData(metadata=meta, 
                                                                                                            data=image_bytes[i:i+CHUNK_SIZE]))))
            client.SessionUploadImage(iter(chunked))

if __name__ == "__main__":
        dir_path = sys.argv[1]
        channel = grpc.insecure_channel('localhost:9999')
        client = ReconstructionServiceStub(channel)

        print("Requesting new reconstruction...")
        new_reconstruction_resp = client.NewReconstruction(NewReconstructionRequest())
        reconstruction_id = new_reconstruction_resp.reconstruction_id
        print(f"Created new reconstruction {reconstruction_id}")
        print(f"Starting a new session for reconstruction {reconstruction_id}")
        session_id = client.StartSession(StartSessionRequest(reconstruction_id=reconstruction_id)).session_id
        print(f"Started session {session_id}")

        mlab.figure(bgcolor=(0, 0, 0))
        Thread(target=do_upload, args=[client, reconstruction_id, session_id, dir_path]).start()
        '''@mlab.show
        @mlab.animate
        def anim(delay=3000, ui=False):
            """Animate the b1 box."""