将多个图像读取为块

问题描述

我有 1000 张图像并希望使用 OpenDroneMap 处理它们。使用 Django REST API 将所有图像上传到 ODM EC2 实例。根据此处给出的答案,在 ODM 中有一种块上传方式

https://community.opendronemap.org/t/importing-images-for-processing-in-webodm-api/7492/2

我找不到 python 文档或帮助弄清楚如何将多个图像作为块上传。我已经按照此处给出的代码 https://gist.github.com/nbari/7335384 进行了尝试。不确定如何为多个图像增强此代码

我会在这里发布我尝试过的内容

       def read_in_chunks(file_object,chunk_size=17825860):
            for f in file_object:
                while True:
                    data = f.read(chunk_size)
                    print('test')
                    if not data:
                        break
                yield data

        def createImageChunks():

            f = [open('./DJI_0003.JPG','rb'),open('./DJI_0004.JPG',open('./DJI_0005.JPG','rb')]
            index = 0
            offset = 0
            headers = {}

            for chunk in read_in_chunks(f):
                offset = index + len(chunk)
                index = offset
                try:
                    res = requests.post(webodm_url+'/api/projects/{}/tasks/{}/upload/'.format(int('10'),task_id),headers={'Authorization': 'JWT {}'.format(token),'Content-Type' : 'multipart/form-data',},files = chunk) .json()  
                    print(res)                
                    print ("r: %s,Content-Range: %s" % (res,headers['Content-Range']))
                except Exception as e:
                    print (e)
        createImageChunks()

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)